简体   繁体   中英

Sending shader resource to GPU in DirectX 11

Lets say I have a simple 2D texture (shader resource)

ID3D11ShaderResourceView* srvTexture;

And a default (immediate) device context

ID3D11DeviceContext* dc;

Now, I set my texture in Pixel Shader like this

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. I wander, why there are also similar methods like VSSetShaderResources, GSSetShaderResources and so on. Does it mean that every pipeline stage (VS, GS, ...) has its own GPU memory?

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". However, the shaders binded with this buffer all have the right to read this buffer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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