Reading the book: "Practical Rendering and Computation with Direct3D 11", and looking for a definition online: https://learn.microsoft.com/en-us/windows/uwp/graphics-concepts/shader-resource-view--srv-
I am still confused on what a ID3D11ShaderResourceView is.
Keep in mind, that I am learning DirectX 11 to create a video game. With that in mind ...
What is a Shader Resource View? In what situations would you use a Shader Resource View? And most importantly, how do you use a Shader Resource View?
I am assuming you can use this resource inside your HLSL Code, but in the book I have not seen an example yet on how to do this, and in what generic way it is used for video game engines.
Thank you!
In older version such as Direct3D 9, you had as single interface such as IDirect3DTexture9
, IDirect3DCubeTexture9
, or IDirect3DVolumeTexture9
which encapsulated both the image bits themselves and expected semantics of usage. This had special logic to make it work as a render target as well.
In Direct3D 10, this was split into two elements:
The resource (i.e. the image bits) like ID3DxxTexture1D
, ID3DxxTexture2D
, and ID3DxxTexture3D
The semantics of usage which is either a ID3DxxShaderResourceView
which is used to read a texture in a shader -or- ID3DxxRenderTargetView
which is used to render to a texture. There is also a ID3D11UnorderedAccessView
for working with DirectCompute.
The advantage of the newer design is that you can have a single ID3DxxTexture2D
resource and have a SRV when using it to render, and a RTV when you are using it as a render texture. You can treat a cubemap as a 2D texture with an array size of 6.
You might find the older documentation on Microsoft Docs helpful.
You should take a look at the DirectX Tool Kit tutorials