Addresing some problems with TFB and DR

This commit is contained in:
CamilleLaVey
2026-09-30 00:22:27 -04:00
parent 92cbcb8fe5
commit 63fc150635
5 changed files with 21 additions and 17 deletions
@@ -930,16 +930,7 @@ private:
}); });
return; return;
} }
static constexpr VkMemoryBarrier2 COUNTER_RESUME_BARRIER{
.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER_2,
.pNext = nullptr,
.srcStageMask = VK_PIPELINE_STAGE_2_TRANSFORM_FEEDBACK_BIT_EXT,
.srcAccessMask = VK_ACCESS_2_TRANSFORM_FEEDBACK_COUNTER_WRITE_BIT_EXT,
.dstStageMask = VK_PIPELINE_STAGE_2_TRANSFORM_FEEDBACK_BIT_EXT,
.dstAccessMask = VK_ACCESS_2_TRANSFORM_FEEDBACK_COUNTER_READ_BIT_EXT,
};
scheduler.Record([this, total = static_cast<u32>(buffers_count)](vk::CommandBuffer cmdbuf) { scheduler.Record([this, total = static_cast<u32>(buffers_count)](vk::CommandBuffer cmdbuf) {
cmdbuf.PipelineBarrier(COUNTER_RESUME_BARRIER);
cmdbuf.BeginTransformFeedbackEXT(0, total, counter_buffers.data(), offsets.data()); cmdbuf.BeginTransformFeedbackEXT(0, total, counter_buffers.data(), offsets.data());
}); });
} }
@@ -963,6 +954,7 @@ private:
}); });
} else { } else {
LOG_DEBUG(Render_Vulkan, "EndTransformFeedbackEXT called with counters (buffers_count={})", buffers_count); LOG_DEBUG(Render_Vulkan, "EndTransformFeedbackEXT called with counters (buffers_count={})", buffers_count);
scheduler.MarkRenderPassWrites();
scheduler.Record([this, scheduler.Record([this,
total = static_cast<u32>(buffers_count)](vk::CommandBuffer cmdbuf) { total = static_cast<u32>(buffers_count)](vk::CommandBuffer cmdbuf) {
cmdbuf.EndTransformFeedbackEXT(0, total, counter_buffers.data(), offsets.data()); cmdbuf.EndTransformFeedbackEXT(0, total, counter_buffers.data(), offsets.data());
@@ -390,12 +390,14 @@ void RasterizerVulkan::DrawTexture() {
} }
UpdateDynamicStates(dynamic_vertex_input); UpdateDynamicStates(dynamic_vertex_input);
query_cache.NotifySegment(true);
query_cache.CounterEnable(VideoCommon::QueryType::ZPassPixelCount64, maxwell3d->regs.zpass_pixel_count_enable);
const auto& draw_texture_state = maxwell3d->draw_manager.draw_texture_state; const auto& draw_texture_state = maxwell3d->draw_manager.draw_texture_state;
const auto& sampler = texture_cache.GetSampler(draw_texture_state.src_sampler, false); const auto& sampler = texture_cache.GetSampler(draw_texture_state.src_sampler, false);
const auto& texture = texture_cache.GetImageView(draw_texture_state.src_texture); const auto& texture = texture_cache.GetImageView(draw_texture_state.src_texture);
const auto* framebuffer = texture_cache.GetFramebuffer(); const auto* framebuffer = texture_cache.GetFramebuffer();
scheduler.RequestRenderpass(framebuffer, 0, 0);
query_cache.NotifySegment(true);
query_cache.CounterEnable(VideoCommon::QueryType::ZPassPixelCount64,
maxwell3d->regs.zpass_pixel_count_enable);
const bool src_rescaling = texture_cache.IsRescaling() && texture.IsRescaled(); const bool src_rescaling = texture_cache.IsRescaling() && texture.IsRescaled();
const bool dst_rescaling = texture_cache.IsRescaling() && framebuffer->IsRescaled(); const bool dst_rescaling = texture_cache.IsRescaling() && framebuffer->IsRescaled();
@@ -519,14 +521,15 @@ void RasterizerVulkan::Clear(u32 layer_count) {
clear_rect.rect.extent.height >= render_area.height; clear_rect.rect.extent.height >= render_area.height;
const bool can_defer_clear = ENABLE_DEFERRED_CLEAR && (!regs.clear_control.use_scissor || clear_covers_render_area) && const bool can_defer_clear = ENABLE_DEFERRED_CLEAR && (!regs.clear_control.use_scissor || clear_covers_render_area) &&
regs.clear_surface.layer == 0 && regs.clear_surface.layer == 0 &&
layer_count >= framebuffer->Attachments().layers &&
!scheduler.IsRenderPassActive() && !scheduler.IsRenderPassActive() &&
(!use_color || color_full_channels) && ds_deferrable; (!use_color || color_full_channels) && ds_deferrable;
if (!can_defer_clear) { if (!can_defer_clear) {
scheduler.RequestRenderpass(framebuffer); scheduler.RequestRenderpass(framebuffer);
query_cache.NotifySegment(true);
query_cache.CounterEnable(VideoCommon::QueryType::ZPassPixelCount64,
maxwell3d->regs.zpass_pixel_count_enable);
} }
query_cache.NotifySegment(true);
query_cache.CounterEnable(VideoCommon::QueryType::ZPassPixelCount64, maxwell3d->regs.zpass_pixel_count_enable);
UpdateViewportsState(regs); UpdateViewportsState(regs);
const u32 color_attachment = regs.clear_surface.RT; const u32 color_attachment = regs.clear_surface.RT;
@@ -71,7 +71,9 @@ Scheduler::Scheduler(const Device& device_, StateTracker& state_tracker_)
upload_write_barrier.srcAccessMask = VK_ACCESS_2_TRANSFER_WRITE_BIT; upload_write_barrier.srcAccessMask = VK_ACCESS_2_TRANSFER_WRITE_BIT;
if (device.IsExtTransformFeedbackSupported()) { if (device.IsExtTransformFeedbackSupported()) {
renderpass_write_barrier.srcStageMask |= VK_PIPELINE_STAGE_2_TRANSFORM_FEEDBACK_BIT_EXT; renderpass_write_barrier.srcStageMask |= VK_PIPELINE_STAGE_2_TRANSFORM_FEEDBACK_BIT_EXT;
renderpass_write_barrier.srcAccessMask |= VK_ACCESS_2_TRANSFORM_FEEDBACK_WRITE_BIT_EXT; renderpass_write_barrier.srcAccessMask |=
VK_ACCESS_2_TRANSFORM_FEEDBACK_WRITE_BIT_EXT |
VK_ACCESS_2_TRANSFORM_FEEDBACK_COUNTER_WRITE_BIT_EXT;
} }
AcquireNewChunk(); AcquireNewChunk();
@@ -1212,6 +1212,11 @@ void Device::RemoveUnsuitableExtensions() {
RemoveExtensionFeatureIfUnsuitable(extensions.color_write_enable, features.color_write_enable, RemoveExtensionFeatureIfUnsuitable(extensions.color_write_enable, features.color_write_enable,
VK_EXT_COLOR_WRITE_ENABLE_EXTENSION_NAME); VK_EXT_COLOR_WRITE_ENABLE_EXTENSION_NAME);
extensions.conditional_rendering = features.conditional_rendering.conditionalRendering;
RemoveExtensionFeatureIfUnsuitable(extensions.conditional_rendering,
features.conditional_rendering,
VK_EXT_CONDITIONAL_RENDERING_EXTENSION_NAME);
// VK_EXT_custom_border_color // VK_EXT_custom_border_color
if (extensions.custom_border_color) { if (extensions.custom_border_color) {
extensions.custom_border_color = extensions.custom_border_color =
+4 -2
View File
@@ -57,6 +57,7 @@ VK_DEFINE_HANDLE(VmaAllocator)
#define FOR_EACH_VK_FEATURE_EXT(FEATURE) \ #define FOR_EACH_VK_FEATURE_EXT(FEATURE) \
FEATURE(EXT, BorderColorSwizzle, BORDER_COLOR_SWIZZLE, border_color_swizzle) \ FEATURE(EXT, BorderColorSwizzle, BORDER_COLOR_SWIZZLE, border_color_swizzle) \
FEATURE(EXT, ColorWriteEnable, COLOR_WRITE_ENABLE, color_write_enable) \ FEATURE(EXT, ColorWriteEnable, COLOR_WRITE_ENABLE, color_write_enable) \
FEATURE(EXT, ConditionalRendering, CONDITIONAL_RENDERING, conditional_rendering) \
FEATURE(EXT, CustomBorderColor, CUSTOM_BORDER_COLOR, custom_border_color) \ FEATURE(EXT, CustomBorderColor, CUSTOM_BORDER_COLOR, custom_border_color) \
FEATURE(EXT, DepthBiasControl, DEPTH_BIAS_CONTROL, depth_bias_control) \ FEATURE(EXT, DepthBiasControl, DEPTH_BIAS_CONTROL, depth_bias_control) \
FEATURE(EXT, DepthClipControl, DEPTH_CLIP_CONTROL, depth_clip_control) \ FEATURE(EXT, DepthClipControl, DEPTH_CLIP_CONTROL, depth_clip_control) \
@@ -87,7 +88,6 @@ VK_DEFINE_HANDLE(VmaAllocator)
// Define miscellaneous extensions which may be used by the implementation here. // Define miscellaneous extensions which may be used by the implementation here.
#define FOR_EACH_VK_EXTENSION(EXTENSION) \ #define FOR_EACH_VK_EXTENSION(EXTENSION) \
EXTENSION(EXT, ASTC_DECODE_MODE, astc_decode_mode) \ EXTENSION(EXT, ASTC_DECODE_MODE, astc_decode_mode) \
EXTENSION(EXT, CONDITIONAL_RENDERING, conditional_rendering) \
EXTENSION(EXT, CONSERVATIVE_RASTERIZATION, conservative_rasterization) \ EXTENSION(EXT, CONSERVATIVE_RASTERIZATION, conservative_rasterization) \
EXTENSION(EXT, DEPTH_RANGE_UNRESTRICTED, depth_range_unrestricted) \ EXTENSION(EXT, DEPTH_RANGE_UNRESTRICTED, depth_range_unrestricted) \
EXTENSION(EXT, MEMORY_BUDGET, memory_budget) \ EXTENSION(EXT, MEMORY_BUDGET, memory_budget) \
@@ -903,7 +903,9 @@ FN_MAX_LIMIT_LIST
access |= VK_ACCESS_2_CONDITIONAL_RENDERING_READ_BIT_EXT; access |= VK_ACCESS_2_CONDITIONAL_RENDERING_READ_BIT_EXT;
} }
if (IsExtTransformFeedbackSupported()) { if (IsExtTransformFeedbackSupported()) {
access |= VK_ACCESS_2_TRANSFORM_FEEDBACK_WRITE_BIT_EXT; access |= VK_ACCESS_2_TRANSFORM_FEEDBACK_WRITE_BIT_EXT |
VK_ACCESS_2_TRANSFORM_FEEDBACK_COUNTER_READ_BIT_EXT |
VK_ACCESS_2_TRANSFORM_FEEDBACK_COUNTER_WRITE_BIT_EXT;
} }
return access; return access;
} }