gl_rasterizer: Split SetupTextures
This commit is contained in:
parent
4ee9949639
commit
2e5b5c2358
|
@ -331,7 +331,7 @@ void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) {
|
||||||
const auto stage_enum = static_cast<Maxwell::ShaderStage>(stage);
|
const auto stage_enum = static_cast<Maxwell::ShaderStage>(stage);
|
||||||
SetupDrawConstBuffers(stage_enum, shader);
|
SetupDrawConstBuffers(stage_enum, shader);
|
||||||
SetupDrawGlobalMemory(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 ProgramVariant variant{base_bindings, primitive_mode, texture_buffer_usage};
|
||||||
const auto [program_handle, next_bindings] = shader->GetProgramHandle(variant);
|
const auto [program_handle, next_bindings] = shader->GetProgramHandle(variant);
|
||||||
|
@ -981,7 +981,8 @@ void RasterizerOpenGL::SetupGlobalMemory(const GLShader::GlobalMemoryEntry& entr
|
||||||
bind_ssbo_pushbuffer.Push(ssbo, buffer_offset, static_cast<GLsizeiptr>(size));
|
bind_ssbo_pushbuffer.Push(ssbo, buffer_offset, static_cast<GLsizeiptr>(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureBufferUsage RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, const Shader& shader,
|
TextureBufferUsage RasterizerOpenGL::SetupDrawTextures(Maxwell::ShaderStage stage,
|
||||||
|
const Shader& shader,
|
||||||
BaseBindings base_bindings) {
|
BaseBindings base_bindings) {
|
||||||
MICROPROFILE_SCOPE(OpenGL_Texture);
|
MICROPROFILE_SCOPE(OpenGL_Texture);
|
||||||
const auto& gpu = system.GPU();
|
const auto& gpu = system.GPU();
|
||||||
|
@ -1004,30 +1005,39 @@ TextureBufferUsage RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, c
|
||||||
} else {
|
} else {
|
||||||
texture = maxwell3d.GetStageTexture(stage, entry.GetOffset());
|
texture = maxwell3d.GetStageTexture(stage, entry.GetOffset());
|
||||||
}
|
}
|
||||||
const u32 current_bindpoint = base_bindings.sampler + bindpoint;
|
|
||||||
|
|
||||||
auto& unit{state.texture_units[current_bindpoint]};
|
if (SetupTexture(shader, base_bindings.sampler + bindpoint, texture, entry)) {
|
||||||
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);
|
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return texture_buffer_usage;
|
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) {
|
void RasterizerOpenGL::SyncViewport(OpenGLState& current_state) {
|
||||||
const auto& regs = system.GPU().Maxwell3D().regs;
|
const auto& regs = system.GPU().Maxwell3D().regs;
|
||||||
const bool geometry_shaders_enabled =
|
const bool geometry_shaders_enabled =
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "video_core/renderer_opengl/gl_state.h"
|
#include "video_core/renderer_opengl/gl_state.h"
|
||||||
#include "video_core/renderer_opengl/gl_texture_cache.h"
|
#include "video_core/renderer_opengl/gl_texture_cache.h"
|
||||||
#include "video_core/renderer_opengl/utils.h"
|
#include "video_core/renderer_opengl/utils.h"
|
||||||
|
#include "video_core/textures/texture.h"
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class System;
|
class System;
|
||||||
|
@ -137,9 +138,14 @@ private:
|
||||||
|
|
||||||
/// Configures the current textures to use for the draw command. Returns shaders texture buffer
|
/// Configures the current textures to use for the draw command. Returns shaders texture buffer
|
||||||
/// usage.
|
/// usage.
|
||||||
TextureBufferUsage SetupTextures(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage,
|
TextureBufferUsage SetupDrawTextures(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage,
|
||||||
const Shader& shader, BaseBindings base_bindings);
|
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
|
/// Syncs the viewport and depth range to match the guest state
|
||||||
void SyncViewport(OpenGLState& current_state);
|
void SyncViewport(OpenGLState& current_state);
|
||||||
|
|
||||||
|
|
Reference in New Issue