diff --git a/internal/graphicsdriver/directx/graphics12_windows.go b/internal/graphicsdriver/directx/graphics12_windows.go index 99129fafa..6a5d2eff3 100644 --- a/internal/graphicsdriver/directx/graphics12_windows.go +++ b/internal/graphicsdriver/directx/graphics12_windows.go @@ -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 diff --git a/shader_test.go b/shader_test.go index b325bb8d7..be5990706 100644 --- a/shader_test.go +++ b/shader_test.go @@ -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) + } + } + } + } + }) }