Format: Move the baseType to be per-aspect.

This also introduces a per-aspect supportedComponentTypes that exactly
mirrors baseType for now but will contain additional bits in the future
(like DepthComparison for depth textures).

It is also a step towards being able to create single-aspect view of
depth-stencil textures to sample either the depth or the stencil
component.

Bug: dawn:527

Change-Id: I3ab224d07c136c682cc2993b9a8599237d318130
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/30103
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez
2020-10-16 14:07:06 +00:00
committed by Commit Bot service account
parent b1938273e4
commit 2a8ada7951
9 changed files with 170 additions and 129 deletions

View File

@@ -928,21 +928,27 @@ namespace dawn_native { namespace opengl {
if (attachmentInfo->loadOp == wgpu::LoadOp::Clear) {
gl.ColorMaski(i, true, true, true, true);
const Format& attachmentFormat = attachmentInfo->view->GetFormat();
if (attachmentFormat.HasComponentType(Format::Type::Float)) {
const std::array<float, 4> appliedClearColor =
ConvertToFloatColor(attachmentInfo->clearColor);
gl.ClearBufferfv(GL_COLOR, i, appliedClearColor.data());
} else if (attachmentFormat.HasComponentType(Format::Type::Uint)) {
const std::array<uint32_t, 4> appliedClearColor =
ConvertToUnsignedIntegerColor(attachmentInfo->clearColor);
gl.ClearBufferuiv(GL_COLOR, i, appliedClearColor.data());
} else if (attachmentFormat.HasComponentType(Format::Type::Sint)) {
const std::array<int32_t, 4> appliedClearColor =
ConvertToSignedIntegerColor(attachmentInfo->clearColor);
gl.ClearBufferiv(GL_COLOR, i, appliedClearColor.data());
} else {
UNREACHABLE();
wgpu::TextureComponentType baseType =
attachmentInfo->view->GetFormat().GetAspectInfo(Aspect::Color).baseType;
switch (baseType) {
case wgpu::TextureComponentType::Float: {
const std::array<float, 4> appliedClearColor =
ConvertToFloatColor(attachmentInfo->clearColor);
gl.ClearBufferfv(GL_COLOR, i, appliedClearColor.data());
break;
}
case wgpu::TextureComponentType::Uint: {
const std::array<uint32_t, 4> appliedClearColor =
ConvertToUnsignedIntegerColor(attachmentInfo->clearColor);
gl.ClearBufferuiv(GL_COLOR, i, appliedClearColor.data());
break;
}
case wgpu::TextureComponentType::Sint: {
const std::array<int32_t, 4> appliedClearColor =
ConvertToSignedIntegerColor(attachmentInfo->clearColor);
gl.ClearBufferiv(GL_COLOR, i, appliedClearColor.data());
break;
}
}
}