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 Change-Id: Ieda8475500b0553f8c14aa9ecad57001b9714d49 Reviewed-by: Andy Nichols <andy.nichols@qt.io> (cherry picked from commit e126558b9b4d4bf8f06ed7bf84dcfe3922801663) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
34a64c3771
commit
27d2256494
@ -3832,6 +3832,27 @@ bool QD3D11TextureRenderTarget::create()
|
|||||||
dsvDesc.Format = toD3DDepthTextureDSVFormat(depthTexD->format());
|
dsvDesc.Format = toD3DDepthTextureDSVFormat(depthTexD->format());
|
||||||
dsvDesc.ViewDimension = depthTexD->sampleDesc.Count > 1 ? D3D11_DSV_DIMENSION_TEXTURE2DMS
|
dsvDesc.ViewDimension = depthTexD->sampleDesc.Count > 1 ? D3D11_DSV_DIMENSION_TEXTURE2DMS
|
||||||
: D3D11_DSV_DIMENSION_TEXTURE2D;
|
: 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);
|
HRESULT hr = rhiD->dev->CreateDepthStencilView(depthTexD->tex, &dsvDesc, &dsv);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qWarning("Failed to create dsv: %s",
|
qWarning("Failed to create dsv: %s",
|
||||||
|
@ -4485,6 +4485,27 @@ bool QD3D12TextureRenderTarget::create()
|
|||||||
dsvDesc.Format = toD3DDepthTextureDSVFormat(depthTexD->format());
|
dsvDesc.Format = toD3DDepthTextureDSVFormat(depthTexD->format());
|
||||||
dsvDesc.ViewDimension = depthTexD->sampleDesc.Count > 1 ? D3D12_DSV_DIMENSION_TEXTURE2DMS
|
dsvDesc.ViewDimension = depthTexD->sampleDesc.Count > 1 ? D3D12_DSV_DIMENSION_TEXTURE2DMS
|
||||||
: D3D12_DSV_DIMENSION_TEXTURE2D;
|
: 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);
|
dsv = rhiD->dsvPool.allocate(1);
|
||||||
if (!dsv.isValid()) {
|
if (!dsv.isValid()) {
|
||||||
qWarning("Failed to allocate DSV for texture render target");
|
qWarning("Failed to allocate DSV for texture render target");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user