rhi: d3d: Handle the case of passing in a texture array as depthTexture
Behave identically to Vulkan, i.e. create a view that spans all array elements. (except when the range is set) This becomes relevant with multiview, where the depth/stencil attachment the render target must be set up with a texture array as well, similarly to the color attachment. But applies even to D3D11, even though it is not common to use a texture array there, but it's possible. Task-number: QTBUG-114896 Pick-to: 6.6 Change-Id: Ieda8475500b0553f8c14aa9ecad57001b9714d49 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
parent
ec01f6ae8b
commit
e126558b9b
@ -3834,6 +3834,27 @@ bool QD3D11TextureRenderTarget::create()
|
||||
dsvDesc.Format = toD3DDepthTextureDSVFormat(depthTexD->format());
|
||||
dsvDesc.ViewDimension = depthTexD->sampleDesc.Count > 1 ? D3D11_DSV_DIMENSION_TEXTURE2DMS
|
||||
: D3D11_DSV_DIMENSION_TEXTURE2D;
|
||||
if (depthTexD->flags().testFlag(QRhiTexture::TextureArray)) {
|
||||
if (depthTexD->sampleDesc.Count > 1) {
|
||||
dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY;
|
||||
if (depthTexD->arrayRangeStart() >= 0 && depthTexD->arrayRangeLength() >= 0) {
|
||||
dsvDesc.Texture2DMSArray.FirstArraySlice = UINT(depthTexD->arrayRangeStart());
|
||||
dsvDesc.Texture2DMSArray.ArraySize = UINT(depthTexD->arrayRangeLength());
|
||||
} else {
|
||||
dsvDesc.Texture2DMSArray.FirstArraySlice = 0;
|
||||
dsvDesc.Texture2DMSArray.ArraySize = UINT(qMax(0, depthTexD->arraySize()));
|
||||
}
|
||||
} else {
|
||||
dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
|
||||
if (depthTexD->arrayRangeStart() >= 0 && depthTexD->arrayRangeLength() >= 0) {
|
||||
dsvDesc.Texture2DArray.FirstArraySlice = UINT(depthTexD->arrayRangeStart());
|
||||
dsvDesc.Texture2DArray.ArraySize = UINT(depthTexD->arrayRangeLength());
|
||||
} else {
|
||||
dsvDesc.Texture2DArray.FirstArraySlice = 0;
|
||||
dsvDesc.Texture2DArray.ArraySize = UINT(qMax(0, depthTexD->arraySize()));
|
||||
}
|
||||
}
|
||||
}
|
||||
HRESULT hr = rhiD->dev->CreateDepthStencilView(depthTexD->tex, &dsvDesc, &dsv);
|
||||
if (FAILED(hr)) {
|
||||
qWarning("Failed to create dsv: %s",
|
||||
|
@ -4507,6 +4507,27 @@ bool QD3D12TextureRenderTarget::create()
|
||||
dsvDesc.Format = toD3DDepthTextureDSVFormat(depthTexD->format());
|
||||
dsvDesc.ViewDimension = depthTexD->sampleDesc.Count > 1 ? D3D12_DSV_DIMENSION_TEXTURE2DMS
|
||||
: D3D12_DSV_DIMENSION_TEXTURE2D;
|
||||
if (depthTexD->flags().testFlag(QRhiTexture::TextureArray)) {
|
||||
if (depthTexD->sampleDesc.Count > 1) {
|
||||
dsvDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2DMSARRAY;
|
||||
if (depthTexD->arrayRangeStart() >= 0 && depthTexD->arrayRangeLength() >= 0) {
|
||||
dsvDesc.Texture2DMSArray.FirstArraySlice = UINT(depthTexD->arrayRangeStart());
|
||||
dsvDesc.Texture2DMSArray.ArraySize = UINT(depthTexD->arrayRangeLength());
|
||||
} else {
|
||||
dsvDesc.Texture2DMSArray.FirstArraySlice = 0;
|
||||
dsvDesc.Texture2DMSArray.ArraySize = UINT(qMax(0, depthTexD->arraySize()));
|
||||
}
|
||||
} else {
|
||||
dsvDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2DARRAY;
|
||||
if (depthTexD->arrayRangeStart() >= 0 && depthTexD->arrayRangeLength() >= 0) {
|
||||
dsvDesc.Texture2DArray.FirstArraySlice = UINT(depthTexD->arrayRangeStart());
|
||||
dsvDesc.Texture2DArray.ArraySize = UINT(depthTexD->arrayRangeLength());
|
||||
} else {
|
||||
dsvDesc.Texture2DArray.FirstArraySlice = 0;
|
||||
dsvDesc.Texture2DArray.ArraySize = UINT(qMax(0, depthTexD->arraySize()));
|
||||
}
|
||||
}
|
||||
}
|
||||
dsv = rhiD->dsvPool.allocate(1);
|
||||
if (!dsv.isValid()) {
|
||||
qWarning("Failed to allocate DSV for texture render target");
|
||||
|
Loading…
Reference in New Issue
Block a user