Skip to content

Commit

Permalink
Vulkan: do not set transient flag for depth/stencil attachment when b…
Browse files Browse the repository at this point in the history
…loom (and thus - post-bloom pass) is enabled
  • Loading branch information
ec- committed Feb 10, 2024
1 parent c368633 commit fddf0a8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions code/renderervk/vk.c
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ static void vk_create_render_passes( void )
deps[1].dstSubpass = VK_SUBPASS_EXTERNAL;
deps[1].srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; // Fragment data has been written
deps[1].dstStageMask = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; // Don't start shading until data is available
deps[1].srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; // Waiting for color data to be written
deps[1].srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; // Waiting for color data to be written
deps[1].dstAccessMask = VK_ACCESS_SHADER_READ_BIT; // Don't read things from the shader before ready
deps[1].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT; // Only need the current fragment (or tile) synchronized, not the whole framebuffer

Expand Down Expand Up @@ -3199,7 +3199,7 @@ static void create_color_attachment( uint32_t width, uint32_t height, VkSampleCo
}


static void create_depth_attachment( uint32_t width, uint32_t height, VkSampleCountFlagBits samples, VkImage *image, VkImageView *image_view )
static void create_depth_attachment( uint32_t width, uint32_t height, VkSampleCountFlagBits samples, VkImage *image, VkImageView *image_view, qboolean allowTransient )
{
VkImageCreateInfo create_desc;
VkMemoryRequirements memory_requirements;
Expand All @@ -3218,7 +3218,10 @@ static void create_depth_attachment( uint32_t width, uint32_t height, VkSampleCo
create_desc.arrayLayers = 1;
create_desc.samples = samples;
create_desc.tiling = VK_IMAGE_TILING_OPTIMAL;
create_desc.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
create_desc.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
if ( allowTransient ) {
create_desc.usage |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
}
create_desc.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
create_desc.queueFamilyIndexCount = 0;
create_desc.pQueueFamilyIndices = NULL;
Expand Down Expand Up @@ -3286,7 +3289,7 @@ static void vk_create_attachments( void )
usage, &vk.screenMap.color_image, &vk.screenMap.color_image_view, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, qfalse );

// screenmap depth
create_depth_attachment( vk.screenMapWidth, vk.screenMapHeight, vk.screenMapSamples, &vk.screenMap.depth_image, &vk.screenMap.depth_image_view );
create_depth_attachment( vk.screenMapWidth, vk.screenMapHeight, vk.screenMapSamples, &vk.screenMap.depth_image, &vk.screenMap.depth_image_view, qtrue );

if ( vk.msaaActive ) {
create_color_attachment( glConfig.vidWidth, glConfig.vidHeight, vkSamples, vk.color_format,
Expand All @@ -3303,7 +3306,8 @@ static void vk_create_attachments( void )

//vk_alloc_attachments();

create_depth_attachment( glConfig.vidWidth, glConfig.vidHeight, vkSamples, &vk.depth_image, &vk.depth_image_view );
create_depth_attachment( glConfig.vidWidth, glConfig.vidHeight, vkSamples, &vk.depth_image, &vk.depth_image_view,
(vk.fboActive && r_bloom->integer) ? qfalse : qtrue );

vk_alloc_attachments();

Expand Down

0 comments on commit fddf0a8

Please sign in to comment.