summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_shader_disk_cache.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/renderer_opengl/gl_shader_disk_cache.h')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_disk_cache.h53
1 files changed, 40 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 ecd72ba58..7c9f0cc75 100644
--- a/src/video_core/renderer_opengl/gl_shader_disk_cache.h
+++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.h
@@ -30,15 +30,17 @@ class IOFile;
namespace OpenGL {
-using ProgramCode = std::vector<u64>;
-using Maxwell = Tegra::Engines::Maxwell3D::Regs;
-
struct ShaderDiskCacheUsage;
struct ShaderDiskCacheDump;
using ShaderDumpsMap = std::unordered_map<ShaderDiskCacheUsage, ShaderDiskCacheDump>;
-/// Allocated bindings used by an OpenGL shader program
+using ProgramCode = std::vector<u64>;
+using Maxwell = Tegra::Engines::Maxwell3D::Regs;
+
+using TextureBufferUsage = std::bitset<64>;
+
+/// Allocated bindings used by an OpenGL shader program.
struct BaseBindings {
u32 cbuf{};
u32 gmem{};
@@ -53,15 +55,29 @@ struct BaseBindings {
}
};
-/// Describes how a shader is used
+/// Describes the different variants a single program can be compiled.
+struct ProgramVariant {
+ BaseBindings base_bindings;
+ GLenum primitive_mode{};
+ TextureBufferUsage texture_buffer_usage{};
+
+ bool operator==(const ProgramVariant& rhs) const {
+ return std::tie(base_bindings, primitive_mode, texture_buffer_usage) ==
+ std::tie(rhs.base_bindings, rhs.primitive_mode, rhs.texture_buffer_usage);
+ }
+
+ bool operator!=(const ProgramVariant& rhs) const {
+ return !operator==(rhs);
+ }
+};
+
+/// Describes how a shader is used.
struct ShaderDiskCacheUsage {
u64 unique_identifier{};
- BaseBindings bindings;
- GLenum primitive{};
+ ProgramVariant variant;
bool operator==(const ShaderDiskCacheUsage& rhs) const {
- return std::tie(unique_identifier, bindings, primitive) ==
- std::tie(rhs.unique_identifier, rhs.bindings, rhs.primitive);
+ return std::tie(unique_identifier, variant) == std::tie(rhs.unique_identifier, rhs.variant);
}
bool operator!=(const ShaderDiskCacheUsage& rhs) const {
@@ -81,10 +97,19 @@ struct hash<OpenGL::BaseBindings> {
};
template <>
+struct hash<OpenGL::ProgramVariant> {
+ std::size_t operator()(const OpenGL::ProgramVariant& variant) const {
+ return std::hash<OpenGL::BaseBindings>()(variant.base_bindings) ^
+ std::hash<OpenGL::TextureBufferUsage>()(variant.texture_buffer_usage) ^
+ (static_cast<std::size_t>(variant.primitive_mode) << 6);
+ }
+};
+
+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::BaseBindings>()(usage.bindings) ^ usage.primitive << 16;
+ std::hash<OpenGL::ProgramVariant>()(usage.variant);
}
};
@@ -288,13 +313,15 @@ private:
// Core system
Core::System& system;
- // Stored transferable shaders
- std::map<u64, std::unordered_set<ShaderDiskCacheUsage>> transferable;
- // Stores whole precompiled cache which will be read from/saved to the precompiled cache file
+ // Stores whole precompiled cache which will be read from or saved to the precompiled chache
+ // file
FileSys::VectorVfsFile precompiled_cache_virtual_file;
// Stores the current offset of the precompiled cache file for IO purposes
std::size_t precompiled_cache_virtual_file_offset = 0;
+ // Stored transferable shaders
+ std::unordered_map<u64, std::unordered_set<ShaderDiskCacheUsage>> transferable;
+
// The cache has been loaded at boot
bool tried_to_load{};
};