Skip to content

Commit 388ff62

Browse files
greggmanDawn LUCI CQ
authored andcommitted
Compat: Switch interpolate params to pipeline errors
This turned into a bigger CL because the it removes the last need for ValidationMode which causes an error that mode_ in Validator was unused. Fixed: 357042303,357047899 Bug: 357042303,357047899 Change-Id: I87812d183a054a7869d04bc281cb9ea75b637976 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/201434 Reviewed-by: James Price <[email protected]> Commit-Queue: Gregg Tavares <[email protected]>
1 parent 6f9f342 commit 388ff62

23 files changed

+73
-381
lines changed

src/dawn/native/RenderPipeline.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,29 @@ MaybeError ValidateInterStageMatching(DeviceBase* device,
812812
"different from the interpolation sampling (%s) of the fragment input at "
813813
"location %u.",
814814
vertexOutputInfo.interpolationSampling, i, fragmentInputInfo.interpolationSampling, i);
815+
816+
if (device->IsCompatibilityMode()) {
817+
DAWN_INVALID_IF(
818+
vertexOutputInfo.interpolationType == InterpolationType::Linear,
819+
"The interpolation type (%s) of the vertex output at location %u is not "
820+
"supported in compatibility mode",
821+
vertexOutputInfo.interpolationType, i);
822+
823+
DAWN_INVALID_IF(
824+
vertexOutputInfo.interpolationSampling == InterpolationSampling::Sample ||
825+
vertexOutputInfo.interpolationSampling == InterpolationSampling::First,
826+
"The interpolation sampling (%s) of the vertex output at location %u is "
827+
"not supported in compatibility mode",
828+
vertexOutputInfo.interpolationSampling, i);
829+
830+
DAWN_INVALID_IF(
831+
vertexOutputInfo.interpolationType == InterpolationType::Flat &&
832+
vertexOutputInfo.interpolationSampling == InterpolationSampling::None,
833+
"The interpolation sampling (%s) of the vertex output at location %u when "
834+
"interpolation type is (%s)"
835+
"not supported in compatibility mode",
836+
vertexOutputInfo.interpolationSampling, i, vertexOutputInfo.interpolationType);
837+
}
815838
}
816839

817840
return {};

src/dawn/native/ShaderModule.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,9 @@ ResultOrError<PixelLocalMemberType> FromTintPixelLocalMemberType(
352352

353353
ResultOrError<tint::Program> ParseWGSL(const tint::Source::File* file,
354354
const tint::wgsl::AllowedFeatures& allowedFeatures,
355-
const tint::wgsl::ValidationMode mode,
356355
const std::vector<tint::wgsl::Extension>& internalExtensions,
357356
OwnedCompilationMessages* outMessages) {
358357
tint::wgsl::reader::Options options;
359-
options.mode = mode;
360358
options.allowed_features = allowedFeatures;
361359
options.allowed_features.extensions.insert(internalExtensions.begin(),
362360
internalExtensions.end());
@@ -1204,10 +1202,8 @@ MaybeError ValidateAndParseShaderModule(
12041202
}
12051203

12061204
tint::Program program;
1207-
auto validationMode = device->IsCompatibilityMode() ? tint::wgsl::ValidationMode::kCompat
1208-
: tint::wgsl::ValidationMode::kFull;
12091205
DAWN_TRY_ASSIGN(program, ParseWGSL(tintFile.get(), device->GetWGSLAllowedFeatures(),
1210-
validationMode, internalExtensions, outMessages));
1206+
internalExtensions, outMessages));
12111207

12121208
parseResult->tintProgram = AcquireRef(new TintProgram(std::move(program), std::move(tintFile)));
12131209

src/dawn/tests/unittests/validation/CompatValidationTests.cpp

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -367,15 +367,44 @@ TEST_F(CompatValidationTest, CanNotUseShaderWithUnsupportedInterpolateTypeOrSamp
367367
v.color = vec4f(1);
368368
return v;
369369
}
370+
@fragment fn fsWithoutBadInterpolationUsage() -> @location(0) vec4f {
371+
return vec4f(1);
372+
}
373+
@fragment fn fsWithBadInterpolationUsage1(v: Vertex) -> @location(0) vec4f {
374+
return vec4f(1);
375+
}
376+
@fragment fn fsWithBadInterpolationUsage2(v: Vertex) -> @location(0) vec4f {
377+
return v.pos;
378+
}
379+
@fragment fn fsWithBadInterpolationUsage3(v: Vertex) -> @location(0) vec4f {
380+
return v.color;
381+
}
370382
)",
371383
interpolateParam);
372-
if (strcmp(interpolateParam, "perspective") == 0) {
373-
wgpu::ShaderModule moduleInterpolationLinear =
374-
utils::CreateShaderModule(device, wgsl.c_str());
375-
} else {
376-
ASSERT_DEVICE_ERROR(wgpu::ShaderModule moduleInterpolationLinear =
377-
utils::CreateShaderModule(device, wgsl.c_str()),
378-
testing::HasSubstr("in compatibility mode"));
384+
wgpu::ShaderModule moduleInterpolationLinear =
385+
utils::CreateShaderModule(device, wgsl.c_str());
386+
387+
static const char* entryPoints[] = {
388+
"fsWithoutBadInterpolationUsage",
389+
"fsWithBadInterpolationUsage1",
390+
"fsWithBadInterpolationUsage2",
391+
"fsWithBadInterpolationUsage3",
392+
};
393+
for (auto entryPoint : entryPoints) {
394+
utils::ComboRenderPipelineDescriptor descriptor;
395+
descriptor.vertex.module = moduleInterpolationLinear;
396+
descriptor.cFragment.module = moduleInterpolationLinear;
397+
descriptor.cFragment.entryPoint = entryPoint;
398+
399+
bool shouldSucceed =
400+
entryPoint == entryPoints[0] || interpolateParam == interpolateParams[0];
401+
402+
if (shouldSucceed) {
403+
device.CreateRenderPipeline(&descriptor);
404+
} else {
405+
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor),
406+
testing::HasSubstr("in compatibility mode"));
407+
}
379408
}
380409
}
381410
}

src/tint/cmd/common/helper.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ ProgramInfo LoadProgramInfo(const LoadProgramOptions& opts) {
190190

191191
tint::wgsl::reader::Options options;
192192
options.allowed_features = tint::wgsl::AllowedFeatures::Everything();
193-
options.mode = opts.mode;
194193

195194
auto file = std::make_unique<tint::Source::File>(
196195
opts.filename, std::string(data.begin(), data.end()));

src/tint/cmd/common/helper.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include <string>
3434
#include <vector>
3535

36-
#include "src/tint/lang/wgsl/common/validation_mode.h"
3736
#include "src/tint/lang/wgsl/inspector/inspector.h"
3837
#include "src/tint/utils/diagnostic/source.h"
3938

@@ -78,8 +77,6 @@ void PrintInspectorBindings(tint::inspector::Inspector& inspector);
7877
struct LoadProgramOptions {
7978
/// The file to be loaded
8079
std::string filename;
81-
/// The WGSL validation mode to use.
82-
tint::wgsl::ValidationMode mode = tint::wgsl::ValidationMode::kFull;
8380
#if TINT_BUILD_SPV_READER
8481
/// Spirv-reader options
8582
bool use_ir = false;

src/tint/cmd/tint/main.cc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
#include "src/tint/lang/wgsl/ast/transform/renamer.h"
5050
#include "src/tint/lang/wgsl/ast/transform/single_entry_point.h"
5151
#include "src/tint/lang/wgsl/ast/transform/substitute_override.h"
52-
#include "src/tint/lang/wgsl/common/validation_mode.h"
5352
#include "src/tint/lang/wgsl/helpers/flatten_bindings.h"
5453
#include "src/tint/utils/cli/cli.h"
5554
#include "src/tint/utils/command/command.h"
@@ -181,7 +180,6 @@ struct Options {
181180
bool parse_only = false;
182181
bool disable_workgroup_init = false;
183182
bool validate = false;
184-
bool compatibility_mode = false;
185183
bool print_hash = false;
186184
bool dump_inspector_bindings = false;
187185
bool enable_robustness = false;
@@ -362,11 +360,6 @@ When specified, automatically enables MSL validation)",
362360
options.Add<BoolOption>("parse-only", "Stop after parsing the input", Default{false});
363361
TINT_DEFER(opts->parse_only = *parse_only.value);
364362

365-
auto& compatibility_mode = options.Add<BoolOption>(
366-
"compatibility-mode", "Validate WGSL input using \"compatibility mode\"",
367-
ShortName{"compat"}, Default{false});
368-
TINT_DEFER(opts->compatibility_mode = *compatibility_mode.value);
369-
370363
#if TINT_BUILD_SPV_READER
371364
auto& allow_nud =
372365
options.Add<BoolOption>("allow-non-uniform-derivatives",
@@ -1310,8 +1303,6 @@ int main(int argc, const char** argv) {
13101303

13111304
tint::cmd::LoadProgramOptions opts;
13121305
opts.filename = options.input_filename;
1313-
opts.mode = options.compatibility_mode ? tint::wgsl::ValidationMode::kCompat
1314-
: tint::wgsl::ValidationMode::kFull;
13151306
opts.printer = options.printer.get();
13161307
#if TINT_BUILD_SPV_READER
13171308
opts.use_ir = options.use_ir_reader;

src/tint/lang/wgsl/common/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ cc_library(
4343
],
4444
hdrs = [
4545
"allowed_features.h",
46-
"validation_mode.h",
4746
],
4847
deps = [
4948
"//src/tint/lang/wgsl",

src/tint/lang/wgsl/common/BUILD.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
tint_add_target(tint_lang_wgsl_common lib
4242
lang/wgsl/common/allowed_features.h
4343
lang/wgsl/common/common.cc
44-
lang/wgsl/common/validation_mode.h
4544
)
4645

4746
tint_target_add_dependencies(tint_lang_wgsl_common lib

src/tint/lang/wgsl/common/BUILD.gn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ libtint_source_set("common") {
4747
sources = [
4848
"allowed_features.h",
4949
"common.cc",
50-
"validation_mode.h",
5150
]
5251
deps = [
5352
"${dawn_root}/src/utils:utils",

src/tint/lang/wgsl/common/validation_mode.h

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)