mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-17 17:05:31 +00:00
tint/writer/glsl: Set default precision to highp
WGSL states that `f32` is a IEEE-754 binary32. mediump precision guarantees are much smaller than highp, and using mediump can break code generated by tint. Change-Id: I8a129c4c8ac078c785e0d5d7d21f19ed6b3620b5 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123400 Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
4fea9d0fbb
commit
f1f56b2d3c
@@ -334,7 +334,7 @@ bool GeneratorImpl::Generate() {
|
||||
}
|
||||
|
||||
if (version_.IsES() && requires_default_precision_qualifier_) {
|
||||
current_buffer_->Insert("precision mediump float;", helpers_insertion_point++, indent);
|
||||
current_buffer_->Insert("precision highp float;", helpers_insertion_point++, indent);
|
||||
}
|
||||
|
||||
if (!helpers_.lines.empty()) {
|
||||
|
||||
@@ -98,7 +98,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_NoReturn_Void)
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
void func() {
|
||||
return;
|
||||
@@ -145,7 +145,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_WithInOutVars)
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
layout(location = 0) in float foo_1;
|
||||
layout(location = 1) out float value;
|
||||
@@ -186,7 +186,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_WithInOut_Built
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
float frag_main(vec4 coord) {
|
||||
return coord.x;
|
||||
@@ -239,7 +239,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_SharedStruct_Di
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
layout(location = 1) out float col1_1;
|
||||
layout(location = 2) out float col2_1;
|
||||
@@ -378,7 +378,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_Uniform) {
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
struct UBO {
|
||||
vec4 coord;
|
||||
@@ -419,7 +419,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_UniformStr
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
struct Uniforms {
|
||||
vec4 coord;
|
||||
@@ -460,7 +460,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RW_Storage
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
struct Data {
|
||||
int a;
|
||||
@@ -508,7 +508,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RO_Storage
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
EXPECT_EQ(gen.result(),
|
||||
R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
struct Data {
|
||||
int a;
|
||||
@@ -553,7 +553,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_WO_Storage
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
struct Data {
|
||||
int a;
|
||||
@@ -598,7 +598,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuf
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
struct Data {
|
||||
int a;
|
||||
@@ -645,7 +645,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
struct S {
|
||||
float x;
|
||||
@@ -692,7 +692,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
EXPECT_EQ(gen.result(),
|
||||
R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
struct S {
|
||||
float x;
|
||||
@@ -728,7 +728,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_WithNameCollisi
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
void tint_symbol() {
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_Matrix_Empty) {
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
auto* expected =
|
||||
R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
struct Data {
|
||||
int a;
|
||||
@@ -334,7 +334,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_Matrix_Single_El
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
auto* expected =
|
||||
R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
struct Data {
|
||||
float z;
|
||||
@@ -382,7 +382,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor,
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
auto* expected =
|
||||
R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
struct Data {
|
||||
float z;
|
||||
@@ -430,7 +430,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor,
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
auto* expected =
|
||||
R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
struct Data {
|
||||
float z;
|
||||
@@ -477,7 +477,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_ToArray) {
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
auto* expected =
|
||||
R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
struct Data {
|
||||
float z;
|
||||
@@ -530,7 +530,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_MultiLevel) {
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
auto* expected =
|
||||
R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
struct Inner {
|
||||
vec3 a;
|
||||
@@ -591,7 +591,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_MultiLevel_Swizz
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
auto* expected =
|
||||
R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
struct Inner {
|
||||
vec3 a;
|
||||
@@ -653,7 +653,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor,
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
auto* expected =
|
||||
R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
struct Inner {
|
||||
vec3 a;
|
||||
@@ -714,7 +714,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_MultiLevel_Index
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
auto* expected =
|
||||
R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
struct Inner {
|
||||
vec3 a;
|
||||
@@ -774,7 +774,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_MultiLevel) {
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
auto* expected =
|
||||
R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
struct Inner {
|
||||
vec3 a;
|
||||
@@ -835,7 +835,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_Swizzle_SingleL
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
auto* expected =
|
||||
R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
struct Inner {
|
||||
ivec3 a;
|
||||
|
||||
@@ -43,7 +43,7 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength) {
|
||||
|
||||
auto got = gen.result();
|
||||
auto* expect = R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
layout(binding = 1, std430) buffer my_struct_ssbo {
|
||||
float a[];
|
||||
@@ -83,7 +83,7 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) {
|
||||
|
||||
auto got = gen.result();
|
||||
auto* expect = R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
layout(binding = 1, std430) buffer my_struct_ssbo {
|
||||
float z;
|
||||
@@ -127,7 +127,7 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength_ViaLets) {
|
||||
|
||||
auto got = gen.result();
|
||||
auto* expect = R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
layout(binding = 1, std430) buffer my_struct_ssbo {
|
||||
float a[];
|
||||
@@ -164,7 +164,7 @@ TEST_F(GlslSanitizerTest, PromoteArrayInitializerToConstVar) {
|
||||
|
||||
auto got = gen.result();
|
||||
auto* expect = R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
void tint_symbol() {
|
||||
int idx = 3;
|
||||
@@ -206,7 +206,7 @@ TEST_F(GlslSanitizerTest, PromoteStructInitializerToConstVar) {
|
||||
|
||||
auto got = gen.result();
|
||||
auto* expect = R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
struct S {
|
||||
int a;
|
||||
@@ -252,7 +252,7 @@ TEST_F(GlslSanitizerTest, InlinePtrLetsBasic) {
|
||||
|
||||
auto got = gen.result();
|
||||
auto* expect = R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
void tint_symbol() {
|
||||
int v = 0;
|
||||
@@ -301,7 +301,7 @@ TEST_F(GlslSanitizerTest, InlinePtrLetsComplexChain) {
|
||||
|
||||
auto got = gen.result();
|
||||
auto* expect = R"(#version 310 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
void tint_symbol() {
|
||||
mat4 a[4] = mat4[4](mat4(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f), mat4(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f), mat4(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f), mat4(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
|
||||
|
||||
Reference in New Issue
Block a user