internal/ui: refactoring

This commit is contained in:
Hajime Hoshi 2022-12-03 21:25:28 +09:00
parent 0a6813c17f
commit 6a72b1e10d

View File

@ -34,8 +34,8 @@ type Shader struct {
func NewShader(ir *shaderir.Program) *Shader { func NewShader(ir *shaderir.Program) *Shader {
return &Shader{ return &Shader{
shader: mipmap.NewShader(ir), shader: mipmap.NewShader(ir),
uniformNames: ir.UniformNames, uniformNames: ir.UniformNames[graphics.PreservedUniformVariablesCount:],
uniformTypes: ir.Uniforms, uniformTypes: ir.Uniforms[graphics.PreservedUniformVariablesCount:],
} }
} }
@ -46,14 +46,14 @@ func (s *Shader) MarkDisposed() {
func (s *Shader) ConvertUniforms(uniforms map[string]any) []uint32 { func (s *Shader) ConvertUniforms(uniforms map[string]any) []uint32 {
var n int var n int
for _, typ := range s.uniformTypes[graphics.PreservedUniformVariablesCount:] { for _, typ := range s.uniformTypes {
n += typ.Uint32Count() n += typ.Uint32Count()
} }
us := make([]uint32, n) us := make([]uint32, n)
var idx int var idx int
for i, name := range s.uniformNames[graphics.PreservedUniformVariablesCount:] { for i, name := range s.uniformNames {
typ := s.uniformTypes[graphics.PreservedUniformVariablesCount+i] typ := s.uniformTypes[i]
if uv, ok := uniforms[name]; ok { if uv, ok := uniforms[name]; ok {
// TODO: Panic if uniforms include an invalid name // TODO: Panic if uniforms include an invalid name