mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 15:46:28 +00:00
[tint] do not emit space for binding group 0
D3D11 only supports HLSL SM5.0 which doesn't support `space` (binding group in WGSL). So for D3D11, only one binding group will be used, and tint will not emit `space` for HLSL, so shaders can be used with D3D11. Bug: dawn:1705 Change-Id: Ie0e9868137f10762c5243e188d76f5e41879c2bc Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125080 Commit-Queue: Peng Huang <penghuang@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Ben Clayton <bclayton@google.com>
This commit is contained in:
@@ -148,8 +148,14 @@ struct RegisterAndSpace {
|
||||
};
|
||||
|
||||
utils::StringStream& operator<<(utils::StringStream& s, const RegisterAndSpace& rs) {
|
||||
s << " : register(" << rs.reg << rs.binding_point.binding << ", space" << rs.binding_point.group
|
||||
<< ")";
|
||||
s << " : register(" << rs.reg << rs.binding_point.binding;
|
||||
// Omit the space if it's 0, as it's the default.
|
||||
// SM 5.0 doesn't support spaces, so we don't emit them if group is 0 for better compatibility.
|
||||
if (rs.binding_point.group == 0) {
|
||||
s << ")";
|
||||
} else {
|
||||
s << ", space" << rs.binding_point.group << ")";
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -3123,7 +3129,15 @@ bool GeneratorImpl::EmitHandleVariable(const ast::Var* var, const sem::Variable*
|
||||
|
||||
if (register_space) {
|
||||
auto bp = sem->As<sem::GlobalVariable>()->BindingPoint();
|
||||
out << " : register(" << register_space << bp.binding << ", space" << bp.group << ")";
|
||||
out << " : register(" << register_space << bp.binding;
|
||||
// Omit the space if it's 0, as it's the default.
|
||||
// SM 5.0 doesn't support spaces, so we don't emit them if group is 0 for better
|
||||
// compatibility.
|
||||
if (bp.group == 0) {
|
||||
out << ")";
|
||||
} else {
|
||||
out << ", space" << bp.group << ")";
|
||||
}
|
||||
}
|
||||
|
||||
out << ";";
|
||||
|
||||
@@ -864,7 +864,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Multiple_EntryPoint_With_Same_Module
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
EXPECT_EQ(gen.result(), R"(RWByteAddressBuffer data : register(u0, space0);
|
||||
EXPECT_EQ(gen.result(), R"(RWByteAddressBuffer data : register(u0);
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void a() {
|
||||
|
||||
@@ -191,7 +191,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl_OmittedIfStorageBuffer) {
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
EXPECT_EQ(gen.result(), "RWByteAddressBuffer g : register(u0, space0);\n");
|
||||
EXPECT_EQ(gen.result(), "RWByteAddressBuffer g : register(u0);\n");
|
||||
}
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct) {
|
||||
|
||||
Reference in New Issue
Block a user