Allow using DepthOnly aspect on the depth-only formats in T2T copies
This patch allows the use of DepthOnly as the parameter 'aspect' in the command CopyTextureToTexture() on the depth-only formats (Depth24Plus and Depth32Float) to match the latest WebGPU SPEC. BUG=dawn:439 TEST=dawn_unittests Change-Id: I73c4055bb0a90bed2b5751ce9dff5b319787efca Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/38340 Commit-Queue: Jiawei Shao <jiawei.shao@intel.com> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
45ce1fda88
commit
db383498c5
|
@ -701,10 +701,15 @@ namespace dawn_native {
|
||||||
return DAWN_VALIDATION_ERROR("Source and destination texture formats must match.");
|
return DAWN_VALIDATION_ERROR("Source and destination texture formats must match.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src.aspect != wgpu::TextureAspect::All || dst.aspect != wgpu::TextureAspect::All) {
|
// Metal cannot select a single aspect for texture-to-texture copies.
|
||||||
// Metal cannot select a single aspect for texture-to-texture copies
|
const Format& format = src.texture->GetFormat();
|
||||||
|
if (SelectFormatAspects(format, src.aspect) != format.aspects) {
|
||||||
return DAWN_VALIDATION_ERROR(
|
return DAWN_VALIDATION_ERROR(
|
||||||
"Texture aspect must be \"all\" for texture to texture copies");
|
"Source aspect doesn't select all the aspects of the source format.");
|
||||||
|
}
|
||||||
|
if (SelectFormatAspects(format, dst.aspect) != format.aspects) {
|
||||||
|
return DAWN_VALIDATION_ERROR(
|
||||||
|
"Destination aspect doesn't select all the aspects of the destination format.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src.texture == dst.texture && src.mipLevel == dst.mipLevel) {
|
if (src.texture == dst.texture && src.mipLevel == dst.mipLevel) {
|
||||||
|
|
|
@ -1664,6 +1664,34 @@ TEST_F(CopyCommandTest_T2T, 2DTextureDepthStencil) {
|
||||||
{16, 16, 1}, wgpu::TextureAspect::StencilOnly);
|
{16, 16, 1}, wgpu::TextureAspect::StencilOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(CopyCommandTest_T2T, 2DTextureDepthOnly) {
|
||||||
|
constexpr std::array<wgpu::TextureFormat, 2> kDepthOnlyFormats = {
|
||||||
|
wgpu::TextureFormat::Depth24Plus, wgpu::TextureFormat::Depth32Float};
|
||||||
|
|
||||||
|
for (wgpu::TextureFormat format : kDepthOnlyFormats) {
|
||||||
|
wgpu::Texture source = Create2DTexture(16, 16, 1, 1, format, wgpu::TextureUsage::CopySrc);
|
||||||
|
|
||||||
|
wgpu::Texture destination =
|
||||||
|
Create2DTexture(16, 16, 1, 1, format, wgpu::TextureUsage::CopyDst);
|
||||||
|
|
||||||
|
// Success when entire subresource is copied
|
||||||
|
TestT2TCopy(utils::Expectation::Success, source, 0, {0, 0, 0}, destination, 0, {0, 0, 0},
|
||||||
|
{16, 16, 1});
|
||||||
|
|
||||||
|
// Failure when depth subresource is partially copied
|
||||||
|
TestT2TCopy(utils::Expectation::Failure, source, 0, {0, 0, 0}, destination, 0, {0, 0, 0},
|
||||||
|
{15, 15, 1});
|
||||||
|
|
||||||
|
// Success when selecting the depth aspect (not all)
|
||||||
|
TestT2TCopy(utils::Expectation::Success, source, 0, {0, 0, 0}, destination, 0, {0, 0, 0},
|
||||||
|
{16, 16, 1}, wgpu::TextureAspect::DepthOnly);
|
||||||
|
|
||||||
|
// Failure when selecting the stencil aspect (not all)
|
||||||
|
TestT2TCopy(utils::Expectation::Failure, source, 0, {0, 0, 0}, destination, 0, {0, 0, 0},
|
||||||
|
{16, 16, 1}, wgpu::TextureAspect::StencilOnly);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(CopyCommandTest_T2T, 2DTextureArrayDepthStencil) {
|
TEST_F(CopyCommandTest_T2T, 2DTextureArrayDepthStencil) {
|
||||||
{
|
{
|
||||||
wgpu::Texture source = Create2DTexture(
|
wgpu::Texture source = Create2DTexture(
|
||||||
|
|
Loading…
Reference in New Issue