Update createView default logic to match spec
Textures with more than one arrayLayer will now default to 2DArray rather than 2D. Change-Id: I34dd58aae27c4add65166343641777b3ac4dabcb Bug: dawn:1380 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87306 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
20a4bd8377
commit
7aeac5e67f
|
@ -537,6 +537,7 @@ MaybeError DoCopyTextureForBrowser(DeviceBase* device,
|
||||||
|
|
||||||
// Prepare binding 2 resource: sampled texture
|
// Prepare binding 2 resource: sampled texture
|
||||||
TextureViewDescriptor srcTextureViewDesc = {};
|
TextureViewDescriptor srcTextureViewDesc = {};
|
||||||
|
srcTextureViewDesc.dimension = wgpu::TextureViewDimension::e2D;
|
||||||
srcTextureViewDesc.baseMipLevel = source->mipLevel;
|
srcTextureViewDesc.baseMipLevel = source->mipLevel;
|
||||||
srcTextureViewDesc.mipLevelCount = 1;
|
srcTextureViewDesc.mipLevelCount = 1;
|
||||||
srcTextureViewDesc.arrayLayerCount = 1;
|
srcTextureViewDesc.arrayLayerCount = 1;
|
||||||
|
@ -556,6 +557,7 @@ MaybeError DoCopyTextureForBrowser(DeviceBase* device,
|
||||||
|
|
||||||
// Prepare dst texture view as color Attachment.
|
// Prepare dst texture view as color Attachment.
|
||||||
TextureViewDescriptor dstTextureViewDesc;
|
TextureViewDescriptor dstTextureViewDesc;
|
||||||
|
dstTextureViewDesc.dimension = wgpu::TextureViewDimension::e2D;
|
||||||
dstTextureViewDesc.baseMipLevel = destination->mipLevel;
|
dstTextureViewDesc.baseMipLevel = destination->mipLevel;
|
||||||
dstTextureViewDesc.mipLevelCount = 1;
|
dstTextureViewDesc.mipLevelCount = 1;
|
||||||
dstTextureViewDesc.baseArrayLayer = destination->origin.z;
|
dstTextureViewDesc.baseArrayLayer = destination->origin.z;
|
||||||
|
|
|
@ -441,7 +441,7 @@ ResultOrError<TextureViewDescriptor> GetTextureViewDescriptorWithDefaults(
|
||||||
}
|
}
|
||||||
|
|
||||||
// The default value for the view dimension depends on the texture's dimension with a
|
// The default value for the view dimension depends on the texture's dimension with a
|
||||||
// special case for 2DArray being chosen automatically if arrayLayerCount is unspecified.
|
// special case for 2DArray being chosen if texture is 2D but has more than one array layer.
|
||||||
if (desc.dimension == wgpu::TextureViewDimension::Undefined) {
|
if (desc.dimension == wgpu::TextureViewDimension::Undefined) {
|
||||||
switch (texture->GetDimension()) {
|
switch (texture->GetDimension()) {
|
||||||
case wgpu::TextureDimension::e1D:
|
case wgpu::TextureDimension::e1D:
|
||||||
|
@ -449,7 +449,11 @@ ResultOrError<TextureViewDescriptor> GetTextureViewDescriptorWithDefaults(
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wgpu::TextureDimension::e2D:
|
case wgpu::TextureDimension::e2D:
|
||||||
desc.dimension = wgpu::TextureViewDimension::e2D;
|
if (texture->GetArrayLayers() == 1) {
|
||||||
|
desc.dimension = wgpu::TextureViewDimension::e2D;
|
||||||
|
} else {
|
||||||
|
desc.dimension = wgpu::TextureViewDimension::e2DArray;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wgpu::TextureDimension::e3D:
|
case wgpu::TextureDimension::e3D:
|
||||||
|
|
|
@ -487,10 +487,15 @@ TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaults2DArray) {
|
||||||
{
|
{
|
||||||
wgpu::TextureViewDescriptor descriptor;
|
wgpu::TextureViewDescriptor descriptor;
|
||||||
|
|
||||||
// Setting array layers to non-0 means the dimensionality will
|
// Setting array layers to > 1 with an explicit dimensionality of 2D will
|
||||||
// default to 2D so by itself it causes an error.
|
// causes an error.
|
||||||
descriptor.arrayLayerCount = kDefaultArrayLayers;
|
descriptor.arrayLayerCount = kDefaultArrayLayers;
|
||||||
|
descriptor.dimension = wgpu::TextureViewDimension::e2D;
|
||||||
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
|
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
|
||||||
|
// Setting view dimension to Undefined will result in a dimension of 2DArray because the
|
||||||
|
// underlying texture has > 1 array layers.
|
||||||
|
descriptor.dimension = wgpu::TextureViewDimension::Undefined;
|
||||||
|
texture.CreateView(&descriptor);
|
||||||
descriptor.dimension = wgpu::TextureViewDimension::e2DArray;
|
descriptor.dimension = wgpu::TextureViewDimension::e2DArray;
|
||||||
texture.CreateView(&descriptor);
|
texture.CreateView(&descriptor);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue