TextureView defaults and validation updates

Spec PR: https://github.com/gpuweb/gpuweb/pull/2687

Fixed: dawn:682
Bug: dawn:1276
Change-Id: Ifa8f94fa4c1a27fb40d0ccfb9f032ca4a28ed24e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/84520
Reviewed-by: Loko Kung <lokokung@google.com>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng
2022-04-01 23:04:50 +00:00
committed by Dawn LUCI CQ
parent 595e20085d
commit 42e76ba82a
6 changed files with 106 additions and 62 deletions

View File

@@ -95,7 +95,10 @@ namespace dawn::native::opengl {
bool RequiresCreatingNewTextureView(const TextureBase* texture,
const TextureViewDescriptor* textureViewDescriptor) {
if (texture->GetFormat().format != textureViewDescriptor->format) {
if (texture->GetFormat().format != textureViewDescriptor->format &&
!texture->GetFormat().HasDepthOrStencil()) {
// Color format reinterpretation required. Note: Depth/stencil formats don't support
// reinterpretation.
return true;
}
@@ -561,7 +564,14 @@ namespace dawn::native::opengl {
const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
mHandle = GenTexture(gl);
const Texture* textureGL = ToBackend(texture);
const GLFormat& glFormat = ToBackend(GetDevice())->GetGLFormat(GetFormat());
const Format& textureFormat = GetTexture()->GetFormat();
// Depth/stencil don't support reinterpretation, and the aspect is specified at
// bind time. In that case, we use the base texture format.
const GLFormat& glFormat = textureFormat.HasDepthOrStencil()
? ToBackend(GetDevice())->GetGLFormat(textureFormat)
: ToBackend(GetDevice())->GetGLFormat(GetFormat());
gl.TextureView(mHandle, mTarget, textureGL->GetHandle(), glFormat.internalFormat,
descriptor->baseMipLevel, descriptor->mipLevelCount,
descriptor->baseArrayLayer, descriptor->arrayLayerCount);