Skip to content

Commit

Permalink
Vulkan: Upstream changes from quake3e
Browse files Browse the repository at this point in the history
Cherrypicked: ec-/Quake3e@526944c
  • Loading branch information
JKSunny committed Apr 15, 2024
1 parent fdf7bfb commit 7de282a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions codemp/rd-vulkan/tr_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ cvar_t *cl_ratioFix;
// Vulkan
cvar_t *r_defaultImage;
cvar_t *r_device;
cvar_t *r_stencilbits;
//cvar_t *r_stencilbits;
cvar_t *r_ext_multisample;
cvar_t *r_ext_supersample;
cvar_t *r_ext_alpha_to_coverage;
Expand Down Expand Up @@ -910,7 +910,7 @@ void R_Register( void )
ri.Cvar_CheckRange(r_device, -2, 8, qtrue);
r_device->modified = qfalse;

r_stencilbits = ri.Cvar_Get("r_stencilbits", "8", CVAR_ARCHIVE_ND | CVAR_LATCH, "");
//r_stencilbits = ri.Cvar_Get("r_stencilbits", "8", CVAR_ARCHIVE_ND | CVAR_LATCH, "");
r_ext_multisample = ri.Cvar_Get("r_ext_multisample", "0", CVAR_ARCHIVE_ND | CVAR_LATCH, "");
ri.Cvar_CheckRange(r_ext_multisample, 0, 64, qtrue);
r_ext_supersample = ri.Cvar_Get("r_ext_supersample", "0", CVAR_ARCHIVE_ND | CVAR_LATCH, "");
Expand Down
4 changes: 2 additions & 2 deletions codemp/rd-vulkan/vk_attachments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ static void create_depth_attachment( uint32_t width, uint32_t height, VkSampleCo
desc.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;

image_aspect_flags = VK_IMAGE_ASPECT_DEPTH_BIT;
if (r_stencilbits->integer)
if ( glConfig.stencilBits > 0 )
image_aspect_flags |= VK_IMAGE_ASPECT_STENCIL_BIT;

VK_CHECK(qvkCreateImage(vk.device, &desc, NULL, image));
Expand Down Expand Up @@ -442,7 +442,7 @@ void vk_clear_depthstencil_attachments( qboolean clear_stencil ) {
#endif
attachment.clearValue.depthStencil.stencil = 0;

if ( clear_stencil && r_stencilbits->integer ) {
if ( clear_stencil && glConfig.stencilBits > 0 ) {
attachment.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
}
else {
Expand Down
4 changes: 2 additions & 2 deletions codemp/rd-vulkan/vk_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ void vk_create_render_passes()
attachments[1].samples = (VkSampleCountFlagBits)vkSamples;
attachments[1].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
//attachments[1].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
attachments[1].stencilLoadOp = r_stencilbits->integer ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_DONT_CARE;
attachments[1].stencilLoadOp = glConfig.stencilBits ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_DONT_CARE;
if ( vk.bloomActive || vk.dglowActive || vk.refractionActive ) {
attachments[1].storeOp = VK_ATTACHMENT_STORE_OP_STORE; // keep it for post-bloom/dynamic-glow pass
//attachments[1].stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
attachments[1].stencilStoreOp = r_stencilbits->integer ? VK_ATTACHMENT_STORE_OP_STORE : VK_ATTACHMENT_STORE_OP_DONT_CARE;
attachments[1].stencilStoreOp = glConfig.stencilBits ? VK_ATTACHMENT_STORE_OP_STORE : VK_ATTACHMENT_STORE_OP_DONT_CARE;
}
else {
attachments[1].storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
Expand Down
4 changes: 1 addition & 3 deletions codemp/rd-vulkan/vk_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,13 @@ static VkFormat get_depth_format( VkPhysicalDevice physical_device ) {
VkFormat formats[2];
uint32_t i;

if (r_stencilbits->integer > 0) {
if ( glConfig.stencilBits > 0 ) {
formats[0] = glConfig.depthBits == 16 ? VK_FORMAT_D16_UNORM_S8_UINT : VK_FORMAT_D24_UNORM_S8_UINT;
formats[1] = VK_FORMAT_D32_SFLOAT_S8_UINT;
glConfig.stencilBits = 8;
}
else {
formats[0] = glConfig.depthBits == 16 ? VK_FORMAT_D16_UNORM : VK_FORMAT_X8_D24_UNORM_PACK32;
formats[1] = VK_FORMAT_D32_SFLOAT;
glConfig.stencilBits = 0;
}

for (i = 0; i < ARRAY_LEN(formats); i++) {
Expand Down

0 comments on commit 7de282a

Please sign in to comment.