aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/video_core
diff options
context:
space:
mode:
authorGravatar Tony Wasserka <neobrainx@gmail.com>2015-07-12 03:19:46 +0200
committerGravatar Tony Wasserka <neobrainx@gmail.com>2015-07-12 03:19:46 +0200
commitae7120f5d925da39aea9b66750c148428eca1298 (patch)
tree50f53e790adcf741657ad1ff09997ec43aeeccf3 /src/video_core
parentd5f5666f460cfbfc1f4b20c6b60e5636c97050bb (diff)
parent58d1c6398e555f95bc6da60467c3f49183eb18df (diff)
Merge pull request #907 from Lectem/clamp_to_border
Add GL_CLAMP_TO_BORDER support.
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/pica.h8
-rw-r--r--src/video_core/rasterizer.cpp31
-rw-r--r--src/video_core/renderer_opengl/pica_to_gl.h2
3 files changed, 28 insertions, 13 deletions
diff --git a/src/video_core/pica.h b/src/video_core/pica.h
index be8ff759..feb20214 100644
--- a/src/video_core/pica.h
+++ b/src/video_core/pica.h
@@ -114,11 +114,17 @@ struct Regs {
struct TextureConfig {
enum WrapMode : u32 {
ClampToEdge = 0,
+ ClampToBorder = 1,
Repeat = 2,
MirroredRepeat = 3,
};
- INSERT_PADDING_WORDS(0x1);
+ union {
+ BitField< 0, 8, u32> r;
+ BitField< 8, 8, u32> g;
+ BitField<16, 8, u32> b;
+ BitField<24, 8, u32> a;
+ } border_color;
union {
BitField< 0, 16, u32> height;
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp
index 59d156ee..70b11574 100644
--- a/src/video_core/rasterizer.cpp
+++ b/src/video_core/rasterizer.cpp
@@ -349,6 +349,9 @@ static void ProcessTriangleInternal(const VertexShader::OutputVertex& v0,
val = std::min(val, (int)size - 1);
return val;
+ case Regs::TextureConfig::ClampToBorder:
+ return val;
+
case Regs::TextureConfig::Repeat:
return (int)((unsigned)val % size);
@@ -367,17 +370,23 @@ static void ProcessTriangleInternal(const VertexShader::OutputVertex& v0,
}
};
- // Textures are laid out from bottom to top, hence we invert the t coordinate.
- // NOTE: This may not be the right place for the inversion.
- // TODO: Check if this applies to ETC textures, too.
- s = GetWrappedTexCoord(texture.config.wrap_s, s, texture.config.width);
- t = texture.config.height - 1 - GetWrappedTexCoord(texture.config.wrap_t, t, texture.config.height);
-
- u8* texture_data = Memory::GetPhysicalPointer(texture.config.GetPhysicalAddress());
- auto info = DebugUtils::TextureInfo::FromPicaRegister(texture.config, texture.format);
-
- texture_color[i] = DebugUtils::LookupTexture(texture_data, s, t, info);
- DebugUtils::DumpTexture(texture.config, texture_data);
+ if ((texture.config.wrap_s == Regs::TextureConfig::ClampToBorder && (s < 0 || s >= texture.config.width))
+ || (texture.config.wrap_t == Regs::TextureConfig::ClampToBorder && (t < 0 || t >= texture.config.height))) {
+ auto border_color = texture.config.border_color;
+ texture_color[i] = { border_color.r, border_color.g, border_color.b, border_color.a };
+ } else {
+ // Textures are laid out from bottom to top, hence we invert the t coordinate.
+ // NOTE: This may not be the right place for the inversion.
+ // TODO: Check if this applies to ETC textures, too.
+ s = GetWrappedTexCoord(texture.config.wrap_s, s, texture.config.width);
+ t = texture.config.height - 1 - GetWrappedTexCoord(texture.config.wrap_t, t, texture.config.height);
+
+ u8* texture_data = Memory::GetPhysicalPointer(texture.config.GetPhysicalAddress());
+ auto info = DebugUtils::TextureInfo::FromPicaRegister(texture.config, texture.format);
+
+ texture_color[i] = DebugUtils::LookupTexture(texture_data, s, t, info);
+ DebugUtils::DumpTexture(texture.config, texture_data);
+ }
}
// Texture environment - consists of 6 stages of color and alpha combining.
diff --git a/src/video_core/renderer_opengl/pica_to_gl.h b/src/video_core/renderer_opengl/pica_to_gl.h
index e566f9f7..73f63c55 100644
--- a/src/video_core/renderer_opengl/pica_to_gl.h
+++ b/src/video_core/renderer_opengl/pica_to_gl.h
@@ -15,7 +15,7 @@ namespace PicaToGL {
inline GLenum WrapMode(Pica::Regs::TextureConfig::WrapMode mode) {
static const GLenum wrap_mode_table[] = {
GL_CLAMP_TO_EDGE, // WrapMode::ClampToEdge
- 0, // Unknown
+ GL_CLAMP_TO_BORDER,// WrapMode::ClampToBorder
GL_REPEAT, // WrapMode::Repeat
GL_MIRRORED_REPEAT // WrapMode::MirroredRepeat
};