summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_shader_disk_cache.h
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2019-01-15 06:42:25 +0100
committerReinUsesLisp <reinuseslisp@airmail.cc>2019-02-07 02:23:40 +0100
commit750abcc23d0b9584b716ab93110383209b0971f8 (patch)
treef8299f57d6354c8e2020f3b34e3a50c5c9883fea /src/video_core/renderer_opengl/gl_shader_disk_cache.h
parentgl_shader_disk_cache: Pass return values returning instead of by parameters (diff)
downloadyuzu-750abcc23d0b9584b716ab93110383209b0971f8.tar
yuzu-750abcc23d0b9584b716ab93110383209b0971f8.tar.gz
yuzu-750abcc23d0b9584b716ab93110383209b0971f8.tar.bz2
yuzu-750abcc23d0b9584b716ab93110383209b0971f8.tar.lz
yuzu-750abcc23d0b9584b716ab93110383209b0971f8.tar.xz
yuzu-750abcc23d0b9584b716ab93110383209b0971f8.tar.zst
yuzu-750abcc23d0b9584b716ab93110383209b0971f8.zip
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.h54
1 files changed, 29 insertions, 25 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 c44a776d9..4bffe4307 100644
--- a/src/video_core/renderer_opengl/gl_shader_disk_cache.h
+++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.h
@@ -15,22 +15,20 @@
#include "common/assert.h"
#include "common/common_types.h"
-#include "common/file_util.h"
#include "video_core/engines/maxwell_3d.h"
#include "video_core/renderer_opengl/gl_shader_gen.h"
+namespace FileUtil {
+class IOFile;
+} // namespace FileUtil
+
namespace OpenGL {
using ProgramCode = std::vector<u64>;
using Maxwell = Tegra::Engines::Maxwell3D::Regs;
+/// Allocated bindings used by an OpenGL shader program
struct BaseBindings {
-private:
- auto Tie() const {
- return std::tie(cbuf, gmem, sampler);
- }
-
-public:
u32 cbuf{};
u32 gmem{};
u32 sampler{};
@@ -44,20 +42,24 @@ public:
}
bool operator!=(const BaseBindings& rhs) const {
- return !this->operator==(rhs);
+ return !operator==(rhs);
+ }
+
+ std::tuple<u32, u32, u32> Tie() const {
+ return std::tie(cbuf, gmem, sampler);
}
};
+/// Describes a shader how it's used by the guest GPU
class ShaderDiskCacheRaw {
public:
explicit ShaderDiskCacheRaw(FileUtil::IOFile& file);
explicit ShaderDiskCacheRaw(u64 unique_identifier, Maxwell::ShaderProgram program_type,
u32 program_code_size, u32 program_code_size_b,
- ProgramCode program_code, ProgramCode program_code_b)
- : unique_identifier{unique_identifier}, program_type{program_type},
- program_code_size{program_code_size}, program_code_size_b{program_code_size_b},
- program_code{std::move(program_code)}, program_code_b{std::move(program_code_b)} {}
+ ProgramCode program_code, ProgramCode program_code_b);
+
+ ~ShaderDiskCacheRaw();
void Save(FileUtil::IOFile& file) const;
@@ -108,17 +110,8 @@ private:
ProgramCode program_code_b;
};
+/// Describes how a shader is used
struct ShaderDiskCacheUsage {
-private:
- auto Tie() const {
- return std::tie(unique_identifier, bindings, primitive);
- }
-
-public:
- u64 unique_identifier{};
- BaseBindings bindings;
- GLenum primitive{};
-
bool operator<(const ShaderDiskCacheUsage& rhs) const {
return Tie() < rhs.Tie();
}
@@ -128,15 +121,26 @@ public:
}
bool operator!=(const ShaderDiskCacheUsage& rhs) const {
- return !this->operator==(rhs);
+ return !operator==(rhs);
+ }
+
+ u64 unique_identifier{};
+ BaseBindings bindings;
+ GLenum primitive{};
+
+private:
+ std::tuple<u64, BaseBindings, GLenum> Tie() const {
+ return std::tie(unique_identifier, bindings, primitive);
}
};
+/// Contains decompiled data from a shader
struct ShaderDiskCacheDecompiled {
std::string code;
GLShader::ShaderEntries entries;
};
+/// Contains an OpenGL dumped binary program
struct ShaderDiskCacheDump {
GLenum binary_format;
std::vector<u8> binary;
@@ -154,10 +158,10 @@ public:
LoadPrecompiled();
/// Removes the transferable (and precompiled) cache file.
- void InvalidateTransferable() const;
+ bool InvalidateTransferable() const;
/// Removes the precompiled cache file.
- void InvalidatePrecompiled() const;
+ bool InvalidatePrecompiled() const;
/// Saves a raw dump to the transferable file. Checks for collisions.
void SaveRaw(const ShaderDiskCacheRaw& entry);