From d3c182f385deb44ad1bbb984fb401af573388ee8 Mon Sep 17 00:00:00 2001 From: nmzik Date: Mon, 21 Sep 2026 10:03:19 +0400 Subject: [PATCH] Centralize attachment sample validation before acquisition --- src/graphics/host_gpu/renderer/renderDraw.cpp | 23 +++---------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/src/graphics/host_gpu/renderer/renderDraw.cpp b/src/graphics/host_gpu/renderer/renderDraw.cpp index 5429aca9d..437b9ca48 100644 --- a/src/graphics/host_gpu/renderer/renderDraw.cpp +++ b/src/graphics/host_gpu/renderer/renderDraw.cpp @@ -461,7 +461,6 @@ RenderState RenderExecutor::AcquireRenderTargets(CommandBuffer& buffer, RenderCo state.height = std::numeric_limits::max(); state.num_layers = std::numeric_limits::max(); state.num_color_attachments = 0; - uint32_t attachment_samples = 0; for (uint32_t i = 0; i < color_count; i++) { auto& target = colors[i]; EXIT_IF(!target.image_id); @@ -482,12 +481,6 @@ RenderState RenderExecutor::AcquireRenderTargets(CommandBuffer& buffer, RenderCo target.desc.view_info.base_level, target.desc.view_info.base_layer, target.desc.view_info.layer_count); EXIT_IF(image.backing.samples != target.desc.info.samples || image_view == nullptr); - if (attachment_samples == 0) { - attachment_samples = target.desc.info.samples; - } else if (attachment_samples != target.desc.info.samples) { - EXIT("mixed color attachment sample counts are unsupported: %u and %u\n", - attachment_samples, target.desc.info.samples); - } const auto& view = target.desc.view_info; const auto layout = image.binding.is_bound ? vk::ImageLayout::eGeneral : vk::ImageLayout::eColorAttachmentOptimal; @@ -536,12 +529,6 @@ RenderState RenderExecutor::AcquireRenderTargets(CommandBuffer& buffer, RenderCo image.info.data.address, depth.desc.view_info.base_layer, depth.desc.view_info.layer_count); EXIT_IF(image_view == nullptr || image.backing.samples != depth.desc.info.samples); - if (attachment_samples == 0) { - attachment_samples = depth.desc.info.samples; - } else if (attachment_samples != depth.desc.info.samples) { - EXIT("mixed color/depth sample counts are unsupported: %u and %u\n", attachment_samples, - depth.desc.info.samples); - } const bool feedback = depth.depth_write_enable && pixel && std::ranges::any_of(pixel->images, [&](const TextureBinding& binding) { if (binding.image_id != depth.image_id || @@ -592,9 +579,6 @@ RenderState RenderExecutor::AcquireRenderTargets(CommandBuffer& buffer, RenderCo const auto& limits = buffer.GetGraphics().GetPhysicalDeviceProperties().limits; state.width = limits.maxFramebufferWidth; state.height = limits.maxFramebufferHeight; - } else if (attachment_samples == 0 || - vulkan_sample_count(attachment_samples) == vk::SampleCountFlagBits {}) { - EXIT("render state has no valid attachments\n"); } if (state.num_layers == std::numeric_limits::max()) { state.num_layers = 1; @@ -1109,10 +1093,6 @@ void RenderExecutor::ExecutePreparedDraw(uint64_t submit_id, CommandBuffer& buff vertex_bindings = AcquireVertexBuffers(buffer, state.vertex_info[0]); index_binding = PrepareIndexBuffer(buffer, index_source); } - const auto rendering = - AcquireRenderTargets(buffer, state.color_info, state.color_count, state.depth_info, - bindings.pixel); - if (draw.IsIndexed()) { LogDrawPhase(draw.Name(), "CreatePipeline"); } @@ -1120,6 +1100,9 @@ void RenderExecutor::ExecutePreparedDraw(uint64_t submit_id, CommandBuffer& buff std::span {state.color_info, state.color_count}, state.depth_info, vertex_stages, buffer, state.ps_active ? &state.ps_input_info : nullptr, topology, primitive_restart_enable, state.programs); + const auto rendering = + AcquireRenderTargets(buffer, state.color_info, state.color_count, state.depth_info, + bindings.pixel); // Resource preparation above may synchronously finish and restart the scheduler. From this // point onward, every operation targets the current command buffer and cannot touch guest