summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2019-08-25 06:28:26 +0200
committerReinUsesLisp <reinuseslisp@airmail.cc>2019-09-04 06:54:43 +0200
commit42e1bb6d468523994af29dba1d6dcfc1b87274ea (patch)
treea54e5ba084ec406efdd555a50ff7d2502ccf6b6c /src/video_core/renderer_opengl
parentMerge pull request #2835 from chris062689/master (diff)
downloadyuzu-42e1bb6d468523994af29dba1d6dcfc1b87274ea.tar
yuzu-42e1bb6d468523994af29dba1d6dcfc1b87274ea.tar.gz
yuzu-42e1bb6d468523994af29dba1d6dcfc1b87274ea.tar.bz2
yuzu-42e1bb6d468523994af29dba1d6dcfc1b87274ea.tar.lz
yuzu-42e1bb6d468523994af29dba1d6dcfc1b87274ea.tar.xz
yuzu-42e1bb6d468523994af29dba1d6dcfc1b87274ea.tar.zst
yuzu-42e1bb6d468523994af29dba1d6dcfc1b87274ea.zip
Diffstat (limited to 'src/video_core/renderer_opengl')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_cache.cpp68
-rw-r--r--src/video_core/renderer_opengl/gl_shader_cache.h21
2 files changed, 9 insertions, 80 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp
index cf6a5cddf..909ccb82c 100644
--- a/src/video_core/renderer_opengl/gl_shader_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp
@@ -348,23 +348,16 @@ Shader CachedShader::CreateKernelFromCache(const ShaderParameters& params,
}
std::tuple<GLuint, BaseBindings> CachedShader::GetProgramHandle(const ProgramVariant& variant) {
- GLuint handle{};
- if (program_type == ProgramType::Geometry) {
- handle = GetGeometryShader(variant);
- } else {
- const auto [entry, is_cache_miss] = programs.try_emplace(variant);
- auto& program = entry->second;
- if (is_cache_miss) {
- program = TryLoadProgram(variant);
- if (!program) {
- program = SpecializeShader(code, entries, program_type, variant);
- disk_cache.SaveUsage(GetUsage(variant));
- }
-
- LabelGLObject(GL_PROGRAM, program->handle, cpu_addr);
+ const auto [entry, is_cache_miss] = programs.try_emplace(variant);
+ auto& program = entry->second;
+ if (is_cache_miss) {
+ program = TryLoadProgram(variant);
+ if (!program) {
+ program = SpecializeShader(code, entries, program_type, variant);
+ disk_cache.SaveUsage(GetUsage(variant));
}
- handle = program->handle;
+ LabelGLObject(GL_PROGRAM, program->handle, cpu_addr);
}
auto base_bindings = variant.base_bindings;
@@ -375,52 +368,9 @@ std::tuple<GLuint, BaseBindings> CachedShader::GetProgramHandle(const ProgramVar
base_bindings.gmem += static_cast<u32>(entries.global_memory_entries.size());
base_bindings.sampler += static_cast<u32>(entries.samplers.size());
- return {handle, base_bindings};
+ return {program->handle, base_bindings};
}
-GLuint CachedShader::GetGeometryShader(const ProgramVariant& variant) {
- const auto [entry, is_cache_miss] = geometry_programs.try_emplace(variant);
- auto& programs = entry->second;
-
- switch (variant.primitive_mode) {
- case GL_POINTS:
- return LazyGeometryProgram(programs.points, variant);
- case GL_LINES:
- case GL_LINE_STRIP:
- return LazyGeometryProgram(programs.lines, variant);
- case GL_LINES_ADJACENCY:
- case GL_LINE_STRIP_ADJACENCY:
- return LazyGeometryProgram(programs.lines_adjacency, variant);
- case GL_TRIANGLES:
- case GL_TRIANGLE_STRIP:
- case GL_TRIANGLE_FAN:
- return LazyGeometryProgram(programs.triangles, variant);
- case GL_TRIANGLES_ADJACENCY:
- case GL_TRIANGLE_STRIP_ADJACENCY:
- return LazyGeometryProgram(programs.triangles_adjacency, variant);
- default:
- UNREACHABLE_MSG("Unknown primitive mode.");
- return LazyGeometryProgram(programs.points, variant);
- }
-}
-
-GLuint CachedShader::LazyGeometryProgram(CachedProgram& target_program,
- const ProgramVariant& variant) {
- if (target_program) {
- return target_program->handle;
- }
- const auto [glsl_name, debug_name, vertices] = GetPrimitiveDescription(variant.primitive_mode);
- target_program = TryLoadProgram(variant);
- if (!target_program) {
- target_program = SpecializeShader(code, entries, program_type, variant);
- disk_cache.SaveUsage(GetUsage(variant));
- }
-
- LabelGLObject(GL_PROGRAM, target_program->handle, cpu_addr, debug_name);
-
- return target_program->handle;
-};
-
CachedProgram CachedShader::TryLoadProgram(const ProgramVariant& variant) const {
const auto found = precompiled_programs.find(GetUsage(variant));
if (found == precompiled_programs.end()) {
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.h b/src/video_core/renderer_opengl/gl_shader_cache.h
index 2c8faf855..de195cc5d 100644
--- a/src/video_core/renderer_opengl/gl_shader_cache.h
+++ b/src/video_core/renderer_opengl/gl_shader_cache.h
@@ -86,22 +86,6 @@ private:
explicit CachedShader(const ShaderParameters& params, ProgramType program_type,
GLShader::ProgramResult result);
- // Geometry programs. These are needed because GLSL needs an input topology but it's not
- // declared by the hardware. Workaround this issue by generating a different shader per input
- // topology class.
- struct GeometryPrograms {
- CachedProgram points;
- CachedProgram lines;
- CachedProgram lines_adjacency;
- CachedProgram triangles;
- CachedProgram triangles_adjacency;
- };
-
- GLuint GetGeometryShader(const ProgramVariant& variant);
-
- /// Generates a geometry shader or returns one that already exists.
- GLuint LazyGeometryProgram(CachedProgram& target_program, const ProgramVariant& variant);
-
CachedProgram TryLoadProgram(const ProgramVariant& variant) const;
ShaderDiskCacheUsage GetUsage(const ProgramVariant& variant) const;
@@ -117,11 +101,6 @@ private:
std::size_t shader_length{};
std::unordered_map<ProgramVariant, CachedProgram> programs;
- std::unordered_map<ProgramVariant, GeometryPrograms> geometry_programs;
-
- std::unordered_map<u32, GLuint> cbuf_resource_cache;
- std::unordered_map<u32, GLuint> gmem_resource_cache;
- std::unordered_map<u32, GLint> uniform_cache;
};
class ShaderCacheOpenGL final : public RasterizerCache<Shader> {