ID3D11DeviceContext::PSSetShaderResource() 有什么关系
PSSetShaderResource()的第一个参数:
void PSSetShaderResources(
[in] UINT StartSlot,
[in] UINT NumViews,
[in] ID3D11ShaderResourceView *const *ppShaderResourceViews
);
StartSlot :“索引到设备的从零开始的数组以开始设置着色器资源”
那么整数索引和 .hlsl 变量之间的联系是什么?在 d3d9 中,一切都是基于字符串的名称。现在这些整数索引似乎缺少一些东西......
假设你有一个着色器文件:
// shader_1.psh
Texture2D tex ;
还有另一个..
// shader_2.psh
TextureCube cubeTex ;
如果你只使用shader_1.psh,当它们位于单独的文件中时如何区分它们?
// something like this..
d3d11devicecontext->PSSetShaderResources( 0, 1, &texture2d ) ;
// index 0 sets 0th texture..
// what index is the tex cube?
PSSetShaderResource()'s first parameter:
void PSSetShaderResources(
[in] UINT StartSlot,
[in] UINT NumViews,
[in] ID3D11ShaderResourceView *const *ppShaderResourceViews
);
StartSlot: "Index into the device's zero-based array to begin setting shader resources"
So what's the tie up between integer indices and your .hlsl variables? In d3d9, everything was by string-based name. Now these integer indices seem to have something missing......
Say you have one shader file:
// shader_1.psh
Texture2D tex ;
And another..
// shader_2.psh
TextureCube cubeTex ;
If you're only using shader_1.psh, how do you distinguish between them when they are in separate files?
// something like this..
d3d11devicecontext->PSSetShaderResources( 0, 1, &texture2d ) ;
// index 0 sets 0th texture..
// what index is the tex cube?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这仍然是一个经过实验验证的猜测(没有找到参考文档),但我相信你可以这样做:
所以现在,从 C++ 代码中,将
D3D11Texture2D*
绑定到tex
在着色器中,关系是:This is still an experimentally verified guess (didn't find reference documentation), but I believe you can do it like so:
So now, from the C++ code, to bind a
D3D11Texture2D*
totex
in the shader, the tie up is: