GLSL: implement inf, nan.
Use uintBitsToFloat. Bug: tint:1306 Change-Id: Ie9a5e14c13c0d63b57c126f16c4e2a5c7a77e3f7 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69740 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
This commit is contained in:
parent
d018d2e5bc
commit
1704fe53f5
|
@ -2081,9 +2081,10 @@ bool GeneratorImpl::EmitLiteral(std::ostream& out,
|
||||||
out << (l->value ? "true" : "false");
|
out << (l->value ? "true" : "false");
|
||||||
} else if (auto* fl = lit->As<ast::FloatLiteralExpression>()) {
|
} else if (auto* fl = lit->As<ast::FloatLiteralExpression>()) {
|
||||||
if (std::isinf(fl->value)) {
|
if (std::isinf(fl->value)) {
|
||||||
out << (fl->value >= 0 ? "asfloat(0x7f800000u)" : "asfloat(0xff800000u)");
|
out << (fl->value >= 0 ? "uintBitsToFloat(0x7f800000u)"
|
||||||
|
: "uintBitsToFloat(0xff800000u)");
|
||||||
} else if (std::isnan(fl->value)) {
|
} else if (std::isnan(fl->value)) {
|
||||||
out << "asfloat(0x7fc00000u)";
|
out << "uintBitsToFloat(0x7fc00000u)";
|
||||||
} else {
|
} else {
|
||||||
out << FloatToString(fl->value) << "f";
|
out << FloatToString(fl->value) << "f";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
SKIP: FAILED
|
|
||||||
|
|
||||||
#version 310 es
|
#version 310 es
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
|
@ -28,7 +26,7 @@ float getAAtOutCoords_() {
|
||||||
float unaryOperation_f1_(inout float a) {
|
float unaryOperation_f1_(inout float a) {
|
||||||
float x_47 = a;
|
float x_47 = a;
|
||||||
if ((x_47 < 0.0f)) {
|
if ((x_47 < 0.0f)) {
|
||||||
return asfloat(0x7f800000u);
|
return uintBitsToFloat(0x7f800000u);
|
||||||
}
|
}
|
||||||
float x_55 = a;
|
float x_55 = a;
|
||||||
return log(x_55);
|
return log(x_55);
|
||||||
|
@ -84,10 +82,3 @@ void main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Error parsing GLSL shader:
|
|
||||||
ERROR: 0:29: 'asfloat' : no matching overloaded function found
|
|
||||||
ERROR: 0:29: '' : compilation terminated
|
|
||||||
ERROR: 2 compilation errors. No code generated.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
SKIP: FAILED
|
|
||||||
|
|
||||||
#version 310 es
|
#version 310 es
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
vec4 out_var_SV_TARGET = vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
vec4 out_var_SV_TARGET = vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
void main_1() {
|
void main_1() {
|
||||||
out_var_SV_TARGET = vec4(asfloat(0xff800000u), asfloat(0xff800000u), asfloat(0xff800000u), asfloat(0xff800000u));
|
out_var_SV_TARGET = vec4(uintBitsToFloat(0xff800000u), uintBitsToFloat(0xff800000u), uintBitsToFloat(0xff800000u), uintBitsToFloat(0xff800000u));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,10 +35,3 @@ void main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Error parsing GLSL shader:
|
|
||||||
ERROR: 0:7: 'asfloat' : no matching overloaded function found
|
|
||||||
ERROR: 0:7: '' : compilation terminated
|
|
||||||
ERROR: 2 compilation errors. No code generated.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
SKIP: FAILED
|
|
||||||
|
|
||||||
#version 310 es
|
#version 310 es
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
vec4 out_var_SV_TARGET = vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
vec4 out_var_SV_TARGET = vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
void main_1() {
|
void main_1() {
|
||||||
out_var_SV_TARGET = vec4(asfloat(0x7f800000u), asfloat(0x7f800000u), asfloat(0x7f800000u), asfloat(0x7f800000u));
|
out_var_SV_TARGET = vec4(uintBitsToFloat(0x7f800000u), uintBitsToFloat(0x7f800000u), uintBitsToFloat(0x7f800000u), uintBitsToFloat(0x7f800000u));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,10 +35,3 @@ void main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Error parsing GLSL shader:
|
|
||||||
ERROR: 0:7: 'asfloat' : no matching overloaded function found
|
|
||||||
ERROR: 0:7: '' : compilation terminated
|
|
||||||
ERROR: 2 compilation errors. No code generated.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
SKIP: FAILED
|
|
||||||
|
|
||||||
#version 310 es
|
#version 310 es
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
vec4 out_var_SV_TARGET = vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
vec4 out_var_SV_TARGET = vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
void main_1() {
|
void main_1() {
|
||||||
out_var_SV_TARGET = vec4(asfloat(0x7fc00000u), asfloat(0x7fc00000u), asfloat(0x7fc00000u), asfloat(0x7fc00000u));
|
out_var_SV_TARGET = vec4(uintBitsToFloat(0x7fc00000u), uintBitsToFloat(0x7fc00000u), uintBitsToFloat(0x7fc00000u), uintBitsToFloat(0x7fc00000u));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,10 +35,3 @@ void main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Error parsing GLSL shader:
|
|
||||||
ERROR: 0:7: 'asfloat' : no matching overloaded function found
|
|
||||||
ERROR: 0:7: '' : compilation terminated
|
|
||||||
ERROR: 2 compilation errors. No code generated.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue