diff --git a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp index c6aa28fa23..79b5dc0d01 100644 --- a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp +++ b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp @@ -62,6 +62,7 @@ void FixedPipelineState::Refresh(Tegra::Engines::Maxwell3D& maxwell3d, DynamicFe extended_dynamic_state_2_logic_op.Assign(features.has_extended_dynamic_state_2_logic_op ? 1 : 0); extended_dynamic_state_3_blend.Assign(features.has_extended_dynamic_state_3_blend ? 1 : 0); extended_dynamic_state_3_enables.Assign(features.has_extended_dynamic_state_3_enables ? 1 : 0); + dynamic_state3_depth_clamp_enable.Assign(features.has_dynamic_state3_depth_clamp_enable ? 1 : 0); dynamic_vertex_input.Assign(features.has_dynamic_vertex_input ? 1 : 0); xfb_enabled.Assign(regs.transform_feedback_enabled != 0); ndc_minus_one_to_one.Assign(regs.depth_mode == Maxwell::DepthMode::MinusOneToOne ? 1 : 0); diff --git a/src/video_core/renderer_vulkan/fixed_pipeline_state.h b/src/video_core/renderer_vulkan/fixed_pipeline_state.h index 44157d686d..31b6cd32a4 100644 --- a/src/video_core/renderer_vulkan/fixed_pipeline_state.h +++ b/src/video_core/renderer_vulkan/fixed_pipeline_state.h @@ -208,6 +208,7 @@ struct FixedPipelineState { BitField<12, 2, u32> tessellation_spacing; BitField<14, 1, u32> tessellation_clockwise; BitField<15, 5, u32> patch_control_points_minus_one; + BitField<20, 1, u32> dynamic_state3_depth_clamp_enable; BitField<24, 4, Maxwell::PrimitiveTopology> topology; BitField<28, 4, Tegra::Texture::MsaaMode> msaa_mode; diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index 3b5338a058..5ce3bd3355 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp @@ -907,7 +907,7 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) { // EDS3 - Enables (composite: per-feature) if (key.state.extended_dynamic_state_3_enables) { - if (device.SupportsDynamicState3DepthClampEnable()) { + if (key.state.dynamic_state3_depth_clamp_enable != 0) { dynamic_states.push_back(VK_DYNAMIC_STATE_DEPTH_CLAMP_ENABLE_EXT); } if (device.SupportsDynamicState3LogicOpEnable()) { diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index 798499141e..4ba97547d0 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp @@ -492,7 +492,9 @@ PipelineCache::PipelineCache(Tegra::MaxwellDeviceMemoryManager& device_memory_, device.IsExtExtendedDynamicState3BlendingSupported(); dynamic_features.has_extended_dynamic_state_3_enables = device.IsExtExtendedDynamicState3EnablesSupported(); - dynamic_features.has_dynamic_state3_depth_clamp_enable = false; + dynamic_features.has_dynamic_state3_depth_clamp_enable = + dynamic_features.has_extended_dynamic_state_3_enables && + device.SupportsDynamicState3DepthClampEnable(); dynamic_features.has_dynamic_state3_logic_op_enable = device.SupportsDynamicState3LogicOpEnable(); dynamic_features.has_dynamic_state3_line_stipple_enable = diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.h b/src/video_core/renderer_vulkan/vk_pipeline_cache.h index 490f9da81a..11af34f072 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.h +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.h @@ -113,6 +113,10 @@ public: [[nodiscard]] ComputePipeline* CurrentComputePipeline(); + [[nodiscard]] bool SupportsDynamicState3DepthClampEnable() const { + return dynamic_features.has_dynamic_state3_depth_clamp_enable; + } + void LoadDiskResources(u64 title_id, std::stop_token stop_loading, const VideoCore::DiskResourceLoadCallback& callback); diff --git a/src/video_core/renderer_vulkan/vk_query_cache.cpp b/src/video_core/renderer_vulkan/vk_query_cache.cpp index 2f9382c6ae..06d405c2f5 100644 --- a/src/video_core/renderer_vulkan/vk_query_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_query_cache.cpp @@ -1271,7 +1271,7 @@ struct QueryCacheRuntimeImpl { , tfb_streamer(size_t(QueryType::StreamingByteCount), runtime, device, scheduler, memory_allocator, staging_pool) , primitives_succeeded_streamer(size_t(QueryType::StreamingPrimitivesSucceeded), runtime, tfb_streamer, device_memory_) , primitives_needed_minus_succeeded_streamer(size_t(QueryType::StreamingPrimitivesNeededMinusSucceeded), runtime, 0u) - , hcr_setup{}, hcr_is_set{}, is_hcr_running{}, hcr_bc_resolve_cache{}, maxwell3d{} { + , hcr_setup{}, hcr_is_set{}, is_hcr_running{}, maxwell3d{} { hcr_setup.sType = VK_STRUCTURE_TYPE_CONDITIONAL_RENDERING_BEGIN_INFO_EXT; hcr_setup.pNext = nullptr; @@ -1326,15 +1326,6 @@ struct QueryCacheRuntimeImpl { bool hcr_is_set; bool is_hcr_running; - struct HCRBCResolveCache { - DAddr address{}; - u64 record_serial{}; - bool is_equal{}; - bool compare_to_zero{}; - bool valid{}; - }; - HCRBCResolveCache hcr_bc_resolve_cache; - // maxwell3d Maxwell3D* maxwell3d; }; @@ -1360,7 +1351,6 @@ void QueryCacheRuntime::EndHostConditionalRendering() { PauseHostConditionalRendering(); impl->hcr_is_set = false; impl->is_hcr_running = false; - impl->hcr_bc_resolve_cache.valid = false; impl->hcr_buffer = VkBuffer{}; impl->hcr_offset = 0; } @@ -1390,7 +1380,6 @@ void QueryCacheRuntime::ResumeHostConditionalRendering() { void QueryCacheRuntime::HostConditionalRenderingCompareValueImpl(VideoCommon::LookupData object, bool is_equal) { - impl->hcr_bc_resolve_cache.valid = false; { std::scoped_lock lk(impl->buffer_cache.mutex); static constexpr auto sync_info = VideoCommon::ObtainBufferSynchronize::FullSynchronize; @@ -1422,14 +1411,6 @@ void QueryCacheRuntime::HostConditionalRenderingCompareValueImpl(VideoCommon::Lo void QueryCacheRuntime::HostConditionalRenderingCompareBCImpl(DAddr address, bool is_equal, bool compare_to_zero) { - const u64 current_record_serial = impl->scheduler.CurrentRecordSerial(); - auto& cache = impl->hcr_bc_resolve_cache; - if (cache.valid && cache.address == address && cache.is_equal == is_equal && - cache.compare_to_zero == compare_to_zero && - cache.record_serial == current_record_serial) { - return; - } - VkBuffer to_resolve; u32 to_resolve_offset; const u32 resolve_size = compare_to_zero ? 8 : 24; @@ -1453,66 +1434,16 @@ void QueryCacheRuntime::HostConditionalRenderingCompareBCImpl(DAddr address, boo impl->hcr_setup.flags = is_equal ? 0 : VK_CONDITIONAL_RENDERING_INVERTED_BIT_EXT; impl->hcr_is_set = true; impl->is_hcr_running = false; - - cache.address = address; - cache.record_serial = impl->scheduler.CurrentRecordSerial(); - cache.is_equal = is_equal; - cache.compare_to_zero = compare_to_zero; - cache.valid = true; - if (was_running) { ResumeHostConditionalRendering(); } } bool QueryCacheRuntime::HostConditionalRenderingCompareValue(VideoCommon::LookupData object_1, - bool qc_dirty) { + [[maybe_unused]] bool qc_dirty) { if (!impl->device.IsExtConditionalRendering()) { return false; } - if (object_1.address == 0) { - EndHostConditionalRendering(); - return false; - } - - const bool is_in_qc = object_1.found_query != nullptr; - bool is_in_bc = false; - if (!is_in_qc) { - std::scoped_lock lk(impl->buffer_cache.mutex); - is_in_bc = impl->buffer_cache.IsRegionGpuModified(object_1.address, 8); - } - const bool is_in_ac = is_in_qc || is_in_bc; - - if (!is_in_ac) { - EndHostConditionalRendering(); - return false; - } - - if (!qc_dirty && !is_in_bc) { - EndHostConditionalRendering(); - return false; - } - - const auto driver_id = impl->device.GetDriverID(); - const bool is_gpu_high = Settings::IsGPULevelHigh(); - - if ((!is_gpu_high && driver_id == VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS) || - driver_id == VK_DRIVER_ID_ARM_PROPRIETARY || driver_id == VK_DRIVER_ID_MESA_TURNIP) { - EndHostConditionalRendering(); - return true; - } - - if (!is_gpu_high) { - EndHostConditionalRendering(); - return true; - } - - if (!is_in_bc) { - // Avoid comparing stale data: query cache can be newer than guest memory. - EndHostConditionalRendering(); - return true; - } - HostConditionalRenderingCompareBCImpl(object_1.address, true, true); return true; } @@ -1540,18 +1471,14 @@ bool QueryCacheRuntime::HostConditionalRenderingCompareValues(VideoCommon::Looku std::array is_in_qc{}; std::array is_in_ac{}; std::array is_null{}; - for (size_t i = 0; i < 2; i++) { - is_in_qc[i] = objects[i]->found_query != nullptr; - } - if (!is_in_qc[0] || !is_in_qc[1]) { + { std::scoped_lock lk(impl->buffer_cache.mutex); for (size_t i = 0; i < 2; i++) { + is_in_qc[i] = objects[i]->found_query != nullptr; is_in_bc[i] = !is_in_qc[i] && check_in_bc(objects[i]->address); + is_in_ac[i] = is_in_qc[i] || is_in_bc[i]; } } - for (size_t i = 0; i < 2; i++) { - is_in_ac[i] = is_in_qc[i] || is_in_bc[i]; - } if (!is_in_ac[0] && !is_in_ac[1]) { EndHostConditionalRendering(); diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 35b7aed552..0fc7c10d5f 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -1578,7 +1578,7 @@ void RasterizerVulkan::UpdateDepthClampEnable(Tegra::Engines::Maxwell3D::Regs& r if (!state_tracker.TouchDepthClampEnable()) { return; } - if (!device.SupportsDynamicState3DepthClampEnable()) { + if (!pipeline_cache.SupportsDynamicState3DepthClampEnable()) { return; } bool is_enabled = !(regs.viewport_clip_control.geometry_clip ==