summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lectem2015-07-07 23:36:06 +0200
committerGravatar Lectem2015-07-09 22:23:26 +0200
commit58d1c6398e555f95bc6da60467c3f49183eb18df (patch)
treee8e371e16943c9501594bf8ada6bad8e7c72012e /src
parentMerge pull request #797 from linkmauve/blended-downscaling (diff)
downloadyuzu-58d1c6398e555f95bc6da60467c3f49183eb18df.tar.gz
yuzu-58d1c6398e555f95bc6da60467c3f49183eb18df.tar.xz
yuzu-58d1c6398e555f95bc6da60467c3f49183eb18df.zip
Added GL_CLAMP_TO_BORDER support
Diffstat (limited to 'src')
-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 9628a7589..3a12665eb 100644
--- a/src/video_core/pica.h
+++ b/src/video_core/pica.h
@@ -114,11 +114,17 @@ struct Regs {
114 struct TextureConfig { 114 struct TextureConfig {
115 enum WrapMode : u32 { 115 enum WrapMode : u32 {
116 ClampToEdge = 0, 116 ClampToEdge = 0,
117 ClampToBorder = 1,
117 Repeat = 2, 118 Repeat = 2,
118 MirroredRepeat = 3, 119 MirroredRepeat = 3,
119 }; 120 };
120 121
121 INSERT_PADDING_WORDS(0x1); 122 union {
123 BitField< 0, 8, u32> r;
124 BitField< 8, 8, u32> g;
125 BitField<16, 8, u32> b;
126 BitField<24, 8, u32> a;
127 } border_color;
122 128
123 union { 129 union {
124 BitField< 0, 16, u32> height; 130 BitField< 0, 16, u32> height;
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp
index 59d156ee7..70b115744 100644
--- a/src/video_core/rasterizer.cpp
+++ b/src/video_core/rasterizer.cpp
@@ -349,6 +349,9 @@ static void ProcessTriangleInternal(const VertexShader::OutputVertex& v0,
349 val = std::min(val, (int)size - 1); 349 val = std::min(val, (int)size - 1);
350 return val; 350 return val;
351 351
352 case Regs::TextureConfig::ClampToBorder:
353 return val;
354
352 case Regs::TextureConfig::Repeat: 355 case Regs::TextureConfig::Repeat:
353 return (int)((unsigned)val % size); 356 return (int)((unsigned)val % size);
354 357
@@ -367,17 +370,23 @@ static void ProcessTriangleInternal(const VertexShader::OutputVertex& v0,
367 } 370 }
368 }; 371 };
369 372
370 // Textures are laid out from bottom to top, hence we invert the t coordinate. 373 if ((texture.config.wrap_s == Regs::TextureConfig::ClampToBorder && (s < 0 || s >= texture.config.width))
371 // NOTE: This may not be the right place for the inversion. 374 || (texture.config.wrap_t == Regs::TextureConfig::ClampToBorder && (t < 0 || t >= texture.config.height))) {
372 // TODO: Check if this applies to ETC textures, too. 375 auto border_color = texture.config.border_color;
373 s = GetWrappedTexCoord(texture.config.wrap_s, s, texture.config.width); 376 texture_color[i] = { border_color.r, border_color.g, border_color.b, border_color.a };
374 t = texture.config.height - 1 - GetWrappedTexCoord(texture.config.wrap_t, t, texture.config.height); 377 } else {
375 378 // Textures are laid out from bottom to top, hence we invert the t coordinate.
376 u8* texture_data = Memory::GetPhysicalPointer(texture.config.GetPhysicalAddress()); 379 // NOTE: This may not be the right place for the inversion.
377 auto info = DebugUtils::TextureInfo::FromPicaRegister(texture.config, texture.format); 380 // TODO: Check if this applies to ETC textures, too.
378 381 s = GetWrappedTexCoord(texture.config.wrap_s, s, texture.config.width);
379 texture_color[i] = DebugUtils::LookupTexture(texture_data, s, t, info); 382 t = texture.config.height - 1 - GetWrappedTexCoord(texture.config.wrap_t, t, texture.config.height);
380 DebugUtils::DumpTexture(texture.config, texture_data); 383
384 u8* texture_data = Memory::GetPhysicalPointer(texture.config.GetPhysicalAddress());
385 auto info = DebugUtils::TextureInfo::FromPicaRegister(texture.config, texture.format);
386
387 texture_color[i] = DebugUtils::LookupTexture(texture_data, s, t, info);
388 DebugUtils::DumpTexture(texture.config, texture_data);
389 }
381 } 390 }
382 391
383 // Texture environment - consists of 6 stages of color and alpha combining. 392 // 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 e566f9f7a..73f63c55d 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 {
15inline GLenum WrapMode(Pica::Regs::TextureConfig::WrapMode mode) { 15inline GLenum WrapMode(Pica::Regs::TextureConfig::WrapMode mode) {
16 static const GLenum wrap_mode_table[] = { 16 static const GLenum wrap_mode_table[] = {
17 GL_CLAMP_TO_EDGE, // WrapMode::ClampToEdge 17 GL_CLAMP_TO_EDGE, // WrapMode::ClampToEdge
18 0, // Unknown 18 GL_CLAMP_TO_BORDER,// WrapMode::ClampToBorder
19 GL_REPEAT, // WrapMode::Repeat 19 GL_REPEAT, // WrapMode::Repeat
20 GL_MIRRORED_REPEAT // WrapMode::MirroredRepeat 20 GL_MIRRORED_REPEAT // WrapMode::MirroredRepeat
21 }; 21 };