Fix HLSL emission of cbuffers

Despite the documentation claiming otherwise, the DXC doesn't allow
these to be anonymous.

Change-Id: I853d11970890106b8fd4d6b8bb321940f0658bd3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35281
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton 2020-12-10 13:09:21 +00:00 committed by Commit Bot service account
parent c82eeeef07
commit e1bea58ca4
2 changed files with 5 additions and 3 deletions

View File

@ -1334,7 +1334,9 @@ bool GeneratorImpl::EmitEntryPointData(
// is not a block.
// Relevant: https://github.com/gpuweb/gpuweb/issues/1004
// https://github.com/gpuweb/gpuweb/issues/1008
out << "cbuffer : register(b" << binding->value() << ") {" << std::endl;
auto name = "cbuffer_" + var->name();
out << "cbuffer " << name << " : register(b" << binding->value() << ") {"
<< std::endl;
increment_indent();
make_indent(out);

View File

@ -268,7 +268,7 @@ TEST_F(HlslGeneratorImplTest_Function,
ASSERT_TRUE(td.Determine()) << td.error();
ASSERT_TRUE(gen.Generate(out)) << gen.error();
EXPECT_EQ(result(), R"(cbuffer : register(b0) {
EXPECT_EQ(result(), R"(cbuffer cbuffer_coord : register(b0) {
float4 coord;
};
@ -819,7 +819,7 @@ TEST_F(HlslGeneratorImplTest_Function,
ASSERT_TRUE(td.Determine()) << td.error();
ASSERT_TRUE(gen.Generate(out)) << gen.error();
EXPECT_EQ(result(), R"(cbuffer : register(b0) {
EXPECT_EQ(result(), R"(cbuffer cbuffer_coord : register(b0) {
float4 coord;
};