Skip to content

Commit

Permalink
Vulkan: more correct check for dirty depth attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
ec- committed Mar 13, 2020
1 parent 984fe15 commit b5ab067
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 9 additions & 5 deletions code/renderervk/vk.c
Original file line number Diff line number Diff line change
Expand Up @@ -4687,7 +4687,7 @@ void vk_clear_depth( qboolean clear_stencil ) {
if ( !vk.active )
return;

if ( !vk_world.dirty_depth_attachment )
if ( vk_world.dirty_depth_attachment == 0 )
return;

attachment.colorAttachment = 0;
Expand Down Expand Up @@ -4987,7 +4987,7 @@ void vk_draw_geometry( uint32_t pipeline, Vk_Depth_Range depth_range, qboolean i
qvkCmdDraw( vk.cmd->command_buffer, tess.numVertexes, 1, 0, 0 );
}

vk_world.dirty_depth_attachment = qtrue;
vk_world.dirty_depth_attachment |= ( vk.pipelines[ pipeline ].def.state_bits & GLS_DEPTHMASK_TRUE );
}


Expand Down Expand Up @@ -5023,7 +5023,7 @@ static void vk_begin_render_pass( VkRenderPass renderPass, VkFramebuffer frameBu

qvkCmdBeginRenderPass( vk.cmd->command_buffer, &render_pass_begin_info, VK_SUBPASS_CONTENTS_INLINE );

vk_world.dirty_depth_attachment = qfalse;
vk_world.dirty_depth_attachment = 0;
}


Expand Down Expand Up @@ -5101,6 +5101,10 @@ static qboolean vk_find_drawsurfs( void )
}


#ifndef UINT64_MAX
#define UINT64_MAX 0xFFFFFFFFFFFFFFFFULL
#endif

void vk_begin_frame( void )
{
VkCommandBufferBeginInfo begin_info;
Expand All @@ -5112,7 +5116,7 @@ void vk_begin_frame( void )

if ( vk.cmd->waitForFence ) {
if ( !ri.CL_IsMinimized() ) {
res = qvkAcquireNextImageKHR( vk.device, vk.swapchain, 1e10, vk.image_acquired, VK_NULL_HANDLE, &vk.swapchain_image_index );
res = qvkAcquireNextImageKHR( vk.device, vk.swapchain, UINT64_MAX, vk.image_acquired, VK_NULL_HANDLE, &vk.swapchain_image_index );
// when running via RDP: "Application has already acquired the maximum number of images (0x2)"
// probably caused by "device lost" errors
if ( res < 0 ) {
Expand All @@ -5133,7 +5137,7 @@ void vk_begin_frame( void )
vk.cmd_index %= NUM_COMMAND_BUFFERS;

vk.cmd->waitForFence = qfalse;
VK_CHECK( qvkWaitForFences( vk.device, 1, &vk.cmd->rendering_finished_fence, VK_FALSE, 1e12 ) );
VK_CHECK( qvkWaitForFences( vk.device, 1, &vk.cmd->rendering_finished_fence, VK_FALSE, 1e10 ) );
} else {
// current command buffer has been reset due to geometry buffer overflow/update
// so we will reuse it with current swapchain image as well
Expand Down
6 changes: 3 additions & 3 deletions code/renderervk/vk.h
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,9 @@ typedef struct {
//VkDescriptorSet current_descriptor_sets[ MAX_TEXTURE_UNITS ];

// This flag is used to decide whether framebuffer's depth attachment should be cleared
// with vmCmdClearAttachment (dirty_depth_attachment == true), or it have just been
// cleared by render pass instance clear op (dirty_depth_attachment == false).
qboolean dirty_depth_attachment;
// with vmCmdClearAttachment (dirty_depth_attachment != 0), or it have just been
// cleared by render pass instance clear op (dirty_depth_attachment == 0).
int dirty_depth_attachment;

float modelview_transform[16];
} Vk_World;
Expand Down

0 comments on commit b5ab067

Please sign in to comment.