internal/shaderir: change the naming convention: Num -> Count

This commit is contained in:
Hajime Hoshi 2022-07-13 01:52:15 +09:00
parent dce34d2306
commit 16ff5c5039
4 changed files with 5 additions and 5 deletions

View File

@ -282,7 +282,7 @@ func (g *Graphics) useProgram(program program, uniforms []uniformVariable, textu
}
for _, u := range uniforms {
if got, expected := len(u.value), u.typ.FloatNum(); got != expected {
if got, expected := len(u.value), u.typ.FloatCount(); got != expected {
// Copy a shaderir.Type value once. Do not pass u.typ directly to fmt.Errorf arguments, or
// the value u would be allocated on heap.
typ := u.typ

View File

@ -79,7 +79,7 @@ func calculateMemoryOffsets(uniforms []shaderir.Type) []int {
// TODO: What if the array has 2 or more dimensions?
head = align(head)
offsets = append(offsets, head)
n := u.Sub[0].FloatNum()
n := u.Sub[0].FloatCount()
switch u.Sub[0].Main {
case shaderir.Mat2:
n = 6

View File

@ -81,7 +81,7 @@ func (t *Type) String() string {
}
}
func (t *Type) FloatNum() int {
func (t *Type) FloatCount() int {
switch t.Main {
case Float:
return 1
@ -98,7 +98,7 @@ func (t *Type) FloatNum() int {
case Mat4:
return 16
case Array:
return t.Length * t.Sub[0].FloatNum()
return t.Length * t.Sub[0].FloatCount()
default: // TODO: Parse a struct correctly
return -1
}

View File

@ -94,7 +94,7 @@ func (s *Shader) convertUniforms(uniforms map[string]interface{}) [][]float32 {
continue
}
t := s.uniformNameToType[name]
us[idx] = make([]float32, t.FloatNum())
us[idx] = make([]float32, t.FloatCount())
}
// TODO: Panic if uniforms include an invalid name