summaryrefslogtreecommitdiffstats
path: root/src/video_core
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2019-07-12 01:09:53 +0200
committerReinUsesLisp <reinuseslisp@airmail.cc>2019-09-06 01:35:51 +0200
commit2e5b5c2358caaf8dfd403a30924d49c31aa962a0 (patch)
treebdd4acfce25ee3b409035621af36ca776d9874a8 /src/video_core
parentMerge pull request #2804 from ReinUsesLisp/remove-gs-special (diff)
downloadyuzu-2e5b5c2358caaf8dfd403a30924d49c31aa962a0.tar
yuzu-2e5b5c2358caaf8dfd403a30924d49c31aa962a0.tar.gz
yuzu-2e5b5c2358caaf8dfd403a30924d49c31aa962a0.tar.bz2
yuzu-2e5b5c2358caaf8dfd403a30924d49c31aa962a0.tar.lz
yuzu-2e5b5c2358caaf8dfd403a30924d49c31aa962a0.tar.xz
yuzu-2e5b5c2358caaf8dfd403a30924d49c31aa962a0.tar.zst
yuzu-2e5b5c2358caaf8dfd403a30924d49c31aa962a0.zip
Diffstat (limited to 'src/video_core')
-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) {
const auto stage_enum = static_cast<Maxwell::ShaderStage>(stage);
SetupDrawConstBuffers(stage_enum, shader);
SetupDrawGlobalMemory(stage_enum, shader);
- const auto texture_buffer_usage{SetupTextures(stage_enum, shader, base_bindings)};
+ const auto texture_buffer_usage{SetupDrawTextures(stage_enum, shader, base_bindings)};
const ProgramVariant variant{base_bindings, primitive_mode, texture_buffer_usage};
const auto [program_handle, next_bindings] = shader->GetProgramHandle(variant);
@@ -981,8 +981,9 @@ void RasterizerOpenGL::SetupGlobalMemory(const GLShader::GlobalMemoryEntry& entr
bind_ssbo_pushbuffer.Push(ssbo, buffer_offset, static_cast<GLsizeiptr>(size));
}
-TextureBufferUsage RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, const Shader& shader,
- BaseBindings base_bindings) {
+TextureBufferUsage RasterizerOpenGL::SetupDrawTextures(Maxwell::ShaderStage stage,
+ const Shader& shader,
+ BaseBindings base_bindings) {
MICROPROFILE_SCOPE(OpenGL_Texture);
const auto& gpu = system.GPU();
const auto& maxwell3d = gpu.Maxwell3D();
@@ -1004,30 +1005,39 @@ TextureBufferUsage RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, c
} else {
texture = maxwell3d.GetStageTexture(stage, entry.GetOffset());
}
- const u32 current_bindpoint = base_bindings.sampler + bindpoint;
- auto& unit{state.texture_units[current_bindpoint]};
- unit.sampler = sampler_cache.GetSampler(texture.tsc);
-
- if (const auto view{texture_cache.GetTextureSurface(texture, entry)}; view) {
- if (view->GetSurfaceParams().IsBuffer()) {
- // Record that this texture is a texture buffer.
- texture_buffer_usage.set(bindpoint);
- } else {
- // Apply swizzle to textures that are not buffers.
- view->ApplySwizzle(texture.tic.x_source, texture.tic.y_source, texture.tic.z_source,
- texture.tic.w_source);
- }
- state.texture_units[current_bindpoint].texture = view->GetTexture();
- } else {
- // Can occur when texture addr is null or its memory is unmapped/invalid
- unit.texture = 0;
+ if (SetupTexture(shader, base_bindings.sampler + bindpoint, texture, entry)) {
+ texture_buffer_usage.set(bindpoint);
}
}
return texture_buffer_usage;
}
+bool RasterizerOpenGL::SetupTexture(const Shader& shader, u32 binding,
+ const Tegra::Texture::FullTextureInfo& texture,
+ const GLShader::SamplerEntry& entry) {
+ auto& unit{state.texture_units[binding]};
+ unit.sampler = sampler_cache.GetSampler(texture.tsc);
+
+ const auto view = texture_cache.GetTextureSurface(texture, entry);
+ if (!view) {
+ // Can occur when texture addr is null or its memory is unmapped/invalid
+ unit.texture = 0;
+ return false;
+ }
+ unit.texture = view->GetTexture();
+
+ if (view->GetSurfaceParams().IsBuffer()) {
+ return true;
+ }
+
+ // Apply swizzle to textures that are not buffers.
+ view->ApplySwizzle(texture.tic.x_source, texture.tic.y_source, texture.tic.z_source,
+ texture.tic.w_source);
+ return false;
+}
+
void RasterizerOpenGL::SyncViewport(OpenGLState& current_state) {
const auto& regs = system.GPU().Maxwell3D().regs;
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 @@
#include "video_core/renderer_opengl/gl_state.h"
#include "video_core/renderer_opengl/gl_texture_cache.h"
#include "video_core/renderer_opengl/utils.h"
+#include "video_core/textures/texture.h"
namespace Core {
class System;
@@ -137,8 +138,13 @@ private:
/// Configures the current textures to use for the draw command. Returns shaders texture buffer
/// usage.
- TextureBufferUsage SetupTextures(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage,
- const Shader& shader, BaseBindings base_bindings);
+ TextureBufferUsage SetupDrawTextures(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage,
+ const Shader& shader, BaseBindings base_bindings);
+
+ /// Configures a texture. Returns true when the texture is a texture buffer.
+ bool SetupTexture(const Shader& shader, u32 binding,
+ const Tegra::Texture::FullTextureInfo& texture,
+ const GLShader::SamplerEntry& entry);
/// Syncs the viewport and depth range to match the guest state
void SyncViewport(OpenGLState& current_state);