mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-13 10:51:35 +00:00
glsl: Don't emit structs with runtime-sized arrays
The GLSL emitted for these was invalid, and we don't need these structs since they're only used as the store types of buffers, which are handled elsewhere. Change-Id: I17c15e408b5c36e9b895e5950528a6d02d1802a6 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72381 Reviewed-by: Stephen White <senorblanco@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
57489928c6
commit
1461b032aa
@ -123,8 +123,18 @@ bool GeneratorImpl::Generate() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (auto* str = decl->As<ast::Struct>()) {
|
} else if (auto* str = decl->As<ast::Struct>()) {
|
||||||
if (!EmitStructType(current_buffer_, builder_.Sem().Get(str))) {
|
// Skip emission if the struct contains a runtime-sized array, since its
|
||||||
return false;
|
// only use will be as the store-type of a buffer and we emit those
|
||||||
|
// elsewhere.
|
||||||
|
// TODO(crbug.com/tint/1339): We could also avoid emitting any other
|
||||||
|
// struct that is only used as a buffer store type.
|
||||||
|
TINT_ASSERT(Writer, str->members.size() > 0);
|
||||||
|
auto* last_member = str->members[str->members.size() - 1];
|
||||||
|
auto* arr = last_member->type->As<ast::Array>();
|
||||||
|
if (!arr || !arr->IsRuntimeArray()) {
|
||||||
|
if (!EmitStructType(current_buffer_, builder_.Sem().Get(str))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (auto* func = decl->As<ast::Function>()) {
|
} else if (auto* func = decl->As<ast::Function>()) {
|
||||||
if (func->IsEntryPoint()) {
|
if (func->IsEntryPoint()) {
|
||||||
|
@ -51,9 +51,6 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength) {
|
|||||||
auto* expect = R"(#version 310 es
|
auto* expect = R"(#version 310 es
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
struct my_struct {
|
|
||||||
float a[];
|
|
||||||
};
|
|
||||||
|
|
||||||
layout (binding = 1) buffer my_struct_1 {
|
layout (binding = 1) buffer my_struct_1 {
|
||||||
float a[];
|
float a[];
|
||||||
@ -105,10 +102,6 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) {
|
|||||||
auto* expect = R"(#version 310 es
|
auto* expect = R"(#version 310 es
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
struct my_struct {
|
|
||||||
float z;
|
|
||||||
float a[];
|
|
||||||
};
|
|
||||||
|
|
||||||
layout (binding = 1) buffer my_struct_1 {
|
layout (binding = 1) buffer my_struct_1 {
|
||||||
float z;
|
float z;
|
||||||
@ -163,9 +156,6 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength_ViaLets) {
|
|||||||
auto* expect = R"(#version 310 es
|
auto* expect = R"(#version 310 es
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
struct my_struct {
|
|
||||||
float a[];
|
|
||||||
};
|
|
||||||
|
|
||||||
layout (binding = 1) buffer my_struct_1 {
|
layout (binding = 1) buffer my_struct_1 {
|
||||||
float a[];
|
float a[];
|
||||||
|
@ -1,6 +1,28 @@
|
|||||||
#version 310 es
|
#version 310 es
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
|
struct Uniforms {
|
||||||
|
uint numTriangles;
|
||||||
|
uint gridSize;
|
||||||
|
uint pad1;
|
||||||
|
uint pad2;
|
||||||
|
vec3 bbMin;
|
||||||
|
vec3 bbMax;
|
||||||
|
};
|
||||||
|
struct Dbg {
|
||||||
|
uint offsetCounter;
|
||||||
|
uint pad0;
|
||||||
|
uint pad1;
|
||||||
|
uint pad2;
|
||||||
|
uint value0;
|
||||||
|
uint value1;
|
||||||
|
uint value2;
|
||||||
|
uint value3;
|
||||||
|
float value_f32_0;
|
||||||
|
float value_f32_1;
|
||||||
|
float value_f32_2;
|
||||||
|
float value_f32_3;
|
||||||
|
};
|
||||||
|
|
||||||
layout (binding = 0) uniform Uniforms_1 {
|
layout (binding = 0) uniform Uniforms_1 {
|
||||||
uint numTriangles;
|
uint numTriangles;
|
||||||
@ -118,6 +140,28 @@ void main() {
|
|||||||
#version 310 es
|
#version 310 es
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
|
struct Uniforms {
|
||||||
|
uint numTriangles;
|
||||||
|
uint gridSize;
|
||||||
|
uint pad1;
|
||||||
|
uint pad2;
|
||||||
|
vec3 bbMin;
|
||||||
|
vec3 bbMax;
|
||||||
|
};
|
||||||
|
struct Dbg {
|
||||||
|
uint offsetCounter;
|
||||||
|
uint pad0;
|
||||||
|
uint pad1;
|
||||||
|
uint pad2;
|
||||||
|
uint value0;
|
||||||
|
uint value1;
|
||||||
|
uint value2;
|
||||||
|
uint value3;
|
||||||
|
float value_f32_0;
|
||||||
|
float value_f32_1;
|
||||||
|
float value_f32_2;
|
||||||
|
float value_f32_3;
|
||||||
|
};
|
||||||
|
|
||||||
layout (binding = 0) uniform Uniforms_1 {
|
layout (binding = 0) uniform Uniforms_1 {
|
||||||
uint numTriangles;
|
uint numTriangles;
|
||||||
@ -204,6 +248,28 @@ void main() {
|
|||||||
#version 310 es
|
#version 310 es
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
|
struct Uniforms {
|
||||||
|
uint numTriangles;
|
||||||
|
uint gridSize;
|
||||||
|
uint pad1;
|
||||||
|
uint pad2;
|
||||||
|
vec3 bbMin;
|
||||||
|
vec3 bbMax;
|
||||||
|
};
|
||||||
|
struct Dbg {
|
||||||
|
uint offsetCounter;
|
||||||
|
uint pad0;
|
||||||
|
uint pad1;
|
||||||
|
uint pad2;
|
||||||
|
uint value0;
|
||||||
|
uint value1;
|
||||||
|
uint value2;
|
||||||
|
uint value3;
|
||||||
|
float value_f32_0;
|
||||||
|
float value_f32_1;
|
||||||
|
float value_f32_2;
|
||||||
|
float value_f32_3;
|
||||||
|
};
|
||||||
|
|
||||||
layout (binding = 0) uniform Uniforms_1 {
|
layout (binding = 0) uniform Uniforms_1 {
|
||||||
uint numTriangles;
|
uint numTriangles;
|
||||||
|
@ -15,11 +15,23 @@ struct TileLightIdData {
|
|||||||
uint count;
|
uint count;
|
||||||
uint lightId[64];
|
uint lightId[64];
|
||||||
};
|
};
|
||||||
|
struct Tiles {
|
||||||
|
TileLightIdData data[4];
|
||||||
|
};
|
||||||
|
|
||||||
layout (binding = 0) buffer Tiles_1 {
|
layout (binding = 0) buffer Tiles_1 {
|
||||||
TileLightIdData data[4];
|
TileLightIdData data[4];
|
||||||
} tileLightId;
|
} tileLightId;
|
||||||
|
|
||||||
|
struct Config {
|
||||||
|
uint numLights;
|
||||||
|
uint numTiles;
|
||||||
|
uint tileCountX;
|
||||||
|
uint tileCountY;
|
||||||
|
uint numTileLightSlot;
|
||||||
|
uint tileSize;
|
||||||
|
};
|
||||||
|
|
||||||
layout (binding = 0) uniform Config_1 {
|
layout (binding = 0) uniform Config_1 {
|
||||||
uint numLights;
|
uint numLights;
|
||||||
uint numTiles;
|
uint numTiles;
|
||||||
@ -29,6 +41,14 @@ layout (binding = 0) uniform Config_1 {
|
|||||||
uint tileSize;
|
uint tileSize;
|
||||||
} config;
|
} config;
|
||||||
|
|
||||||
|
struct Uniforms {
|
||||||
|
vec4 tint_symbol;
|
||||||
|
vec4 tint_symbol_1;
|
||||||
|
mat4 viewMatrix;
|
||||||
|
mat4 projectionMatrix;
|
||||||
|
vec4 fullScreenSize;
|
||||||
|
};
|
||||||
|
|
||||||
layout (binding = 0) uniform Uniforms_1 {
|
layout (binding = 0) uniform Uniforms_1 {
|
||||||
vec4 tint_symbol;
|
vec4 tint_symbol;
|
||||||
vec4 tint_symbol_1;
|
vec4 tint_symbol_1;
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
#version 310 es
|
#version 310 es
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
|
struct Uniforms {
|
||||||
|
uint dstTextureFlipY;
|
||||||
|
uint isFloat16;
|
||||||
|
uint isRGB10A2Unorm;
|
||||||
|
uint channelCount;
|
||||||
|
};
|
||||||
|
|
||||||
uniform highp sampler2D src;
|
uniform highp sampler2D src;
|
||||||
uniform highp sampler2D dst;
|
uniform highp sampler2D dst;
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
#version 310 es
|
#version 310 es
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
|
struct Uniforms {
|
||||||
|
uvec2 aShape;
|
||||||
|
uvec2 bShape;
|
||||||
|
uvec2 outShape;
|
||||||
|
};
|
||||||
|
|
||||||
layout (binding = 0) buffer Matrix_1 {
|
layout (binding = 0) buffer Matrix_1 {
|
||||||
uint numbers[];
|
uint numbers[];
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#version 310 es
|
#version 310 es
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
|
struct Constants {
|
||||||
|
int level;
|
||||||
|
};
|
||||||
|
|
||||||
uniform highp sampler2DArray myTexture;
|
uniform highp sampler2DArray myTexture;
|
||||||
|
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
#version 310 es
|
#version 310 es
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
|
struct Uniforms {
|
||||||
|
uint dstTextureFlipY;
|
||||||
|
uint channelCount;
|
||||||
|
uvec2 srcCopyOrigin;
|
||||||
|
uvec2 dstCopyOrigin;
|
||||||
|
uvec2 copySize;
|
||||||
|
};
|
||||||
|
|
||||||
uniform highp sampler2D src;
|
uniform highp sampler2D src;
|
||||||
uniform highp sampler2D dst;
|
uniform highp sampler2D dst;
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
#version 310 es
|
#version 310 es
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
|
struct Uniforms {
|
||||||
|
uint dimAOuter;
|
||||||
|
uint dimInner;
|
||||||
|
uint dimBOuter;
|
||||||
|
};
|
||||||
|
|
||||||
layout (binding = 0) buffer Matrix_1 {
|
layout (binding = 0) buffer Matrix_1 {
|
||||||
float numbers[];
|
float numbers[];
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
intrinsics/ignore/runtime_array.wgsl:10:5 warning: use of deprecated intrinsic
|
intrinsics/ignore/runtime_array.wgsl:9:5 warning: use of deprecated intrinsic
|
||||||
ignore(s.arr);
|
ignore(s.arr);
|
||||||
^^^^^^
|
^^^^^^
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
intrinsics/ignore/storage_buffer.wgsl:10:5 warning: use of deprecated intrinsic
|
intrinsics/ignore/storage_buffer.wgsl:9:5 warning: use of deprecated intrinsic
|
||||||
ignore(s);
|
ignore(s);
|
||||||
^^^^^^
|
^^^^^^
|
||||||
|
|
||||||
intrinsics/ignore/storage_buffer.wgsl:11:5 warning: use of deprecated intrinsic
|
intrinsics/ignore/storage_buffer.wgsl:10:5 warning: use of deprecated intrinsic
|
||||||
ignore(s.i);
|
ignore(s.i);
|
||||||
^^^^^^
|
^^^^^^
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
intrinsics/ignore/uniform_buffer.wgsl:10:5 warning: use of deprecated intrinsic
|
intrinsics/ignore/uniform_buffer.wgsl:9:5 warning: use of deprecated intrinsic
|
||||||
ignore(u);
|
ignore(u);
|
||||||
^^^^^^
|
^^^^^^
|
||||||
|
|
||||||
intrinsics/ignore/uniform_buffer.wgsl:11:5 warning: use of deprecated intrinsic
|
intrinsics/ignore/uniform_buffer.wgsl:10:5 warning: use of deprecated intrinsic
|
||||||
ignore(u.i);
|
ignore(u.i);
|
||||||
^^^^^^
|
^^^^^^
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user