简体   繁体   English

将着色器资源发送到DirectX 11中的GPU

[英]Sending shader resource to GPU in DirectX 11

Lets say I have a simple 2D texture (shader resource) 可以说我有一个简单的2D纹理(着色器资源)

ID3D11ShaderResourceView* srvTexture;

And a default (immediate) device context 和默认(立即)设备上下文

ID3D11DeviceContext* dc;

Now, I set my texture in Pixel Shader like this 现在,我像这样在Pixel Shader中设置纹理

ID3D11ShaderResourceView* srvArrayTexture[1];
srvArrayTexture[0] = srvTexture; 

dc->PSSetShaderResources(
0,                 // start slot (not important in this case)
1,                 // nb of views (one texture)
srvArrayTexture);  // my texture as array (because DirectX wants array)

I understand this process as sending actual texture from RAM memory to GPU memory. 我将这个过程理解为将实际纹理从RAM内存发送到GPU内存。 I wander, why there are also similar methods like VSSetShaderResources, GSSetShaderResources and so on. 我徘徊,为什么还有类似的方法,例如VSSetShaderResources,GSSetShaderResources等。 Does it mean that every pipeline stage (VS, GS, ...) has its own GPU memory? 这是否意味着每个流水线阶段(VS,GS等)都有自己的GPU内存?

If I call 如果我打电话

dc->VSSetShaderResources(A);
dc->GSSetShaderResources(A);
dc->PSSetShaderResources(A);

Does it mean that I am sending same data three times? 这是否意味着我要发送三次相同的数据? Or maybe my data sending concept is inefficient? 还是我的数据发送概念效率低下?

These three functions are just binding, not copying, specific resources in the resource buffer to different shaders(vertex shader, pixel shader, geometry shader). 这三个功能只是将资源缓冲区中的特定资源绑定(而不是复制)到不同的着色器(顶点着色器,像素着色器,几何着色器)。 A resource buffer can be read during different stages of the pipeline. 可以在管道的不同阶段读取资源缓冲区。 In your example, there is only one buffer of "A". 在您的示例中,只有一个缓冲区“ A”。 However, the shaders binded with this buffer all have the right to read this buffer. 但是,绑定到此缓冲区的着色器都有权读取此缓冲区。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM