Code : Tout sélectionner
Structure zbuffer
*depth_buffer.i
w.l
h.l
EndStructure
ProcedureDLL.i zbuffer(w.l, h.l, mFar.f)
*zb.zbuffer = AllocateMemory(SizeOf(zbuffer))
*zb\depth_buffer = AllocateMemory( w * h * 4 )
*zb\w = w
*zb\h = h
FillMemory(*zb\depth_buffer , MemorySize(*zb\depth_buffer), mFar, #PB_Long)
ProcedureReturn *zb
EndProcedure
ProcedureDLL zbuffer_write(*zb.zbuffer,x.i, y.i, depth.f)
If x=>0 And x < *zb\w And y=>0 And y < *zb\h
PokeF(*zb\depth_buffer + (x*4) + *zb\w * (y*4), depth)
EndIf
EndProcedure
ProcedureDLL.f zbuffer_read(*zb.zbuffer, x.i, y.i)
If x=>0 And x < *zb\w And y=>0 And y < *zb\h
ProcedureReturn PeekF(*zb\depth_buffer + (x*4) + *zb\w * (y*4))
EndIf
EndProcedure
ProcedureDLL.f zbuffer_fill(*zb.zbuffer, value.f)
FillMemory(*zb\depth_buffer , MemorySize(*zb\depth_buffer), value, #PB_Long)
EndProcedure
Buffer = zbuffer(640,480,1500)
A = ElapsedMilliseconds()
For i = 0 To 50
For y = 0 To 480-1
For x = 0 To 640
zbuffer_write(Buffer,x,y,Random(1500))
Next
Next
Next
B = ElapsedMilliseconds()
WriteTime = B-A
A = ElapsedMilliseconds()
For i = 0 To 50
For y = 0 To 480-1
For x = 0 To 640
zbuffer_read(Buffer,x,y)
Next
Next
Next
B = ElapsedMilliseconds()
ReadTime = B-A
MessageRequester("", "Ecriture = "+Str(WriteTime) + Chr(10) + "Lecture = " + Str(ReadTime))
Sur ma bécane j'obtiens en moyen 380ms pour l'écriture , 170ms pour la lecture.
Comment je pourrais descendre encore en temps ?