mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
Revert "ebiten: panic if a non-existent uniform variable name is given"
This reverts commit 1b8580fab7
.
Reason: some existing applications don't work with this fix.
Updates #2710
This commit is contained in:
parent
3493358fd2
commit
a9b2f5f9ca
4
image.go
4
image.go
@ -582,8 +582,6 @@ var _ [len(DrawTrianglesShaderOptions{}.Images) - graphics.ShaderImageCount]stru
|
||||
//
|
||||
// If a specified uniform variable's length or type doesn't match with an expected one, DrawTrianglesShader panics.
|
||||
//
|
||||
// If a non-existent uniform variable name is specified, DrawTrianglesShader panics.
|
||||
//
|
||||
// When the image i is disposed, DrawTrianglesShader does nothing.
|
||||
func (i *Image) DrawTrianglesShader(vertices []Vertex, indices []uint16, shader *Shader, options *DrawTrianglesShaderOptions) {
|
||||
i.copyCheck()
|
||||
@ -736,8 +734,6 @@ var _ [len(DrawRectShaderOptions{}.Images)]struct{} = [graphics.ShaderImageCount
|
||||
//
|
||||
// If a specified uniform variable's length or type doesn't match with an expected one, DrawRectShader panics.
|
||||
//
|
||||
// If a non-existent uniform variable name is specified, DrawRectShader panics.
|
||||
//
|
||||
// In a shader, texCoord in Fragment represents a position in a source image.
|
||||
// If no source images are specified, texCoord represents the position from (0, 0) to (width, height) in pixels.
|
||||
// If the unit is pixels by a compiler directive `//kage:unit pixelss`, texCoord values are valid.
|
||||
|
@ -46,22 +46,6 @@ func (s *Shader) MarkDisposed() {
|
||||
}
|
||||
|
||||
func (s *Shader) AppendUniforms(dst []uint32, uniforms map[string]any) []uint32 {
|
||||
// Check the given names are valid.
|
||||
// This is a linear search and not efficient, but the number of uniform variables should not be so big.
|
||||
for n := range uniforms {
|
||||
var found bool
|
||||
for _, nn := range s.uniformNames {
|
||||
if n == nn {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if found {
|
||||
continue
|
||||
}
|
||||
panic(fmt.Sprintf("ui: unexpected uniform name: %s", n))
|
||||
}
|
||||
|
||||
if s.uniformUint32Count == 0 {
|
||||
for _, typ := range s.uniformTypes {
|
||||
s.uniformUint32Count += typ.Uint32Count()
|
||||
@ -82,6 +66,7 @@ func (s *Shader) AppendUniforms(dst []uint32, uniforms map[string]any) []uint32
|
||||
for i, name := range s.uniformNames {
|
||||
typ := s.uniformTypes[i]
|
||||
|
||||
// Ignore if an unused name is specified (#2710).
|
||||
if uv, ok := uniforms[name]; ok {
|
||||
v := reflect.ValueOf(uv)
|
||||
t := v.Type()
|
||||
|
@ -1942,18 +1942,6 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
},
|
||||
err: true,
|
||||
},
|
||||
{
|
||||
uniforms: map[string]any{
|
||||
"W": 1,
|
||||
},
|
||||
err: true,
|
||||
},
|
||||
{
|
||||
uniforms: map[string]any{
|
||||
"W": []int32{1, 2, 3},
|
||||
},
|
||||
err: true,
|
||||
},
|
||||
}
|
||||
for _, tc := range tests {
|
||||
tc := tc
|
||||
|
Loading…
Reference in New Issue
Block a user