summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2019-07-11 20:09:53 -0300
committerGravatar ReinUsesLisp2019-09-05 20:35:51 -0300
commit2e5b5c2358caaf8dfd403a30924d49c31aa962a0 (patch)
treebdd4acfce25ee3b409035621af36ca776d9874a8 /src
parentMerge pull request #2804 from ReinUsesLisp/remove-gs-special (diff)
downloadyuzu-2e5b5c2358caaf8dfd403a30924d49c31aa962a0.tar.gz
yuzu-2e5b5c2358caaf8dfd403a30924d49c31aa962a0.tar.xz
yuzu-2e5b5c2358caaf8dfd403a30924d49c31aa962a0.zip
gl_rasterizer: Split SetupTextures
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp50
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h10
2 files changed, 38 insertions, 22 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 01d89f47d..0f0902259 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -331,7 +331,7 @@ void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) {
331 const auto stage_enum = static_cast<Maxwell::ShaderStage>(stage); 331 const auto stage_enum = static_cast<Maxwell::ShaderStage>(stage);
332 SetupDrawConstBuffers(stage_enum, shader); 332 SetupDrawConstBuffers(stage_enum, shader);
333 SetupDrawGlobalMemory(stage_enum, shader); 333 SetupDrawGlobalMemory(stage_enum, shader);
334 const auto texture_buffer_usage{SetupTextures(stage_enum, shader, base_bindings)}; 334 const auto texture_buffer_usage{SetupDrawTextures(stage_enum, shader, base_bindings)};
335 335
336 const ProgramVariant variant{base_bindings, primitive_mode, texture_buffer_usage}; 336 const ProgramVariant variant{base_bindings, primitive_mode, texture_buffer_usage};
337 const auto [program_handle, next_bindings] = shader->GetProgramHandle(variant); 337 const auto [program_handle, next_bindings] = shader->GetProgramHandle(variant);
@@ -981,8 +981,9 @@ void RasterizerOpenGL::SetupGlobalMemory(const GLShader::GlobalMemoryEntry& entr
981 bind_ssbo_pushbuffer.Push(ssbo, buffer_offset, static_cast<GLsizeiptr>(size)); 981 bind_ssbo_pushbuffer.Push(ssbo, buffer_offset, static_cast<GLsizeiptr>(size));
982} 982}
983 983
984TextureBufferUsage RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, const Shader& shader, 984TextureBufferUsage RasterizerOpenGL::SetupDrawTextures(Maxwell::ShaderStage stage,
985 BaseBindings base_bindings) { 985 const Shader& shader,
986 BaseBindings base_bindings) {
986 MICROPROFILE_SCOPE(OpenGL_Texture); 987 MICROPROFILE_SCOPE(OpenGL_Texture);
987 const auto& gpu = system.GPU(); 988 const auto& gpu = system.GPU();
988 const auto& maxwell3d = gpu.Maxwell3D(); 989 const auto& maxwell3d = gpu.Maxwell3D();
@@ -1004,30 +1005,39 @@ TextureBufferUsage RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, c
1004 } else { 1005 } else {
1005 texture = maxwell3d.GetStageTexture(stage, entry.GetOffset()); 1006 texture = maxwell3d.GetStageTexture(stage, entry.GetOffset());
1006 } 1007 }
1007 const u32 current_bindpoint = base_bindings.sampler + bindpoint;
1008 1008
1009 auto& unit{state.texture_units[current_bindpoint]}; 1009 if (SetupTexture(shader, base_bindings.sampler + bindpoint, texture, entry)) {
1010 unit.sampler = sampler_cache.GetSampler(texture.tsc); 1010 texture_buffer_usage.set(bindpoint);
1011
1012 if (const auto view{texture_cache.GetTextureSurface(texture, entry)}; view) {
1013 if (view->GetSurfaceParams().IsBuffer()) {
1014 // Record that this texture is a texture buffer.
1015 texture_buffer_usage.set(bindpoint);
1016 } else {
1017 // Apply swizzle to textures that are not buffers.
1018 view->ApplySwizzle(texture.tic.x_source, texture.tic.y_source, texture.tic.z_source,
1019 texture.tic.w_source);
1020 }
1021 state.texture_units[current_bindpoint].texture = view->GetTexture();
1022 } else {
1023 // Can occur when texture addr is null or its memory is unmapped/invalid
1024 unit.texture = 0;
1025 } 1011 }
1026 } 1012 }
1027 1013
1028 return texture_buffer_usage; 1014 return texture_buffer_usage;
1029} 1015}
1030 1016
1017bool RasterizerOpenGL::SetupTexture(const Shader& shader, u32 binding,
1018 const Tegra::Texture::FullTextureInfo& texture,
1019 const GLShader::SamplerEntry& entry) {
1020 auto& unit{state.texture_units[binding]};
1021 unit.sampler = sampler_cache.GetSampler(texture.tsc);
1022
1023 const auto view = texture_cache.GetTextureSurface(texture, entry);
1024 if (!view) {
1025 // Can occur when texture addr is null or its memory is unmapped/invalid
1026 unit.texture = 0;
1027 return false;
1028 }
1029 unit.texture = view->GetTexture();
1030
1031 if (view->GetSurfaceParams().IsBuffer()) {
1032 return true;
1033 }
1034
1035 // Apply swizzle to textures that are not buffers.
1036 view->ApplySwizzle(texture.tic.x_source, texture.tic.y_source, texture.tic.z_source,
1037 texture.tic.w_source);
1038 return false;
1039}
1040
1031void RasterizerOpenGL::SyncViewport(OpenGLState& current_state) { 1041void RasterizerOpenGL::SyncViewport(OpenGLState& current_state) {
1032 const auto& regs = system.GPU().Maxwell3D().regs; 1042 const auto& regs = system.GPU().Maxwell3D().regs;
1033 const bool geometry_shaders_enabled = 1043 const bool geometry_shaders_enabled =
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index 9d20a4fbf..23ab7aff0 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -32,6 +32,7 @@
32#include "video_core/renderer_opengl/gl_state.h" 32#include "video_core/renderer_opengl/gl_state.h"
33#include "video_core/renderer_opengl/gl_texture_cache.h" 33#include "video_core/renderer_opengl/gl_texture_cache.h"
34#include "video_core/renderer_opengl/utils.h" 34#include "video_core/renderer_opengl/utils.h"
35#include "video_core/textures/texture.h"
35 36
36namespace Core { 37namespace Core {
37class System; 38class System;
@@ -137,8 +138,13 @@ private:
137 138
138 /// Configures the current textures to use for the draw command. Returns shaders texture buffer 139 /// Configures the current textures to use for the draw command. Returns shaders texture buffer
139 /// usage. 140 /// usage.
140 TextureBufferUsage SetupTextures(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage, 141 TextureBufferUsage SetupDrawTextures(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage,
141 const Shader& shader, BaseBindings base_bindings); 142 const Shader& shader, BaseBindings base_bindings);
143
144 /// Configures a texture. Returns true when the texture is a texture buffer.
145 bool SetupTexture(const Shader& shader, u32 binding,
146 const Tegra::Texture::FullTextureInfo& texture,
147 const GLShader::SamplerEntry& entry);
142 148
143 /// Syncs the viewport and depth range to match the guest state 149 /// Syncs the viewport and depth range to match the guest state
144 void SyncViewport(OpenGLState& current_state); 150 void SyncViewport(OpenGLState& current_state);