mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-18 02:52:10 +01:00
[d3d11] Added support for raw and structured shader resource views
This commit is contained in:
parent
a72727a173
commit
410d3a86d9
@ -148,26 +148,37 @@ namespace dxvk {
|
|||||||
if (resourceDim == D3D11_RESOURCE_DIMENSION_BUFFER) {
|
if (resourceDim == D3D11_RESOURCE_DIMENSION_BUFFER) {
|
||||||
auto resource = static_cast<D3D11Buffer*>(pResource);
|
auto resource = static_cast<D3D11Buffer*>(pResource);
|
||||||
|
|
||||||
// TODO implement raw and structured buffers
|
D3D11_BUFFER_DESC resourceDesc;
|
||||||
if (pDesc->Format == DXGI_FORMAT_UNKNOWN) {
|
resource->GetDesc(&resourceDesc);
|
||||||
Logger::err("D3D11Device: Raw and structured buffers not yet supported");
|
|
||||||
return E_INVALIDARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Typed buffer views support uncompressed color formats only
|
|
||||||
const VkFormat format = m_dxgiAdapter->LookupFormat(
|
|
||||||
pDesc->Format, DxgiFormatMode::Color).format;
|
|
||||||
const DxvkFormatInfo* formatInfo = imageFormatInfo(format);
|
|
||||||
|
|
||||||
if (formatInfo->flags.test(DxvkFormatFlag::BlockCompressed)) {
|
|
||||||
Logger::err("D3D11Device: Compressed formats for buffer views not supported");
|
|
||||||
return E_INVALIDARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
DxvkBufferViewCreateInfo viewInfo;
|
DxvkBufferViewCreateInfo viewInfo;
|
||||||
viewInfo.format = format;
|
|
||||||
viewInfo.rangeOffset = formatInfo->elementSize * pDesc->Buffer.FirstElement;
|
if (desc.ViewDimension == D3D11_SRV_DIMENSION_BUFFEREX) {
|
||||||
viewInfo.rangeLength = formatInfo->elementSize * pDesc->Buffer.NumElements;
|
// Raw or structured view. We'll represent this
|
||||||
|
// as a uniform texel buffer with UINT32 elements.
|
||||||
|
viewInfo.format = VK_FORMAT_R32_UINT;
|
||||||
|
|
||||||
|
if (desc.BufferEx.Flags & D3D11_BUFFEREX_SRV_FLAG_RAW) {
|
||||||
|
viewInfo.rangeOffset = sizeof(uint32_t) * desc.BufferEx.FirstElement;
|
||||||
|
viewInfo.rangeLength = sizeof(uint32_t) * desc.BufferEx.NumElements;
|
||||||
|
} else {
|
||||||
|
viewInfo.rangeOffset = resourceDesc.StructureByteStride * desc.BufferEx.FirstElement;
|
||||||
|
viewInfo.rangeLength = resourceDesc.StructureByteStride * desc.BufferEx.NumElements;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Typed buffer view - must use an uncompressed color format
|
||||||
|
viewInfo.format = m_dxgiAdapter->LookupFormat(
|
||||||
|
desc.Format, DxgiFormatMode::Color).format;
|
||||||
|
|
||||||
|
const DxvkFormatInfo* formatInfo = imageFormatInfo(viewInfo.format);
|
||||||
|
viewInfo.rangeOffset = formatInfo->elementSize * desc.Buffer.FirstElement;
|
||||||
|
viewInfo.rangeLength = formatInfo->elementSize * desc.Buffer.NumElements;
|
||||||
|
|
||||||
|
if (formatInfo->flags.test(DxvkFormatFlag::BlockCompressed)) {
|
||||||
|
Logger::err("D3D11Device: Compressed formats for buffer views not supported");
|
||||||
|
return E_INVALIDARG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ppSRView == nullptr)
|
if (ppSRView == nullptr)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
|
@ -23,4 +23,6 @@ typedef struct D3D11_FEATURE_DATA_FORMAT_SUPPORT {
|
|||||||
DXGI_FORMAT InFormat;
|
DXGI_FORMAT InFormat;
|
||||||
UINT OutFormatSupport;
|
UINT OutFormatSupport;
|
||||||
} D3D11_FEATURE_DATA_FORMAT_SUPPORT;
|
} D3D11_FEATURE_DATA_FORMAT_SUPPORT;
|
||||||
|
typedef enum D3D11_BUFFEREX_SRV_FLAG {
|
||||||
|
D3D11_BUFFEREX_SRV_FLAG_RAW = 1
|
||||||
|
} D3D11_BUFFEREX_SRV_FLAG;
|
Loading…
x
Reference in New Issue
Block a user