directx: Better logic to assume MRT

This commit is contained in:
Zyko 2024-04-10 20:17:20 +02:00
parent 65646df8ed
commit 92a257a557

View File

@ -587,11 +587,15 @@ func (g *graphics11) DrawTriangles(dstIDs [graphics.ShaderDstImageCount]graphics
var dsts [graphics.ShaderDstImageCount]*image11 var dsts [graphics.ShaderDstImageCount]*image11
var viewports [graphics.ShaderDstImageCount]_D3D11_VIEWPORT var viewports [graphics.ShaderDstImageCount]_D3D11_VIEWPORT
var targetCount int var targetCount int
firstTarget := -1
for i, id := range dstIDs { for i, id := range dstIDs {
img := g.images[id] img := g.images[id]
if img == nil { if img == nil {
continue continue
} }
if firstTarget == -1 {
firstTarget = i
}
dsts[i] = img dsts[i] = img
w, h := img.internalSize() w, h := img.internalSize()
viewports[i] = _D3D11_VIEWPORT{ viewports[i] = _D3D11_VIEWPORT{
@ -614,8 +618,12 @@ func (g *graphics11) DrawTriangles(dstIDs [graphics.ShaderDstImageCount]graphics
srcs[i] = img srcs[i] = img
} }
// TODO: this is not correct, we can't assume that a single image means no MRT! // If the number of targets is more than one, or if the only target is the first one, then
if targetCount > 1 { // 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.
usesMRT := targetCount > 1 || firstTarget > 0
if usesMRT {
targetCount = graphics.ShaderDstImageCount targetCount = graphics.ShaderDstImageCount
} }
g.deviceContext.RSSetViewports(viewports[:targetCount]) g.deviceContext.RSSetViewports(viewports[:targetCount])