diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index 8cb6cb93..ef0058a8 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -4538,7 +4538,7 @@ static bool d3d12_command_list_update_rendering_info(struct d3d12_command_list * graphics = &list->state->graphics; rendering_info->rtv_mask = graphics->rtv_active_mask; - rendering_info->info.colorAttachmentCount = vkd3d_get_color_attachment_count(graphics->rtv_active_mask); + rendering_info->info.colorAttachmentCount = graphics->rt_count; /* The pipeline has fallback PSO in case we're attempting to render to unbound RTV. */ for (i = 0; i < D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT; i++) @@ -4713,8 +4713,10 @@ static bool d3d12_command_list_update_graphics_pipeline(struct d3d12_command_lis dsv_layout = VK_IMAGE_LAYOUT_UNDEFINED; } - /* If we need to bind or unbind certain render targets or if the DSV layout changed, interrupt rendering */ + /* If we need to bind or unbind certain render targets or if the DSV layout changed, interrupt rendering. + * It's also possible that rtv_active_mask is constant, but rt_count increases (if last RT format is NULL). */ if ((list->state->graphics.rtv_active_mask != list->rendering_info.rtv_mask) || + (list->state->graphics.rt_count != list->rendering_info.info.colorAttachmentCount) || (dsv_layout != list->rendering_info.dsv.imageLayout)) { d3d12_command_list_invalidate_rendering_info(list); diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index 1104d188..7585b09d 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -3935,7 +3935,7 @@ VkPipeline d3d12_pipeline_state_create_pipeline_variant(struct d3d12_pipeline_st rendering_info.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR; rendering_info.pNext = NULL; rendering_info.viewMask = 0; - rendering_info.colorAttachmentCount = vkd3d_get_color_attachment_count(graphics->rtv_active_mask); + rendering_info.colorAttachmentCount = graphics->rt_count; rendering_info.pColorAttachmentFormats = rtv_formats; rendering_info.depthAttachmentFormat = dsv_format ? dsv_format->vk_format : VK_FORMAT_UNDEFINED; rendering_info.stencilAttachmentFormat = dsv_format ? dsv_format->vk_format : VK_FORMAT_UNDEFINED; diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index 28b2729f..1248b785 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -3401,16 +3401,6 @@ static inline const struct vkd3d_format *vkd3d_format_from_d3d12_resource_desc( desc->Flags & D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL); } -static inline unsigned int vkd3d_get_color_attachment_count(unsigned int attachment_mask) -{ - unsigned int count = 0; - - while (attachment_mask >> count) - count++; - - return count; -} - static inline VkImageSubresourceRange vk_subresource_range_from_layers(const VkImageSubresourceLayers *layers) { VkImageSubresourceRange range;