GPU: D3D12 stencil plane transition (#15519)

This commit is contained in:
Evan Hemsley
2026-05-05 12:55:16 -07:00
committed by GitHub
parent c7df6fe847
commit fee8c94b5c

View File

@@ -1838,6 +1838,16 @@ static inline Uint32 D3D12_INTERNAL_CalcSubresource(
return mipLevel + (layer * numLevels);
}
static inline Uint32 D3D12_INTERNAL_CalcSubresourceWithPlane(
Uint32 mipLevel,
Uint32 layer,
Uint32 planeSlice,
Uint32 numLevels,
Uint32 arraySize)
{
return mipLevel + (layer * numLevels) + (planeSlice * numLevels * arraySize);
}
static void D3D12_INTERNAL_ResourceBarrier(
D3D12CommandBuffer *commandBuffer,
D3D12_RESOURCE_STATES sourceState,
@@ -1894,6 +1904,27 @@ static void D3D12_INTERNAL_TextureSubresourceBarrier(
textureSubresource->parent->resource,
textureSubresource->index,
needsUAVBarrier);
// D3D12 stores planar values on a separate subresource.
// Since depth-stencil is our only supported planar format,
// just force an extra transition if we're using a stencil format.
if (IsStencilFormat(textureSubresource->parent->container->header.info.format)) {
Uint32 planeSubresourceIndex = D3D12_INTERNAL_CalcSubresourceWithPlane(
textureSubresource->level,
textureSubresource->layer,
1,
textureSubresource->parent->container->header.info.num_levels,
textureSubresource->parent->container->header.info.layer_count_or_depth
);
D3D12_INTERNAL_ResourceBarrier(
commandBuffer,
sourceState,
destinationState,
textureSubresource->parent->resource,
planeSubresourceIndex,
needsUAVBarrier);
}
}
static D3D12_RESOURCE_STATES D3D12_INTERNAL_DefaultTextureResourceState(