summaryrefslogtreecommitdiff
path: root/src/video_core/textures/texture.h
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2020-04-07 20:38:14 -0300
committerGravatar ReinUsesLisp2020-04-07 20:38:14 -0300
commitd7db0881808376864eb71eb5dde8b651a5cf891d (patch)
treefceb12bc74d567151cb15da8b51001683dc12976 /src/video_core/textures/texture.h
parentfile_sys: fix LayeredFS error when loading some games made with… (#3602) (diff)
downloadyuzu-d7db0881808376864eb71eb5dde8b651a5cf891d.tar.gz
yuzu-d7db0881808376864eb71eb5dde8b651a5cf891d.tar.xz
yuzu-d7db0881808376864eb71eb5dde8b651a5cf891d.zip
video_core/texture: Use a LUT to convert sRGB texture borders
This is a reversed look up table extracted from https://gist.github.com/rygorous/2203834#file-gistfile1-cpp-L41-L62 that is used in https://github.com/devkitPro/deko3d/blob/04d4e9e587fa3dc5447b43d273bc45f440226e41/source/maxwell/tsc_generate.cpp#L38 Games usually bind 0xFD expecting a float texture border of 1.0f. The conversion previous to this commit was multiplying the uint8 sRGB texture border color by 255. This is close to 1.0f but when that difference matters, some graphical glitches appear. This look up table is manually changed in the edges, clamping towards 0.0f and 1.0f. While we are at it, move this logic to its own translation unit.
Diffstat (limited to 'src/video_core/textures/texture.h')
-rw-r--r--src/video_core/textures/texture.h11
1 files changed, 2 insertions, 9 deletions
diff --git a/src/video_core/textures/texture.h b/src/video_core/textures/texture.h
index 7edc4abe1..262cd3cc1 100644
--- a/src/video_core/textures/texture.h
+++ b/src/video_core/textures/texture.h
@@ -336,6 +336,8 @@ struct TSCEntry {
336 std::array<u8, 0x20> raw; 336 std::array<u8, 0x20> raw;
337 }; 337 };
338 338
339 std::array<float, 4> GetBorderColor() const noexcept;
340
339 float GetMaxAnisotropy() const { 341 float GetMaxAnisotropy() const {
340 const u32 min_value = [] { 342 const u32 min_value = [] {
341 switch (static_cast<Anisotropy>(Settings::values.max_anisotropy)) { 343 switch (static_cast<Anisotropy>(Settings::values.max_anisotropy)) {
@@ -368,15 +370,6 @@ struct TSCEntry {
368 constexpr u32 mask = 1U << (13 - 1); 370 constexpr u32 mask = 1U << (13 - 1);
369 return static_cast<float>(static_cast<s32>((mip_lod_bias ^ mask) - mask)) / 256.0f; 371 return static_cast<float>(static_cast<s32>((mip_lod_bias ^ mask) - mask)) / 256.0f;
370 } 372 }
371
372 std::array<float, 4> GetBorderColor() const {
373 if (srgb_conversion) {
374 return {static_cast<float>(srgb_border_color_r) / 255.0f,
375 static_cast<float>(srgb_border_color_g) / 255.0f,
376 static_cast<float>(srgb_border_color_b) / 255.0f, border_color[3]};
377 }
378 return border_color;
379 }
380}; 373};
381static_assert(sizeof(TSCEntry) == 0x20, "TSCEntry has wrong size"); 374static_assert(sizeof(TSCEntry) == 0x20, "TSCEntry has wrong size");
382 375