From 16ff5c50396a515f3214acb9240d408506e9a0e5 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 13 Jul 2022 01:52:15 +0900 Subject: [PATCH] internal/shaderir: change the naming convention: Num -> Count --- internal/graphicsdriver/opengl/program.go | 2 +- internal/shaderir/hlsl/packing.go | 2 +- internal/shaderir/type.go | 4 ++-- shader.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/graphicsdriver/opengl/program.go b/internal/graphicsdriver/opengl/program.go index 0bdb886dc..adeb28c82 100644 --- a/internal/graphicsdriver/opengl/program.go +++ b/internal/graphicsdriver/opengl/program.go @@ -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 diff --git a/internal/shaderir/hlsl/packing.go b/internal/shaderir/hlsl/packing.go index 246e74658..3fa58098d 100644 --- a/internal/shaderir/hlsl/packing.go +++ b/internal/shaderir/hlsl/packing.go @@ -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 diff --git a/internal/shaderir/type.go b/internal/shaderir/type.go index be699409f..d4b2a35cb 100644 --- a/internal/shaderir/type.go +++ b/internal/shaderir/type.go @@ -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 } diff --git a/shader.go b/shader.go index 7892b847b..029348dc1 100644 --- a/shader.go +++ b/shader.go @@ -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