I have been playing with Direct3D 11 and was surprised to discover that an HLSL StructuredBuffer<T>
must be bound to a Shader Resource View (SRV) whereas a RWStructuredBuffer<T>
must be bound to a Uniform Access View (UAV). Looking deeper into this, it seems like all read-write shader resources require UAVs whereas readonly resources require SRVs.
Comparing the UNORDERED_ACCESS_VIEW_DESC and SHADER_RESOURCE_VIEW_DESC structures, UAVs are described with more or less a subset of the information to describe SRVs. The APIs to set UAVs and SRVs to pipeline stages are also very similar. Even the documentation of the two interfaces look like the same concept explained by two different technical writers:
- SRV: A shader-resource-view interface specifies the subresources a shader can access during rendering.
- UAV: A view interface specifies the parts of a resource the pipeline can access during rendering
I'm not very well-versed in D3D11, but it seems to me that the concept of UAVs complicates the API without much benefit. Does the distinction between SRVs and UAVs exist to better map to the hardware or because of technical restrictions? Or was it just an API design decision?