diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common/nvidia_flags.h | 2 | ||||
-rw-r--r-- | src/core/hle/kernel/k_thread.h | 2 | ||||
-rw-r--r-- | src/video_core/query_cache.h | 9 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/vk_master_semaphore.h | 4 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/vk_texture_cache.cpp | 11 | ||||
-rw-r--r-- | src/video_core/texture_cache/util.cpp | 21 | ||||
-rw-r--r-- | src/video_core/texture_cache/util.h | 5 |
7 files changed, 30 insertions, 24 deletions
diff --git a/src/common/nvidia_flags.h b/src/common/nvidia_flags.h index 75a0233ac..8930efcec 100644 --- a/src/common/nvidia_flags.h +++ b/src/common/nvidia_flags.h @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#pragma once + namespace Common { /// Configure platform specific flags for Nvidia's driver diff --git a/src/core/hle/kernel/k_thread.h b/src/core/hle/kernel/k_thread.h index 1c86fdd20..b442dfe57 100644 --- a/src/core/hle/kernel/k_thread.h +++ b/src/core/hle/kernel/k_thread.h @@ -402,7 +402,7 @@ public: return wait_cancelled; } - [[nodiscard]] void ClearWaitCancelled() { + void ClearWaitCancelled() { wait_cancelled = false; } diff --git a/src/video_core/query_cache.h b/src/video_core/query_cache.h index 203f2af05..639d7ce7e 100644 --- a/src/video_core/query_cache.h +++ b/src/video_core/query_cache.h @@ -208,9 +208,9 @@ public: private: /// Flushes a memory range to guest memory and removes it from the cache. void FlushAndRemoveRegion(VAddr addr, std::size_t size) { - const u64 addr_begin = static_cast<u64>(addr); - const u64 addr_end = addr_begin + static_cast<u64>(size); - const auto in_range = [addr_begin, addr_end](CachedQuery& query) { + const u64 addr_begin = addr; + const u64 addr_end = addr_begin + size; + const auto in_range = [addr_begin, addr_end](const CachedQuery& query) { const u64 cache_begin = query.GetCpuAddr(); const u64 cache_end = cache_begin + query.SizeInBytes(); return cache_begin < addr_end && addr_begin < cache_end; @@ -230,8 +230,7 @@ private: rasterizer.UpdatePagesCachedCount(query.GetCpuAddr(), query.SizeInBytes(), -1); query.Flush(); } - contents.erase(std::remove_if(std::begin(contents), std::end(contents), in_range), - std::end(contents)); + std::erase_if(contents, in_range); } } diff --git a/src/video_core/renderer_vulkan/vk_master_semaphore.h b/src/video_core/renderer_vulkan/vk_master_semaphore.h index 2c7ed654d..4b6d64daa 100644 --- a/src/video_core/renderer_vulkan/vk_master_semaphore.h +++ b/src/video_core/renderer_vulkan/vk_master_semaphore.h @@ -35,8 +35,8 @@ public: } /// Returns true when a tick has been hit by the GPU. - [[nodiscard]] bool IsFree(u64 tick) { - return gpu_tick.load(std::memory_order_relaxed) >= tick; + [[nodiscard]] bool IsFree(u64 tick) const noexcept { + return KnownGpuTick() >= tick; } /// Advance to the logical tick. diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 18155e449..bc2a53841 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -7,6 +7,8 @@ #include <span> #include <vector> +#include "common/bit_cast.h" + #include "video_core/engines/fermi_2d.h" #include "video_core/renderer_vulkan/blit_image.h" #include "video_core/renderer_vulkan/maxwell_to_vk.h" @@ -1062,14 +1064,13 @@ vk::ImageView ImageView::MakeDepthStencilView(VkImageAspectFlags aspect_mask) { Sampler::Sampler(TextureCacheRuntime& runtime, const Tegra::Texture::TSCEntry& tsc) { const auto& device = runtime.device; const bool arbitrary_borders = runtime.device.IsExtCustomBorderColorSupported(); - const std::array<float, 4> color = tsc.BorderColor(); - // C++20 bit_cast - VkClearColorValue border_color; - std::memcpy(&border_color, &color, sizeof(color)); + const auto color = tsc.BorderColor(); + const VkSamplerCustomBorderColorCreateInfoEXT border_ci{ .sType = VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT, .pNext = nullptr, - .customBorderColor = border_color, + // TODO: Make use of std::bit_cast once libc++ supports it. + .customBorderColor = Common::BitCast<VkClearColorValue>(color), .format = VK_FORMAT_UNDEFINED, }; const void* pnext = nullptr; diff --git a/src/video_core/texture_cache/util.cpp b/src/video_core/texture_cache/util.cpp index c22dd0148..0ab297413 100644 --- a/src/video_core/texture_cache/util.cpp +++ b/src/video_core/texture_cache/util.cpp @@ -268,16 +268,19 @@ template <u32 GOB_EXTENT> return num_tiles << shift; } -[[nodiscard]] constexpr std::array<u32, MAX_MIP_LEVELS> CalculateLevelSizes(const LevelInfo& info, - u32 num_levels) { +[[nodiscard]] constexpr LevelArray CalculateLevelSizes(const LevelInfo& info, u32 num_levels) { ASSERT(num_levels <= MAX_MIP_LEVELS); - std::array<u32, MAX_MIP_LEVELS> sizes{}; + LevelArray sizes{}; for (u32 level = 0; level < num_levels; ++level) { sizes[level] = CalculateLevelSize(info, level); } return sizes; } +[[nodiscard]] u32 CalculateLevelBytes(const LevelArray& sizes, u32 num_levels) { + return std::reduce(sizes.begin(), sizes.begin() + num_levels, 0U); +} + [[nodiscard]] constexpr LevelInfo MakeLevelInfo(PixelFormat format, Extent3D size, Extent3D block, u32 num_samples, u32 tile_width_spacing) { const auto [samples_x, samples_y] = Samples(num_samples); @@ -566,10 +569,10 @@ void SwizzleBlockLinearImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr const u32 num_levels = info.resources.levels; const std::array sizes = CalculateLevelSizes(level_info, num_levels); - size_t guest_offset = std::reduce(sizes.begin(), sizes.begin() + level, 0); + size_t guest_offset = CalculateLevelBytes(sizes, level); const size_t layer_stride = - AlignLayerSize(std::reduce(sizes.begin(), sizes.begin() + num_levels, 0), size, - level_info.block, tile_size.height, info.tile_width_spacing); + AlignLayerSize(CalculateLevelBytes(sizes, num_levels), size, level_info.block, + tile_size.height, info.tile_width_spacing); const size_t subresource_size = sizes[level]; const auto dst_data = std::make_unique<u8[]>(subresource_size); @@ -643,10 +646,10 @@ u32 CalculateLayerSize(const ImageInfo& info) noexcept { info.tile_width_spacing, info.resources.levels); } -std::array<u32, MAX_MIP_LEVELS> CalculateMipLevelOffsets(const ImageInfo& info) noexcept { +LevelArray CalculateMipLevelOffsets(const ImageInfo& info) noexcept { ASSERT(info.resources.levels <= static_cast<s32>(MAX_MIP_LEVELS)); const LevelInfo level_info = MakeLevelInfo(info); - std::array<u32, MAX_MIP_LEVELS> offsets{}; + LevelArray offsets{}; u32 offset = 0; for (s32 level = 0; level < info.resources.levels; ++level) { offsets[level] = offset; @@ -812,7 +815,7 @@ std::vector<BufferImageCopy> UnswizzleImage(Tegra::MemoryManager& gpu_memory, GP const Extent2D tile_size = DefaultBlockSize(info.format); const std::array level_sizes = CalculateLevelSizes(level_info, num_levels); const Extent2D gob = GobSize(bpp_log2, info.block.height, info.tile_width_spacing); - const u32 layer_size = std::reduce(level_sizes.begin(), level_sizes.begin() + num_levels, 0); + const u32 layer_size = CalculateLevelBytes(level_sizes, num_levels); const u32 layer_stride = AlignLayerSize(layer_size, size, level_info.block, tile_size.height, info.tile_width_spacing); size_t guest_offset = 0; diff --git a/src/video_core/texture_cache/util.h b/src/video_core/texture_cache/util.h index 4d0072867..cdc5cbc75 100644 --- a/src/video_core/texture_cache/util.h +++ b/src/video_core/texture_cache/util.h @@ -20,6 +20,8 @@ namespace VideoCommon { using Tegra::Texture::TICEntry; +using LevelArray = std::array<u32, MAX_MIP_LEVELS>; + struct OverlapResult { GPUVAddr gpu_addr; VAddr cpu_addr; @@ -36,8 +38,7 @@ struct OverlapResult { [[nodiscard]] u32 CalculateLayerSize(const ImageInfo& info) noexcept; -[[nodiscard]] std::array<u32, MAX_MIP_LEVELS> CalculateMipLevelOffsets( - const ImageInfo& info) noexcept; +[[nodiscard]] LevelArray CalculateMipLevelOffsets(const ImageInfo& info) noexcept; [[nodiscard]] std::vector<u32> CalculateSliceOffsets(const ImageInfo& info); |