summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-07-24 13:44:37 +0200
committerGitHub <noreply@github.com>2018-07-24 13:44:37 +0200
commit54af9c206a533e63a5785504fdac3d40e9a02cad (patch)
tree66693082aa4ed4378bf91818c9bf2f2652e66554
parentMerge pull request #793 from lioncash/priv (diff)
parentgl_rasterizer: Implement texture border color. (diff)
downloadyuzu-54af9c206a533e63a5785504fdac3d40e9a02cad.tar
yuzu-54af9c206a533e63a5785504fdac3d40e9a02cad.tar.gz
yuzu-54af9c206a533e63a5785504fdac3d40e9a02cad.tar.bz2
yuzu-54af9c206a533e63a5785504fdac3d40e9a02cad.tar.lz
yuzu-54af9c206a533e63a5785504fdac3d40e9a02cad.tar.xz
yuzu-54af9c206a533e63a5785504fdac3d40e9a02cad.tar.zst
yuzu-54af9c206a533e63a5785504fdac3d40e9a02cad.zip
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp9
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h5
-rw-r--r--src/video_core/renderer_opengl/maxwell_to_gl.h2
-rw-r--r--src/video_core/textures/texture.h8
4 files changed, 13 insertions, 11 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 56d9c575b..5d5ad84b7 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -601,7 +601,6 @@ void RasterizerOpenGL::SamplerInfo::Create() {
sampler.Create();
mag_filter = min_filter = Tegra::Texture::TextureFilter::Linear;
wrap_u = wrap_v = Tegra::Texture::WrapMode::Wrap;
- border_color_r = border_color_g = border_color_b = border_color_a = 0;
// default is GL_LINEAR_MIPMAP_LINEAR
glSamplerParameteri(sampler.handle, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -630,8 +629,12 @@ void RasterizerOpenGL::SamplerInfo::SyncWithConfig(const Tegra::Texture::TSCEntr
}
if (wrap_u == Tegra::Texture::WrapMode::Border || wrap_v == Tegra::Texture::WrapMode::Border) {
- // TODO(Subv): Implement border color
- ASSERT(false);
+ const GLvec4 new_border_color = {{config.border_color_r, config.border_color_g,
+ config.border_color_b, config.border_color_a}};
+ if (border_color != new_border_color) {
+ border_color = new_border_color;
+ glSamplerParameterfv(s, GL_TEXTURE_BORDER_COLOR, border_color.data());
+ }
}
}
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index c406142e4..ab06e2d95 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -77,10 +77,7 @@ private:
Tegra::Texture::TextureFilter min_filter;
Tegra::Texture::WrapMode wrap_u;
Tegra::Texture::WrapMode wrap_v;
- u32 border_color_r;
- u32 border_color_g;
- u32 border_color_b;
- u32 border_color_a;
+ GLvec4 border_color;
};
/// Configures the color and depth framebuffer states and returns the dirty <Color, Depth>
diff --git a/src/video_core/renderer_opengl/maxwell_to_gl.h b/src/video_core/renderer_opengl/maxwell_to_gl.h
index e19c3b280..369bdd905 100644
--- a/src/video_core/renderer_opengl/maxwell_to_gl.h
+++ b/src/video_core/renderer_opengl/maxwell_to_gl.h
@@ -112,6 +112,8 @@ inline GLenum WrapMode(Tegra::Texture::WrapMode wrap_mode) {
return GL_MIRRORED_REPEAT;
case Tegra::Texture::WrapMode::ClampToEdge:
return GL_CLAMP_TO_EDGE;
+ case Tegra::Texture::WrapMode::Border:
+ return GL_CLAMP_TO_BORDER;
case Tegra::Texture::WrapMode::ClampOGL:
// TODO(Subv): GL_CLAMP was removed as of OpenGL 3.1, to implement GL_CLAMP, we can use
// GL_CLAMP_TO_BORDER to get the border color of the texture, and then sample the edge to
diff --git a/src/video_core/textures/texture.h b/src/video_core/textures/texture.h
index d1c755033..c6bd2f4b9 100644
--- a/src/video_core/textures/texture.h
+++ b/src/video_core/textures/texture.h
@@ -242,10 +242,10 @@ struct TSCEntry {
BitField<6, 2, TextureMipmapFilter> mip_filter;
};
INSERT_PADDING_BYTES(8);
- u32 border_color_r;
- u32 border_color_g;
- u32 border_color_b;
- u32 border_color_a;
+ float border_color_r;
+ float border_color_g;
+ float border_color_b;
+ float border_color_a;
};
static_assert(sizeof(TSCEntry) == 0x20, "TSCEntry has wrong size");