summaryrefslogtreecommitdiff
path: root/src/video_core/textures
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2019-03-09 03:12:28 -0300
committerGravatar ReinUsesLisp2019-03-09 04:35:57 -0300
commita0be7b3b92f8a38d8d793f8f61f6337d212e899c (patch)
tree6a70b231938be0becadd001082fdd682477e5d26 /src/video_core/textures
parentMerge pull request #2210 from lioncash/optional (diff)
downloadyuzu-a0be7b3b92f8a38d8d793f8f61f6337d212e899c.tar.gz
yuzu-a0be7b3b92f8a38d8d793f8f61f6337d212e899c.tar.xz
yuzu-a0be7b3b92f8a38d8d793f8f61f6337d212e899c.zip
gl_rasterizer: Encapsulate sampler queries into methods
Diffstat (limited to 'src/video_core/textures')
-rw-r--r--src/video_core/textures/texture.h34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/video_core/textures/texture.h b/src/video_core/textures/texture.h
index 0fc5530f2..8c278c0e2 100644
--- a/src/video_core/textures/texture.h
+++ b/src/video_core/textures/texture.h
@@ -4,6 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <array>
7#include "common/assert.h" 8#include "common/assert.h"
8#include "common/bit_field.h" 9#include "common/bit_field.h"
9#include "common/common_funcs.h" 10#include "common/common_funcs.h"
@@ -293,7 +294,7 @@ struct TSCEntry {
293 union { 294 union {
294 BitField<0, 2, TextureFilter> mag_filter; 295 BitField<0, 2, TextureFilter> mag_filter;
295 BitField<4, 2, TextureFilter> min_filter; 296 BitField<4, 2, TextureFilter> min_filter;
296 BitField<6, 2, TextureMipmapFilter> mip_filter; 297 BitField<6, 2, TextureMipmapFilter> mipmap_filter;
297 BitField<9, 1, u32> cubemap_interface_filtering; 298 BitField<9, 1, u32> cubemap_interface_filtering;
298 BitField<12, 13, u32> mip_lod_bias; 299 BitField<12, 13, u32> mip_lod_bias;
299 }; 300 };
@@ -306,10 +307,33 @@ struct TSCEntry {
306 BitField<12, 8, u32> srgb_border_color_g; 307 BitField<12, 8, u32> srgb_border_color_g;
307 BitField<20, 8, u32> srgb_border_color_b; 308 BitField<20, 8, u32> srgb_border_color_b;
308 }; 309 };
309 float border_color_r; 310 std::array<f32, 4> border_color;
310 float border_color_g; 311
311 float border_color_b; 312 float GetMaxAnisotropy() const {
312 float border_color_a; 313 return static_cast<float>(1U << max_anisotropy);
314 }
315
316 float GetMinLod() const {
317 return static_cast<float>(min_lod_clamp) / 256.0f;
318 }
319
320 float GetMaxLod() const {
321 return static_cast<float>(max_lod_clamp) / 256.0f;
322 }
323
324 float GetLodBias() const {
325 // Sign extend the 13-bit value.
326 constexpr u32 mask = 1U << (13 - 1);
327 return static_cast<float>((mip_lod_bias ^ mask) - mask) / 256.0f;
328 }
329
330 std::array<float, 4> GetBorderColor() const {
331 if (srgb_conversion) {
332 return {srgb_border_color_r / 255.0f, srgb_border_color_g / 255.0f,
333 srgb_border_color_b / 255.0f, border_color[3]};
334 }
335 return border_color;
336 }
313}; 337};
314static_assert(sizeof(TSCEntry) == 0x20, "TSCEntry has wrong size"); 338static_assert(sizeof(TSCEntry) == 0x20, "TSCEntry has wrong size");
315 339