Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.7.2, 6.8.0
-
None
-
Windows 10, Windows 11, DirectX 11, DirectX 12
Description
I tried bind QRhi 3D texture to compute shader.
Following error messages are occured at QRhiCommandBuffer::setShaderResources() if I select QRhi::D3D11 and D3D12 for QRhi Api.
(error messages from application output of Qt Creator)
D3D11 ERROR: ID3D11Device::CreateUnorderedAccessView: The Dimensions of the View are invalid. MipSlice (value = 0) must be between 0 and MipLevels-1 of the Texture Resource, 0, inclusively. FirstWSlice (value = 0) must be between 0 and the Depth size of the Mip Level, 63, inclusively. With the current FirstWSlice, WSize (value = 0) must be between 1 and 64, or -1 to default to all slices from MipSlice, inclusively, in order that the View fit on the Texture. ... Failed to create UAV: COM error 0x80070057: ??? ?????? ??????.
D3D12 ERROR: ID3D12Device::CreateUnorderedAccessView: The Dimensions of the View are invalid. MipSlice (value = 0) must be between 0 and MipLevels-1 of the Texture Resource, 0, inclusively. FirstWSlice (value = 0) must be between 0 and the Depth size of the Mip Level, 63, inclusively. With the current FirstWSlice, WSize (value = 0) must be between 1 and 64, or -1 to default to all slices from MipSlice, inclusively, in order that the View fit on the Texture....
The error messages are produced at
CreateUnorderedAccessView() in "6.7.2\Src\qtbase\src\gui\rhi\qrhid3d11.cpp" and "6.7.2\Src\qtbase\src\gui\rhi\qrhid3d12.cpp".
Errors are removed by assigning Texture3D.WSize to -1.
Following codelets are working version without error message.
"6.7.2\Src\qtbase\src\gui\rhi\qrhid3d11.cpp"
IID3D11UnorderedAccessView *QD3D11Texture::unorderedAccessViewForLevel(int level) { if (perLevelViews[level]) return perLevelViews[level]; const bool isCube = m_flags.testFlag(CubeMap); const bool isArray = m_flags.testFlag(TextureArray); const bool is3D = m_flags.testFlag(ThreeDimensional); D3D11_UNORDERED_ACCESS_VIEW_DESC desc = {}; desc.Format = dxgiFormat; if (isCube) { desc.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2DARRAY; desc.Texture2DArray.MipSlice = UINT(level); desc.Texture2DArray.FirstArraySlice = 0; desc.Texture2DArray.ArraySize = 6; } else if (isArray) { desc.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2DARRAY; desc.Texture2DArray.MipSlice = UINT(level); desc.Texture2DArray.FirstArraySlice = 0; desc.Texture2DArray.ArraySize = UINT(qMax(0, m_arraySize)); } else if (is3D) { desc.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE3D; desc.Texture3D.MipSlice = UINT(level); desc.Texture3D.WSize = -1; // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< added } else { desc.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2D; desc.Texture2D.MipSlice = UINT(level); } QRHI_RES_RHI(QRhiD3D11); ID3D11UnorderedAccessView *uav = nullptr; HRESULT hr = rhiD->dev->CreateUnorderedAccessView(textureResource(), &desc, &uav); if (FAILED(hr)) { qWarning("Failed to create UAV: %s", qPrintable(QSystemError::windowsComString(hr))); return nullptr; } perLevelViews[level] = uav; return uav; }
"6.7.2\Src\qtbase\src\gui\rhi\qrhid3d12.cpp"
void QD3D12CommandBuffer::visitStorageImage(QD3D12Stage s, const QRhiShaderResourceBinding::Data::StorageImageData &d, QD3D12ShaderResourceVisitor::StorageOp, int) { QD3D12Texture *texD = QRHI_RES(QD3D12Texture, d.tex); const bool isCube = texD->m_flags.testFlag(QRhiTexture::CubeMap); const bool isArray = texD->m_flags.testFlag(QRhiTexture::TextureArray); const bool is3D = texD->m_flags.testFlag(QRhiTexture::ThreeDimensional); D3D12_UNORDERED_ACCESS_VIEW_DESC uavDesc = {}; uavDesc.Format = texD->dxgiFormat; if (isCube) { uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY; uavDesc.Texture2DArray.MipSlice = UINT(d.level); uavDesc.Texture2DArray.FirstArraySlice = 0; uavDesc.Texture2DArray.ArraySize = 6; } else if (isArray) { uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY; uavDesc.Texture2DArray.MipSlice = UINT(d.level); uavDesc.Texture2DArray.FirstArraySlice = 0; uavDesc.Texture2DArray.ArraySize = UINT(qMax(0, texD->m_arraySize)); } else if (is3D) { uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE3D; uavDesc.Texture3D.MipSlice = UINT(d.level); uavDesc.Texture3D.WSize = -1; // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< added } else { uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D; uavDesc.Texture2D.MipSlice = UINT(d.level); } visitorData.uavs[s].append({ texD->handle, uavDesc }); }