@@ -550,13 +550,7 @@ void MOJOSHADER_sdlMapUniformBufferMemory(
550
550
551
551
void MOJOSHADER_sdlUnmapUniformBufferMemory (MOJOSHADER_sdlContext * ctx )
552
552
{
553
- if (ctx -> bound_program == NULL )
554
- {
555
- return ; /* Ignore buffer updates until we have a real program linked */
556
- }
557
-
558
- update_uniform_buffer (ctx , ctx -> bound_program -> vertexShader );
559
- update_uniform_buffer (ctx , ctx -> bound_program -> pixelShader );
553
+ /* no-op! real work done in sdlUpdateUniformBuffers */
560
554
}
561
555
562
556
int32_t MOJOSHADER_sdlGetUniformBufferSize (MOJOSHADER_sdlShader * shader )
@@ -573,6 +567,19 @@ int32_t MOJOSHADER_sdlGetUniformBufferSize(MOJOSHADER_sdlShader *shader)
573
567
return buflen ;
574
568
}
575
569
570
+ void MOJOSHADER_sdlUpdateUniformBuffers (MOJOSHADER_sdlContext * ctx )
571
+ {
572
+ if (MOJOSHADER_sdlGetUniformBufferSize (ctx -> bound_program -> vertexShader ) > 0 )
573
+ {
574
+ update_uniform_buffer (ctx , ctx -> bound_program -> vertexShader );
575
+ }
576
+
577
+ if (MOJOSHADER_sdlGetUniformBufferSize (ctx -> bound_program -> pixelShader ) > 0 )
578
+ {
579
+ update_uniform_buffer (ctx , ctx -> bound_program -> pixelShader );
580
+ }
581
+ }
582
+
576
583
int MOJOSHADER_sdlGetVertexAttribLocation (
577
584
MOJOSHADER_sdlShader * vert ,
578
585
MOJOSHADER_usage usage , int index
@@ -1276,33 +1283,36 @@ static void SDLGPU_SwapBuffers(
1276
1283
& height
1277
1284
);
1278
1285
1279
- srcRegion .textureSlice .texture = renderer -> fauxBackbufferColor ;
1280
- srcRegion .textureSlice .layer = 0 ;
1281
- srcRegion .textureSlice .mipLevel = 0 ;
1282
- srcRegion .x = 0 ;
1283
- srcRegion .y = 0 ;
1284
- srcRegion .z = 0 ;
1285
- srcRegion .w = width ;
1286
- srcRegion .h = height ;
1287
- srcRegion .d = 1 ;
1288
-
1289
- dstRegion .textureSlice .texture = swapchainTexture ;
1290
- dstRegion .textureSlice .layer = 0 ;
1291
- dstRegion .textureSlice .mipLevel = 0 ;
1292
- dstRegion .x = 0 ;
1293
- dstRegion .y = 0 ;
1294
- dstRegion .z = 0 ;
1295
- srcRegion .w = width ;
1296
- srcRegion .h = height ;
1297
- srcRegion .d = 1 ;
1298
-
1299
- SDL_GpuCopyTextureToTexture (
1300
- renderer -> device ,
1301
- renderer -> commandBuffer ,
1302
- & srcRegion ,
1303
- & dstRegion ,
1304
- SDL_GPU_TEXTUREWRITEOPTIONS_SAFE
1305
- );
1286
+ if (swapchainTexture != NULL )
1287
+ {
1288
+ srcRegion .textureSlice .texture = renderer -> fauxBackbufferColor ;
1289
+ srcRegion .textureSlice .layer = 0 ;
1290
+ srcRegion .textureSlice .mipLevel = 0 ;
1291
+ srcRegion .x = 0 ;
1292
+ srcRegion .y = 0 ;
1293
+ srcRegion .z = 0 ;
1294
+ srcRegion .w = width ;
1295
+ srcRegion .h = height ;
1296
+ srcRegion .d = 1 ;
1297
+
1298
+ dstRegion .textureSlice .texture = swapchainTexture ;
1299
+ dstRegion .textureSlice .layer = 0 ;
1300
+ dstRegion .textureSlice .mipLevel = 0 ;
1301
+ dstRegion .x = 0 ;
1302
+ dstRegion .y = 0 ;
1303
+ dstRegion .z = 0 ;
1304
+ srcRegion .w = width ;
1305
+ srcRegion .h = height ;
1306
+ srcRegion .d = 1 ;
1307
+
1308
+ SDL_GpuCopyTextureToTexture (
1309
+ renderer -> device ,
1310
+ renderer -> commandBuffer ,
1311
+ & srcRegion ,
1312
+ & dstRegion ,
1313
+ SDL_GPU_TEXTUREWRITEOPTIONS_SAFE
1314
+ );
1315
+ }
1306
1316
1307
1317
SDLGPU_INTERNAL_FlushCommands (renderer );
1308
1318
}
@@ -1476,6 +1486,10 @@ static void SDLGPU_INTERNAL_EndPass(
1476
1486
renderer -> device ,
1477
1487
renderer -> commandBuffer
1478
1488
);
1489
+
1490
+ renderer -> currentGraphicsPipeline = NULL ;
1491
+ renderer -> needNewGraphicsPipeline = 1 ;
1492
+ renderer -> renderPassInProgress = 0 ;
1479
1493
}
1480
1494
}
1481
1495
@@ -1596,6 +1610,8 @@ static void SDLGPU_INTERNAL_BeginRenderPass(
1596
1610
renderer -> shouldClearStencilOnBeginPass = 0 ;
1597
1611
1598
1612
renderer -> needNewGraphicsPipeline = 1 ;
1613
+
1614
+ renderer -> renderPassInProgress = 1 ;
1599
1615
}
1600
1616
1601
1617
static void SDLGPU_SetRenderTargets (
@@ -2047,6 +2063,8 @@ static void SDLGPU_INTERNAL_BindGraphicsPipeline(
2047
2063
renderer -> currentGraphicsPipeline = pipeline ;
2048
2064
}
2049
2065
2066
+ MOJOSHADER_sdlUpdateUniformBuffers (renderer -> mojoshaderContext );
2067
+
2050
2068
renderer -> currentVertexShader = vertShader ;
2051
2069
renderer -> currentFragmentShader = fragShader ;
2052
2070
0 commit comments