My question is that it is necessary to do map/unmap always when I want to get data from GPU.
My code is:
Me._ge3d.Device.ImmediateContext.CopyResource(BufferRectangles, Me.buf2)
Dim databox2 As SlimDX.DataBox = Me._ge3d.Device.ImmediateContext.MapSubresource(Me.buf2, 0, Me.buf2.Description.SizeInBytes, MapMode.Read, SlimDX.Direct3D11.MapFlags.None)
databox2.Data.Seek(0, IO.SeekOrigin.Begin)
If _arrayRectanglesMaximos Is Nothing Then
System.Array.Resize(_arrayRectanglesMaximos, CInt(MAXRECTANGLES))
End If
For i As Integer = 0 To Me._numRectanglesLeidos - 1
'Metemos los valores en el array...
Me._arrayRectanglesMaximos(i).X = databox2.Data.Read(Of Integer)()
Me._arrayRectanglesMaximos(i).Y = databox2.Data.Read(Of Integer)()
Me._arrayRectanglesMaximos(i).Width = databox2.Data.Read(Of Integer)()
Me._arrayRectanglesMaximos(i).Height = databox2.Data.Read(Of Integer)()
Next
Me._ge3d.Device.ImmediateContext.UnmapSubresource(Me.buf2, 0)
-----------------------------------------------
The last line is very slow (order of 30 mseg.) and I want to do it fast. Each frame I have to get this data from GPU and i do a copy of buffer. What ocurrs when I don`t have "unmap"??? Memory exception??
Thanks.
[SlimDX] Is necessary Map/Unmap always???
Uh. Why are you reading back from the GPU? That's never going to be a terribly fast operation.
Also, I believe there's a ReadRange or ReadArray function (or similar) which you can use to fill the entire array, assuming struct types, instead of a for loop.
Also, I believe there's a ReadRange or ReadArray function (or similar) which you can use to fill the entire array, assuming struct types, instead of a for loop.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement