Validate format is blendable when blending is enabled

Treat color target format with "float" capabilities as
blendable format and validate when blending is enabled.
Add helpers for checking float16 texture values.

Bug: dawn:726

Change-Id: Icf8c0182e5e9a13523970c84b5af91f395a089af
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57744
Commit-Queue: Shrek Shao <shrekshao@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
shrekshao
2021-07-19 23:27:27 +00:00
committed by Dawn LUCI CQ
parent 631b300262
commit bdc029ee39
8 changed files with 131 additions and 23 deletions

View File

@@ -35,10 +35,16 @@ class RenderPipelineValidationTest : public ValidationTest {
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})");
fsModuleUint = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<u32> {
return vec4<u32>(0u, 255u, 0u, 255u);
})");
}
wgpu::ShaderModule vsModule;
wgpu::ShaderModule fsModule;
wgpu::ShaderModule fsModuleUint;
};
// Test cases where creation should succeed
@@ -148,6 +154,66 @@ TEST_F(RenderPipelineValidationTest, NonRenderableFormat) {
}
}
// Tests that the color formats must be blendable when blending is enabled.
// Those are renderable color formats with "float" capabilities in
// https://gpuweb.github.io/gpuweb/#plain-color-formats
TEST_F(RenderPipelineValidationTest, NonBlendableFormat) {
{
// Succeeds because RGBA8Unorm is blendable
utils::ComboRenderPipelineDescriptor descriptor;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
descriptor.cTargets[0].blend = &descriptor.cBlends[0];
descriptor.cTargets[0].format = wgpu::TextureFormat::RGBA8Unorm;
device.CreateRenderPipeline(&descriptor);
}
{
// Fails because RGBA32Float is not blendable
utils::ComboRenderPipelineDescriptor descriptor;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
descriptor.cTargets[0].blend = &descriptor.cBlends[0];
descriptor.cTargets[0].format = wgpu::TextureFormat::RGBA32Float;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
}
{
// Succeeds because RGBA32Float is not blendable but blending is disabled
utils::ComboRenderPipelineDescriptor descriptor;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
descriptor.cTargets[0].blend = nullptr;
descriptor.cTargets[0].format = wgpu::TextureFormat::RGBA32Float;
device.CreateRenderPipeline(&descriptor);
}
{
// Fails because RGBA8Uint is not blendable
utils::ComboRenderPipelineDescriptor descriptor;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModuleUint;
descriptor.cTargets[0].blend = &descriptor.cBlends[0];
descriptor.cTargets[0].format = wgpu::TextureFormat::RGBA8Uint;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
}
{
// Succeeds because RGBA8Uint is not blendable but blending is disabled
utils::ComboRenderPipelineDescriptor descriptor;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModuleUint;
descriptor.cTargets[0].blend = nullptr;
descriptor.cTargets[0].format = wgpu::TextureFormat::RGBA8Uint;
device.CreateRenderPipeline(&descriptor);
}
}
// Tests that the format of the color state descriptor must match the output of the fragment shader.
TEST_F(RenderPipelineValidationTest, FragmentOutputFormatCompatibility) {
constexpr uint32_t kNumTextureFormatBaseType = 3u;