Skip to content

Commit a8dfd9e

Browse files
dj2Dawn LUCI CQ
authored andcommitted
Validate out CullDistance in HLSL, MSL and GLSL.
Only the SPIR-V backend supports the CullDistance builtin. Update the CanGenerate methods for the other backends to validate out the usage of CullDistance. Fixed: 467683480 Change-Id: Ic1b291cd1a7ac92ded5b0bf3fb5dd30a67ca2eb5 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/280615 Commit-Queue: James Price <jrprice@google.com> Auto-Submit: dan sinclair <dsinclair@chromium.org> Commit-Queue: dan sinclair <dsinclair@chromium.org> Reviewed-by: James Price <jrprice@google.com>
1 parent f7c52f2 commit a8dfd9e

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

src/tint/lang/glsl/writer/writer.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ Result<SuccessType> CanGenerate(const core::ir::Module& ir, const Options& optio
215215
if (member->Attributes().builtin == core::BuiltinValue::kClipDistances) {
216216
return Failure("clip_distances is not supported by the GLSL backend");
217217
}
218+
if (member->Attributes().builtin == core::BuiltinValue::kCullDistance) {
219+
return Failure("cull_distance is not supported by the GLSL backend");
220+
}
218221
}
219222
}
220223
}

src/tint/lang/hlsl/writer/writer.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ Result<SuccessType> CanGenerate(const core::ir::Module& ir, const Options& optio
166166
options.compiler == Options::Compiler::kFXC) {
167167
return Failure("barycentric_coord is not supported by the FXC HLSL backend");
168168
}
169+
if (attributes.builtin == core::BuiltinValue::kCullDistance) {
170+
return Failure("cull_distance is not supported by the HLSL backend");
171+
}
169172
if (options.truncate_interstage_variables) {
170173
if (attributes.location >= 30u) {
171174
return Failure("too many locations for interstage variable truncation");

src/tint/lang/msl/writer/writer.cc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,52 @@ Result<SuccessType> CanGenerate(const core::ir::Module& ir, const Options& optio
8080
}
8181
}
8282

83+
// Check for unsupported shader IO builtins.
84+
auto check_io_attributes = [&](const core::IOAttributes& attributes) -> Result<SuccessType> {
85+
if (attributes.builtin == core::BuiltinValue::kCullDistance) {
86+
return Failure("cull_distance is not supported by the MSL backend");
87+
}
88+
return Success;
89+
};
90+
8391
core::ir::Function* ep_func = nullptr;
8492
for (auto* f : ir.functions) {
8593
if (!f->IsEntryPoint()) {
8694
continue;
8795
}
96+
97+
// Check input attributes.
98+
for (auto* param : f->Params()) {
99+
if (auto* str = param->Type()->As<core::type::Struct>()) {
100+
for (auto* member : str->Members()) {
101+
auto res = check_io_attributes(member->Attributes());
102+
if (res != Success) {
103+
return res;
104+
}
105+
}
106+
} else {
107+
auto res = check_io_attributes(param->Attributes());
108+
if (res != Success) {
109+
return res;
110+
}
111+
}
112+
}
113+
114+
// Check output attributes.
115+
if (auto* str = f->ReturnType()->As<core::type::Struct>()) {
116+
for (auto* member : str->Members()) {
117+
auto res = check_io_attributes(member->Attributes());
118+
if (res != Success) {
119+
return res;
120+
}
121+
}
122+
} else {
123+
auto res = check_io_attributes(f->ReturnAttributes());
124+
if (res != Success) {
125+
return res;
126+
}
127+
}
128+
88129
if (ir.NameOf(f).NameView() == options.entry_point_name) {
89130
ep_func = f;
90131
break;

0 commit comments

Comments
 (0)