shaderir: Bug fix: A wrong argument for fmt.Sprintf

This change also improves the result of espcae analysis.

Closes #1863
This commit is contained in:
Hajime Hoshi 2021-11-02 00:05:03 +09:00
parent 7661147e31
commit 00e2b15e2a
4 changed files with 4 additions and 10 deletions

View File

@ -418,9 +418,7 @@ func (c *context) uniformFloats(p program, location string, v []float32, typ sha
case shaderir.Mat4: case shaderir.Mat4:
gl.UniformMatrix4fv(l, len, false, (*float32)(gl.Ptr(v))) gl.UniformMatrix4fv(l, len, false, (*float32)(gl.Ptr(v)))
default: default:
// Copy shaderir.Type value to avoid heap allocation of typ. panic(fmt.Sprintf("opengl: unexpected type: %s", typ.String()))
t := typ
panic(fmt.Sprintf("opengl: unexpected type: %s", t.String()))
} }
return true return true
} }

View File

@ -517,9 +517,7 @@ func (c *context) uniformFloats(p program, location string, v []float32, typ sha
gl.uniformMatrix4fv.Invoke(js.Value(l), false, arr.Call("subarray", 0, len(v))) gl.uniformMatrix4fv.Invoke(js.Value(l), false, arr.Call("subarray", 0, len(v)))
} }
default: default:
// Copy shaderir.Type value to avoid heap allocation of typ. panic(fmt.Sprintf("opengl: unexpected type: %s", typ.String()))
t := typ
panic(fmt.Sprintf("opengl: unexpected type: %s", t.String()))
} }
return true return true

View File

@ -384,9 +384,7 @@ func (c *context) uniformFloats(p program, location string, v []float32, typ sha
case shaderir.Mat4: case shaderir.Mat4:
c.ctx.UniformMatrix4fv(int32(l), false, v) c.ctx.UniformMatrix4fv(int32(l), false, v)
default: default:
// Copy shaderir.Type value to avoid heap allocation of typ. panic(fmt.Sprintf("opengl: unexpected type: %s", typ.String()))
t := typ
panic(fmt.Sprintf("opengl: unexpected type: %s", t.String()))
} }
return true return true
} }

View File

@ -77,7 +77,7 @@ func (t *Type) String() string {
str += "}" str += "}"
return str return str
default: default:
return fmt.Sprintf("?(unknown type: %d)", t) return fmt.Sprintf("?(unknown type: %d)", t.Main)
} }
} }