How to use Map/Unmap in DirectX11 with textures in unity? (either RenderTextures or Texture2D are fine)
I've been trying to use quite a few different things, and I followed this answer to put it in a callback via GL.IssuePluginEvent
, but it seemed to still have the flag D3D11_USAGE_DEFAULT
as mentioned there. Is there a way to set this to D3D11_USAGE_DYNAMIC
, or somehow otherwise use Map/Unmap with a texture?
Okay I found that actually using CreateExternalTexture
then creating the resource in code works great
Answer by idan_bismut · Jul 23, 2019 at 08:32 PM
I couldn't find any direct way of doing so in forums / documentation... In my case I needed a texture I can read back from CPU, so eventually ended up creating a new texture (on native plugin) via D3D11 code, with a "D3D11_USAGE_STAGING" flag, and then performed a: map, memcpy & unmap.
But if you managed somehow to define Unity's RenderTexture directly with the desired flag, that can save me extra memcpy.
Your answer
Follow this Question
Related Questions
Unity rendering correctly in editor, but incorrectly in build. 1 Answer
Material not rendering correctly on Submesh 0 Answers
Rendering objects in the same position 0 Answers
Best way to render hundreds of textures for flooring in an in-game editor? 0 Answers
Baked reflection probes causing overexposure in build. 1 Answer