VERY experimental Nintendo Switch 2 emulator
C++
Merge pull request #3784 from ReinUsesLisp/shader-memory-util
bunnei510842d82769
diff --cc src/video_core/renderer_vulkan/vk_pipeline_cache.hindex 84d26b8227,2cce53162e..ebddafb738--- a/src/video_core/renderer_vulkan/vk_pipeline_cache.h+++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.h@@@ -46,42 -48,44 +47,40 @@@ class CachedShaderusing Shader = std::shared_ptr<CachedShader>;using Maxwell = Tegra::Engines::Maxwell3D::Regs;- using ProgramCode = std::vector<u64>;-struct GraphicsPipelineCacheKey {FixedPipelineState fixed_state;- std::array<GPUVAddr, Maxwell::MaxShaderProgram> shaders;RenderPassParams renderpass_params;+ std::array<GPUVAddr, Maxwell::MaxShaderProgram> shaders;+ u64 padding; // This is necessary for unique object representations- std::size_t Hash() const noexcept {- std::size_t hash = fixed_state.Hash();- for (const auto& shader : shaders) {- boost::hash_combine(hash, shader);- }- boost::hash_combine(hash, renderpass_params.Hash());- return hash;- }+ std::size_t Hash() const noexcept;++ bool operator==(const GraphicsPipelineCacheKey& rhs) const noexcept;- bool operator==(const GraphicsPipelineCacheKey& rhs) const noexcept {- return std::tie(fixed_state, shaders, renderpass_params) ==- std::tie(rhs.fixed_state, rhs.shaders, rhs.renderpass_params);+ bool operator!=(const GraphicsPipelineCacheKey& rhs) const noexcept {+ return !operator==(rhs);}};+static_assert(std::has_unique_object_representations_v<GraphicsPipelineCacheKey>);+static_assert(std::is_trivially_copyable_v<GraphicsPipelineCacheKey>);+static_assert(std::is_trivially_constructible_v<GraphicsPipelineCacheKey>);struct ComputePipelineCacheKey {- GPUVAddr shader{};- u32 shared_memory_size{};- std::array<u32, 3> workgroup_size{};-- std::size_t Hash() const noexcept {- return static_cast<std::size_t>(shader) ^- ((static_cast<std::size_t>(shared_memory_size) >> 7) << 40) ^- static_cast<std::size_t>(workgroup_size[0]) ^- (static_cast<std::size_t>(workgroup_size[1]) << 16) ^- (static_cast<std::size_t>(workgroup_size[2]) << 24);- }+ GPUVAddr shader;+ u32 shared_memory_size;+ std::array<u32, 3> workgroup_size;++ std::size_t Hash() const noexcept;++ bool operator==(const ComputePipelineCacheKey& rhs) const noexcept;- bool operator==(const ComputePipelineCacheKey& rhs) const noexcept {- return std::tie(shader, shared_memory_size, workgroup_size) ==- std::tie(rhs.shader, rhs.shared_memory_size, rhs.workgroup_size);+ bool operator!=(const ComputePipelineCacheKey& rhs) const noexcept {+ return !operator==(rhs);}};+static_assert(std::has_unique_object_representations_v<ComputePipelineCacheKey>);+static_assert(std::is_trivially_copyable_v<ComputePipelineCacheKey>);+static_assert(std::is_trivially_constructible_v<ComputePipelineCacheKey>);} // namespace Vulkan