summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_rasterizer.cpp
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2019-04-29 02:08:31 +0200
committerReinUsesLisp <reinuseslisp@airmail.cc>2019-06-21 02:38:33 +0200
commit007ffbef1c3bb6ae5fb85d24754a60d4eea87e45 (patch)
tree1e82380947cab3bb4dc6d952acd600682e6d173f /src/video_core/renderer_opengl/gl_rasterizer.cpp
parentvideo_core: Make ARB_buffer_storage a required extension (diff)
downloadyuzu-007ffbef1c3bb6ae5fb85d24754a60d4eea87e45.tar
yuzu-007ffbef1c3bb6ae5fb85d24754a60d4eea87e45.tar.gz
yuzu-007ffbef1c3bb6ae5fb85d24754a60d4eea87e45.tar.bz2
yuzu-007ffbef1c3bb6ae5fb85d24754a60d4eea87e45.tar.lz
yuzu-007ffbef1c3bb6ae5fb85d24754a60d4eea87e45.tar.xz
yuzu-007ffbef1c3bb6ae5fb85d24754a60d4eea87e45.tar.zst
yuzu-007ffbef1c3bb6ae5fb85d24754a60d4eea87e45.zip
Diffstat (limited to 'src/video_core/renderer_opengl/gl_rasterizer.cpp')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 56f2d2972..4f7eeb22c 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -29,8 +29,10 @@
namespace OpenGL {
using Maxwell = Tegra::Engines::Maxwell3D::Regs;
-using PixelFormat = VideoCore::Surface::PixelFormat;
-using SurfaceType = VideoCore::Surface::SurfaceType;
+
+using VideoCore::Surface::PixelFormat;
+using VideoCore::Surface::SurfaceTarget;
+using VideoCore::Surface::SurfaceType;
MICROPROFILE_DEFINE(OpenGL_VAO, "OpenGL", "Vertex Format Setup", MP_RGB(128, 128, 192));
MICROPROFILE_DEFINE(OpenGL_VB, "OpenGL", "Vertex Buffer Setup", MP_RGB(128, 128, 192));
@@ -281,8 +283,14 @@ void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) {
static_cast<GLsizeiptr>(sizeof(ubo)));
Shader shader{shader_cache.GetStageProgram(program)};
- const auto [program_handle, next_bindings] =
- shader->GetProgramHandle(primitive_mode, base_bindings);
+
+ const auto stage_enum{static_cast<Maxwell::ShaderStage>(stage)};
+ SetupDrawConstBuffers(stage_enum, shader);
+ SetupGlobalRegions(stage_enum, shader);
+ const auto texture_buffer_usage{SetupTextures(stage_enum, shader, base_bindings)};
+
+ const ProgramVariant variant{base_bindings, primitive_mode, texture_buffer_usage};
+ const auto [program_handle, next_bindings] = shader->GetProgramHandle(variant);
switch (program) {
case Maxwell::ShaderProgram::VertexA:
@@ -300,11 +308,6 @@ void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) {
shader_config.enable.Value(), shader_config.offset);
}
- const auto stage_enum = static_cast<Maxwell::ShaderStage>(stage);
- SetupDrawConstBuffers(stage_enum, shader);
- SetupGlobalRegions(stage_enum, shader);
- SetupTextures(stage_enum, shader, base_bindings);
-
// Workaround for Intel drivers.
// When a clip distance is enabled but not set in the shader it crops parts of the screen
// (sometimes it's half the screen, sometimes three quarters). To avoid this, enable the
@@ -791,8 +794,8 @@ void RasterizerOpenGL::SetupGlobalRegions(Tegra::Engines::Maxwell3D::Regs::Shade
}
}
-void RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, const Shader& shader,
- BaseBindings base_bindings) {
+TextureBufferUsage RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, const Shader& shader,
+ BaseBindings base_bindings) {
MICROPROFILE_SCOPE(OpenGL_Texture);
const auto& gpu = system.GPU();
const auto& maxwell3d = gpu.Maxwell3D();
@@ -801,6 +804,8 @@ void RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, const Shader& s
ASSERT_MSG(base_bindings.sampler + entries.size() <= std::size(state.texture_units),
"Exceeded the number of active textures.");
+ TextureBufferUsage texture_buffer_usage{0};
+
for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) {
const auto& entry = entries[bindpoint];
Tegra::Texture::FullTextureInfo texture;
@@ -814,7 +819,8 @@ void RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, const Shader& s
}
const u32 current_bindpoint = base_bindings.sampler + bindpoint;
- state.texture_units[current_bindpoint].sampler = sampler_cache.GetSampler(texture.tsc);
+ auto& unit{state.texture_units[current_bindpoint]};
+ unit.sampler = sampler_cache.GetSampler(texture.tsc);
if (const auto view{texture_cache.GetTextureSurface(texture, entry)}; view) {
view->ApplySwizzle(texture.tic.x_source, texture.tic.y_source, texture.tic.z_source,
@@ -822,9 +828,11 @@ void RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, const Shader& s
state.texture_units[current_bindpoint].texture = view->GetTexture();
} else {
// Can occur when texture addr is null or its memory is unmapped/invalid
- state.texture_units[current_bindpoint].texture = 0;
+ unit.texture = 0;
}
}
+
+ return texture_buffer_usage;
}
void RasterizerOpenGL::SyncViewport(OpenGLState& current_state) {