@@ -342,7 +342,7 @@ void RB_BeginDrawingView (void) {
342
342
{
343
343
FBO_t * fbo = backEnd .viewParms .targetFbo ;
344
344
345
- if (fbo == NULL && (! r_postProcess -> integer || !( backEnd . refdef . rdflags & RDF_NOWORLDMODEL )) )
345
+ if (fbo == NULL )
346
346
fbo = tr .renderFbo ;
347
347
348
348
if (tr .renderCubeFbo && fbo == tr .renderCubeFbo )
@@ -708,7 +708,7 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *
708
708
709
709
if (glRefConfig .framebufferObject )
710
710
{
711
- FBO_Bind (r_postProcess -> integer ? NULL : tr .renderFbo );
711
+ FBO_Bind (tr .renderFbo );
712
712
}
713
713
714
714
RB_SetGL2D ();
@@ -793,7 +793,7 @@ const void *RB_StretchPic ( const void *data ) {
793
793
cmd = (const stretchPicCommand_t * )data ;
794
794
795
795
if (glRefConfig .framebufferObject )
796
- FBO_Bind (r_postProcess -> integer ? NULL : tr .renderFbo );
796
+ FBO_Bind (tr .renderFbo );
797
797
798
798
RB_SetGL2D ();
799
799
@@ -1202,15 +1202,12 @@ const void *RB_DrawBuffer( const void *data ) {
1202
1202
1203
1203
// clear screen for debugging
1204
1204
if ( r_clear -> integer ) {
1205
- qglClearColor ( 1 , 0 , 0.5 , 1 );
1206
- qglClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
1207
-
1208
1205
if (glRefConfig .framebufferObject && tr .renderFbo ) {
1209
1206
FBO_Bind (tr .renderFbo );
1210
-
1211
- qglClearColor ( 1 , 0 , 0.5 , 1 );
1212
- qglClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
1213
1207
}
1208
+
1209
+ qglClearColor ( 1 , 0 , 0.5 , 1 );
1210
+ qglClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
1214
1211
}
1215
1212
1216
1213
return (const void * )(cmd + 1 );
@@ -1381,18 +1378,15 @@ const void *RB_SwapBuffers( const void *data ) {
1381
1378
1382
1379
if (glRefConfig .framebufferObject )
1383
1380
{
1384
- if (! r_postProcess -> integer )
1381
+ if (tr . msaaResolveFbo && r_hdr -> integer )
1385
1382
{
1386
- if (tr .msaaResolveFbo && r_hdr -> integer )
1387
- {
1388
- // Resolving an RGB16F MSAA FBO to the screen messes with the brightness, so resolve to an RGB16F FBO first
1389
- FBO_FastBlit (tr .renderFbo , NULL , tr .msaaResolveFbo , NULL , GL_COLOR_BUFFER_BIT , GL_NEAREST );
1390
- FBO_FastBlit (tr .msaaResolveFbo , NULL , NULL , NULL , GL_COLOR_BUFFER_BIT , GL_NEAREST );
1391
- }
1392
- else if (tr .renderFbo )
1393
- {
1394
- FBO_FastBlit (tr .renderFbo , NULL , NULL , NULL , GL_COLOR_BUFFER_BIT , GL_NEAREST );
1395
- }
1383
+ // Resolving an RGB16F MSAA FBO to the screen messes with the brightness, so resolve to an RGB16F FBO first
1384
+ FBO_FastBlit (tr .renderFbo , NULL , tr .msaaResolveFbo , NULL , GL_COLOR_BUFFER_BIT , GL_NEAREST );
1385
+ FBO_FastBlit (tr .msaaResolveFbo , NULL , NULL , NULL , GL_COLOR_BUFFER_BIT , GL_NEAREST );
1386
+ }
1387
+ else if (tr .renderFbo )
1388
+ {
1389
+ FBO_FastBlit (tr .renderFbo , NULL , NULL , NULL , GL_COLOR_BUFFER_BIT , GL_NEAREST );
1396
1390
}
1397
1391
}
1398
1392
@@ -1454,7 +1448,7 @@ RB_PostProcess
1454
1448
const void * RB_PostProcess (const void * data )
1455
1449
{
1456
1450
const postProcessCommand_t * cmd = data ;
1457
- FBO_t * srcFbo ;
1451
+ FBO_t * srcFbo , * dstFbo ;
1458
1452
ivec4_t srcBox , dstBox ;
1459
1453
qboolean autoExposure ;
1460
1454
@@ -1475,6 +1469,8 @@ const void *RB_PostProcess(const void *data)
1475
1469
}
1476
1470
1477
1471
srcFbo = tr .renderFbo ;
1472
+ dstFbo = tr .renderFbo ;
1473
+
1478
1474
if (tr .msaaResolveFbo )
1479
1475
{
1480
1476
// Resolve the MSAA before anything else
@@ -1508,13 +1504,13 @@ const void *RB_PostProcess(const void *data)
1508
1504
if (r_hdr -> integer && (r_toneMap -> integer || r_forceToneMap -> integer ))
1509
1505
{
1510
1506
autoExposure = r_autoExposure -> integer || r_forceAutoExposure -> integer ;
1511
- RB_ToneMap (srcFbo , srcBox , NULL , dstBox , autoExposure );
1507
+
1508
+ // Use an intermediate FBO because it can't blit to the same FBO directly
1509
+ // and can't read from an MSAA dstFbo later.
1510
+ RB_ToneMap (srcFbo , srcBox , tr .screenScratchFbo , srcBox , autoExposure );
1511
+ FBO_FastBlit (tr .screenScratchFbo , srcBox , srcFbo , srcBox , GL_COLOR_BUFFER_BIT , GL_NEAREST );
1512
1512
}
1513
- else if (r_cameraExposure -> value == 0.0f )
1514
- {
1515
- FBO_FastBlit (srcFbo , srcBox , NULL , dstBox , GL_COLOR_BUFFER_BIT , GL_NEAREST );
1516
- }
1517
- else
1513
+ else if (r_cameraExposure -> value != 0.0f )
1518
1514
{
1519
1515
vec4_t color ;
1520
1516
@@ -1523,17 +1519,20 @@ const void *RB_PostProcess(const void *data)
1523
1519
color [2 ] = pow (2 , r_cameraExposure -> value ); //exp2(r_cameraExposure->value);
1524
1520
color [3 ] = 1.0f ;
1525
1521
1526
- FBO_Blit ( srcFbo , srcBox , NULL , NULL , dstBox , NULL , color , 0 );
1522
+ FBO_BlitFromTexture ( tr . whiteImage , NULL , NULL , srcFbo , srcBox , NULL , color , GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO );
1527
1523
}
1528
1524
}
1529
1525
1530
1526
if (r_drawSunRays -> integer )
1531
- RB_SunRays (NULL , srcBox , NULL , dstBox );
1527
+ RB_SunRays (srcFbo , srcBox , srcFbo , srcBox );
1532
1528
1533
1529
if (1 )
1534
- RB_BokehBlur (NULL , srcBox , NULL , dstBox , backEnd .refdef .blurFactor );
1530
+ RB_BokehBlur (srcFbo , srcBox , srcFbo , srcBox , backEnd .refdef .blurFactor );
1535
1531
else
1536
- RB_GaussianBlur (backEnd .refdef .blurFactor );
1532
+ RB_GaussianBlur (srcFbo , srcFbo , backEnd .refdef .blurFactor );
1533
+
1534
+ if (srcFbo != dstFbo )
1535
+ FBO_FastBlit (srcFbo , srcBox , dstFbo , dstBox , GL_COLOR_BUFFER_BIT , GL_NEAREST );
1537
1536
1538
1537
#if 0
1539
1538
if (0 )
@@ -1549,7 +1548,7 @@ const void *RB_PostProcess(const void *data)
1549
1548
if (scale < 0.01f )
1550
1549
scale = 5.0f ;
1551
1550
1552
- FBO_FastBlit (NULL , NULL , tr .quarterFbo [0 ], NULL , GL_COLOR_BUFFER_BIT , GL_LINEAR );
1551
+ FBO_FastBlit (dstFbo , NULL , tr .quarterFbo [0 ], NULL , GL_COLOR_BUFFER_BIT , GL_LINEAR );
1553
1552
1554
1553
iQtrBox [0 ] = backEnd .viewParms .viewportX * tr .quarterImage [0 ]-> width / (float )glConfig .vidWidth ;
1555
1554
iQtrBox [1 ] = backEnd .viewParms .viewportY * tr .quarterImage [0 ]-> height / (float )glConfig .vidHeight ;
@@ -1595,7 +1594,7 @@ const void *RB_PostProcess(const void *data)
1595
1594
1596
1595
SetViewportAndScissor ();
1597
1596
1598
- FBO_FastBlit (tr .quarterFbo [1 ], NULL , NULL , NULL , GL_COLOR_BUFFER_BIT , GL_LINEAR );
1597
+ FBO_FastBlit (tr .quarterFbo [1 ], NULL , dstFbo , NULL , GL_COLOR_BUFFER_BIT , GL_LINEAR );
1599
1598
FBO_Bind (NULL );
1600
1599
}
1601
1600
#endif
@@ -1604,42 +1603,42 @@ const void *RB_PostProcess(const void *data)
1604
1603
{
1605
1604
ivec4_t dstBox ;
1606
1605
VectorSet4 (dstBox , 0 , glConfig .vidHeight - 128 , 128 , 128 );
1607
- FBO_BlitFromTexture (tr .sunShadowDepthImage [0 ], NULL , NULL , NULL , dstBox , NULL , NULL , 0 );
1606
+ FBO_BlitFromTexture (tr .sunShadowDepthImage [0 ], NULL , NULL , dstFbo , dstBox , NULL , NULL , 0 );
1608
1607
VectorSet4 (dstBox , 128 , glConfig .vidHeight - 128 , 128 , 128 );
1609
- FBO_BlitFromTexture (tr .sunShadowDepthImage [1 ], NULL , NULL , NULL , dstBox , NULL , NULL , 0 );
1608
+ FBO_BlitFromTexture (tr .sunShadowDepthImage [1 ], NULL , NULL , dstFbo , dstBox , NULL , NULL , 0 );
1610
1609
VectorSet4 (dstBox , 256 , glConfig .vidHeight - 128 , 128 , 128 );
1611
- FBO_BlitFromTexture (tr .sunShadowDepthImage [2 ], NULL , NULL , NULL , dstBox , NULL , NULL , 0 );
1610
+ FBO_BlitFromTexture (tr .sunShadowDepthImage [2 ], NULL , NULL , dstFbo , dstBox , NULL , NULL , 0 );
1612
1611
VectorSet4 (dstBox , 384 , glConfig .vidHeight - 128 , 128 , 128 );
1613
- FBO_BlitFromTexture (tr .sunShadowDepthImage [3 ], NULL , NULL , NULL , dstBox , NULL , NULL , 0 );
1612
+ FBO_BlitFromTexture (tr .sunShadowDepthImage [3 ], NULL , NULL , dstFbo , dstBox , NULL , NULL , 0 );
1614
1613
}
1615
1614
1616
1615
if (0 && r_shadows -> integer == 4 )
1617
1616
{
1618
1617
ivec4_t dstBox ;
1619
1618
VectorSet4 (dstBox , 512 + 0 , glConfig .vidHeight - 128 , 128 , 128 );
1620
- FBO_BlitFromTexture (tr .pshadowMaps [0 ], NULL , NULL , NULL , dstBox , NULL , NULL , 0 );
1619
+ FBO_BlitFromTexture (tr .pshadowMaps [0 ], NULL , NULL , dstFbo , dstBox , NULL , NULL , 0 );
1621
1620
VectorSet4 (dstBox , 512 + 128 , glConfig .vidHeight - 128 , 128 , 128 );
1622
- FBO_BlitFromTexture (tr .pshadowMaps [1 ], NULL , NULL , NULL , dstBox , NULL , NULL , 0 );
1621
+ FBO_BlitFromTexture (tr .pshadowMaps [1 ], NULL , NULL , dstFbo , dstBox , NULL , NULL , 0 );
1623
1622
VectorSet4 (dstBox , 512 + 256 , glConfig .vidHeight - 128 , 128 , 128 );
1624
- FBO_BlitFromTexture (tr .pshadowMaps [2 ], NULL , NULL , NULL , dstBox , NULL , NULL , 0 );
1623
+ FBO_BlitFromTexture (tr .pshadowMaps [2 ], NULL , NULL , dstFbo , dstBox , NULL , NULL , 0 );
1625
1624
VectorSet4 (dstBox , 512 + 384 , glConfig .vidHeight - 128 , 128 , 128 );
1626
- FBO_BlitFromTexture (tr .pshadowMaps [3 ], NULL , NULL , NULL , dstBox , NULL , NULL , 0 );
1625
+ FBO_BlitFromTexture (tr .pshadowMaps [3 ], NULL , NULL , dstFbo , dstBox , NULL , NULL , 0 );
1627
1626
}
1628
1627
1629
1628
if (0 )
1630
1629
{
1631
1630
ivec4_t dstBox ;
1632
1631
VectorSet4 (dstBox , 256 , glConfig .vidHeight - 256 , 256 , 256 );
1633
- FBO_BlitFromTexture (tr .renderDepthImage , NULL , NULL , NULL , dstBox , NULL , NULL , 0 );
1632
+ FBO_BlitFromTexture (tr .renderDepthImage , NULL , NULL , dstFbo , dstBox , NULL , NULL , 0 );
1634
1633
VectorSet4 (dstBox , 512 , glConfig .vidHeight - 256 , 256 , 256 );
1635
- FBO_BlitFromTexture (tr .screenShadowImage , NULL , NULL , NULL , dstBox , NULL , NULL , 0 );
1634
+ FBO_BlitFromTexture (tr .screenShadowImage , NULL , NULL , dstFbo , dstBox , NULL , NULL , 0 );
1636
1635
}
1637
1636
1638
1637
if (0 )
1639
1638
{
1640
1639
ivec4_t dstBox ;
1641
1640
VectorSet4 (dstBox , 256 , glConfig .vidHeight - 256 , 256 , 256 );
1642
- FBO_BlitFromTexture (tr .sunRaysImage , NULL , NULL , NULL , dstBox , NULL , NULL , 0 );
1641
+ FBO_BlitFromTexture (tr .sunRaysImage , NULL , NULL , dstFbo , dstBox , NULL , NULL , 0 );
1643
1642
}
1644
1643
1645
1644
#if 0
@@ -1651,8 +1650,8 @@ const void *RB_PostProcess(const void *data)
1651
1650
if (cubemapIndex )
1652
1651
{
1653
1652
VectorSet4 (dstBox , 0 , glConfig .vidHeight - 256 , 256 , 256 );
1654
- //FBO_BlitFromTexture(tr.renderCubeImage, NULL, NULL, NULL , dstBox, &tr.testcubeShader, NULL, 0);
1655
- FBO_BlitFromTexture (tr .cubemaps [cubemapIndex - 1 ].image , NULL , NULL , NULL , dstBox , & tr .testcubeShader , NULL , 0 );
1653
+ //FBO_BlitFromTexture(tr.renderCubeImage, NULL, NULL, dstFbo , dstBox, &tr.testcubeShader, NULL, 0);
1654
+ FBO_BlitFromTexture (tr .cubemaps [cubemapIndex - 1 ].image , NULL , NULL , dstFbo , dstBox , & tr .testcubeShader , NULL , 0 );
1656
1655
}
1657
1656
}
1658
1657
#endif
0 commit comments