@@ -1104,6 +1104,8 @@ typedef struct SDLGPU_Renderer
1104
1104
SDL_GpuTexture * nextRenderPassDepthStencilAttachment ; /* may be NULL */
1105
1105
SDL_GpuTextureFormat nextRenderPassDepthStencilFormat ;
1106
1106
1107
+ uint8_t renderTargetInUse ;
1108
+
1107
1109
uint8_t needNewGraphicsPipeline ;
1108
1110
int32_t currentVertexBufferBindingsIndex ;
1109
1111
@@ -1522,6 +1524,8 @@ static void SDLGPU_INTERNAL_BeginRenderPass(
1522
1524
colorAttachmentInfos [i ].clearColor .z = 0 ;
1523
1525
colorAttachmentInfos [i ].clearColor .w = 0 ;
1524
1526
}
1527
+
1528
+ renderer -> colorAttachmentFormats [i ] = renderer -> nextRenderPassColorAttachmentFormats [i ];
1525
1529
}
1526
1530
1527
1531
if (renderer -> nextRenderPassDepthStencilAttachment != NULL )
@@ -1558,6 +1562,7 @@ static void SDLGPU_INTERNAL_BeginRenderPass(
1558
1562
/* We always have to store just in case changing render state breaks the render pass. */
1559
1563
/* FIXME: perhaps there is a way around this? */
1560
1564
depthStencilAttachmentInfo .storeOp = SDL_GPU_STOREOP_STORE ;
1565
+ depthStencilAttachmentInfo .stencilStoreOp = SDL_GPU_STOREOP_STORE ;
1561
1566
1562
1567
depthStencilAttachmentInfo .writeOption =
1563
1568
depthStencilAttachmentInfo .loadOp == SDL_GPU_LOADOP_LOAD || depthStencilAttachmentInfo .loadOp == SDL_GPU_LOADOP_LOAD ?
@@ -1622,12 +1627,14 @@ static void SDLGPU_SetRenderTargets(
1622
1627
{
1623
1628
renderer -> nextRenderPassColorAttachments [0 ] = renderer -> fauxBackbufferColor ;
1624
1629
renderer -> nextRenderPassColorAttachmentCubeFace [0 ] = 0 ;
1625
- renderer -> nextRenderPassColorAttachmentFormats [0 ] = renderer -> fauxBackbufferColorFormat ;
1626
- renderer -> nextRenderPassColorAttachmentCount = 1 ;
1627
-
1630
+ renderer -> nextRenderPassColorAttachmentFormats [0 ] = XNAToSDL_SurfaceFormat [renderer -> fauxBackbufferColorFormat ];
1628
1631
renderer -> nextRenderPassMultisampleCount = XNAToSDL_SampleCount (renderer -> fauxBackbufferSampleCount );
1632
+ renderer -> nextRenderPassColorAttachmentCount = 1 ;
1629
1633
1630
1634
renderer -> nextRenderPassDepthStencilAttachment = renderer -> fauxBackbufferDepthStencil ;
1635
+ renderer -> nextRenderPassDepthStencilFormat = XNAToSDL_DepthFormat (renderer -> fauxBackbufferDepthStencilFormat );
1636
+
1637
+ renderer -> renderTargetInUse = 0 ;
1631
1638
}
1632
1639
else
1633
1640
{
@@ -1654,6 +1661,7 @@ static void SDLGPU_SetRenderTargets(
1654
1661
}
1655
1662
1656
1663
renderer -> nextRenderPassColorAttachmentCount = numRenderTargets ;
1664
+ renderer -> renderTargetInUse = 1 ;
1657
1665
}
1658
1666
1659
1667
if (depthStencilBuffer != NULL )
@@ -2687,6 +2695,22 @@ static void SDLGPU_INTERNAL_CreateFauxBackbuffer(
2687
2695
renderer -> fauxBackbufferDepthStencilFormat = presentationParameters -> depthStencilFormat ;
2688
2696
2689
2697
renderer -> fauxBackbufferSampleCount = presentationParameters -> multiSampleCount ;
2698
+
2699
+ /* Set default render pass state if necessary */
2700
+ if (!renderer -> renderTargetInUse )
2701
+ {
2702
+ renderer -> nextRenderPassColorAttachments [0 ] = renderer -> fauxBackbufferColor ;
2703
+ renderer -> nextRenderPassColorAttachmentCubeFace [0 ] = 0 ;
2704
+ renderer -> nextRenderPassColorAttachmentFormats [0 ] = XNAToSDL_SurfaceFormat [renderer -> fauxBackbufferColorFormat ];
2705
+ renderer -> nextRenderPassColorAttachmentCount = 1 ;
2706
+ renderer -> nextRenderPassMultisampleCount = renderer -> fauxBackbufferSampleCount ;
2707
+
2708
+ if (presentationParameters -> depthStencilFormat != FNA3D_DEPTHFORMAT_NONE )
2709
+ {
2710
+ renderer -> nextRenderPassDepthStencilAttachment = renderer -> fauxBackbufferDepthStencil ;
2711
+ renderer -> nextRenderPassDepthStencilFormat = XNAToSDL_DepthFormat (renderer -> fauxBackbufferDepthStencilFormat );
2712
+ }
2713
+ }
2690
2714
}
2691
2715
2692
2716
static void SDLGPU_ResetBackbuffer (
0 commit comments