RenderPipeline: validate depth bias params are not NaN

Also changes the sampler validation to allow INFINITY and only check for
NaN.

BUG=dawn:296

Change-Id: I2a61df807d37dcaf280b12a1ffe56dc670d0f455
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14480
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Corentin Wallez
2019-12-12 11:41:02 +00:00
committed by Commit Bot service account
parent ab4485f86c
commit 69cdaf94df
4 changed files with 74 additions and 10 deletions

View File

@@ -18,6 +18,7 @@
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/WGPUHelpers.h"
#include <cmath>
#include <sstream>
class RenderPipelineValidationTest : public ValidationTest {
@@ -71,6 +72,51 @@ TEST_F(RenderPipelineValidationTest, CreationSuccess) {
}
}
// Tests that depth bias parameters must not be NaN.
TEST_F(RenderPipelineValidationTest, DepthBiasParameterNotBeNaN) {
// Control case, depth bias parameters in ComboRenderPipeline default to 0 which is finite
{
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
device.CreateRenderPipeline(&descriptor);
}
// Infinite depth bias clamp is valid
{
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.cRasterizationState.depthBiasClamp = INFINITY;
device.CreateRenderPipeline(&descriptor);
}
// NAN depth bias clamp is invalid
{
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.cRasterizationState.depthBiasClamp = NAN;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
}
// Infinite depth bias slope is valid
{
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.cRasterizationState.depthBiasSlopeScale = INFINITY;
device.CreateRenderPipeline(&descriptor);
}
// NAN depth bias slope is invalid
{
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.cRasterizationState.depthBiasSlopeScale = NAN;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
}
}
// Tests that at least one color state is required.
TEST_F(RenderPipelineValidationTest, ColorStateRequired) {
{

View File

@@ -24,6 +24,10 @@ namespace {
// Test NaN and INFINITY values are not allowed
TEST_F(SamplerValidationTest, InvalidLOD) {
{
wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor();
device.CreateSampler(&samplerDesc);
}
{
wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor();
samplerDesc.lodMinClamp = NAN;
@@ -36,13 +40,14 @@ namespace {
}
{
wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor();
samplerDesc.lodMinClamp = INFINITY;
ASSERT_DEVICE_ERROR(device.CreateSampler(&samplerDesc));
samplerDesc.lodMaxClamp = INFINITY;
device.CreateSampler(&samplerDesc);
}
{
wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor();
samplerDesc.lodMaxClamp = INFINITY;
ASSERT_DEVICE_ERROR(device.CreateSampler(&samplerDesc));
samplerDesc.lodMinClamp = INFINITY;
device.CreateSampler(&samplerDesc);
}
}