writer/hlsl: Emit static for private global variables

Fixed: tint:812
Change-Id: I822eb6b13f07a74eb47c4c8e18d1f75dcc4818bf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51366
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
Ben Clayton 2021-05-19 09:03:48 +00:00 committed by Commit Bot service account
parent ee449e2625
commit 09d53d5ed1
12 changed files with 38 additions and 12 deletions

View File

@ -1893,9 +1893,11 @@ bool GeneratorImpl::EmitEntryPointData(
}
switch (var->StorageClass()) {
case ast::StorageClass::kPrivate:
case ast::StorageClass::kUniformConstant:
break;
case ast::StorageClass::kPrivate:
out << "static ";
break;
case ast::StorageClass::kWorkgroup:
out << "groupshared ";
break;

View File

@ -137,7 +137,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) {
float mem;
};
Data str;
static Data str;
[numthreads(1, 1, 1)]
void test_function() {

View File

@ -75,7 +75,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Private) {
gen.increment_indent();
ASSERT_TRUE(gen.Generate(out)) << gen.error();
EXPECT_THAT(result(), HasSubstr(" float a;\n"));
EXPECT_THAT(result(), HasSubstr(" static float a;\n"));
}
TEST_F(HlslGeneratorImplTest_VariableDecl,

View File

@ -1 +1 @@
SKIP: TINT_UNIMPLEMENTED crbug.com/tint/726: module-scope private and workgroup variables not yet implemented
SKIP: crbug.com/tint/818: [HLSL] Loop emission broken for `let` function declarations

View File

@ -1,4 +1,4 @@
int I = 0;
static int I = 0;
[numthreads(1, 1, 1)]
void main() {

View File

@ -1,4 +1,4 @@
int I;
static int I;
[numthreads(1, 1, 1)]
void main() {

View File

@ -1 +1,14 @@
SKIP: error: pointers not supported in HLSL
struct S {
int i;
};
static S V;
[numthreads(1, 1, 1)]
void main() {
int i = 0;
const int x_15 = V.i;
i = x_15;
return;
}

View File

@ -2,7 +2,7 @@ struct S {
int i;
};
S V;
static S V;
[numthreads(1, 1, 1)]
void main() {

View File

@ -1,4 +1,4 @@
int I = 0;
static int I = 0;
[numthreads(1, 1, 1)]
void main() {

View File

@ -1,4 +1,4 @@
int I;
static int I;
[numthreads(1, 1, 1)]
void main() {

View File

@ -1 +1,12 @@
SKIP: error: pointers not supported in HLSL
struct S {
int i;
};
static S V;
[numthreads(1, 1, 1)]
void main() {
V.i = 5;
return;
}

View File

@ -1 +1 @@
SKIP: error: pointers not supported in HLSL
SKIP: Failed to generate: error: pointers not supported in HLSL