-
Notifications
You must be signed in to change notification settings - Fork 344
Closed
Milestone
Description
On Windows10 (Version 10.0.19042.1645) Intel Skylake GPU (HD530, i7-6700K, 0x1912) with latest Intel driver (30.0.101.1994) , when we call CopyTextureRegion() to copy between a depth stencil texture and a buffer at a non-zero offset, a device lost will occur when offset is not a multiple of D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT (512), but such issue cannot be reproduced on Intel Gen12 GPUs (Win11) or Nvidia 2080Ti (Win10 Version 10.0.19044.1706).
I think there are two options:
- Add a restriction on the 'offset' parameter of buffer-texture copies with depth stencil textures (offset must be a multiple of 512)
- On the affected platforms, implement such buffer-texture copy into two copies with an internal buffer so that we can ensure the offset of the internal buffer passed in CopyTextureRegion() is always a multiple of 512.
More discussions can be found through this link.
For example, when running below D3D12 code, D3D12 debug layer will generate an error.
// The format of depthTexture is DXGI_FORMAT_D16_UNORM, and its size is {1, 1, 1}
// The valid data in uploadBuffer is at offset 2 and 3.
D3D12_RANGE range = { 0, 8 };
void* mappedUploadBufferPtr = nullptr;
uploadBuffer->Map(0, &range, &mappedUploadBufferPtr);
uint8_t* uint8Ptr = static_cast<uint8_t*>(mappedUploadBufferPtr);
uint8Ptr[2] = 204;
uint8Ptr[3] = 204;
uploadBuffer->Unmap(0, &range);
D3D12_TEXTURE_COPY_LOCATION textureLocation, uploadBufferLocation;
textureLocation.pResource = depthTexture.Get();
textureLocation.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
textureLocation.SubresourceIndex = 0;
uploadBufferLocation.pResource = uploadBuffer.Get();
uploadBufferLocation.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
uploadBufferLocation.PlacedFootprint.Offset = 0;
uploadBufferLocation.PlacedFootprint.Footprint.Width = 4;
uploadBufferLocation.PlacedFootprint.Footprint.Height = 1;
uploadBufferLocation.PlacedFootprint.Footprint.Depth = 1;
uploadBufferLocation.PlacedFootprint.Footprint.Format = DXGI_FORMAT_D16_UNORM;
uploadBufferLocation.PlacedFootprint.Footprint.RowPitch = 256;
D3D12_BOX region = {};
region.left = 1;
region.right = 2;
region.bottom = 1;
region.back = 1;
commandList2->CopyTextureRegion(&textureLocation, 0, 0, 0, &uploadBufferLocation, ®ion);The error message is as below:
D3D12 ERROR: ID3D12CommandList::CopyTextureRegion: Resources with either DXGI_SAMPLE_DESC::Count greater than 1 or that use
D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL can only copy the entire subresource at a time, where the subresource dimensions
must match. pSrcBox must be NULL, or specify the entire subresource. The source subresource 1 samples. The destination
subresource has 1 samples. pSrcBox left is 1, top is 0, front is 0, and all must be 0; right is 2, bottom is 1, and back is
1. But, the source subresource has 4 width, 1 height, and 1 depth. [ RESOURCE_MANIPULATION ERROR #873:
COPYTEXTUREREGION_INVALIDSRCBOX]
Metadata
Metadata
Assignees
Labels
No labels