diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-11-13 03:26:56 +0100 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-11-23 01:28:47 +0100 |
commit | 4f5d8e434278cd5999bf21e91f0923d55ec8d52b (patch) | |
tree | 542e261e7169cb9ba8ed129a53e0bbd181868752 /src/video_core/renderer_opengl/gl_shader_disk_cache.h | |
parent | shader/texture: Handle TLDS texture type mismatches (diff) | |
download | yuzu-4f5d8e434278cd5999bf21e91f0923d55ec8d52b.tar yuzu-4f5d8e434278cd5999bf21e91f0923d55ec8d52b.tar.gz yuzu-4f5d8e434278cd5999bf21e91f0923d55ec8d52b.tar.bz2 yuzu-4f5d8e434278cd5999bf21e91f0923d55ec8d52b.tar.lz yuzu-4f5d8e434278cd5999bf21e91f0923d55ec8d52b.tar.xz yuzu-4f5d8e434278cd5999bf21e91f0923d55ec8d52b.tar.zst yuzu-4f5d8e434278cd5999bf21e91f0923d55ec8d52b.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/renderer_opengl/gl_shader_disk_cache.h | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_disk_cache.h b/src/video_core/renderer_opengl/gl_shader_disk_cache.h index 55311dc6d..4c7ca004d 100644 --- a/src/video_core/renderer_opengl/gl_shader_disk_cache.h +++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.h @@ -44,32 +44,49 @@ struct BaseBindings { u32 sampler{}; u32 image{}; - bool operator==(const BaseBindings& rhs) const { + bool operator==(const BaseBindings& rhs) const noexcept { return std::tie(cbuf, gmem, sampler, image) == std::tie(rhs.cbuf, rhs.gmem, rhs.sampler, rhs.image); } - bool operator!=(const BaseBindings& rhs) const { + bool operator!=(const BaseBindings& rhs) const noexcept { return !operator==(rhs); } }; static_assert(std::is_trivially_copyable_v<BaseBindings>); -/// Describes the different variants a single program can be compiled. -struct ProgramVariant { - BaseBindings base_bindings; +/// Describes the different variants a program can be compiled with. +struct ProgramVariant final { + ProgramVariant() = default; + + /// Graphics constructor. + explicit constexpr ProgramVariant(BaseBindings base_bindings, GLenum primitive_mode) noexcept + : base_bindings{base_bindings}, primitive_mode{primitive_mode} {} + + /// Compute constructor. + explicit constexpr ProgramVariant(u32 block_x, u32 block_y, u32 block_z) noexcept + : block_x{block_x}, block_y{static_cast<u16>(block_y)}, block_z{static_cast<u16>(block_z)} { + } + + // Graphics specific parameters. + BaseBindings base_bindings{}; GLenum primitive_mode{}; - bool operator==(const ProgramVariant& rhs) const { - return std::tie(base_bindings, primitive_mode) == - std::tie(rhs.base_bindings, rhs.primitive_mode); + // Compute specific parameters. + u32 block_x{}; + u16 block_y{}; + u16 block_z{}; + + bool operator==(const ProgramVariant& rhs) const noexcept { + return std::tie(base_bindings, primitive_mode, block_x, block_y, block_z) == + std::tie(rhs.base_bindings, rhs.primitive_mode, rhs.block_x, rhs.block_y, + rhs.block_z); } - bool operator!=(const ProgramVariant& rhs) const { + bool operator!=(const ProgramVariant& rhs) const noexcept { return !operator==(rhs); } }; - static_assert(std::is_trivially_copyable_v<ProgramVariant>); /// Describes how a shader is used. @@ -108,8 +125,11 @@ struct hash<OpenGL::BaseBindings> { template <> struct hash<OpenGL::ProgramVariant> { std::size_t operator()(const OpenGL::ProgramVariant& variant) const noexcept { - return std::hash<OpenGL::BaseBindings>()(variant.base_bindings) ^ - (static_cast<std::size_t>(variant.primitive_mode) << 6); + return std::hash<OpenGL::BaseBindings>{}(variant.base_bindings) ^ + (static_cast<std::size_t>(variant.primitive_mode) << 6) ^ + static_cast<std::size_t>(variant.block_x) ^ + (static_cast<std::size_t>(variant.block_y) << 32) ^ + (static_cast<std::size_t>(variant.block_z) << 48); } }; @@ -117,7 +137,7 @@ template <> struct hash<OpenGL::ShaderDiskCacheUsage> { std::size_t operator()(const OpenGL::ShaderDiskCacheUsage& usage) const noexcept { return static_cast<std::size_t>(usage.unique_identifier) ^ - std::hash<OpenGL::ProgramVariant>()(usage.variant); + std::hash<OpenGL::ProgramVariant>{}(usage.variant); } }; |