sharpdx / SharpDX

SharpDX GitHub Repository
http://sharpdx.org
MIT License
1.68k stars 642 forks source link

One cannot pass NULL to MapSubresource for the parameter D3D11_MAPPED_SUBRESOURCE *pMappedResource #1131

Open adiba opened 5 years ago

adiba commented 5 years ago

Since MapSubresource returns the mapped subresource rather than taking a destination pointer, there is no way to pass pMappedResource = NULL to Map, which is required for the ReadFromSubresource operation.

Relevant docs:

h1cks commented 5 years ago

I've dug through this one and it definitely is a bug and I believe we can fix this without a breaking change. But relies on use of a default parameter to be added.

The base call into MapSubresource is the problem, its calling by mapping a databox address which then always passes a non null address to Map Sub resource.

Need to understand what to set in the mapping xml to pass as a nullable struct. Then test the struct for null in the code, prior to mapping it to a reference. I feel that this will need to be hand coded rather than auto generated. Additional changes up the call tree are required to pass through a flag to make the input variable pass whether the call should be made with a null or a data struct.

Need some advice on how to set up the mapping xml so to hand code the call to MapSubresource

h1cks commented 5 years ago

Update: Still working through the fix, may have to rethink a couple of parts of the proposed solution.