testing: Bug fix: Image's size should not be in uniform variables

This commit is contained in:
Hajime Hoshi 2020-05-30 05:16:50 +09:00
parent f92253487f
commit 833a364ba8
4 changed files with 5 additions and 11 deletions

View File

@ -265,6 +265,8 @@ func (q *commandQueue) Flush() error {
vs[i*graphics.VertexFloatNum+6] -= 1.0 / s.width * texelAdjustmentFactor
vs[i*graphics.VertexFloatNum+7] -= 1.0 / s.height * texelAdjustmentFactor
}
// TODO: Adjust the source sizes in uniform variables.
} else {
n := q.nvertices / graphics.VertexFloatNum
for i := 0; i < n; i++ {

View File

@ -116,10 +116,8 @@ func TestShaderMultipleSources(t *testing.T) {
[]float32{1, 1},
srcs[0],
srcs[1],
[]float32{1, 1},
[]float32{0, 0, 1, 1},
srcs[2],
[]float32{1, 1},
[]float32{0, 0, 1, 1},
}
dst.DrawTriangles(nil, quadVertices(1, 1, 0, 0), graphics.QuadIndices(), nil, driver.CompositeModeCopy, driver.FilterNearest, driver.AddressClampToZero, s, us)

View File

@ -328,10 +328,6 @@ func (i *Image) DrawTriangles(img *Image, vertices []float32, indices []uint16,
case *Image:
us[i] = v.backend.restorable
if !firstImage {
i++
pos := us[i].([]float32)
pos[0] += oxf
pos[1] += oyf
i++
region := us[i].([]float32)
region[0] += oxf

View File

@ -266,9 +266,8 @@ func ShaderProgramFill(r, g, b, a byte) shaderir.Program {
//
// 0: the framebuffer size (Vec2)
// 1: the first images (Sampler2D)
// 3n-1: the (n+1)th image (Sampler2D)
// 3n: the (n+1)th image's size (Vec2)
// 3n+1: the (n+1)th image's region (Vec4)
// 2n: the n-th image (Sampler2D)
// 2n+1: the n-th image's region (Vec4)
//
// The first image's size and region are represented in attribute variables.
//
@ -283,7 +282,6 @@ func ShaderProgramImages(imageNum int) shaderir.Program {
for i := 0; i < imageNum; i++ {
p.Uniforms = append(p.Uniforms, shaderir.Type{Main: shaderir.Sampler2D})
if i > 0 {
p.Uniforms = append(p.Uniforms, shaderir.Type{Main: shaderir.Vec2})
p.Uniforms = append(p.Uniforms, shaderir.Type{Main: shaderir.Vec4})
}
}
@ -341,7 +339,7 @@ func ShaderProgramImages(imageNum int) shaderir.Program {
},
{
Type: shaderir.UniformVariable,
Index: 3*i - 1,
Index: 2 * i,
},
texPos,
},