mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Add a test when a single image is used with DrawMRT
This commit is contained in:
parent
d706d38ada
commit
dbe06ec468
@ -1225,7 +1225,7 @@ func (g *graphics12) DrawTriangles(dstIDs [graphics.ShaderDstImageCount]graphics
|
||||
// If the number of targets is more than one, or if the only target is the first one, then
|
||||
// it is safe to assume that MRT is used.
|
||||
// Also, it only matters in order to specify empty targets/viewports when not all slots are
|
||||
// being filled.
|
||||
// being filled, even though it's not a MRT scenario.
|
||||
usesMRT := targetCount > 1 || firstTarget > 0
|
||||
if usesMRT {
|
||||
targetCount = graphics.ShaderDstImageCount
|
||||
|
@ -2677,6 +2677,7 @@ func Fragment(dstPos vec4, srcPos vec2, color vec4) (vec4, vec4, vec4, vec4, vec
|
||||
}
|
||||
})
|
||||
|
||||
// Clear images
|
||||
for _, img := range imgs {
|
||||
img.Clear()
|
||||
}
|
||||
@ -2707,4 +2708,30 @@ func Fragment(dstPos vec4, srcPos vec2, color vec4) (vec4, vec4, vec4, vec4, vec
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// Clear images
|
||||
for _, img := range imgs {
|
||||
img.Clear()
|
||||
}
|
||||
t.Run("1 location (first slot)", func(t *testing.T) {
|
||||
wantColors := [8]color.RGBA{
|
||||
{R: 0xff, G: 0, B: 0, A: 0xff},
|
||||
{}, {}, {}, {}, {}, {}, {},
|
||||
}
|
||||
dsts := [8]*ebiten.Image{
|
||||
imgs[0], nil, nil, nil, nil, nil, nil, nil,
|
||||
}
|
||||
ebiten.DrawTrianglesShaderMRT(dsts, vertices, indices, s, nil)
|
||||
for k, dst := range imgs {
|
||||
for j := 0; j < h; j++ {
|
||||
for i := 0; i < w; i++ {
|
||||
got := dst.At(i, j).(color.RGBA)
|
||||
want := wantColors[k]
|
||||
if !sameColors(got, want, 1) {
|
||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user