將 ID3D11Texture2D 轉換為內存緩衝區 (Convert ID3D11Texture2D into a memory buffer)


問題描述

將 ID3D11Texture2D 轉換為內存緩衝區 (Convert ID3D11Texture2D into a memory buffer)

我們如何將ID3D11Texture2D 轉換為內存緩衝區?我有 ID3D11Texture2D* 並且需要從它讀取數據到內存緩衝區。


參考解法

方法 1:

You need to create a second texture with the same format/size, but create it as staging.

Texture description

Cpu access flags needs to be set to D3D11_CPU_ACCESS_READ and usage needs to be set to D3D11_USAGE_STAGING.

Then you can call ID3D11DeviceContext::CopyResource to copy from the texture to the staging one.

And then you call Map to access data.

(by starmrvux)

參考文件

  1. Convert ID3D11Texture2D into a memory buffer (CC BY‑SA 2.5/3.0/4.0)

#directx-10 #directx-9 #directx-11






相關問題

D3D10 (DirectX10) 全屏性能問題 (D3D10 (DirectX10) fullscreen performance issue)

directx10 中的精靈和紋理過濾 (Sprites in directx10 and texture filtering)

Firemonkey 中的 DirectX10 支持(非 10.1) (DirectX10 support in Firemonkey (not 10.1))

錯誤 LNK2019 Directx10 VC++2010 (Error LNK2019 Directx10 VC++2010)

管理 HLSL 效果 (Managing HLSL effects)

D3DX10CreateTextureFromFile 返回未知錯誤 (D3DX10CreateTextureFromFile returns unknown error)

使用 HLSL 變量分配 struct C++ (Assign struct C++ with HLSL variable)

ID3DX10Mesh::CloneMesh (ID3DX10Mesh::CloneMesh)

在 DirectX 10 中清除單個視口 (Clear single viewport in DirectX 10)

Visual c++ DirectX 編譯錯誤 (Visual c++ DirectX compilation error)

將 ID3D11Texture2D 轉換為內存緩衝區 (Convert ID3D11Texture2D into a memory buffer)

DirectX 10.1 / C++:如何通過 ID3D10Resource* 紋理在精靈上渲染文本? (DirectX 10.1 / C++: How to render text on sprite over ID3D10Resource* textures?)







留言討論