mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-17 00:47:13 +00:00
Add two missing checks on render pass descriptor
This patch adds two missing checks on the render pass descriptor: 1. NaN is not allowed to be a value of clearColor and clearDepth. 2. Ensure only valid values can be used as loadOp and storeOp. This patch also adds the unit tests to ensure INFINITY is a valid value for both clearColor and clearDepth. BUG=dawn:299 Change-Id: Ia5500701ccd99abf488a80c87adb809521d7873f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14460 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
committed by
Commit Bot service account
parent
af094e6a88
commit
51c347a231
@@ -18,6 +18,8 @@
|
||||
|
||||
#include "utils/WGPUHelpers.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace {
|
||||
|
||||
class RenderPassDescriptorValidationTest : public ValidationTest {
|
||||
@@ -661,6 +663,80 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, DepthStencilAttachmentSam
|
||||
}
|
||||
}
|
||||
|
||||
// Tests that NaN cannot be accepted as a valid color or depth clear value and INFINITY is valid in
|
||||
// both color and depth clear values.
|
||||
TEST_F(RenderPassDescriptorValidationTest, UseNaNOrINFINITYAsColorOrDepthClearValue) {
|
||||
wgpu::TextureView color = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
|
||||
|
||||
// Tests that NaN cannot be used in clearColor.
|
||||
{
|
||||
utils::ComboRenderPassDescriptor renderPass({color}, nullptr);
|
||||
renderPass.cColorAttachments[0].clearColor.r = NAN;
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
|
||||
{
|
||||
utils::ComboRenderPassDescriptor renderPass({color}, nullptr);
|
||||
renderPass.cColorAttachments[0].clearColor.g = NAN;
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
|
||||
{
|
||||
utils::ComboRenderPassDescriptor renderPass({color}, nullptr);
|
||||
renderPass.cColorAttachments[0].clearColor.b = NAN;
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
|
||||
{
|
||||
utils::ComboRenderPassDescriptor renderPass({color}, nullptr);
|
||||
renderPass.cColorAttachments[0].clearColor.a = NAN;
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
|
||||
// Tests that INFINITY can be used in clearColor.
|
||||
{
|
||||
utils::ComboRenderPassDescriptor renderPass({color}, nullptr);
|
||||
renderPass.cColorAttachments[0].clearColor.r = INFINITY;
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
|
||||
{
|
||||
utils::ComboRenderPassDescriptor renderPass({color}, nullptr);
|
||||
renderPass.cColorAttachments[0].clearColor.g = INFINITY;
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
|
||||
{
|
||||
utils::ComboRenderPassDescriptor renderPass({color}, nullptr);
|
||||
renderPass.cColorAttachments[0].clearColor.b = INFINITY;
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
|
||||
{
|
||||
utils::ComboRenderPassDescriptor renderPass({color}, nullptr);
|
||||
renderPass.cColorAttachments[0].clearColor.a = INFINITY;
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
|
||||
// Tests that NaN cannot be used in clearDepth.
|
||||
{
|
||||
wgpu::TextureView depth =
|
||||
Create2DAttachment(device, 1, 1, wgpu::TextureFormat::Depth24Plus);
|
||||
utils::ComboRenderPassDescriptor renderPass({color}, depth);
|
||||
renderPass.cDepthStencilAttachmentInfo.clearDepth = NAN;
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
|
||||
// Tests that INFINITY can be used in clearDepth.
|
||||
{
|
||||
wgpu::TextureView depth =
|
||||
Create2DAttachment(device, 1, 1, wgpu::TextureFormat::Depth24Plus);
|
||||
utils::ComboRenderPassDescriptor renderPass({color}, depth);
|
||||
renderPass.cDepthStencilAttachmentInfo.clearDepth = INFINITY;
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(cwallez@chromium.org): Constraints on attachment aliasing?
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
Reference in New Issue
Block a user