summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2019-07-12 07:17:18 +0200
committerReinUsesLisp <reinuseslisp@airmail.cc>2019-09-06 01:35:51 +0200
commit954fc02fdd639a3e83ade8776d23b50559cd2f73 (patch)
tree5ff6bb093e484379c082437a5376ddb75ab4e9d4
parentgl_state: Split textures and samplers into two arrays (diff)
downloadyuzu-954fc02fdd639a3e83ade8776d23b50559cd2f73.tar
yuzu-954fc02fdd639a3e83ade8776d23b50559cd2f73.tar.gz
yuzu-954fc02fdd639a3e83ade8776d23b50559cd2f73.tar.bz2
yuzu-954fc02fdd639a3e83ade8776d23b50559cd2f73.tar.lz
yuzu-954fc02fdd639a3e83ade8776d23b50559cd2f73.tar.xz
yuzu-954fc02fdd639a3e83ade8776d23b50559cd2f73.tar.zst
yuzu-954fc02fdd639a3e83ade8776d23b50559cd2f73.zip
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp43
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h8
2 files changed, 31 insertions, 20 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 818e71754..5454bacb0 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -998,17 +998,17 @@ TextureBufferUsage RasterizerOpenGL::SetupDrawTextures(Maxwell::ShaderStage stag
for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) {
const auto& entry = entries[bindpoint];
- Tegra::Texture::FullTextureInfo texture;
- if (entry.IsBindless()) {
+ const auto texture = [&]() {
+ if (!entry.IsBindless()) {
+ return maxwell3d.GetStageTexture(stage, entry.GetOffset());
+ }
const auto cbuf = entry.GetBindlessCBuf();
Tegra::Texture::TextureHandle tex_handle;
tex_handle.raw = maxwell3d.AccessConstBuffer32(stage, cbuf.first, cbuf.second);
- texture = maxwell3d.GetTextureInfo(tex_handle, entry.GetOffset());
- } else {
- texture = maxwell3d.GetStageTexture(stage, entry.GetOffset());
- }
+ return maxwell3d.GetTextureInfo(tex_handle, entry.GetOffset());
+ }();
- if (SetupTexture(shader, base_bindings.sampler + bindpoint, texture, entry)) {
+ if (SetupTexture(base_bindings.sampler + bindpoint, texture, entry)) {
texture_buffer_usage.set(bindpoint);
}
}
@@ -1016,8 +1016,7 @@ TextureBufferUsage RasterizerOpenGL::SetupDrawTextures(Maxwell::ShaderStage stag
return texture_buffer_usage;
}
-bool RasterizerOpenGL::SetupTexture(const Shader& shader, u32 binding,
- const Tegra::Texture::FullTextureInfo& texture,
+bool RasterizerOpenGL::SetupTexture(u32 binding, const Tegra::Texture::FullTextureInfo& texture,
const GLShader::SamplerEntry& entry) {
state.samplers[binding] = sampler_cache.GetSampler(texture.tsc);
@@ -1044,22 +1043,30 @@ void RasterizerOpenGL::SetupComputeImages(const Shader& shader) {
const auto& entries = shader->GetShaderEntries().images;
for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) {
const auto& entry = entries[bindpoint];
- const auto texture = [&]() {
+ const auto tic = [&]() {
if (!entry.IsBindless()) {
- return compute.GetTexture(entry.GetOffset());
+ return compute.GetTexture(entry.GetOffset()).tic;
}
const auto cbuf = entry.GetBindlessCBuf();
Tegra::Texture::TextureHandle tex_handle;
tex_handle.raw = compute.AccessConstBuffer32(cbuf.first, cbuf.second);
- return compute.GetTextureInfo(tex_handle, entry.GetOffset());
+ return compute.GetTextureInfo(tex_handle, entry.GetOffset()).tic;
}();
- const auto view = texture_cache.GetImageSurface(texture.tic, entry);
- if (!view) {
- state.images[bindpoint] = 0;
- continue;
- }
- state.images[bindpoint] = view->GetTexture();
+ SetupImage(bindpoint, tic, entry);
+ }
+}
+
+void RasterizerOpenGL::SetupImage(u32 binding, const Tegra::Texture::TICEntry& tic,
+ const GLShader::ImageEntry& entry) {
+ const auto view = texture_cache.GetImageSurface(tic, entry);
+ if (!view) {
+ state.images[binding] = 0;
+ return;
+ }
+ if (!tic.IsBuffer()) {
+ view->ApplySwizzle(tic.x_source, tic.y_source, tic.z_source, tic.w_source);
}
+ state.images[binding] = view->GetTexture();
}
void RasterizerOpenGL::SyncViewport(OpenGLState& current_state) {
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index 6fa1b7ec4..35265b4a2 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -142,12 +142,16 @@ private:
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,
+ bool SetupTexture(u32 binding, const Tegra::Texture::FullTextureInfo& texture,
const GLShader::SamplerEntry& entry);
+ /// Configures images in a compute shader.
void SetupComputeImages(const Shader& shader);
+ /// Configures an image.
+ void SetupImage(u32 binding, const Tegra::Texture::TICEntry& tic,
+ const GLShader::ImageEntry& entry);
+
/// Syncs the viewport and depth range to match the guest state
void SyncViewport(OpenGLState& current_state);