summaryrefslogtreecommitdiffstats
path: root/src/video_core
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/dirty_flags.h3
-rw-r--r--src/video_core/query_cache.h8
-rw-r--r--src/video_core/rasterizer_accelerated.h2
-rw-r--r--src/video_core/renderer_opengl/gl_device.cpp1
-rw-r--r--src/video_core/renderer_vulkan/vk_master_semaphore.h17
-rw-r--r--src/video_core/renderer_vulkan/vk_query_cache.cpp3
-rw-r--r--src/video_core/renderer_vulkan/vk_rasterizer.cpp16
-rw-r--r--src/video_core/renderer_vulkan/vk_state_tracker.cpp1
-rw-r--r--src/video_core/renderer_vulkan/vk_state_tracker.h3
-rw-r--r--src/video_core/texture_cache/texture_cache.h3
-rw-r--r--src/video_core/vulkan_common/vulkan_device.cpp4
-rw-r--r--src/video_core/vulkan_common/vulkan_device.h5
12 files changed, 53 insertions, 13 deletions
diff --git a/src/video_core/dirty_flags.h b/src/video_core/dirty_flags.h
index 504465d3f..f0d545f90 100644
--- a/src/video_core/dirty_flags.h
+++ b/src/video_core/dirty_flags.h
@@ -38,6 +38,9 @@ enum : u8 {
Shaders,
+ // Special entries
+ DepthBiasGlobal,
+
LastCommonEntry,
};
diff --git a/src/video_core/query_cache.h b/src/video_core/query_cache.h
index 73231061a..392f82eb7 100644
--- a/src/video_core/query_cache.h
+++ b/src/video_core/query_cache.h
@@ -258,9 +258,9 @@ private:
void AsyncFlushQuery(VAddr addr) {
if (!uncommitted_flushes) {
- uncommitted_flushes = std::make_shared<std::unordered_set<VAddr>>();
+ uncommitted_flushes = std::make_shared<std::vector<VAddr>>();
}
- uncommitted_flushes->insert(addr);
+ uncommitted_flushes->push_back(addr);
}
static constexpr std::uintptr_t PAGE_SIZE = 4096;
@@ -276,8 +276,8 @@ private:
std::array<CounterStream, VideoCore::NumQueryTypes> streams;
- std::shared_ptr<std::unordered_set<VAddr>> uncommitted_flushes{};
- std::list<std::shared_ptr<std::unordered_set<VAddr>>> committed_flushes;
+ std::shared_ptr<std::vector<VAddr>> uncommitted_flushes{};
+ std::list<std::shared_ptr<std::vector<VAddr>>> committed_flushes;
};
template <class QueryCache, class HostCounter>
diff --git a/src/video_core/rasterizer_accelerated.h b/src/video_core/rasterizer_accelerated.h
index ea879bfdd..249644e50 100644
--- a/src/video_core/rasterizer_accelerated.h
+++ b/src/video_core/rasterizer_accelerated.h
@@ -42,7 +42,7 @@ private:
};
static_assert(sizeof(CacheEntry) == 8, "CacheEntry should be 8 bytes!");
- std::array<CacheEntry, 0x1000000> cached_pages;
+ std::array<CacheEntry, 0x2000000> cached_pages;
Core::Memory::Memory& cpu_memory;
};
diff --git a/src/video_core/renderer_opengl/gl_device.cpp b/src/video_core/renderer_opengl/gl_device.cpp
index 9692b8e94..1e1d1d020 100644
--- a/src/video_core/renderer_opengl/gl_device.cpp
+++ b/src/video_core/renderer_opengl/gl_device.cpp
@@ -10,6 +10,7 @@
#include <limits>
#include <optional>
#include <span>
+#include <stdexcept>
#include <vector>
#include <glad/glad.h>
diff --git a/src/video_core/renderer_vulkan/vk_master_semaphore.h b/src/video_core/renderer_vulkan/vk_master_semaphore.h
index 4f8688118..0886b7da8 100644
--- a/src/video_core/renderer_vulkan/vk_master_semaphore.h
+++ b/src/video_core/renderer_vulkan/vk_master_semaphore.h
@@ -21,12 +21,12 @@ public:
/// Returns the current logical tick.
[[nodiscard]] u64 CurrentTick() const noexcept {
- return current_tick.load(std::memory_order_relaxed);
+ return current_tick.load(std::memory_order_acquire);
}
/// Returns the last known GPU tick.
[[nodiscard]] u64 KnownGpuTick() const noexcept {
- return gpu_tick.load(std::memory_order_relaxed);
+ return gpu_tick.load(std::memory_order_acquire);
}
/// Returns the timeline semaphore handle.
@@ -41,12 +41,21 @@ public:
/// Advance to the logical tick and return the old one
[[nodiscard]] u64 NextTick() noexcept {
- return current_tick.fetch_add(1, std::memory_order::relaxed);
+ return current_tick.fetch_add(1, std::memory_order_release);
}
/// Refresh the known GPU tick
void Refresh() {
- gpu_tick.store(semaphore.GetCounter(), std::memory_order_relaxed);
+ u64 this_tick{};
+ u64 counter{};
+ do {
+ this_tick = gpu_tick.load(std::memory_order_acquire);
+ counter = semaphore.GetCounter();
+ if (counter < this_tick) {
+ return;
+ }
+ } while (!gpu_tick.compare_exchange_weak(this_tick, counter, std::memory_order_release,
+ std::memory_order_relaxed));
}
/// Waits for a tick to be hit on the GPU
diff --git a/src/video_core/renderer_vulkan/vk_query_cache.cpp b/src/video_core/renderer_vulkan/vk_query_cache.cpp
index c9cb32d71..259cba156 100644
--- a/src/video_core/renderer_vulkan/vk_query_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_query_cache.cpp
@@ -117,7 +117,8 @@ u64 HostCounter::BlockingQuery() const {
cache.GetScheduler().Wait(tick);
u64 data;
const VkResult query_result = cache.GetDevice().GetLogical().GetQueryResults(
- query.first, query.second, 1, sizeof(data), &data, sizeof(data), VK_QUERY_RESULT_64_BIT);
+ query.first, query.second, 1, sizeof(data), &data, sizeof(data),
+ VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT);
switch (query_result) {
case VK_SUCCESS:
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
index 3bcd6d6cc..30b47a7a0 100644
--- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp
+++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
@@ -627,9 +627,21 @@ void RasterizerVulkan::UpdateDepthBias(Tegra::Engines::Maxwell3D::Regs& regs) {
if (!state_tracker.TouchDepthBias()) {
return;
}
- scheduler.Record([constant = regs.polygon_offset_units, clamp = regs.polygon_offset_clamp,
+ float units = regs.polygon_offset_units / 2.0f;
+ const bool is_d24 = regs.zeta.format == Tegra::DepthFormat::S8_UINT_Z24_UNORM ||
+ regs.zeta.format == Tegra::DepthFormat::D24X8_UNORM ||
+ regs.zeta.format == Tegra::DepthFormat::D24S8_UNORM ||
+ regs.zeta.format == Tegra::DepthFormat::D24C8_UNORM;
+ if (is_d24 && !device.SupportsD24DepthBuffer()) {
+ // the base formulas can be obtained from here:
+ // https://docs.microsoft.com/en-us/windows/win32/direct3d11/d3d10-graphics-programming-guide-output-merger-stage-depth-bias
+ const double rescale_factor =
+ static_cast<double>(1ULL << (32 - 24)) / (static_cast<double>(0x1.ep+127));
+ units = static_cast<float>(static_cast<double>(units) * rescale_factor);
+ }
+ scheduler.Record([constant = units, clamp = regs.polygon_offset_clamp,
factor = regs.polygon_offset_factor](vk::CommandBuffer cmdbuf) {
- cmdbuf.SetDepthBias(constant, clamp, factor / 2.0f);
+ cmdbuf.SetDepthBias(constant, clamp, factor);
});
}
diff --git a/src/video_core/renderer_vulkan/vk_state_tracker.cpp b/src/video_core/renderer_vulkan/vk_state_tracker.cpp
index e3b7dd61c..c00913f55 100644
--- a/src/video_core/renderer_vulkan/vk_state_tracker.cpp
+++ b/src/video_core/renderer_vulkan/vk_state_tracker.cpp
@@ -54,6 +54,7 @@ void SetupDirtyViewports(Tables& tables) {
FillBlock(tables[0], OFF(viewport_transform), NUM(viewport_transform), Viewports);
FillBlock(tables[0], OFF(viewports), NUM(viewports), Viewports);
tables[0][OFF(viewport_transform_enabled)] = Viewports;
+ tables[1][OFF(screen_y_control)] = Viewports;
}
void SetupDirtyScissors(Tables& tables) {
diff --git a/src/video_core/renderer_vulkan/vk_state_tracker.h b/src/video_core/renderer_vulkan/vk_state_tracker.h
index d90935f52..2f2d6b31f 100644
--- a/src/video_core/renderer_vulkan/vk_state_tracker.h
+++ b/src/video_core/renderer_vulkan/vk_state_tracker.h
@@ -79,7 +79,8 @@ public:
}
bool TouchDepthBias() {
- return Exchange(Dirty::DepthBias, false);
+ return Exchange(Dirty::DepthBias, false) ||
+ Exchange(VideoCommon::Dirty::DepthBiasGlobal, false);
}
bool TouchBlendConstants() {
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index 329df2e49..f70c1f764 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -221,6 +221,7 @@ void TextureCache<P>::UpdateRenderTargets(bool is_clear) {
BindRenderTarget(&render_targets.depth_buffer_id, FindDepthBuffer(is_clear));
}
const ImageViewId depth_buffer_id = render_targets.depth_buffer_id;
+
PrepareImageView(depth_buffer_id, true, is_clear && IsFullClear(depth_buffer_id));
for (size_t index = 0; index < NUM_RT; ++index) {
@@ -230,6 +231,8 @@ void TextureCache<P>::UpdateRenderTargets(bool is_clear) {
maxwell3d.regs.render_area.width,
maxwell3d.regs.render_area.height,
};
+
+ flags[Dirty::DepthBiasGlobal] = true;
}
template <class P>
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp
index 6388ed2eb..0f807990c 100644
--- a/src/video_core/vulkan_common/vulkan_device.cpp
+++ b/src/video_core/vulkan_common/vulkan_device.cpp
@@ -623,6 +623,10 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
is_float16_supported = false;
}
+ supports_d24_depth =
+ IsFormatSupported(VK_FORMAT_D24_UNORM_S8_UINT,
+ VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT, FormatType::Optimal);
+
graphics_queue = logical.GetQueue(graphics_family);
present_queue = logical.GetQueue(present_family);
}
diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h
index d9e74f1aa..2d5daf6cd 100644
--- a/src/video_core/vulkan_common/vulkan_device.h
+++ b/src/video_core/vulkan_common/vulkan_device.h
@@ -332,6 +332,10 @@ public:
return sets_per_pool;
}
+ bool SupportsD24DepthBuffer() const {
+ return supports_d24_depth;
+ }
+
private:
/// Checks if the physical device is suitable.
void CheckSuitability(bool requires_swapchain) const;
@@ -425,6 +429,7 @@ private:
bool has_broken_cube_compatibility{}; ///< Has broken cube compatiblity bit
bool has_renderdoc{}; ///< Has RenderDoc attached
bool has_nsight_graphics{}; ///< Has Nsight Graphics attached
+ bool supports_d24_depth{}; ///< Supports D24 depth buffers.
// Telemetry parameters
std::string vendor_name; ///< Device's driver name.