shaderir: Adopt the precision 10 for float literals

Adopted the same precision of (*math/big.Float).String().
This commit is contained in:
Hajime Hoshi 2020-08-13 00:01:14 +09:00
parent 50cd33ed9b
commit f6c3e0579f
5 changed files with 10 additions and 10 deletions

View File

@ -1,7 +1,7 @@
void main(void) {
vec4 l0 = vec4(0);
for (float l1 = 0.0; l1 < 4.0; l1++) {
(l0).x = ((l0).x) + ((l1) * (1.000000000e-02));
(l0).x = ((l0).x) + ((l1) * (1.0000000000e-02));
}
gl_FragColor = l0;
return;

View File

@ -3,7 +3,7 @@ attribute vec2 A0;
void main(void) {
vec4 l0 = vec4(0);
for (float l1 = 0.0; l1 < 4.0; l1++) {
(l0).x = ((l0).x) + ((l1) * (1.000000000e-02));
(l0).x = ((l0).x) + ((l1) * (1.0000000000e-02));
}
gl_Position = l0;
return;

View File

@ -7,9 +7,9 @@ void F0(out vec4 l0) {
float l3 = float(0);
float l4 = float(0);
l1 = 2;
l2 = 2.500000000e+00;
l3 = 2.500000000e+00;
l4 = 2.500000000e+00;
l2 = 2.5000000000e+00;
l3 = 2.5000000000e+00;
l4 = 2.5000000000e+00;
l0 = vec4(l1, l2, l3, l4);
return;
}
@ -20,9 +20,9 @@ void F1(out vec4 l0) {
float l3 = float(0);
float l4 = float(0);
l1 = 2;
l2 = 2.500000000e+00;
l3 = 2.500000000e+00;
l4 = 2.500000000e+00;
l2 = 2.5000000000e+00;
l3 = 2.5000000000e+00;
l4 = 2.5000000000e+00;
l0 = vec4(l1, l2, l3, l4);
return;
}

View File

@ -262,7 +262,7 @@ func constantToNumberLiteral(t shaderir.ConstType, v constant.Value) string {
}
if i := constant.ToFloat(v); i.Kind() == constant.Float {
x, _ := constant.Float64Val(i)
return fmt.Sprintf("%.9e", x)
return fmt.Sprintf("%.10e", x)
}
case shaderir.ConstTypeInt:
if i := constant.ToInt(v); i.Kind() == constant.Int {

View File

@ -268,7 +268,7 @@ func constantToNumberLiteral(t shaderir.ConstType, v constant.Value) string {
}
if i := constant.ToFloat(v); i.Kind() == constant.Float {
x, _ := constant.Float64Val(i)
return fmt.Sprintf("%.9e", x)
return fmt.Sprintf("%.10e", x)
}
case shaderir.ConstTypeInt:
if i := constant.ToInt(v); i.Kind() == constant.Int {