Skip to content

Commit 526944c

Browse files
committed
Win32: report actual color bits and correct PFD count
X11: request alpha bits for >=24 bit color profiles Renderers: use glConfig.stencilBits instead of dereferencing \r_stencilbits cvar Vulkan: increase MAX_IMAGE_CHUNKS from 48 to 56
1 parent f9ca298 commit 526944c

File tree

14 files changed

+68
-86
lines changed

14 files changed

+68
-86
lines changed

code/client/cl_main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3822,7 +3822,7 @@ static void CL_InitGLimp_Cvars( void )
38223822
// shared with renderer:
38233823
cl_stencilbits = Cvar_Get( "r_stencilbits", "8", CVAR_ARCHIVE_ND | CVAR_LATCH );
38243824
Cvar_CheckRange( cl_stencilbits, "0", "8", CV_INTEGER );
3825-
Cvar_SetDescription( cl_stencilbits, "Stencil buffer size, value decreases Z-buffer depth." );
3825+
Cvar_SetDescription( cl_stencilbits, "Stencil buffer size, required to be 8 for stencil shadows." );
38263826
cl_depthbits = Cvar_Get( "r_depthbits", "0", CVAR_ARCHIVE_ND | CVAR_LATCH );
38273827
Cvar_CheckRange( cl_depthbits, "0", "32", CV_INTEGER );
38283828
Cvar_SetDescription( cl_depthbits, "Sets precision of Z-buffer." );

code/qcommon/cmd.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ void Cbuf_Execute( void )
255255
{
256256
char line[MAX_CMD_LINE], *text;
257257
int i, n, quotes;
258+
qboolean in_star_comment;
259+
qboolean in_slash_comment;
258260

259261
if ( cmd_wait > 0 ) {
260262
// delay command buffer execution
@@ -265,8 +267,8 @@ void Cbuf_Execute( void )
265267
// This will keep // style comments all on one line by not breaking on
266268
// a semicolon. It will keep /* ... */ style comments all on one line by not
267269
// breaking it for semicolon or newline.
268-
qboolean in_star_comment = qfalse;
269-
qboolean in_slash_comment = qfalse;
270+
in_star_comment = qfalse;
271+
in_slash_comment = qfalse;
270272

271273
while ( cmd_text.cursize > 0 )
272274
{

code/renderer/tr_arb.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ void FBO_Clean( frameBuffer_t *fb )
11101110
fb->depthStencil = 0;
11111111
}
11121112
#else
1113-
if ( r_stencilbits->integer == 0 )
1113+
if ( glConfig.stencilBits == 0 )
11141114
qglFramebufferTexture2D( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0 );
11151115
else
11161116
qglFramebufferTexture2D( GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0 );
@@ -1165,7 +1165,7 @@ static GLuint FBO_CreateDepthTextureOrBuffer( GLsizei width, GLsizei height )
11651165
GLuint buffer;
11661166
qglGenRenderbuffers( 1, &buffer );
11671167
qglBindRenderbuffer( GL_RENDERBUFFER, buffer );
1168-
if ( r_stencilbits->integer == 0 )
1168+
if ( glConfig.stencilBits == 0 )
11691169
qglRenderbufferStorage( GL_RENDERBUFFER, GL_DEPTH_COMPONENT32, width, height );
11701170
else
11711171
qglRenderbufferStorage( GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height );
@@ -1176,7 +1176,7 @@ static GLuint FBO_CreateDepthTextureOrBuffer( GLsizei width, GLsizei height )
11761176
GL_BindTexture( 0, tex );
11771177
qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
11781178
qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
1179-
if ( r_stencilbits->integer == 0 )
1179+
if ( glConfig.stencilBits == 0 )
11801180
qglTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL );
11811181
else
11821182
qglTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, width, height, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL );
@@ -1336,12 +1336,12 @@ static qboolean FBO_Create( frameBuffer_t *fb, GLsizei width, GLsizei height, qb
13361336
fb->depthStencil = FBO_CreateDepthTextureOrBuffer( width, height );
13371337
#endif
13381338
#ifdef DEPTH_RENDER_BUFFER
1339-
if ( r_stencilbits->integer == 0 )
1339+
if ( glConfig.stencilBits == 0 )
13401340
qglFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, fb->depthStencil );
13411341
else
13421342
qglFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, fb->depthStencil );
13431343
#else
1344-
if ( r_stencilbits->integer == 0 )
1344+
if ( glConfig.stencilBits == 0 )
13451345
qglFramebufferTexture2D( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, fb->depthStencil, 0 );
13461346
else
13471347
qglFramebufferTexture2D( GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, fb->depthStencil, 0 );
@@ -1413,7 +1413,7 @@ static qboolean FBO_CreateMS( frameBuffer_t *fb, int width, int height )
14131413

14141414
qglGenRenderbuffers( 1, &fb->depthStencil );
14151415
qglBindRenderbuffer( GL_RENDERBUFFER, fb->depthStencil );
1416-
if ( r_stencilbits->integer == 0 )
1416+
if ( glConfig.stencilBits == 0 )
14171417
qglRenderbufferStorageMultisample( GL_RENDERBUFFER, nSamples, GL_DEPTH_COMPONENT32, width, height );
14181418
else
14191419
qglRenderbufferStorageMultisample( GL_RENDERBUFFER, nSamples, GL_DEPTH24_STENCIL8, width, height );
@@ -1424,7 +1424,7 @@ static qboolean FBO_CreateMS( frameBuffer_t *fb, int width, int height )
14241424
return qfalse;
14251425
}
14261426

1427-
if ( r_stencilbits->integer == 0 )
1427+
if ( glConfig.stencilBits == 0 )
14281428
qglFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, fb->depthStencil );
14291429
else
14301430
qglFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, fb->depthStencil );

code/renderer/tr_common.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ extern int gl_version;
7070
//
7171
// cvars
7272
//
73-
extern cvar_t *r_stencilbits; // number of desired stencil bits
73+
//extern cvar_t *r_stencilbits; // number of desired stencil bits
7474
extern cvar_t *r_texturebits; // number of desired texture bits
7575
// 0 = use framebuffer depth
7676
// 16 = use 16-bit textures

code/renderer/tr_image.c

+15-15
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ return a hash value for the filename
4646
*/
4747
void R_GammaCorrect( byte *buffer, int bufSize ) {
4848
int i;
49-
#ifdef USE_FBO
49+
#ifdef USE_FBO
5050
if ( fboEnabled ) {
5151
return;
5252
}
53-
#endif
53+
#endif
5454
if ( !gls.deviceSupportsGamma ) {
5555
return;
5656
}
@@ -304,11 +304,11 @@ static void R_LightScaleTexture( byte *in, int inwidth, int inheight, qboolean o
304304

305305
if ( only_gamma )
306306
{
307-
#ifdef USE_FBO
307+
#ifdef USE_FBO
308308
if ( !glConfig.deviceSupportsGamma && !fboEnabled )
309-
#else
310-
if ( !glConfig.deviceSupportsGamma )
311-
#endif
309+
#else
310+
if ( !glConfig.deviceSupportsGamma )
311+
#endif
312312
{
313313
int i, c;
314314
byte *p;
@@ -333,10 +333,10 @@ static void R_LightScaleTexture( byte *in, int inwidth, int inheight, qboolean o
333333

334334
c = inwidth*inheight;
335335

336-
#ifdef USE_FBO
337-
if ( glConfig.deviceSupportsGamma || fboEnabled )
338-
#else
339-
if ( glConfig.deviceSupportsGamma )
336+
#ifdef USE_FBO
337+
if ( glConfig.deviceSupportsGamma || fboEnabled )
338+
#else
339+
if ( glConfig.deviceSupportsGamma )
340340
#endif
341341
{
342342
for (i=0 ; i<c ; i++, p+=4)
@@ -1376,11 +1376,11 @@ void R_SetColorMappings( void ) {
13761376
tr.overbrightBits = abs( r_overBrightBits->integer );
13771377

13781378
// never overbright in windowed mode
1379-
#ifdef USE_FBO
1379+
#ifdef USE_FBO
13801380
if ( !glConfig.isFullscreen && r_overBrightBits->integer >= 0 && !fboEnabled ) {
1381-
#else
1381+
#else
13821382
if ( !glConfig.isFullscreen && r_overBrightBits->integer >= 0 ) {
1383-
#endif
1383+
#endif
13841384
tr.overbrightBits = 0;
13851385
applyGamma = qfalse;
13861386
} else {
@@ -1442,11 +1442,11 @@ void R_SetColorMappings( void ) {
14421442
}
14431443

14441444
if ( gls.deviceSupportsGamma ) {
1445-
#ifdef USE_FBO
1445+
#ifdef USE_FBO
14461446
if ( fboEnabled )
14471447
ri.GLimp_SetGamma( s_gammatable_linear, s_gammatable_linear, s_gammatable_linear );
14481448
else
1449-
#endif
1449+
#endif
14501450
{
14511451
if ( applyGamma ) {
14521452
ri.GLimp_SetGamma( s_gammatable, s_gammatable, s_gammatable );

code/renderer/tr_init.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ cvar_t *r_ext_max_anisotropy;
124124

125125
cvar_t *r_ignoreGLErrors;
126126

127-
cvar_t *r_stencilbits;
127+
//cvar_t *r_stencilbits;
128128
cvar_t *r_texturebits;
129129

130130
#ifdef USE_FBO
@@ -1759,8 +1759,7 @@ static void R_Register( void )
17591759
ri.Cvar_CheckRange( r_ext_max_anisotropy, "1", NULL, CV_INTEGER );
17601760
ri.Cvar_SetDescription( r_ext_max_anisotropy, "Sets maximum anisotropic level for your graphics driver. Requires \\r_ext_texture_filter_anisotropic." );
17611761

1762-
r_stencilbits = ri.Cvar_Get( "r_stencilbits", "8", CVAR_ARCHIVE_ND | CVAR_LATCH );
1763-
ri.Cvar_SetDescription( r_stencilbits, "Stencil buffer size, value decreases Z-buffer depth." );
1762+
//r_stencilbits = ri.Cvar_Get( "r_stencilbits", "8", CVAR_ARCHIVE_ND | CVAR_LATCH );
17641763
r_ignorehwgamma = ri.Cvar_Get( "r_ignorehwgamma", "0", CVAR_ARCHIVE_ND | CVAR_LATCH );
17651764
ri.Cvar_CheckRange( r_ignorehwgamma, "0", "1", CV_INTEGER );
17661765
ri.Cvar_SetDescription( r_ignorehwgamma, "Overrides hardware gamma capabilities." );

code/renderer2/tr_init.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ cvar_t *r_ignoreDstAlpha;
157157
cvar_t *r_ignoreGLErrors;
158158
cvar_t *r_logFile;
159159

160-
cvar_t *r_stencilbits;
160+
//cvar_t *r_stencilbits;
161161
cvar_t *r_texturebits;
162162
cvar_t *r_ext_multisample;
163163

@@ -1140,8 +1140,7 @@ static void R_Register( void )
11401140
ri.Cvar_SetDescription( r_detailTextures, "Enables usage of shader stages flagged as detail." );
11411141
r_texturebits = ri.Cvar_Get( "r_texturebits", "0", CVAR_ARCHIVE | CVAR_LATCH );
11421142
ri.Cvar_SetDescription( r_texturebits, "Number of texture bits per texture." );
1143-
r_stencilbits = ri.Cvar_Get( "r_stencilbits", "8", CVAR_ARCHIVE | CVAR_LATCH );
1144-
ri.Cvar_SetDescription( r_stencilbits, "Stencil buffer size, value decreases Z-buffer depth." );
1143+
// r_stencilbits = ri.Cvar_Get( "r_stencilbits", "8", CVAR_ARCHIVE | CVAR_LATCH );
11451144
r_ext_multisample = ri.Cvar_Get( "r_ext_multisample", "0", CVAR_ARCHIVE | CVAR_LATCH );
11461145
ri.Cvar_CheckRange( r_ext_multisample, "0", "8", CV_INTEGER );
11471146
ri.Cvar_SetDescription( r_ext_multisample, "For anti-aliasing geometry edges." );

code/renderervk/tr_common.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ extern int maxAnisotropy;
7171
//
7272
// cvars
7373
//
74-
extern cvar_t *r_stencilbits; // number of desired stencil bits
74+
//extern cvar_t *r_stencilbits; // number of desired stencil bits
7575
extern cvar_t *r_texturebits; // number of desired texture bits
7676
// 0 = use framebuffer depth
7777
// 16 = use 16-bit textures

code/renderervk/tr_init.c

+2-5
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ cvar_t *r_ext_max_anisotropy;
121121

122122
cvar_t *r_ignoreGLErrors;
123123

124-
cvar_t *r_stencilbits;
124+
//cvar_t *r_stencilbits;
125125
cvar_t *r_texturebits;
126126
cvar_t *r_ext_multisample;
127127
cvar_t *r_ext_alpha_to_coverage;
@@ -1762,10 +1762,7 @@ static void R_Register( void )
17621762
ri.Cvar_CheckRange( r_ext_max_anisotropy, "1", NULL, CV_INTEGER );
17631763
ri.Cvar_SetDescription( r_ext_max_anisotropy, "Sets maximum anisotropic level for your graphics driver. Requires \\r_ext_texture_filter_anisotropic." );
17641764

1765-
r_stencilbits = ri.Cvar_Get( "r_stencilbits", "8", CVAR_ARCHIVE_ND | CVAR_LATCH );
1766-
ri.Cvar_CheckRange( r_stencilbits, "0", "8", CV_INTEGER );
1767-
ri.Cvar_SetDescription( r_stencilbits, "Stencil buffer size, value decreases Z-buffer depth." );
1768-
1765+
//r_stencilbits = ri.Cvar_Get( "r_stencilbits", "8", CVAR_ARCHIVE_ND | CVAR_LATCH );
17691766
r_ignorehwgamma = ri.Cvar_Get( "r_ignorehwgamma", "0", CVAR_ARCHIVE_ND | CVAR_LATCH );
17701767
ri.Cvar_CheckRange( r_ignorehwgamma, "0", "1", CV_INTEGER );
17711768
ri.Cvar_SetDescription( r_ignorehwgamma, "Overrides hardware gamma capabilities." );

code/renderervk/vk.c

+6-7
Original file line numberDiff line numberDiff line change
@@ -677,10 +677,10 @@ static void vk_create_render_passes( void )
677677
attachments[1].format = depth_format;
678678
attachments[1].samples = vkSamples;
679679
attachments[1].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; // Need empty depth buffer before use
680-
attachments[1].stencilLoadOp = r_stencilbits->integer ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_DONT_CARE;
680+
attachments[1].stencilLoadOp = glConfig.stencilBits ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_DONT_CARE;
681681
if ( r_bloom->integer ) {
682682
attachments[1].storeOp = VK_ATTACHMENT_STORE_OP_STORE; // keep it for post-bloom pass
683-
attachments[1].stencilStoreOp = r_stencilbits->integer ? VK_ATTACHMENT_STORE_OP_STORE : VK_ATTACHMENT_STORE_OP_DONT_CARE;
683+
attachments[1].stencilStoreOp = glConfig.stencilBits ? VK_ATTACHMENT_STORE_OP_STORE : VK_ATTACHMENT_STORE_OP_DONT_CARE;
684684
} else {
685685
attachments[1].storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
686686
attachments[1].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
@@ -1247,15 +1247,14 @@ static VkFormat get_depth_format( VkPhysicalDevice physical_device ) {
12471247
VkFormat formats[2];
12481248
int i;
12491249

1250-
if (r_stencilbits->integer > 0) {
1250+
if ( glConfig.stencilBits > 0 ) {
12511251
formats[0] = glConfig.depthBits == 16 ? VK_FORMAT_D16_UNORM_S8_UINT : VK_FORMAT_D24_UNORM_S8_UINT;
12521252
formats[1] = VK_FORMAT_D32_SFLOAT_S8_UINT;
1253-
glConfig.stencilBits = 8;
12541253
} else {
12551254
formats[0] = glConfig.depthBits == 16 ? VK_FORMAT_D16_UNORM : VK_FORMAT_X8_D24_UNORM_PACK32;
12561255
formats[1] = VK_FORMAT_D32_SFLOAT;
1257-
glConfig.stencilBits = 0;
12581256
}
1257+
12591258
for ( i = 0; i < ARRAY_LEN( formats ); i++ ) {
12601259
qvkGetPhysicalDeviceFormatProperties( physical_device, formats[i], &props );
12611260
if ( ( props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT ) != 0 ) {
@@ -3228,7 +3227,7 @@ static void create_depth_attachment( uint32_t width, uint32_t height, VkSampleCo
32283227
create_desc.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
32293228

32303229
image_aspect_flags = VK_IMAGE_ASPECT_DEPTH_BIT;
3231-
if ( r_stencilbits->integer )
3230+
if ( glConfig.stencilBits > 0 )
32323231
image_aspect_flags |= VK_IMAGE_ASPECT_STENCIL_BIT;
32333232

32343233
VK_CHECK( qvkCreateImage( vk.device, &create_desc, NULL, image ) );
@@ -6383,7 +6382,7 @@ void vk_clear_depth( qboolean clear_stencil ) {
63836382
attachment.clearValue.depthStencil.depth = 1.0f;
63846383
#endif
63856384
attachment.clearValue.depthStencil.stencil = 0;
6386-
if ( clear_stencil && r_stencilbits->integer ) {
6385+
if ( clear_stencil && glConfig.stencilBits > 0 ) {
63876386
attachment.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
63886387
} else {
63896388
attachment.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;

code/renderervk/vk.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#define VERTEX_BUFFER_SIZE (4 * 1024 * 1024)
1616
#define IMAGE_CHUNK_SIZE (32 * 1024 * 1024)
17-
#define MAX_IMAGE_CHUNKS 48
17+
#define MAX_IMAGE_CHUNKS 56
1818

1919
#define NUM_COMMAND_BUFFERS 2 // number of command buffers / render semaphores / framebuffer sets
2020

code/sdl/sdl_glimp.c

+1-7
Original file line numberDiff line numberDiff line change
@@ -348,17 +348,11 @@ static int GLW_SetMode( int mode, const char *modeFS, qboolean fullscreen, qbool
348348
{ // reduce depthBits
349349
if (testDepthBits == 24)
350350
testDepthBits = 16;
351-
else if (testDepthBits == 16)
352-
testDepthBits = 8;
353351
}
354352

355353
if ((i % 4) == 1)
356354
{ // reduce stencilBits
357-
if (testStencilBits == 24)
358-
testStencilBits = 16;
359-
else if (testStencilBits == 16)
360-
testStencilBits = 8;
361-
else
355+
if (testStencilBits == 8)
362356
testStencilBits = 0;
363357
}
364358

0 commit comments

Comments
 (0)