[SlimDX] Is necessary Map/Unmap always???

Started by
1 comment, last by Pulsar79 13 years, 5 months ago
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.
Advertisement
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.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

Because I use Compute Shader for calculating data from one image, and later I need this data for my program in .NET.

ReadRange o read from datastrem is fast, it is slow UNMAP the resource...

This topic is closed to new replies.

Advertisement