Metal/GL: Make new texture view for non-2D view of single-layer texture

Fixed: dawn:1309
Change-Id: Ide68f6498fc5fe9dd9e06c6c5caf7d3fff74e526
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/83060
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng
2022-03-09 01:07:20 +00:00
committed by Dawn LUCI CQ
parent 5073fb5685
commit 154bcbbf4d
3 changed files with 51 additions and 9 deletions

View File

@@ -56,8 +56,9 @@ namespace dawn::native::opengl {
case wgpu::TextureViewDimension::e2D:
return (sampleCount > 1) ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D;
case wgpu::TextureViewDimension::e2DArray:
if (arrayLayerCount == 1) {
return (sampleCount > 1) ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D;
if (sampleCount > 1) {
ASSERT(arrayLayerCount == 1);
return GL_TEXTURE_2D_MULTISAMPLE;
}
ASSERT(sampleCount == 1);
return GL_TEXTURE_2D_ARRAY;
@@ -93,7 +94,13 @@ namespace dawn::native::opengl {
return true;
}
if (texture->GetArrayLayers() != textureViewDescriptor->arrayLayerCount) {
if (texture->GetArrayLayers() != textureViewDescriptor->arrayLayerCount ||
(texture->GetArrayLayers() == 1 &&
texture->GetDimension() == wgpu::TextureDimension::e2D &&
textureViewDescriptor->dimension == wgpu::TextureViewDimension::e2DArray)) {
// If the view has a different number of array layers, we need a new view.
// And, if the original texture is a 2D texture with one array layer, we need a new
// view to view it as a 2D array texture.
return true;
}