Make crt-royale compile on GLES (#580)

GLES rejected every pass. The sources define "const" away, so their
global "static const" values become globals initialised from other
globals, which ESSL doesn't allow, and they lean on desktop GLSL's
implicit int to float conversions and default float precision.

Turn the affected globals into typed macros, convert the ints
explicitly, and give the passes a default precision on GLES only.
Desktop GL compiles the same as before.
This commit is contained in:
Chris Dixon authored and GitHub committed 2026-10-23 08:51:10 -05:00
1 parent 30bb6f3a05
commit 61ec83e64c
21 files changed
+474 -505

No files matched your search

@@ -1,4 +1,8 @@
#version 130
#ifdef GL_ES
precision highp float;
precision highp int;
#endif
///////////////////////////////// MIT LICENSE ////////////////////////////////
@@ -1,4 +1,8 @@
#version 130
#ifdef GL_ES
precision highp float;
precision highp int;
#endif
///////////////////////////////// MIT LICENSE ////////////////////////////////
@@ -1,4 +1,8 @@
#version 130
#ifdef GL_ES
precision highp float;
precision highp int;
#endif
///////////////////////////////// MIT LICENSE ////////////////////////////////
@@ -1,4 +1,8 @@
#version 130
#ifdef GL_ES
precision highp float;
precision highp int;
#endif
///////////////////////////////// MIT LICENSE ////////////////////////////////
@@ -1,4 +1,8 @@
#version 130
#ifdef GL_ES
precision highp float;
precision highp int;
#endif
///////////////////////////////// MIT LICENSE ////////////////////////////////
@@ -1,4 +1,8 @@
#version 130
#ifdef GL_ES
precision highp float;
precision highp int;
#endif
///////////////////////////////// MIT LICENSE ////////////////////////////////
@@ -1,4 +1,8 @@
#version 130
#ifdef GL_ES
precision highp float;
precision highp int;
#endif
#define INTEGRATED_GRAPHICS_COMPATIBILITY_MODE
#define PHOSPHOR_BLOOM_FAKE
@@ -557,9 +561,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
// TileableLinearShadowMaskEDP*.png
#ifdef PHOSPHOR_MASK_GRILLE14
static const float mask_grille_avg_color = mask_grille14_avg_color;
#define mask_grille_avg_color float(mask_grille14_avg_color)
#else
static const float mask_grille_avg_color = mask_grille15_avg_color;
#define mask_grille_avg_color float(mask_grille15_avg_color)
#endif
@@ -619,10 +623,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Mode 2 (4x4 Gaussian resize) won't work, and mode 1 (3x3 blur) is
// inferior in most cases, so replace 2.0 with 0.0:
static const float bloom_approx_filter =
bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static)
#else
static const float bloom_approx_filter = bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static)
#endif
// Disable slow runtime paths if static parameters are used. Most of these
@@ -737,12 +740,12 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#ifdef ANISOTROPIC_RESAMPLING_COMPAT_TEX2DLOD
// TODO: Take advantage of this!
#define PHOSPHOR_MASK_RESIZE_MIPMAPPED_LUT
static const float2 mask_resize_src_lut_size = mask_texture_large_size;
#define mask_resize_src_lut_size float2(mask_texture_large_size)
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
@@ -784,27 +787,25 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Anisotropic filtering adds about 0.5 to the pixel border:
#ifndef ANISOTROPIC_TILING_COMPAT_TEX2DLOD_FAMILY
static const float max_aniso_pixel_border = max_aa_base_pixel_border + 0.5;
#define max_aniso_pixel_border float(max_aa_base_pixel_border + 0.5)
#else
static const float max_aniso_pixel_border = max_aa_base_pixel_border;
#define max_aniso_pixel_border float(max_aa_base_pixel_border)
#endif
// Fixing discontinuities adds 1.0 more to the pixel border:
#ifdef ANISOTROPIC_TILING_COMPAT_FIX_DISCONTINUITIES
static const float max_tiled_pixel_border = max_aniso_pixel_border + 1.0;
#define max_tiled_pixel_border float(max_aniso_pixel_border + 1.0)
#else
static const float max_tiled_pixel_border = max_aniso_pixel_border;
#define max_tiled_pixel_border float(max_aniso_pixel_border)
#endif
// Convert the pixel border to an integer texel border. Assume same-pass
// curvature about triples the texel frequency:
#ifdef GEOMETRY_EARLY
static const float max_mask_texel_border =
ceil(max_tiled_pixel_border * 3.0);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border * 3.0))
#else
static const float max_mask_texel_border = ceil(max_tiled_pixel_border);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border))
#endif
// Convert the texel border to a tile border using worst-case assumptions:
static const float max_mask_tile_border = max_mask_texel_border/
(mask_min_allowed_triad_size * mask_triads_per_tile);
#define max_mask_tile_border float(max_mask_texel_border/ (mask_min_allowed_triad_size * mask_triads_per_tile))
// Finally, set the number of resized tiles to render to MASK_RESIZE, and set
// the starting texel (inside borders) for sampling it.
@@ -828,10 +829,8 @@ static const float max_mask_tile_border = max_mask_texel_border/
// mask_resize_viewport_scale. This limits the maximum final triad size.
// Estimate the minimum number of triads we can split the screen into in each
// dimension (we'll be as correct as mask_resize_viewport_scale is):
static const float mask_resize_num_triads =
mask_resize_num_tiles * mask_triads_per_tile;
static const float2 min_allowed_viewport_triads =
float2(mask_resize_num_triads) / mask_resize_viewport_scale;
#define mask_resize_num_triads float(mask_resize_num_tiles * mask_triads_per_tile)
#define min_allowed_viewport_triads float2(float2(mask_resize_num_triads) / mask_resize_viewport_scale)
//////////////////////// COMMON MATHEMATICAL CONSTANTS ///////////////////////
@@ -1330,7 +1329,7 @@ inline float get_mask_sample_mode()
#endif
// Users might want to know if bilinear filtering will be gamma-correct:
static const bool gamma_aware_bilinear = !linearize_input;
#define gamma_aware_bilinear bool(!linearize_input)
////////////////////// COLOR ENCODING/DECODING FUNCTIONS /////////////////////
@@ -1471,10 +1470,10 @@ inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords)
{ return decode_input(COMPAT_TEXTURE(tex, tex_coords.xy)); }
inline float4 tex2D_linearize(const sampler2D tex, float2 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords, float(texel_off))); }
inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
//inline float4 tex2D_linearize(const sampler2D tex, const float2 tex_coords, const float2 dx, const float2 dy)
//{ return decode_input(COMPAT_TEXTURE(tex, tex_coords, dx, dy)); }
@@ -1507,7 +1506,7 @@ inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords)
{ return decode_input(textureLod(tex, tex_coords.xy, 0.0)); }
inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
/*
// tex2Dproj:
inline float4 tex2Dproj_linearize(const sampler2D tex, const float3 tex_coords)
@@ -1625,7 +1624,7 @@ inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, f
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, 0.0), gamma); }
inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, int texel_off, float3 gamma)
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, texel_off), gamma); }
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, float(texel_off)), gamma); }
#endif // GAMMA_MANAGEMENT_H
@@ -2780,7 +2779,7 @@ uniform COMPAT_PRECISION vec2 PassPrev2InputSize;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
COMPAT_PRECISION float bloom_approx_scale_x = OutputSize.x / TextureSize.y;
#define bloom_approx_scale_x (OutputSize.x / TextureSize.y)
const COMPAT_PRECISION float max_viewport_size_x = 1080.0*1024.0*(4.0/3.0);
void main()
@@ -2877,7 +2876,7 @@ COMPAT_VARYING vec2 tex_uv_to_pixel_scale;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
COMPAT_PRECISION float bloom_approx_scale_x = OutputSize.x / TextureSize.y;
#define bloom_approx_scale_x (OutputSize.x / TextureSize.y)
const COMPAT_PRECISION float max_viewport_size_x = 1080.0*1024.0*(4.0/3.0);
////////////////////////////// FRAGMENT INCLUDES //////////////////////////////
@@ -1,4 +1,8 @@
#version 130
#ifdef GL_ES
precision highp float;
precision highp int;
#endif
#define PHOSPHOR_BLOOM_FAKE
@@ -556,9 +560,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
// TileableLinearShadowMaskEDP*.png
#ifdef PHOSPHOR_MASK_GRILLE14
static const float mask_grille_avg_color = mask_grille14_avg_color;
#define mask_grille_avg_color float(mask_grille14_avg_color)
#else
static const float mask_grille_avg_color = mask_grille15_avg_color;
#define mask_grille_avg_color float(mask_grille15_avg_color)
#endif
@@ -618,10 +622,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Mode 2 (4x4 Gaussian resize) won't work, and mode 1 (3x3 blur) is
// inferior in most cases, so replace 2.0 with 0.0:
static const float bloom_approx_filter =
bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static)
#else
static const float bloom_approx_filter = bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static)
#endif
// Disable slow runtime paths if static parameters are used. Most of these
@@ -736,12 +739,12 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#ifdef ANISOTROPIC_RESAMPLING_COMPAT_TEX2DLOD
// TODO: Take advantage of this!
#define PHOSPHOR_MASK_RESIZE_MIPMAPPED_LUT
static const float2 mask_resize_src_lut_size = mask_texture_large_size;
#define mask_resize_src_lut_size float2(mask_texture_large_size)
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
@@ -783,27 +786,25 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Anisotropic filtering adds about 0.5 to the pixel border:
#ifndef ANISOTROPIC_TILING_COMPAT_TEX2DLOD_FAMILY
static const float max_aniso_pixel_border = max_aa_base_pixel_border + 0.5;
#define max_aniso_pixel_border float(max_aa_base_pixel_border + 0.5)
#else
static const float max_aniso_pixel_border = max_aa_base_pixel_border;
#define max_aniso_pixel_border float(max_aa_base_pixel_border)
#endif
// Fixing discontinuities adds 1.0 more to the pixel border:
#ifdef ANISOTROPIC_TILING_COMPAT_FIX_DISCONTINUITIES
static const float max_tiled_pixel_border = max_aniso_pixel_border + 1.0;
#define max_tiled_pixel_border float(max_aniso_pixel_border + 1.0)
#else
static const float max_tiled_pixel_border = max_aniso_pixel_border;
#define max_tiled_pixel_border float(max_aniso_pixel_border)
#endif
// Convert the pixel border to an integer texel border. Assume same-pass
// curvature about triples the texel frequency:
#ifdef GEOMETRY_EARLY
static const float max_mask_texel_border =
ceil(max_tiled_pixel_border * 3.0);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border * 3.0))
#else
static const float max_mask_texel_border = ceil(max_tiled_pixel_border);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border))
#endif
// Convert the texel border to a tile border using worst-case assumptions:
static const float max_mask_tile_border = max_mask_texel_border/
(mask_min_allowed_triad_size * mask_triads_per_tile);
#define max_mask_tile_border float(max_mask_texel_border/ (mask_min_allowed_triad_size * mask_triads_per_tile))
// Finally, set the number of resized tiles to render to MASK_RESIZE, and set
// the starting texel (inside borders) for sampling it.
@@ -827,10 +828,8 @@ static const float max_mask_tile_border = max_mask_texel_border/
// mask_resize_viewport_scale. This limits the maximum final triad size.
// Estimate the minimum number of triads we can split the screen into in each
// dimension (we'll be as correct as mask_resize_viewport_scale is):
static const float mask_resize_num_triads =
mask_resize_num_tiles * mask_triads_per_tile;
static const float2 min_allowed_viewport_triads =
float2(mask_resize_num_triads) / mask_resize_viewport_scale;
#define mask_resize_num_triads float(mask_resize_num_tiles * mask_triads_per_tile)
#define min_allowed_viewport_triads float2(float2(mask_resize_num_triads) / mask_resize_viewport_scale)
//////////////////////// COMMON MATHEMATICAL CONSTANTS ///////////////////////
@@ -1329,7 +1328,7 @@ inline float get_mask_sample_mode()
#endif
// Users might want to know if bilinear filtering will be gamma-correct:
static const bool gamma_aware_bilinear = !linearize_input;
#define gamma_aware_bilinear bool(!linearize_input)
////////////////////// COLOR ENCODING/DECODING FUNCTIONS /////////////////////
@@ -1470,10 +1469,10 @@ inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords)
{ return decode_input(COMPAT_TEXTURE(tex, tex_coords.xy)); }
inline float4 tex2D_linearize(const sampler2D tex, float2 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords, float(texel_off))); }
inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
//inline float4 tex2D_linearize(const sampler2D tex, const float2 tex_coords, const float2 dx, const float2 dy)
//{ return decode_input(COMPAT_TEXTURE(tex, tex_coords, dx, dy)); }
@@ -1506,7 +1505,7 @@ inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords)
{ return decode_input(textureLod(tex, tex_coords.xy, 0.0)); }
inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
/*
// tex2Dproj:
inline float4 tex2Dproj_linearize(const sampler2D tex, const float3 tex_coords)
@@ -1624,7 +1623,7 @@ inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, f
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, 0.0), gamma); }
inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, int texel_off, float3 gamma)
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, texel_off), gamma); }
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, float(texel_off)), gamma); }
#endif // GAMMA_MANAGEMENT_H
@@ -2779,7 +2778,7 @@ uniform COMPAT_PRECISION vec2 PassPrev2InputSize;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
COMPAT_PRECISION float bloom_approx_scale_x = OutputSize.x / TextureSize.y;
#define bloom_approx_scale_x (OutputSize.x / TextureSize.y)
const COMPAT_PRECISION float max_viewport_size_x = 1080.0*1024.0*(4.0/3.0);
void main()
@@ -2876,7 +2875,7 @@ COMPAT_VARYING vec2 tex_uv_to_pixel_scale;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
COMPAT_PRECISION float bloom_approx_scale_x = OutputSize.x / TextureSize.y;
#define bloom_approx_scale_x (OutputSize.x / TextureSize.y)
const COMPAT_PRECISION float max_viewport_size_x = 1080.0*1024.0*(4.0/3.0);
////////////////////////////// FRAGMENT INCLUDES //////////////////////////////
@@ -1,4 +1,8 @@
#version 130
#ifdef GL_ES
precision highp float;
precision highp int;
#endif
///////////////////////////// GPL LICENSE NOTICE /////////////////////////////
@@ -554,9 +558,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
// TileableLinearShadowMaskEDP*.png
#ifdef PHOSPHOR_MASK_GRILLE14
static const float mask_grille_avg_color = mask_grille14_avg_color;
#define mask_grille_avg_color float(mask_grille14_avg_color)
#else
static const float mask_grille_avg_color = mask_grille15_avg_color;
#define mask_grille_avg_color float(mask_grille15_avg_color)
#endif
@@ -616,10 +620,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Mode 2 (4x4 Gaussian resize) won't work, and mode 1 (3x3 blur) is
// inferior in most cases, so replace 2.0 with 0.0:
static const float bloom_approx_filter =
bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static)
#else
static const float bloom_approx_filter = bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static)
#endif
// Disable slow runtime paths if static parameters are used. Most of these
@@ -734,12 +737,12 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#ifdef ANISOTROPIC_RESAMPLING_COMPAT_TEX2DLOD
// TODO: Take advantage of this!
#define PHOSPHOR_MASK_RESIZE_MIPMAPPED_LUT
static const float2 mask_resize_src_lut_size = mask_texture_large_size;
#define mask_resize_src_lut_size float2(mask_texture_large_size)
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
@@ -781,27 +784,25 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Anisotropic filtering adds about 0.5 to the pixel border:
#ifndef ANISOTROPIC_TILING_COMPAT_TEX2DLOD_FAMILY
static const float max_aniso_pixel_border = max_aa_base_pixel_border + 0.5;
#define max_aniso_pixel_border float(max_aa_base_pixel_border + 0.5)
#else
static const float max_aniso_pixel_border = max_aa_base_pixel_border;
#define max_aniso_pixel_border float(max_aa_base_pixel_border)
#endif
// Fixing discontinuities adds 1.0 more to the pixel border:
#ifdef ANISOTROPIC_TILING_COMPAT_FIX_DISCONTINUITIES
static const float max_tiled_pixel_border = max_aniso_pixel_border + 1.0;
#define max_tiled_pixel_border float(max_aniso_pixel_border + 1.0)
#else
static const float max_tiled_pixel_border = max_aniso_pixel_border;
#define max_tiled_pixel_border float(max_aniso_pixel_border)
#endif
// Convert the pixel border to an integer texel border. Assume same-pass
// curvature about triples the texel frequency:
#ifdef GEOMETRY_EARLY
static const float max_mask_texel_border =
ceil(max_tiled_pixel_border * 3.0);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border * 3.0))
#else
static const float max_mask_texel_border = ceil(max_tiled_pixel_border);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border))
#endif
// Convert the texel border to a tile border using worst-case assumptions:
static const float max_mask_tile_border = max_mask_texel_border/
(mask_min_allowed_triad_size * mask_triads_per_tile);
#define max_mask_tile_border float(max_mask_texel_border/ (mask_min_allowed_triad_size * mask_triads_per_tile))
// Finally, set the number of resized tiles to render to MASK_RESIZE, and set
// the starting texel (inside borders) for sampling it.
@@ -825,10 +826,8 @@ static const float max_mask_tile_border = max_mask_texel_border/
// mask_resize_viewport_scale. This limits the maximum final triad size.
// Estimate the minimum number of triads we can split the screen into in each
// dimension (we'll be as correct as mask_resize_viewport_scale is):
static const float mask_resize_num_triads =
mask_resize_num_tiles * mask_triads_per_tile;
static const float2 min_allowed_viewport_triads =
float2(mask_resize_num_triads) / mask_resize_viewport_scale;
#define mask_resize_num_triads float(mask_resize_num_tiles * mask_triads_per_tile)
#define min_allowed_viewport_triads float2(float2(mask_resize_num_triads) / mask_resize_viewport_scale)
//////////////////////// COMMON MATHEMATICAL CONSTANTS ///////////////////////
@@ -1327,7 +1326,7 @@ inline float get_mask_sample_mode()
#endif
// Users might want to know if bilinear filtering will be gamma-correct:
static const bool gamma_aware_bilinear = !linearize_input;
#define gamma_aware_bilinear bool(!linearize_input)
////////////////////// COLOR ENCODING/DECODING FUNCTIONS /////////////////////
@@ -1468,10 +1467,10 @@ inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords)
{ return decode_input(COMPAT_TEXTURE(tex, tex_coords.xy)); }
inline float4 tex2D_linearize(const sampler2D tex, float2 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords, float(texel_off))); }
inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
//inline float4 tex2D_linearize(const sampler2D tex, const float2 tex_coords, const float2 dx, const float2 dy)
//{ return decode_input(COMPAT_TEXTURE(tex, tex_coords, dx, dy)); }
@@ -1504,7 +1503,7 @@ inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords)
{ return decode_input(textureLod(tex, tex_coords.xy, 0.0)); }
inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
/*
// tex2Dproj:
inline float4 tex2Dproj_linearize(const sampler2D tex, const float3 tex_coords)
@@ -1622,7 +1621,7 @@ inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, f
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, 0.0), gamma); }
inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, int texel_off, float3 gamma)
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, texel_off), gamma); }
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, float(texel_off)), gamma); }
#endif // GAMMA_MANAGEMENT_H
@@ -2777,7 +2776,7 @@ uniform COMPAT_PRECISION vec2 PassPrev2InputSize;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
COMPAT_PRECISION float bloom_approx_scale_x = OutputSize.x / TextureSize.y;
#define bloom_approx_scale_x (OutputSize.x / TextureSize.y)
const COMPAT_PRECISION float max_viewport_size_x = 1080.0*1024.0*(4.0/3.0);
void main()
@@ -2874,7 +2873,7 @@ COMPAT_VARYING vec2 tex_uv_to_pixel_scale;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
COMPAT_PRECISION float bloom_approx_scale_x = OutputSize.x / TextureSize.y;
#define bloom_approx_scale_x (OutputSize.x / TextureSize.y)
const COMPAT_PRECISION float max_viewport_size_x = 1080.0*1024.0*(4.0/3.0);
////////////////////////////// FRAGMENT INCLUDES //////////////////////////////
@@ -1,4 +1,8 @@
#version 130
#ifdef GL_ES
precision highp float;
precision highp int;
#endif
///////////////////////////// GPL LICENSE NOTICE /////////////////////////////
@@ -529,9 +533,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
// TileableLinearShadowMaskEDP*.png
#ifdef PHOSPHOR_MASK_GRILLE14
static const float mask_grille_avg_color = mask_grille14_avg_color;
#define mask_grille_avg_color float(mask_grille14_avg_color)
#else
static const float mask_grille_avg_color = mask_grille15_avg_color;
#define mask_grille_avg_color float(mask_grille15_avg_color)
#endif
@@ -591,10 +595,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Mode 2 (4x4 Gaussian resize) won't work, and mode 1 (3x3 blur) is
// inferior in most cases, so replace 2.0 with 0.0:
static const float bloom_approx_filter =
bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static)
#else
static const float bloom_approx_filter = bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static)
#endif
// Disable slow runtime paths if static parameters are used. Most of these
@@ -709,12 +712,12 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#ifdef ANISOTROPIC_RESAMPLING_COMPAT_TEX2DLOD
// TODO: Take advantage of this!
#define PHOSPHOR_MASK_RESIZE_MIPMAPPED_LUT
static const float2 mask_resize_src_lut_size = mask_texture_large_size;
#define mask_resize_src_lut_size float2(mask_texture_large_size)
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
@@ -756,27 +759,25 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Anisotropic filtering adds about 0.5 to the pixel border:
#ifndef ANISOTROPIC_TILING_COMPAT_TEX2DLOD_FAMILY
static const float max_aniso_pixel_border = max_aa_base_pixel_border + 0.5;
#define max_aniso_pixel_border float(max_aa_base_pixel_border + 0.5)
#else
static const float max_aniso_pixel_border = max_aa_base_pixel_border;
#define max_aniso_pixel_border float(max_aa_base_pixel_border)
#endif
// Fixing discontinuities adds 1.0 more to the pixel border:
#ifdef ANISOTROPIC_TILING_COMPAT_FIX_DISCONTINUITIES
static const float max_tiled_pixel_border = max_aniso_pixel_border + 1.0;
#define max_tiled_pixel_border float(max_aniso_pixel_border + 1.0)
#else
static const float max_tiled_pixel_border = max_aniso_pixel_border;
#define max_tiled_pixel_border float(max_aniso_pixel_border)
#endif
// Convert the pixel border to an integer texel border. Assume same-pass
// curvature about triples the texel frequency:
#ifdef GEOMETRY_EARLY
static const float max_mask_texel_border =
ceil(max_tiled_pixel_border * 3.0);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border * 3.0))
#else
static const float max_mask_texel_border = ceil(max_tiled_pixel_border);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border))
#endif
// Convert the texel border to a tile border using worst-case assumptions:
static const float max_mask_tile_border = max_mask_texel_border/
(mask_min_allowed_triad_size * mask_triads_per_tile);
#define max_mask_tile_border float(max_mask_texel_border/ (mask_min_allowed_triad_size * mask_triads_per_tile))
// Finally, set the number of resized tiles to render to MASK_RESIZE, and set
// the starting texel (inside borders) for sampling it.
@@ -800,10 +801,8 @@ static const float max_mask_tile_border = max_mask_texel_border/
// mask_resize_viewport_scale. This limits the maximum final triad size.
// Estimate the minimum number of triads we can split the screen into in each
// dimension (we'll be as correct as mask_resize_viewport_scale is):
static const float mask_resize_num_triads =
mask_resize_num_tiles * mask_triads_per_tile;
static const float2 min_allowed_viewport_triads =
float2(mask_resize_num_triads) / mask_resize_viewport_scale;
#define mask_resize_num_triads float(mask_resize_num_tiles * mask_triads_per_tile)
#define min_allowed_viewport_triads float2(float2(mask_resize_num_triads) / mask_resize_viewport_scale)
//////////////////////// COMMON MATHEMATICAL CONSTANTS ///////////////////////
@@ -1338,7 +1337,7 @@ inline float get_mask_sample_mode()
#endif
// Users might want to know if bilinear filtering will be gamma-correct:
static const bool gamma_aware_bilinear = !linearize_input;
#define gamma_aware_bilinear bool(!linearize_input)
////////////////////// COLOR ENCODING/DECODING FUNCTIONS /////////////////////
@@ -1479,10 +1478,10 @@ inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords)
{ return decode_input(COMPAT_TEXTURE(tex, tex_coords.xy)); }
inline float4 tex2D_linearize(const sampler2D tex, float2 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords, float(texel_off))); }
inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
//inline float4 tex2D_linearize(const sampler2D tex, const float2 tex_coords, const float2 dx, const float2 dy)
//{ return decode_input(COMPAT_TEXTURE(tex, tex_coords, dx, dy)); }
@@ -1515,7 +1514,7 @@ inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords)
{ return decode_input(textureLod(tex, tex_coords.xy, 0.0)); }
inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
/*
// tex2Dproj:
inline float4 tex2Dproj_linearize(const sampler2D tex, const float3 tex_coords)
@@ -1633,7 +1632,7 @@ inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, f
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, 0.0), gamma); }
inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, int texel_off, float3 gamma)
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, texel_off), gamma); }
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, float(texel_off)), gamma); }
#endif // GAMMA_MANAGEMENT_H
@@ -1692,17 +1691,13 @@ inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, i
// The larger the resized tile, the fewer samples we'll need for downsizing.
// See if we can get a static min tile size > mask_min_allowed_tile_size:
static const float mask_min_allowed_tile_size = ceil(
mask_min_allowed_triad_size * mask_triads_per_tile);
static const float mask_min_expected_tile_size =
mask_min_allowed_tile_size;
#define mask_min_allowed_tile_size float(ceil( mask_min_allowed_triad_size * mask_triads_per_tile))
#define mask_min_expected_tile_size float(mask_min_allowed_tile_size)
// Limit the number of sinc resize taps by the maximum minification factor:
static const float pi_over_lobes = pi/mask_sinc_lobes;
static const float max_sinc_resize_samples_float = 2.0 * mask_sinc_lobes *
mask_resize_src_lut_size.x/mask_min_expected_tile_size;
#define pi_over_lobes float(pi/mask_sinc_lobes)
#define max_sinc_resize_samples_float float(2.0 * mask_sinc_lobes * mask_resize_src_lut_size.x/mask_min_expected_tile_size)
// Vectorized loops sample in multiples of 4. Round up to be safe:
static const float max_sinc_resize_samples_m4 = ceil(
max_sinc_resize_samples_float * 0.25) * 4.0;
#define max_sinc_resize_samples_m4 float(ceil( max_sinc_resize_samples_float * 0.25) * 4.0)
///////////////////////// RESAMPLING FUNCTION HELPERS ////////////////////////
@@ -1895,7 +1890,7 @@ float3 downsample_vertical_sinc_tiled(const sampler2D tex,
static const float input_tiles_per_texture_r = 1.0/tile_size_uv_r;
// true = vertical resize:
const float2 first_texel_tile_r_and_dist = get_first_texel_tile_uv_and_dist(
tex_uv, tex_size, dr, input_tiles_per_texture_r, samples, true);
tex_uv, tex_size, dr, input_tiles_per_texture_r, float(samples), true);
const float4 first_texel_tile_uv_rrrr = first_texel_tile_r_and_dist.xxxx;
const float4 first_dist_unscaled = first_texel_tile_r_and_dist.yyyy;
// Get the tile sample offset:
@@ -2000,7 +1995,7 @@ float3 downsample_horizontal_sinc_tiled(const sampler2D tex,
const float input_tiles_per_texture_r = 1.0/tile_size_uv_r;
// false = horizontal resize:
const float2 first_texel_tile_r_and_dist = get_first_texel_tile_uv_and_dist(
tex_uv, tex_size, dr, input_tiles_per_texture_r, samples, false);
tex_uv, tex_size, dr, input_tiles_per_texture_r, float(samples), false);
const float4 first_texel_tile_uv_rrrr = first_texel_tile_r_and_dist.xxxx;
const float4 first_dist_unscaled = first_texel_tile_r_and_dist.yyyy;
// Get the tile sample offset:
@@ -3477,7 +3472,7 @@ uniform COMPAT_PRECISION vec2 BRIGHTPASSvideo_size;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
float bloom_approx_scale_x = OutputSize.x / TextureSize.y;
#define bloom_approx_scale_x (OutputSize.x / TextureSize.y)
const float max_viewport_size_x = 1080.0*1024.0*(4.0/3.0);
const float bloom_diff_thresh_ = 1.0/256.0;
@@ -3582,7 +3577,7 @@ COMPAT_VARYING float bloom_sigma_runtime;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
float bloom_approx_scale_x = OutputSize.x / TextureSize.y;
#define bloom_approx_scale_x (OutputSize.x / TextureSize.y)
const float max_viewport_size_x = 1080.0*1024.0*(4.0/3.0);
const float bloom_diff_thresh_ = 1.0/256.0;
@@ -1,4 +1,8 @@
#version 130
#ifdef GL_ES
precision highp float;
precision highp int;
#endif
///////////////////////////// GPL LICENSE NOTICE /////////////////////////////
@@ -519,9 +523,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
// TileableLinearShadowMaskEDP*.png
#ifdef PHOSPHOR_MASK_GRILLE14
static const float mask_grille_avg_color = mask_grille14_avg_color;
#define mask_grille_avg_color float(mask_grille14_avg_color)
#else
static const float mask_grille_avg_color = mask_grille15_avg_color;
#define mask_grille_avg_color float(mask_grille15_avg_color)
#endif
@@ -581,10 +585,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Mode 2 (4x4 Gaussian resize) won't work, and mode 1 (3x3 blur) is
// inferior in most cases, so replace 2.0 with 0.0:
static const float bloom_approx_filter =
bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static)
#else
static const float bloom_approx_filter = bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static)
#endif
// Disable slow runtime paths if static parameters are used. Most of these
@@ -699,12 +702,12 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#ifdef ANISOTROPIC_RESAMPLING_COMPAT_TEX2DLOD
// TODO: Take advantage of this!
#define PHOSPHOR_MASK_RESIZE_MIPMAPPED_LUT
static const float2 mask_resize_src_lut_size = mask_texture_large_size;
#define mask_resize_src_lut_size float2(mask_texture_large_size)
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
@@ -746,27 +749,25 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Anisotropic filtering adds about 0.5 to the pixel border:
#ifndef ANISOTROPIC_TILING_COMPAT_TEX2DLOD_FAMILY
static const float max_aniso_pixel_border = max_aa_base_pixel_border + 0.5;
#define max_aniso_pixel_border float(max_aa_base_pixel_border + 0.5)
#else
static const float max_aniso_pixel_border = max_aa_base_pixel_border;
#define max_aniso_pixel_border float(max_aa_base_pixel_border)
#endif
// Fixing discontinuities adds 1.0 more to the pixel border:
#ifdef ANISOTROPIC_TILING_COMPAT_FIX_DISCONTINUITIES
static const float max_tiled_pixel_border = max_aniso_pixel_border + 1.0;
#define max_tiled_pixel_border float(max_aniso_pixel_border + 1.0)
#else
static const float max_tiled_pixel_border = max_aniso_pixel_border;
#define max_tiled_pixel_border float(max_aniso_pixel_border)
#endif
// Convert the pixel border to an integer texel border. Assume same-pass
// curvature about triples the texel frequency:
#ifdef GEOMETRY_EARLY
static const float max_mask_texel_border =
ceil(max_tiled_pixel_border * 3.0);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border * 3.0))
#else
static const float max_mask_texel_border = ceil(max_tiled_pixel_border);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border))
#endif
// Convert the texel border to a tile border using worst-case assumptions:
static const float max_mask_tile_border = max_mask_texel_border/
(mask_min_allowed_triad_size * mask_triads_per_tile);
#define max_mask_tile_border float(max_mask_texel_border/ (mask_min_allowed_triad_size * mask_triads_per_tile))
// Finally, set the number of resized tiles to render to MASK_RESIZE, and set
// the starting texel (inside borders) for sampling it.
@@ -790,10 +791,8 @@ static const float max_mask_tile_border = max_mask_texel_border/
// mask_resize_viewport_scale. This limits the maximum final triad size.
// Estimate the minimum number of triads we can split the screen into in each
// dimension (we'll be as correct as mask_resize_viewport_scale is):
static const float mask_resize_num_triads =
mask_resize_num_tiles * mask_triads_per_tile;
static const float2 min_allowed_viewport_triads =
float2(mask_resize_num_triads) / mask_resize_viewport_scale;
#define mask_resize_num_triads float(mask_resize_num_tiles * mask_triads_per_tile)
#define min_allowed_viewport_triads float2(float2(mask_resize_num_triads) / mask_resize_viewport_scale)
//////////////////////// COMMON MATHEMATICAL CONSTANTS ///////////////////////
@@ -1328,7 +1327,7 @@ inline float get_mask_sample_mode()
#endif
// Users might want to know if bilinear filtering will be gamma-correct:
static const bool gamma_aware_bilinear = !linearize_input;
#define gamma_aware_bilinear bool(!linearize_input)
////////////////////// COLOR ENCODING/DECODING FUNCTIONS /////////////////////
@@ -1469,10 +1468,10 @@ inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords)
{ return decode_input(COMPAT_TEXTURE(tex, tex_coords.xy)); }
inline float4 tex2D_linearize(const sampler2D tex, float2 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords, float(texel_off))); }
inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
//inline float4 tex2D_linearize(const sampler2D tex, const float2 tex_coords, const float2 dx, const float2 dy)
//{ return decode_input(COMPAT_TEXTURE(tex, tex_coords, dx, dy)); }
@@ -1505,7 +1504,7 @@ inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords)
{ return decode_input(textureLod(tex, tex_coords.xy, 0.0)); }
inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
/*
// tex2Dproj:
inline float4 tex2Dproj_linearize(const sampler2D tex, const float3 tex_coords)
@@ -1623,7 +1622,7 @@ inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, f
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, 0.0), gamma); }
inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, int texel_off, float3 gamma)
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, texel_off), gamma); }
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, float(texel_off)), gamma); }
#endif // GAMMA_MANAGEMENT_H
@@ -1682,17 +1681,13 @@ inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, i
// The larger the resized tile, the fewer samples we'll need for downsizing.
// See if we can get a static min tile size > mask_min_allowed_tile_size:
static const float mask_min_allowed_tile_size = ceil(
mask_min_allowed_triad_size * mask_triads_per_tile);
static const float mask_min_expected_tile_size =
mask_min_allowed_tile_size;
#define mask_min_allowed_tile_size float(ceil( mask_min_allowed_triad_size * mask_triads_per_tile))
#define mask_min_expected_tile_size float(mask_min_allowed_tile_size)
// Limit the number of sinc resize taps by the maximum minification factor:
static const float pi_over_lobes = pi/mask_sinc_lobes;
static const float max_sinc_resize_samples_float = 2.0 * mask_sinc_lobes *
mask_resize_src_lut_size.x/mask_min_expected_tile_size;
#define pi_over_lobes float(pi/mask_sinc_lobes)
#define max_sinc_resize_samples_float float(2.0 * mask_sinc_lobes * mask_resize_src_lut_size.x/mask_min_expected_tile_size)
// Vectorized loops sample in multiples of 4. Round up to be safe:
static const float max_sinc_resize_samples_m4 = ceil(
max_sinc_resize_samples_float * 0.25) * 4.0;
#define max_sinc_resize_samples_m4 float(ceil( max_sinc_resize_samples_float * 0.25) * 4.0)
///////////////////////// RESAMPLING FUNCTION HELPERS ////////////////////////
@@ -1885,7 +1880,7 @@ float3 downsample_vertical_sinc_tiled(const sampler2D tex,
static const float input_tiles_per_texture_r = 1.0/tile_size_uv_r;
// true = vertical resize:
const float2 first_texel_tile_r_and_dist = get_first_texel_tile_uv_and_dist(
tex_uv, tex_size, dr, input_tiles_per_texture_r, samples, true);
tex_uv, tex_size, dr, input_tiles_per_texture_r, float(samples), true);
const float4 first_texel_tile_uv_rrrr = first_texel_tile_r_and_dist.xxxx;
const float4 first_dist_unscaled = first_texel_tile_r_and_dist.yyyy;
// Get the tile sample offset:
@@ -1990,7 +1985,7 @@ float3 downsample_horizontal_sinc_tiled(const sampler2D tex,
const float input_tiles_per_texture_r = 1.0/tile_size_uv_r;
// false = horizontal resize:
const float2 first_texel_tile_r_and_dist = get_first_texel_tile_uv_and_dist(
tex_uv, tex_size, dr, input_tiles_per_texture_r, samples, false);
tex_uv, tex_size, dr, input_tiles_per_texture_r, float(samples), false);
const float4 first_texel_tile_uv_rrrr = first_texel_tile_r_and_dist.xxxx;
const float4 first_dist_unscaled = first_texel_tile_r_and_dist.yyyy;
// Get the tile sample offset:
@@ -2362,7 +2357,7 @@ uniform COMPAT_PRECISION vec2 InputSize;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
float bloom_approx_scale_x = OutputSize.y / TextureSize.y;
#define bloom_approx_scale_x (OutputSize.y / TextureSize.y)
const float max_viewport_size_x = 1080.0*1024.0*(4.0/3.0);
const float bloom_diff_thresh_ = 1.0/256.0;
@@ -2445,7 +2440,7 @@ COMPAT_VARYING float bloom_sigma_runtime;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
float bloom_approx_scale_x = OutputSize.y / TextureSize.y;
#define bloom_approx_scale_x (OutputSize.y / TextureSize.y)
const float max_viewport_size_x = 1080.0*1024.0*(4.0/3.0);
const float bloom_diff_thresh_ = 1.0/256.0;
@@ -1,4 +1,8 @@
#version 130
#ifdef GL_ES
precision highp float;
precision highp int;
#endif
///////////////////////////// GPL LICENSE NOTICE /////////////////////////////
@@ -527,9 +531,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
// TileableLinearShadowMaskEDP*.png
#ifdef PHOSPHOR_MASK_GRILLE14
static const float mask_grille_avg_color = mask_grille14_avg_color;
#define mask_grille_avg_color float(mask_grille14_avg_color)
#else
static const float mask_grille_avg_color = mask_grille15_avg_color;
#define mask_grille_avg_color float(mask_grille15_avg_color)
#endif
@@ -589,10 +593,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Mode 2 (4x4 Gaussian resize) won't work, and mode 1 (3x3 blur) is
// inferior in most cases, so replace 2.0 with 0.0:
static const float bloom_approx_filter =
bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static)
#else
static const float bloom_approx_filter = bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static)
#endif
// Disable slow runtime paths if static parameters are used. Most of these
@@ -707,12 +710,12 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#ifdef ANISOTROPIC_RESAMPLING_COMPAT_TEX2DLOD
// TODO: Take advantage of this!
#define PHOSPHOR_MASK_RESIZE_MIPMAPPED_LUT
static const float2 mask_resize_src_lut_size = mask_texture_large_size;
#define mask_resize_src_lut_size float2(mask_texture_large_size)
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
@@ -754,27 +757,25 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Anisotropic filtering adds about 0.5 to the pixel border:
#ifndef ANISOTROPIC_TILING_COMPAT_TEX2DLOD_FAMILY
static const float max_aniso_pixel_border = max_aa_base_pixel_border + 0.5;
#define max_aniso_pixel_border float(max_aa_base_pixel_border + 0.5)
#else
static const float max_aniso_pixel_border = max_aa_base_pixel_border;
#define max_aniso_pixel_border float(max_aa_base_pixel_border)
#endif
// Fixing discontinuities adds 1.0 more to the pixel border:
#ifdef ANISOTROPIC_TILING_COMPAT_FIX_DISCONTINUITIES
static const float max_tiled_pixel_border = max_aniso_pixel_border + 1.0;
#define max_tiled_pixel_border float(max_aniso_pixel_border + 1.0)
#else
static const float max_tiled_pixel_border = max_aniso_pixel_border;
#define max_tiled_pixel_border float(max_aniso_pixel_border)
#endif
// Convert the pixel border to an integer texel border. Assume same-pass
// curvature about triples the texel frequency:
#ifdef GEOMETRY_EARLY
static const float max_mask_texel_border =
ceil(max_tiled_pixel_border * 3.0);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border * 3.0))
#else
static const float max_mask_texel_border = ceil(max_tiled_pixel_border);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border))
#endif
// Convert the texel border to a tile border using worst-case assumptions:
static const float max_mask_tile_border = max_mask_texel_border/
(mask_min_allowed_triad_size * mask_triads_per_tile);
#define max_mask_tile_border float(max_mask_texel_border/ (mask_min_allowed_triad_size * mask_triads_per_tile))
// Finally, set the number of resized tiles to render to MASK_RESIZE, and set
// the starting texel (inside borders) for sampling it.
@@ -798,10 +799,8 @@ static const float max_mask_tile_border = max_mask_texel_border/
// mask_resize_viewport_scale. This limits the maximum final triad size.
// Estimate the minimum number of triads we can split the screen into in each
// dimension (we'll be as correct as mask_resize_viewport_scale is):
static const float mask_resize_num_triads =
mask_resize_num_tiles * mask_triads_per_tile;
static const float2 min_allowed_viewport_triads =
float2(mask_resize_num_triads) / mask_resize_viewport_scale;
#define mask_resize_num_triads float(mask_resize_num_tiles * mask_triads_per_tile)
#define min_allowed_viewport_triads float2(float2(mask_resize_num_triads) / mask_resize_viewport_scale)
//////////////////////// COMMON MATHEMATICAL CONSTANTS ///////////////////////
@@ -1336,7 +1335,7 @@ inline float get_mask_sample_mode()
#endif
// Users might want to know if bilinear filtering will be gamma-correct:
static const bool gamma_aware_bilinear = !linearize_input;
#define gamma_aware_bilinear bool(!linearize_input)
////////////////////// COLOR ENCODING/DECODING FUNCTIONS /////////////////////
@@ -1477,10 +1476,10 @@ inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords)
{ return decode_input(COMPAT_TEXTURE(tex, tex_coords.xy)); }
inline float4 tex2D_linearize(const sampler2D tex, float2 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords, float(texel_off))); }
inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
//inline float4 tex2D_linearize(const sampler2D tex, const float2 tex_coords, const float2 dx, const float2 dy)
//{ return decode_input(COMPAT_TEXTURE(tex, tex_coords, dx, dy)); }
@@ -1513,7 +1512,7 @@ inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords)
{ return decode_input(textureLod(tex, tex_coords.xy, 0.0)); }
inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
/*
// tex2Dproj:
inline float4 tex2Dproj_linearize(const sampler2D tex, const float3 tex_coords)
@@ -1631,7 +1630,7 @@ inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, f
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, 0.0), gamma); }
inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, int texel_off, float3 gamma)
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, texel_off), gamma); }
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, float(texel_off)), gamma); }
#endif // GAMMA_MANAGEMENT_H
@@ -1690,17 +1689,13 @@ inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, i
// The larger the resized tile, the fewer samples we'll need for downsizing.
// See if we can get a static min tile size > mask_min_allowed_tile_size:
static const float mask_min_allowed_tile_size = ceil(
mask_min_allowed_triad_size * mask_triads_per_tile);
static const float mask_min_expected_tile_size =
mask_min_allowed_tile_size;
#define mask_min_allowed_tile_size float(ceil( mask_min_allowed_triad_size * mask_triads_per_tile))
#define mask_min_expected_tile_size float(mask_min_allowed_tile_size)
// Limit the number of sinc resize taps by the maximum minification factor:
static const float pi_over_lobes = pi/mask_sinc_lobes;
static const float max_sinc_resize_samples_float = 2.0 * mask_sinc_lobes *
mask_resize_src_lut_size.x/mask_min_expected_tile_size;
#define pi_over_lobes float(pi/mask_sinc_lobes)
#define max_sinc_resize_samples_float float(2.0 * mask_sinc_lobes * mask_resize_src_lut_size.x/mask_min_expected_tile_size)
// Vectorized loops sample in multiples of 4. Round up to be safe:
static const float max_sinc_resize_samples_m4 = ceil(
max_sinc_resize_samples_float * 0.25) * 4.0;
#define max_sinc_resize_samples_m4 float(ceil( max_sinc_resize_samples_float * 0.25) * 4.0)
///////////////////////// RESAMPLING FUNCTION HELPERS ////////////////////////
@@ -1893,7 +1888,7 @@ float3 downsample_vertical_sinc_tiled(const sampler2D tex,
static const float input_tiles_per_texture_r = 1.0/tile_size_uv_r;
// true = vertical resize:
const float2 first_texel_tile_r_and_dist = get_first_texel_tile_uv_and_dist(
tex_uv, tex_size, dr, input_tiles_per_texture_r, samples, true);
tex_uv, tex_size, dr, input_tiles_per_texture_r, float(samples), true);
const float4 first_texel_tile_uv_rrrr = first_texel_tile_r_and_dist.xxxx;
const float4 first_dist_unscaled = first_texel_tile_r_and_dist.yyyy;
// Get the tile sample offset:
@@ -1998,7 +1993,7 @@ float3 downsample_horizontal_sinc_tiled(const sampler2D tex,
const float input_tiles_per_texture_r = 1.0/tile_size_uv_r;
// false = horizontal resize:
const float2 first_texel_tile_r_and_dist = get_first_texel_tile_uv_and_dist(
tex_uv, tex_size, dr, input_tiles_per_texture_r, samples, false);
tex_uv, tex_size, dr, input_tiles_per_texture_r, float(samples), false);
const float4 first_texel_tile_uv_rrrr = first_texel_tile_r_and_dist.xxxx;
const float4 first_dist_unscaled = first_texel_tile_r_and_dist.yyyy;
// Get the tile sample offset:
@@ -3468,7 +3463,7 @@ uniform COMPAT_PRECISION vec2 PassPrev4InputSize;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
float bloom_approx_scale_x = OutputSize.x / TextureSize.y;
#define bloom_approx_scale_x (OutputSize.x / TextureSize.y)
const float max_viewport_size_x = 1080.0*1024.0*(4.0/3.0);
const float bloom_diff_thresh_ = 1.0/256.0;
@@ -3552,7 +3547,7 @@ COMPAT_VARYING float bloom_sigma_runtime;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
float bloom_approx_scale_x = OutputSize.x / TextureSize.y;
#define bloom_approx_scale_x (OutputSize.x / TextureSize.y)
const float max_viewport_size_x = 1080.0*1024.0*(4.0/3.0);
const float bloom_diff_thresh_ = 1.0/256.0;
@@ -1,4 +1,8 @@
#version 130
#ifdef GL_ES
precision highp float;
precision highp int;
#endif
///////////////////////////// GPL LICENSE NOTICE /////////////////////////////
@@ -559,9 +563,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
// TileableLinearShadowMaskEDP*.png
#ifdef PHOSPHOR_MASK_GRILLE14
static const float mask_grille_avg_color = mask_grille14_avg_color;
#define mask_grille_avg_color float(mask_grille14_avg_color)
#else
static const float mask_grille_avg_color = mask_grille15_avg_color;
#define mask_grille_avg_color float(mask_grille15_avg_color)
#endif
@@ -621,10 +625,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Mode 2 (4x4 Gaussian resize) won't work, and mode 1 (3x3 blur) is
// inferior in most cases, so replace 2.0 with 0.0:
static const float bloom_approx_filter =
bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static)
#else
static const float bloom_approx_filter = bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static)
#endif
// Disable slow runtime paths if static parameters are used. Most of these
@@ -739,12 +742,12 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#ifdef ANISOTROPIC_RESAMPLING_COMPAT_TEX2DLOD
// TODO: Take advantage of this!
#define PHOSPHOR_MASK_RESIZE_MIPMAPPED_LUT
static const float2 mask_resize_src_lut_size = mask_texture_large_size;
#define mask_resize_src_lut_size float2(mask_texture_large_size)
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
@@ -786,27 +789,25 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Anisotropic filtering adds about 0.5 to the pixel border:
#ifndef ANISOTROPIC_TILING_COMPAT_TEX2DLOD_FAMILY
static const float max_aniso_pixel_border = max_aa_base_pixel_border + 0.5;
#define max_aniso_pixel_border float(max_aa_base_pixel_border + 0.5)
#else
static const float max_aniso_pixel_border = max_aa_base_pixel_border;
#define max_aniso_pixel_border float(max_aa_base_pixel_border)
#endif
// Fixing discontinuities adds 1.0 more to the pixel border:
#ifdef ANISOTROPIC_TILING_COMPAT_FIX_DISCONTINUITIES
static const float max_tiled_pixel_border = max_aniso_pixel_border + 1.0;
#define max_tiled_pixel_border float(max_aniso_pixel_border + 1.0)
#else
static const float max_tiled_pixel_border = max_aniso_pixel_border;
#define max_tiled_pixel_border float(max_aniso_pixel_border)
#endif
// Convert the pixel border to an integer texel border. Assume same-pass
// curvature about triples the texel frequency:
#ifdef GEOMETRY_EARLY
static const float max_mask_texel_border =
ceil(max_tiled_pixel_border * 3.0);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border * 3.0))
#else
static const float max_mask_texel_border = ceil(max_tiled_pixel_border);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border))
#endif
// Convert the texel border to a tile border using worst-case assumptions:
static const float max_mask_tile_border = max_mask_texel_border/
(mask_min_allowed_triad_size * mask_triads_per_tile);
#define max_mask_tile_border float(max_mask_texel_border/ (mask_min_allowed_triad_size * mask_triads_per_tile))
// Finally, set the number of resized tiles to render to MASK_RESIZE, and set
// the starting texel (inside borders) for sampling it.
@@ -830,10 +831,8 @@ static const float max_mask_tile_border = max_mask_texel_border/
// mask_resize_viewport_scale. This limits the maximum final triad size.
// Estimate the minimum number of triads we can split the screen into in each
// dimension (we'll be as correct as mask_resize_viewport_scale is):
static const float mask_resize_num_triads =
mask_resize_num_tiles * mask_triads_per_tile;
static const float2 min_allowed_viewport_triads =
float2(mask_resize_num_triads) / mask_resize_viewport_scale;
#define mask_resize_num_triads float(mask_resize_num_tiles * mask_triads_per_tile)
#define min_allowed_viewport_triads float2(float2(mask_resize_num_triads) / mask_resize_viewport_scale)
//////////////////////// COMMON MATHEMATICAL CONSTANTS ///////////////////////
@@ -1332,7 +1331,7 @@ inline float get_mask_sample_mode()
#endif
// Users might want to know if bilinear filtering will be gamma-correct:
static const bool gamma_aware_bilinear = !linearize_input;
#define gamma_aware_bilinear bool(!linearize_input)
////////////////////// COLOR ENCODING/DECODING FUNCTIONS /////////////////////
@@ -1473,10 +1472,10 @@ inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords)
{ return decode_input(COMPAT_TEXTURE(tex, tex_coords.xy)); }
inline float4 tex2D_linearize(const sampler2D tex, float2 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords, float(texel_off))); }
inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
//inline float4 tex2D_linearize(const sampler2D tex, const float2 tex_coords, const float2 dx, const float2 dy)
//{ return decode_input(COMPAT_TEXTURE(tex, tex_coords, dx, dy)); }
@@ -1509,7 +1508,7 @@ inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords)
{ return decode_input(textureLod(tex, tex_coords.xy, 0.0)); }
inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
/*
// tex2Dproj:
inline float4 tex2Dproj_linearize(const sampler2D tex, const float3 tex_coords)
@@ -1627,7 +1626,7 @@ inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, f
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, 0.0), gamma); }
inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, int texel_off, float3 gamma)
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, texel_off), gamma); }
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, float(texel_off)), gamma); }
#endif // GAMMA_MANAGEMENT_H
@@ -2847,7 +2846,7 @@ void main()
// If we're interlacing, determine which field curr_line is in:
const float modulus = interlaced + 1.0;
const float field_offset =
fmod(frame_count + interlace_bff, modulus);
fmod(float(frame_count) + interlace_bff, modulus);
const float curr_line_texel = tex_uv.y * texture_size.y;
// Use under_half to fix a rounding bug around exact texel locations.
const float line_num_last = floor(curr_line_texel - under_half);
@@ -1,4 +1,8 @@
#version 130
#ifdef GL_ES
precision highp float;
precision highp int;
#endif
#define INTEGRATED_GRAPHICS_COMPATIBILITY_MODE
@@ -569,9 +573,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
// TileableLinearShadowMaskEDP*.png
#ifdef PHOSPHOR_MASK_GRILLE14
static const float mask_grille_avg_color = mask_grille14_avg_color;
#define mask_grille_avg_color float(mask_grille14_avg_color)
#else
static const float mask_grille_avg_color = mask_grille15_avg_color;
#define mask_grille_avg_color float(mask_grille15_avg_color)
#endif
@@ -631,10 +635,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Mode 2 (4x4 Gaussian resize) won't work, and mode 1 (3x3 blur) is
// inferior in most cases, so replace 2.0 with 0.0:
static const float bloom_approx_filter =
bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static)
#else
static const float bloom_approx_filter = bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static)
#endif
// Disable slow runtime paths if static parameters are used. Most of these
@@ -749,12 +752,12 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#ifdef ANISOTROPIC_RESAMPLING_COMPAT_TEX2DLOD
// TODO: Take advantage of this!
#define PHOSPHOR_MASK_RESIZE_MIPMAPPED_LUT
static const float2 mask_resize_src_lut_size = mask_texture_large_size;
#define mask_resize_src_lut_size float2(mask_texture_large_size)
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
@@ -796,27 +799,25 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Anisotropic filtering adds about 0.5 to the pixel border:
#ifndef ANISOTROPIC_TILING_COMPAT_TEX2DLOD_FAMILY
static const float max_aniso_pixel_border = max_aa_base_pixel_border + 0.5;
#define max_aniso_pixel_border float(max_aa_base_pixel_border + 0.5)
#else
static const float max_aniso_pixel_border = max_aa_base_pixel_border;
#define max_aniso_pixel_border float(max_aa_base_pixel_border)
#endif
// Fixing discontinuities adds 1.0 more to the pixel border:
#ifdef ANISOTROPIC_TILING_COMPAT_FIX_DISCONTINUITIES
static const float max_tiled_pixel_border = max_aniso_pixel_border + 1.0;
#define max_tiled_pixel_border float(max_aniso_pixel_border + 1.0)
#else
static const float max_tiled_pixel_border = max_aniso_pixel_border;
#define max_tiled_pixel_border float(max_aniso_pixel_border)
#endif
// Convert the pixel border to an integer texel border. Assume same-pass
// curvature about triples the texel frequency:
#ifdef GEOMETRY_EARLY
static const float max_mask_texel_border =
ceil(max_tiled_pixel_border * 3.0);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border * 3.0))
#else
static const float max_mask_texel_border = ceil(max_tiled_pixel_border);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border))
#endif
// Convert the texel border to a tile border using worst-case assumptions:
static const float max_mask_tile_border = max_mask_texel_border/
(mask_min_allowed_triad_size * mask_triads_per_tile);
#define max_mask_tile_border float(max_mask_texel_border/ (mask_min_allowed_triad_size * mask_triads_per_tile))
// Finally, set the number of resized tiles to render to MASK_RESIZE, and set
// the starting texel (inside borders) for sampling it.
@@ -840,10 +841,8 @@ static const float max_mask_tile_border = max_mask_texel_border/
// mask_resize_viewport_scale. This limits the maximum final triad size.
// Estimate the minimum number of triads we can split the screen into in each
// dimension (we'll be as correct as mask_resize_viewport_scale is):
static const float mask_resize_num_triads =
mask_resize_num_tiles * mask_triads_per_tile;
static const float2 min_allowed_viewport_triads =
float2(mask_resize_num_triads) / mask_resize_viewport_scale;
#define mask_resize_num_triads float(mask_resize_num_tiles * mask_triads_per_tile)
#define min_allowed_viewport_triads float2(float2(mask_resize_num_triads) / mask_resize_viewport_scale)
//////////////////////// COMMON MATHEMATICAL CONSTANTS ///////////////////////
@@ -1394,7 +1393,7 @@ inline float get_mask_sample_mode()
#endif
// Users might want to know if bilinear filtering will be gamma-correct:
static const bool gamma_aware_bilinear = !linearize_input;
#define gamma_aware_bilinear bool(!linearize_input)
////////////////////// COLOR ENCODING/DECODING FUNCTIONS /////////////////////
@@ -1535,10 +1534,10 @@ inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords)
{ return decode_input(COMPAT_TEXTURE(tex, tex_coords.xy)); }
inline float4 tex2D_linearize(const sampler2D tex, float2 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords, float(texel_off))); }
inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
//inline float4 tex2D_linearize(const sampler2D tex, const float2 tex_coords, const float2 dx, const float2 dy)
//{ return decode_input(COMPAT_TEXTURE(tex, tex_coords, dx, dy)); }
@@ -1571,7 +1570,7 @@ inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords)
{ return decode_input(textureLod(tex, tex_coords.xy, 0.0)); }
inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
/*
// tex2Dproj:
inline float4 tex2Dproj_linearize(const sampler2D tex, const float3 tex_coords)
@@ -1689,7 +1688,7 @@ inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, f
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, 0.0), gamma); }
inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, int texel_off, float3 gamma)
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, texel_off), gamma); }
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, float(texel_off)), gamma); }
#endif // GAMMA_MANAGEMENT_H
@@ -1873,18 +1872,14 @@ inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, i
// them to be static constants; see the descriptions above.
static const float aa_pixel_diameter = 1.0;
static const float aa_lanczos_lobes = 3.0;
static const float aa_gauss_support = 1.0 / aa_pixel_diameter;
static const float aa_tent_support = 1.0 / aa_pixel_diameter;
#define aa_gauss_support float(1.0 / aa_pixel_diameter)
#define aa_tent_support float(1.0 / aa_pixel_diameter)
// If we're using a negative-lobed filter, default to using it horizontally
// only, and use only the first lobe vertically or a box filter, over a
// correspondingly smaller range. This compensates for the sparse sampling
// grid's typically large positive/negative x/y covariance.
static const float2 aa_xy_axis_importance =
aa_filter < 5.5 ? float2(1.0) : // Box, tent, Gaussian
aa_filter < 8.5 ? float2(1.0, 0.0) : // Cubic and Lanczos sinc
aa_filter < 9.5 ? float2(1.0, 1.0/aa_lanczos_lobes) : // Lanczos jinc
float2(1.0); // Default to box
#define aa_xy_axis_importance float2(aa_filter < 5.5 ? float2(1.0) : aa_filter < 8.5 ? float2(1.0, 0.0) : aa_filter < 9.5 ? float2(1.0, 1.0/aa_lanczos_lobes) : float2(1.0))
#endif
#ifndef ANTIALIAS_OVERRIDE_PARAMETERS
@@ -3057,11 +3052,11 @@ float3 tex2Daa_debug_dynamic(const sampler2D tex, const float2 tex_uv,
for(int i = 0; i < grid_size; ++i)
{
const float2 row_i_first_sample_uv =
sample0_uv + i * uv_offset_step_y;
sample0_uv + float(i) * uv_offset_step_y;
for(int j = 0; j < grid_size; ++j)
{
const float2 sample_uv =
row_i_first_sample_uv + j * uv_offset_step_x;
row_i_first_sample_uv + float(j) * uv_offset_step_x;
sum += weights[i*grid_size + j] *
tex2Daa_tiled_linearize(tex, sample_uv).rgb;
}
@@ -1,4 +1,8 @@
#version 130
#ifdef GL_ES
precision highp float;
precision highp int;
#endif
///////////////////////////// GPL LICENSE NOTICE /////////////////////////////
@@ -567,9 +571,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
// TileableLinearShadowMaskEDP*.png
#ifdef PHOSPHOR_MASK_GRILLE14
static const float mask_grille_avg_color = mask_grille14_avg_color;
#define mask_grille_avg_color float(mask_grille14_avg_color)
#else
static const float mask_grille_avg_color = mask_grille15_avg_color;
#define mask_grille_avg_color float(mask_grille15_avg_color)
#endif
@@ -628,10 +632,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Mode 2 (4x4 Gaussian resize) won't work, and mode 1 (3x3 blur) is
// inferior in most cases, so replace 2.0 with 0.0:
static const float bloom_approx_filter =
bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static)
#else
static const float bloom_approx_filter = bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static)
#endif
// Disable slow runtime paths if static parameters are used. Most of these
@@ -746,12 +749,12 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#ifdef ANISOTROPIC_RESAMPLING_COMPAT_TEX2DLOD
// TODO: Take advantage of this!
#define PHOSPHOR_MASK_RESIZE_MIPMAPPED_LUT
static const float2 mask_resize_src_lut_size = mask_texture_large_size;
#define mask_resize_src_lut_size float2(mask_texture_large_size)
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
@@ -793,27 +796,25 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Anisotropic filtering adds about 0.5 to the pixel border:
#ifndef ANISOTROPIC_TILING_COMPAT_TEX2DLOD_FAMILY
static const float max_aniso_pixel_border = max_aa_base_pixel_border + 0.5;
#define max_aniso_pixel_border float(max_aa_base_pixel_border + 0.5)
#else
static const float max_aniso_pixel_border = max_aa_base_pixel_border;
#define max_aniso_pixel_border float(max_aa_base_pixel_border)
#endif
// Fixing discontinuities adds 1.0 more to the pixel border:
#ifdef ANISOTROPIC_TILING_COMPAT_FIX_DISCONTINUITIES
static const float max_tiled_pixel_border = max_aniso_pixel_border + 1.0;
#define max_tiled_pixel_border float(max_aniso_pixel_border + 1.0)
#else
static const float max_tiled_pixel_border = max_aniso_pixel_border;
#define max_tiled_pixel_border float(max_aniso_pixel_border)
#endif
// Convert the pixel border to an integer texel border. Assume same-pass
// curvature about triples the texel frequency:
#ifdef GEOMETRY_EARLY
static const float max_mask_texel_border =
ceil(max_tiled_pixel_border * 3.0);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border * 3.0))
#else
static const float max_mask_texel_border = ceil(max_tiled_pixel_border);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border))
#endif
// Convert the texel border to a tile border using worst-case assumptions:
static const float max_mask_tile_border = max_mask_texel_border/
(mask_min_allowed_triad_size * mask_triads_per_tile);
#define max_mask_tile_border float(max_mask_texel_border/ (mask_min_allowed_triad_size * mask_triads_per_tile))
// Finally, set the number of resized tiles to render to MASK_RESIZE, and set
// the starting texel (inside borders) for sampling it.
@@ -837,10 +838,8 @@ static const float max_mask_tile_border = max_mask_texel_border/
// mask_resize_viewport_scale. This limits the maximum final triad size.
// Estimate the minimum number of triads we can split the screen into in each
// dimension (we'll be as correct as mask_resize_viewport_scale is):
static const float mask_resize_num_triads =
mask_resize_num_tiles * mask_triads_per_tile;
static const float2 min_allowed_viewport_triads =
float2(mask_resize_num_triads) / mask_resize_viewport_scale;
#define mask_resize_num_triads float(mask_resize_num_tiles * mask_triads_per_tile)
#define min_allowed_viewport_triads float2(float2(mask_resize_num_triads) / mask_resize_viewport_scale)
//////////////////////// COMMON MATHEMATICAL CONSTANTS ///////////////////////
@@ -1382,7 +1381,7 @@ inline float get_mask_sample_mode()
#endif
// Users might want to know if bilinear filtering will be gamma-correct:
static const bool gamma_aware_bilinear = !linearize_input;
#define gamma_aware_bilinear bool(!linearize_input)
////////////////////// COLOR ENCODING/DECODING FUNCTIONS /////////////////////
@@ -1523,10 +1522,10 @@ inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords)
{ return decode_input(COMPAT_TEXTURE(tex, tex_coords.xy)); }
inline float4 tex2D_linearize(const sampler2D tex, float2 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords, float(texel_off))); }
inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
//inline float4 tex2D_linearize(const sampler2D tex, const float2 tex_coords, const float2 dx, const float2 dy)
//{ return decode_input(COMPAT_TEXTURE(tex, tex_coords, dx, dy)); }
@@ -1559,7 +1558,7 @@ inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords)
{ return decode_input(textureLod(tex, tex_coords.xy, 0.0)); }
inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
/*
// tex2Dproj:
inline float4 tex2Dproj_linearize(const sampler2D tex, const float3 tex_coords)
@@ -1677,7 +1676,7 @@ inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, f
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, 0.0), gamma); }
inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, int texel_off, float3 gamma)
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, texel_off), gamma); }
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, float(texel_off)), gamma); }
#endif // GAMMA_MANAGEMENT_H
@@ -1859,18 +1858,14 @@ inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, i
// them to be static constants; see the descriptions above.
static const float aa_pixel_diameter = 1.0;
static const float aa_lanczos_lobes = 3.0;
static const float aa_gauss_support = 1.0 / aa_pixel_diameter;
static const float aa_tent_support = 1.0 / aa_pixel_diameter;
#define aa_gauss_support float(1.0 / aa_pixel_diameter)
#define aa_tent_support float(1.0 / aa_pixel_diameter)
// If we're using a negative-lobed filter, default to using it horizontally
// only, and use only the first lobe vertically or a box filter, over a
// correspondingly smaller range. This compensates for the sparse sampling
// grid's typically large positive/negative x/y covariance.
static const float2 aa_xy_axis_importance =
aa_filter < 5.5 ? float2(1.0) : // Box, tent, Gaussian
aa_filter < 8.5 ? float2(1.0, 0.0) : // Cubic and Lanczos sinc
aa_filter < 9.5 ? float2(1.0, 1.0/aa_lanczos_lobes) : // Lanczos jinc
float2(1.0); // Default to box
#define aa_xy_axis_importance float2(aa_filter < 5.5 ? float2(1.0) : aa_filter < 8.5 ? float2(1.0, 0.0) : aa_filter < 9.5 ? float2(1.0, 1.0/aa_lanczos_lobes) : float2(1.0))
#endif
#ifndef ANTIALIAS_OVERRIDE_PARAMETERS
@@ -3042,11 +3037,11 @@ float3 tex2Daa_debug_dynamic(const sampler2D tex, const float2 tex_uv,
for(int i = 0; i < grid_size; ++i)
{
const float2 row_i_first_sample_uv =
sample0_uv + i * uv_offset_step_y;
sample0_uv + float(i) * uv_offset_step_y;
for(int j = 0; j < grid_size; ++j)
{
const float2 sample_uv =
row_i_first_sample_uv + j * uv_offset_step_x;
row_i_first_sample_uv + float(j) * uv_offset_step_x;
sum += weights[i*grid_size + j] *
tex2Daa_tiled_linearize(tex, sample_uv).rgb;
}
@@ -1,4 +1,8 @@
#version 130
#ifdef GL_ES
precision highp float;
precision highp int;
#endif
///////////////////////////// GPL LICENSE NOTICE /////////////////////////////
@@ -519,9 +523,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
// TileableLinearShadowMaskEDP*.png
#ifdef PHOSPHOR_MASK_GRILLE14
static const float mask_grille_avg_color = mask_grille14_avg_color;
#define mask_grille_avg_color float(mask_grille14_avg_color)
#else
static const float mask_grille_avg_color = mask_grille15_avg_color;
#define mask_grille_avg_color float(mask_grille15_avg_color)
#endif
@@ -581,10 +585,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Mode 2 (4x4 Gaussian resize) won't work, and mode 1 (3x3 blur) is
// inferior in most cases, so replace 2.0 with 0.0:
static const float bloom_approx_filter =
bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static)
#else
static const float bloom_approx_filter = bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static)
#endif
// Disable slow runtime paths if static parameters are used. Most of these
@@ -699,12 +702,12 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#ifdef ANISOTROPIC_RESAMPLING_COMPAT_TEX2DLOD
// TODO: Take advantage of this!
#define PHOSPHOR_MASK_RESIZE_MIPMAPPED_LUT
static const float2 mask_resize_src_lut_size = mask_texture_large_size;
#define mask_resize_src_lut_size float2(mask_texture_large_size)
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
@@ -746,27 +749,25 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Anisotropic filtering adds about 0.5 to the pixel border:
#ifndef ANISOTROPIC_TILING_COMPAT_TEX2DLOD_FAMILY
static const float max_aniso_pixel_border = max_aa_base_pixel_border + 0.5;
#define max_aniso_pixel_border float(max_aa_base_pixel_border + 0.5)
#else
static const float max_aniso_pixel_border = max_aa_base_pixel_border;
#define max_aniso_pixel_border float(max_aa_base_pixel_border)
#endif
// Fixing discontinuities adds 1.0 more to the pixel border:
#ifdef ANISOTROPIC_TILING_COMPAT_FIX_DISCONTINUITIES
static const float max_tiled_pixel_border = max_aniso_pixel_border + 1.0;
#define max_tiled_pixel_border float(max_aniso_pixel_border + 1.0)
#else
static const float max_tiled_pixel_border = max_aniso_pixel_border;
#define max_tiled_pixel_border float(max_aniso_pixel_border)
#endif
// Convert the pixel border to an integer texel border. Assume same-pass
// curvature about triples the texel frequency:
#ifdef GEOMETRY_EARLY
static const float max_mask_texel_border =
ceil(max_tiled_pixel_border * 3.0);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border * 3.0))
#else
static const float max_mask_texel_border = ceil(max_tiled_pixel_border);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border))
#endif
// Convert the texel border to a tile border using worst-case assumptions:
static const float max_mask_tile_border = max_mask_texel_border/
(mask_min_allowed_triad_size * mask_triads_per_tile);
#define max_mask_tile_border float(max_mask_texel_border/ (mask_min_allowed_triad_size * mask_triads_per_tile))
// Finally, set the number of resized tiles to render to MASK_RESIZE, and set
// the starting texel (inside borders) for sampling it.
@@ -790,10 +791,8 @@ static const float max_mask_tile_border = max_mask_texel_border/
// mask_resize_viewport_scale. This limits the maximum final triad size.
// Estimate the minimum number of triads we can split the screen into in each
// dimension (we'll be as correct as mask_resize_viewport_scale is):
static const float mask_resize_num_triads =
mask_resize_num_tiles * mask_triads_per_tile;
static const float2 min_allowed_viewport_triads =
float2(mask_resize_num_triads) / mask_resize_viewport_scale;
#define mask_resize_num_triads float(mask_resize_num_tiles * mask_triads_per_tile)
#define min_allowed_viewport_triads float2(float2(mask_resize_num_triads) / mask_resize_viewport_scale)
//////////////////////// COMMON MATHEMATICAL CONSTANTS ///////////////////////
@@ -1127,17 +1126,13 @@ inline float get_mask_sample_mode()
// The larger the resized tile, the fewer samples we'll need for downsizing.
// See if we can get a static min tile size > mask_min_allowed_tile_size:
static const float mask_min_allowed_tile_size = ceil(
mask_min_allowed_triad_size * mask_triads_per_tile);
static const float mask_min_expected_tile_size =
mask_min_allowed_tile_size;
#define mask_min_allowed_tile_size float(ceil( mask_min_allowed_triad_size * mask_triads_per_tile))
#define mask_min_expected_tile_size float(mask_min_allowed_tile_size)
// Limit the number of sinc resize taps by the maximum minification factor:
static const float pi_over_lobes = pi/mask_sinc_lobes;
static const float max_sinc_resize_samples_float = 2.0 * mask_sinc_lobes *
mask_resize_src_lut_size.x/mask_min_expected_tile_size;
#define pi_over_lobes float(pi/mask_sinc_lobes)
#define max_sinc_resize_samples_float float(2.0 * mask_sinc_lobes * mask_resize_src_lut_size.x/mask_min_expected_tile_size)
// Vectorized loops sample in multiples of 4. Round up to be safe:
static const float max_sinc_resize_samples_m4 = ceil(
max_sinc_resize_samples_float * 0.25) * 4.0;
#define max_sinc_resize_samples_m4 float(ceil( max_sinc_resize_samples_float * 0.25) * 4.0)
///////////////////////// RESAMPLING FUNCTION HELPERS ////////////////////////
@@ -1330,7 +1325,7 @@ float3 downsample_vertical_sinc_tiled(const sampler2D tex,
static const float input_tiles_per_texture_r = 1.0/tile_size_uv_r;
// true = vertical resize:
const float2 first_texel_tile_r_and_dist = get_first_texel_tile_uv_and_dist(
tex_uv, tex_size, dr, input_tiles_per_texture_r, samples, true);
tex_uv, tex_size, dr, input_tiles_per_texture_r, float(samples), true);
const float4 first_texel_tile_uv_rrrr = first_texel_tile_r_and_dist.xxxx;
const float4 first_dist_unscaled = first_texel_tile_r_and_dist.yyyy;
// Get the tile sample offset:
@@ -1435,7 +1430,7 @@ float3 downsample_horizontal_sinc_tiled(const sampler2D tex,
const float input_tiles_per_texture_r = 1.0/tile_size_uv_r;
// false = horizontal resize:
const float2 first_texel_tile_r_and_dist = get_first_texel_tile_uv_and_dist(
tex_uv, tex_size, dr, input_tiles_per_texture_r, samples, false);
tex_uv, tex_size, dr, input_tiles_per_texture_r, float(samples), false);
const float4 first_texel_tile_uv_rrrr = first_texel_tile_r_and_dist.xxxx;
const float4 first_dist_unscaled = first_texel_tile_r_and_dist.yyyy;
// Get the tile sample offset:
@@ -1,4 +1,8 @@
#version 130
#ifdef GL_ES
precision highp float;
precision highp int;
#endif
///////////////////////////// GPL LICENSE NOTICE /////////////////////////////
@@ -519,9 +523,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
// TileableLinearShadowMaskEDP*.png
#ifdef PHOSPHOR_MASK_GRILLE14
static const float mask_grille_avg_color = mask_grille14_avg_color;
#define mask_grille_avg_color float(mask_grille14_avg_color)
#else
static const float mask_grille_avg_color = mask_grille15_avg_color;
#define mask_grille_avg_color float(mask_grille15_avg_color)
#endif
@@ -581,10 +585,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Mode 2 (4x4 Gaussian resize) won't work, and mode 1 (3x3 blur) is
// inferior in most cases, so replace 2.0 with 0.0:
static const float bloom_approx_filter =
bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static)
#else
static const float bloom_approx_filter = bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static)
#endif
// Disable slow runtime paths if static parameters are used. Most of these
@@ -699,12 +702,12 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#ifdef ANISOTROPIC_RESAMPLING_COMPAT_TEX2DLOD
// TODO: Take advantage of this!
#define PHOSPHOR_MASK_RESIZE_MIPMAPPED_LUT
static const float2 mask_resize_src_lut_size = mask_texture_large_size;
#define mask_resize_src_lut_size float2(mask_texture_large_size)
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
@@ -746,27 +749,25 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Anisotropic filtering adds about 0.5 to the pixel border:
#ifndef ANISOTROPIC_TILING_COMPAT_TEX2DLOD_FAMILY
static const float max_aniso_pixel_border = max_aa_base_pixel_border + 0.5;
#define max_aniso_pixel_border float(max_aa_base_pixel_border + 0.5)
#else
static const float max_aniso_pixel_border = max_aa_base_pixel_border;
#define max_aniso_pixel_border float(max_aa_base_pixel_border)
#endif
// Fixing discontinuities adds 1.0 more to the pixel border:
#ifdef ANISOTROPIC_TILING_COMPAT_FIX_DISCONTINUITIES
static const float max_tiled_pixel_border = max_aniso_pixel_border + 1.0;
#define max_tiled_pixel_border float(max_aniso_pixel_border + 1.0)
#else
static const float max_tiled_pixel_border = max_aniso_pixel_border;
#define max_tiled_pixel_border float(max_aniso_pixel_border)
#endif
// Convert the pixel border to an integer texel border. Assume same-pass
// curvature about triples the texel frequency:
#ifdef GEOMETRY_EARLY
static const float max_mask_texel_border =
ceil(max_tiled_pixel_border * 3.0);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border * 3.0))
#else
static const float max_mask_texel_border = ceil(max_tiled_pixel_border);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border))
#endif
// Convert the texel border to a tile border using worst-case assumptions:
static const float max_mask_tile_border = max_mask_texel_border/
(mask_min_allowed_triad_size * mask_triads_per_tile);
#define max_mask_tile_border float(max_mask_texel_border/ (mask_min_allowed_triad_size * mask_triads_per_tile))
// Finally, set the number of resized tiles to render to MASK_RESIZE, and set
// the starting texel (inside borders) for sampling it.
@@ -790,10 +791,8 @@ static const float max_mask_tile_border = max_mask_texel_border/
// mask_resize_viewport_scale. This limits the maximum final triad size.
// Estimate the minimum number of triads we can split the screen into in each
// dimension (we'll be as correct as mask_resize_viewport_scale is):
static const float mask_resize_num_triads =
mask_resize_num_tiles * mask_triads_per_tile;
static const float2 min_allowed_viewport_triads =
float2(mask_resize_num_triads) / mask_resize_viewport_scale;
#define mask_resize_num_triads float(mask_resize_num_tiles * mask_triads_per_tile)
#define min_allowed_viewport_triads float2(float2(mask_resize_num_triads) / mask_resize_viewport_scale)
//////////////////////// COMMON MATHEMATICAL CONSTANTS ///////////////////////
@@ -1127,17 +1126,13 @@ inline float get_mask_sample_mode()
// The larger the resized tile, the fewer samples we'll need for downsizing.
// See if we can get a static min tile size > mask_min_allowed_tile_size:
static const float mask_min_allowed_tile_size = ceil(
mask_min_allowed_triad_size * mask_triads_per_tile);
static const float mask_min_expected_tile_size =
mask_min_allowed_tile_size;
#define mask_min_allowed_tile_size float(ceil( mask_min_allowed_triad_size * mask_triads_per_tile))
#define mask_min_expected_tile_size float(mask_min_allowed_tile_size)
// Limit the number of sinc resize taps by the maximum minification factor:
static const float pi_over_lobes = pi/mask_sinc_lobes;
static const float max_sinc_resize_samples_float = 2.0 * mask_sinc_lobes *
mask_resize_src_lut_size.x/mask_min_expected_tile_size;
#define pi_over_lobes float(pi/mask_sinc_lobes)
#define max_sinc_resize_samples_float float(2.0 * mask_sinc_lobes * mask_resize_src_lut_size.x/mask_min_expected_tile_size)
// Vectorized loops sample in multiples of 4. Round up to be safe:
static const float max_sinc_resize_samples_m4 = ceil(
max_sinc_resize_samples_float * 0.25) * 4.0;
#define max_sinc_resize_samples_m4 float(ceil( max_sinc_resize_samples_float * 0.25) * 4.0)
///////////////////////// RESAMPLING FUNCTION HELPERS ////////////////////////
@@ -1330,7 +1325,7 @@ float3 downsample_vertical_sinc_tiled(const sampler2D tex,
static const float input_tiles_per_texture_r = 1.0/tile_size_uv_r;
// true = vertical resize:
const float2 first_texel_tile_r_and_dist = get_first_texel_tile_uv_and_dist(
tex_uv, tex_size, dr, input_tiles_per_texture_r, samples, true);
tex_uv, tex_size, dr, input_tiles_per_texture_r, float(samples), true);
const float4 first_texel_tile_uv_rrrr = first_texel_tile_r_and_dist.xxxx;
const float4 first_dist_unscaled = first_texel_tile_r_and_dist.yyyy;
// Get the tile sample offset:
@@ -1435,7 +1430,7 @@ float3 downsample_horizontal_sinc_tiled(const sampler2D tex,
const float input_tiles_per_texture_r = 1.0/tile_size_uv_r;
// false = horizontal resize:
const float2 first_texel_tile_r_and_dist = get_first_texel_tile_uv_and_dist(
tex_uv, tex_size, dr, input_tiles_per_texture_r, samples, false);
tex_uv, tex_size, dr, input_tiles_per_texture_r, float(samples), false);
const float4 first_texel_tile_uv_rrrr = first_texel_tile_r_and_dist.xxxx;
const float4 first_dist_unscaled = first_texel_tile_r_and_dist.yyyy;
// Get the tile sample offset:
@@ -1,4 +1,8 @@
#version 130
#ifdef GL_ES
precision highp float;
precision highp int;
#endif
#define INTEGRATED_GRAPHICS_COMPATIBILITY_MODE
#define PHOSPHOR_BLOOM_FAKE
@@ -539,9 +543,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
// TileableLinearShadowMaskEDP*.png
#ifdef PHOSPHOR_MASK_GRILLE14
static const float mask_grille_avg_color = mask_grille14_avg_color;
#define mask_grille_avg_color float(mask_grille14_avg_color)
#else
static const float mask_grille_avg_color = mask_grille15_avg_color;
#define mask_grille_avg_color float(mask_grille15_avg_color)
#endif
@@ -601,10 +605,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Mode 2 (4x4 Gaussian resize) won't work, and mode 1 (3x3 blur) is
// inferior in most cases, so replace 2.0 with 0.0:
static const float bloom_approx_filter =
bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static)
#else
static const float bloom_approx_filter = bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static)
#endif
// Disable slow runtime paths if static parameters are used. Most of these
@@ -719,12 +722,12 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#ifdef ANISOTROPIC_RESAMPLING_COMPAT_TEX2DLOD
// TODO: Take advantage of this!
#define PHOSPHOR_MASK_RESIZE_MIPMAPPED_LUT
static const float2 mask_resize_src_lut_size = mask_texture_large_size;
#define mask_resize_src_lut_size float2(mask_texture_large_size)
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
@@ -766,27 +769,25 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Anisotropic filtering adds about 0.5 to the pixel border:
#ifndef ANISOTROPIC_TILING_COMPAT_TEX2DLOD_FAMILY
static const float max_aniso_pixel_border = max_aa_base_pixel_border + 0.5;
#define max_aniso_pixel_border float(max_aa_base_pixel_border + 0.5)
#else
static const float max_aniso_pixel_border = max_aa_base_pixel_border;
#define max_aniso_pixel_border float(max_aa_base_pixel_border)
#endif
// Fixing discontinuities adds 1.0 more to the pixel border:
#ifdef ANISOTROPIC_TILING_COMPAT_FIX_DISCONTINUITIES
static const float max_tiled_pixel_border = max_aniso_pixel_border + 1.0;
#define max_tiled_pixel_border float(max_aniso_pixel_border + 1.0)
#else
static const float max_tiled_pixel_border = max_aniso_pixel_border;
#define max_tiled_pixel_border float(max_aniso_pixel_border)
#endif
// Convert the pixel border to an integer texel border. Assume same-pass
// curvature about triples the texel frequency:
#ifdef GEOMETRY_EARLY
static const float max_mask_texel_border =
ceil(max_tiled_pixel_border * 3.0);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border * 3.0))
#else
static const float max_mask_texel_border = ceil(max_tiled_pixel_border);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border))
#endif
// Convert the texel border to a tile border using worst-case assumptions:
static const float max_mask_tile_border = max_mask_texel_border/
(mask_min_allowed_triad_size * mask_triads_per_tile);
#define max_mask_tile_border float(max_mask_texel_border/ (mask_min_allowed_triad_size * mask_triads_per_tile))
// Finally, set the number of resized tiles to render to MASK_RESIZE, and set
// the starting texel (inside borders) for sampling it.
@@ -810,10 +811,8 @@ static const float max_mask_tile_border = max_mask_texel_border/
// mask_resize_viewport_scale. This limits the maximum final triad size.
// Estimate the minimum number of triads we can split the screen into in each
// dimension (we'll be as correct as mask_resize_viewport_scale is):
static const float mask_resize_num_triads =
mask_resize_num_tiles * mask_triads_per_tile;
static const float2 min_allowed_viewport_triads =
float2(mask_resize_num_triads) / mask_resize_viewport_scale;
#define mask_resize_num_triads float(mask_resize_num_tiles * mask_triads_per_tile)
#define min_allowed_viewport_triads float2(float2(mask_resize_num_triads) / mask_resize_viewport_scale)
//////////////////////// COMMON MATHEMATICAL CONSTANTS ///////////////////////
@@ -1895,7 +1894,7 @@ float normalized_ligamma(const float s, const float z)
#endif
// Users might want to know if bilinear filtering will be gamma-correct:
static const bool gamma_aware_bilinear = !linearize_input;
#define gamma_aware_bilinear bool(!linearize_input)
////////////////////// COLOR ENCODING/DECODING FUNCTIONS /////////////////////
@@ -2036,10 +2035,10 @@ inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords)
{ return decode_input(COMPAT_TEXTURE(tex, tex_coords.xy)); }
inline float4 tex2D_linearize(const sampler2D tex, float2 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords, float(texel_off))); }
inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
//inline float4 tex2D_linearize(const sampler2D tex, const float2 tex_coords, const float2 dx, const float2 dy)
//{ return decode_input(COMPAT_TEXTURE(tex, tex_coords, dx, dy)); }
@@ -2072,7 +2071,7 @@ inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords)
{ return decode_input(textureLod(tex, tex_coords.xy, 0.0)); }
inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
/*
// tex2Dproj:
inline float4 tex2Dproj_linearize(const sampler2D tex, const float3 tex_coords)
@@ -2190,7 +2189,7 @@ inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, f
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, 0.0), gamma); }
inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, int texel_off, float3 gamma)
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, texel_off), gamma); }
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, float(texel_off)), gamma); }
#endif // GAMMA_MANAGEMENT_H
@@ -2796,17 +2795,13 @@ inline bool is_interlaced(float num_lines)
// The larger the resized tile, the fewer samples we'll need for downsizing.
// See if we can get a static min tile size > mask_min_allowed_tile_size:
static const float mask_min_allowed_tile_size = ceil(
mask_min_allowed_triad_size * mask_triads_per_tile);
static const float mask_min_expected_tile_size =
mask_min_allowed_tile_size;
#define mask_min_allowed_tile_size float(ceil( mask_min_allowed_triad_size * mask_triads_per_tile))
#define mask_min_expected_tile_size float(mask_min_allowed_tile_size)
// Limit the number of sinc resize taps by the maximum minification factor:
static const float pi_over_lobes = pi/mask_sinc_lobes;
static const float max_sinc_resize_samples_float = 2.0 * mask_sinc_lobes *
mask_resize_src_lut_size.x/mask_min_expected_tile_size;
#define pi_over_lobes float(pi/mask_sinc_lobes)
#define max_sinc_resize_samples_float float(2.0 * mask_sinc_lobes * mask_resize_src_lut_size.x/mask_min_expected_tile_size)
// Vectorized loops sample in multiples of 4. Round up to be safe:
static const float max_sinc_resize_samples_m4 = ceil(
max_sinc_resize_samples_float * 0.25) * 4.0;
#define max_sinc_resize_samples_m4 float(ceil( max_sinc_resize_samples_float * 0.25) * 4.0)
///////////////////////// RESAMPLING FUNCTION HELPERS ////////////////////////
@@ -2999,7 +2994,7 @@ float3 downsample_vertical_sinc_tiled(const sampler2D tex,
static const float input_tiles_per_texture_r = 1.0/tile_size_uv_r;
// true = vertical resize:
const float2 first_texel_tile_r_and_dist = get_first_texel_tile_uv_and_dist(
tex_uv, tex_size, dr, input_tiles_per_texture_r, samples, true);
tex_uv, tex_size, dr, input_tiles_per_texture_r, float(samples), true);
const float4 first_texel_tile_uv_rrrr = first_texel_tile_r_and_dist.xxxx;
const float4 first_dist_unscaled = first_texel_tile_r_and_dist.yyyy;
// Get the tile sample offset:
@@ -3104,7 +3099,7 @@ float3 downsample_horizontal_sinc_tiled(const sampler2D tex,
const float input_tiles_per_texture_r = 1.0/tile_size_uv_r;
// false = horizontal resize:
const float2 first_texel_tile_r_and_dist = get_first_texel_tile_uv_and_dist(
tex_uv, tex_size, dr, input_tiles_per_texture_r, samples, false);
tex_uv, tex_size, dr, input_tiles_per_texture_r, float(samples), false);
const float4 first_texel_tile_uv_rrrr = first_texel_tile_r_and_dist.xxxx;
const float4 first_dist_unscaled = first_texel_tile_r_and_dist.yyyy;
// Get the tile sample offset:
@@ -3511,7 +3506,7 @@ uniform COMPAT_PRECISION vec2 PassPrev2InputSize;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
float bloom_approx_scale_x = OutputSize.x / TextureSize.y;
#define bloom_approx_scale_x (OutputSize.x / TextureSize.y)
const float max_viewport_size_x = 1080.0*1024.0*(4.0/3.0);
void main()
@@ -3609,7 +3604,7 @@ COMPAT_VARYING vec2 mask_tiles_per_screen;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
float bloom_approx_scale_x = OutputSize.x / TextureSize.y;
#define bloom_approx_scale_x (OutputSize.x / TextureSize.y)
const float max_viewport_size_x = 1080.0*1024.0*(4.0/3.0);
////////////////////////////// FRAGMENT INCLUDES //////////////////////////////
@@ -1,4 +1,8 @@
#version 130
#ifdef GL_ES
precision highp float;
precision highp int;
#endif
#define PHOSPHOR_BLOOM_FAKE
@@ -538,9 +542,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
// TileableLinearShadowMaskEDP*.png
#ifdef PHOSPHOR_MASK_GRILLE14
static const float mask_grille_avg_color = mask_grille14_avg_color;
#define mask_grille_avg_color float(mask_grille14_avg_color)
#else
static const float mask_grille_avg_color = mask_grille15_avg_color;
#define mask_grille_avg_color float(mask_grille15_avg_color)
#endif
@@ -600,10 +604,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Mode 2 (4x4 Gaussian resize) won't work, and mode 1 (3x3 blur) is
// inferior in most cases, so replace 2.0 with 0.0:
static const float bloom_approx_filter =
bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static)
#else
static const float bloom_approx_filter = bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static)
#endif
// Disable slow runtime paths if static parameters are used. Most of these
@@ -718,12 +721,12 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#ifdef ANISOTROPIC_RESAMPLING_COMPAT_TEX2DLOD
// TODO: Take advantage of this!
#define PHOSPHOR_MASK_RESIZE_MIPMAPPED_LUT
static const float2 mask_resize_src_lut_size = mask_texture_large_size;
#define mask_resize_src_lut_size float2(mask_texture_large_size)
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
@@ -765,27 +768,25 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Anisotropic filtering adds about 0.5 to the pixel border:
#ifndef ANISOTROPIC_TILING_COMPAT_TEX2DLOD_FAMILY
static const float max_aniso_pixel_border = max_aa_base_pixel_border + 0.5;
#define max_aniso_pixel_border float(max_aa_base_pixel_border + 0.5)
#else
static const float max_aniso_pixel_border = max_aa_base_pixel_border;
#define max_aniso_pixel_border float(max_aa_base_pixel_border)
#endif
// Fixing discontinuities adds 1.0 more to the pixel border:
#ifdef ANISOTROPIC_TILING_COMPAT_FIX_DISCONTINUITIES
static const float max_tiled_pixel_border = max_aniso_pixel_border + 1.0;
#define max_tiled_pixel_border float(max_aniso_pixel_border + 1.0)
#else
static const float max_tiled_pixel_border = max_aniso_pixel_border;
#define max_tiled_pixel_border float(max_aniso_pixel_border)
#endif
// Convert the pixel border to an integer texel border. Assume same-pass
// curvature about triples the texel frequency:
#ifdef GEOMETRY_EARLY
static const float max_mask_texel_border =
ceil(max_tiled_pixel_border * 3.0);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border * 3.0))
#else
static const float max_mask_texel_border = ceil(max_tiled_pixel_border);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border))
#endif
// Convert the texel border to a tile border using worst-case assumptions:
static const float max_mask_tile_border = max_mask_texel_border/
(mask_min_allowed_triad_size * mask_triads_per_tile);
#define max_mask_tile_border float(max_mask_texel_border/ (mask_min_allowed_triad_size * mask_triads_per_tile))
// Finally, set the number of resized tiles to render to MASK_RESIZE, and set
// the starting texel (inside borders) for sampling it.
@@ -809,10 +810,8 @@ static const float max_mask_tile_border = max_mask_texel_border/
// mask_resize_viewport_scale. This limits the maximum final triad size.
// Estimate the minimum number of triads we can split the screen into in each
// dimension (we'll be as correct as mask_resize_viewport_scale is):
static const float mask_resize_num_triads =
mask_resize_num_tiles * mask_triads_per_tile;
static const float2 min_allowed_viewport_triads =
float2(mask_resize_num_triads) / mask_resize_viewport_scale;
#define mask_resize_num_triads float(mask_resize_num_tiles * mask_triads_per_tile)
#define min_allowed_viewport_triads float2(float2(mask_resize_num_triads) / mask_resize_viewport_scale)
//////////////////////// COMMON MATHEMATICAL CONSTANTS ///////////////////////
@@ -1894,7 +1893,7 @@ float normalized_ligamma(const float s, const float z)
#endif
// Users might want to know if bilinear filtering will be gamma-correct:
static const bool gamma_aware_bilinear = !linearize_input;
#define gamma_aware_bilinear bool(!linearize_input)
////////////////////// COLOR ENCODING/DECODING FUNCTIONS /////////////////////
@@ -2035,10 +2034,10 @@ inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords)
{ return decode_input(COMPAT_TEXTURE(tex, tex_coords.xy)); }
inline float4 tex2D_linearize(const sampler2D tex, float2 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords, float(texel_off))); }
inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
//inline float4 tex2D_linearize(const sampler2D tex, const float2 tex_coords, const float2 dx, const float2 dy)
//{ return decode_input(COMPAT_TEXTURE(tex, tex_coords, dx, dy)); }
@@ -2071,7 +2070,7 @@ inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords)
{ return decode_input(textureLod(tex, tex_coords.xy, 0.0)); }
inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
/*
// tex2Dproj:
inline float4 tex2Dproj_linearize(const sampler2D tex, const float3 tex_coords)
@@ -2189,7 +2188,7 @@ inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, f
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, 0.0), gamma); }
inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, int texel_off, float3 gamma)
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, texel_off), gamma); }
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, float(texel_off)), gamma); }
#endif // GAMMA_MANAGEMENT_H
@@ -2795,17 +2794,13 @@ inline bool is_interlaced(float num_lines)
// The larger the resized tile, the fewer samples we'll need for downsizing.
// See if we can get a static min tile size > mask_min_allowed_tile_size:
static const float mask_min_allowed_tile_size = ceil(
mask_min_allowed_triad_size * mask_triads_per_tile);
static const float mask_min_expected_tile_size =
mask_min_allowed_tile_size;
#define mask_min_allowed_tile_size float(ceil( mask_min_allowed_triad_size * mask_triads_per_tile))
#define mask_min_expected_tile_size float(mask_min_allowed_tile_size)
// Limit the number of sinc resize taps by the maximum minification factor:
static const float pi_over_lobes = pi/mask_sinc_lobes;
static const float max_sinc_resize_samples_float = 2.0 * mask_sinc_lobes *
mask_resize_src_lut_size.x/mask_min_expected_tile_size;
#define pi_over_lobes float(pi/mask_sinc_lobes)
#define max_sinc_resize_samples_float float(2.0 * mask_sinc_lobes * mask_resize_src_lut_size.x/mask_min_expected_tile_size)
// Vectorized loops sample in multiples of 4. Round up to be safe:
static const float max_sinc_resize_samples_m4 = ceil(
max_sinc_resize_samples_float * 0.25) * 4.0;
#define max_sinc_resize_samples_m4 float(ceil( max_sinc_resize_samples_float * 0.25) * 4.0)
///////////////////////// RESAMPLING FUNCTION HELPERS ////////////////////////
@@ -2998,7 +2993,7 @@ float3 downsample_vertical_sinc_tiled(const sampler2D tex,
static const float input_tiles_per_texture_r = 1.0/tile_size_uv_r;
// true = vertical resize:
const float2 first_texel_tile_r_and_dist = get_first_texel_tile_uv_and_dist(
tex_uv, tex_size, dr, input_tiles_per_texture_r, samples, true);
tex_uv, tex_size, dr, input_tiles_per_texture_r, float(samples), true);
const float4 first_texel_tile_uv_rrrr = first_texel_tile_r_and_dist.xxxx;
const float4 first_dist_unscaled = first_texel_tile_r_and_dist.yyyy;
// Get the tile sample offset:
@@ -3103,7 +3098,7 @@ float3 downsample_horizontal_sinc_tiled(const sampler2D tex,
const float input_tiles_per_texture_r = 1.0/tile_size_uv_r;
// false = horizontal resize:
const float2 first_texel_tile_r_and_dist = get_first_texel_tile_uv_and_dist(
tex_uv, tex_size, dr, input_tiles_per_texture_r, samples, false);
tex_uv, tex_size, dr, input_tiles_per_texture_r, float(samples), false);
const float4 first_texel_tile_uv_rrrr = first_texel_tile_r_and_dist.xxxx;
const float4 first_dist_unscaled = first_texel_tile_r_and_dist.yyyy;
// Get the tile sample offset:
@@ -3510,7 +3505,7 @@ uniform COMPAT_PRECISION vec2 PassPrev3InputSize;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
float bloom_approx_scale_x = OutputSize.x / TextureSize.y;
#define bloom_approx_scale_x (OutputSize.x / TextureSize.y)
const float max_viewport_size_x = 1080.0*1024.0*(4.0/3.0);
void main()
@@ -3608,7 +3603,7 @@ COMPAT_VARYING vec2 mask_tiles_per_screen;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
float bloom_approx_scale_x = OutputSize.x / TextureSize.y;
#define bloom_approx_scale_x (OutputSize.x / TextureSize.y)
const float max_viewport_size_x = 1080.0*1024.0*(4.0/3.0);
////////////////////////////// FRAGMENT INCLUDES //////////////////////////////
@@ -1,4 +1,8 @@
#version 130
#ifdef GL_ES
precision highp float;
precision highp int;
#endif
///////////////////////////// GPL LICENSE NOTICE /////////////////////////////
@@ -536,9 +540,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
// TileableLinearShadowMaskEDP*.png
#ifdef PHOSPHOR_MASK_GRILLE14
static const float mask_grille_avg_color = mask_grille14_avg_color;
#define mask_grille_avg_color float(mask_grille14_avg_color)
#else
static const float mask_grille_avg_color = mask_grille15_avg_color;
#define mask_grille_avg_color float(mask_grille15_avg_color)
#endif
@@ -598,10 +602,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Mode 2 (4x4 Gaussian resize) won't work, and mode 1 (3x3 blur) is
// inferior in most cases, so replace 2.0 with 0.0:
static const float bloom_approx_filter =
bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static)
#else
static const float bloom_approx_filter = bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static)
#endif
// Disable slow runtime paths if static parameters are used. Most of these
@@ -716,12 +719,12 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#ifdef ANISOTROPIC_RESAMPLING_COMPAT_TEX2DLOD
// TODO: Take advantage of this!
#define PHOSPHOR_MASK_RESIZE_MIPMAPPED_LUT
static const float2 mask_resize_src_lut_size = mask_texture_large_size;
#define mask_resize_src_lut_size float2(mask_texture_large_size)
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
@@ -763,27 +766,25 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Anisotropic filtering adds about 0.5 to the pixel border:
#ifndef ANISOTROPIC_TILING_COMPAT_TEX2DLOD_FAMILY
static const float max_aniso_pixel_border = max_aa_base_pixel_border + 0.5;
#define max_aniso_pixel_border float(max_aa_base_pixel_border + 0.5)
#else
static const float max_aniso_pixel_border = max_aa_base_pixel_border;
#define max_aniso_pixel_border float(max_aa_base_pixel_border)
#endif
// Fixing discontinuities adds 1.0 more to the pixel border:
#ifdef ANISOTROPIC_TILING_COMPAT_FIX_DISCONTINUITIES
static const float max_tiled_pixel_border = max_aniso_pixel_border + 1.0;
#define max_tiled_pixel_border float(max_aniso_pixel_border + 1.0)
#else
static const float max_tiled_pixel_border = max_aniso_pixel_border;
#define max_tiled_pixel_border float(max_aniso_pixel_border)
#endif
// Convert the pixel border to an integer texel border. Assume same-pass
// curvature about triples the texel frequency:
#ifdef GEOMETRY_EARLY
static const float max_mask_texel_border =
ceil(max_tiled_pixel_border * 3.0);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border * 3.0))
#else
static const float max_mask_texel_border = ceil(max_tiled_pixel_border);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border))
#endif
// Convert the texel border to a tile border using worst-case assumptions:
static const float max_mask_tile_border = max_mask_texel_border/
(mask_min_allowed_triad_size * mask_triads_per_tile);
#define max_mask_tile_border float(max_mask_texel_border/ (mask_min_allowed_triad_size * mask_triads_per_tile))
// Finally, set the number of resized tiles to render to MASK_RESIZE, and set
// the starting texel (inside borders) for sampling it.
@@ -807,10 +808,8 @@ static const float max_mask_tile_border = max_mask_texel_border/
// mask_resize_viewport_scale. This limits the maximum final triad size.
// Estimate the minimum number of triads we can split the screen into in each
// dimension (we'll be as correct as mask_resize_viewport_scale is):
static const float mask_resize_num_triads =
mask_resize_num_tiles * mask_triads_per_tile;
static const float2 min_allowed_viewport_triads =
float2(mask_resize_num_triads) / mask_resize_viewport_scale;
#define mask_resize_num_triads float(mask_resize_num_tiles * mask_triads_per_tile)
#define min_allowed_viewport_triads float2(float2(mask_resize_num_triads) / mask_resize_viewport_scale)
//////////////////////// COMMON MATHEMATICAL CONSTANTS ///////////////////////
@@ -1892,7 +1891,7 @@ float normalized_ligamma(const float s, const float z)
#endif
// Users might want to know if bilinear filtering will be gamma-correct:
static const bool gamma_aware_bilinear = !linearize_input;
#define gamma_aware_bilinear bool(!linearize_input)
////////////////////// COLOR ENCODING/DECODING FUNCTIONS /////////////////////
@@ -2033,10 +2032,10 @@ inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords)
{ return decode_input(COMPAT_TEXTURE(tex, tex_coords.xy)); }
inline float4 tex2D_linearize(const sampler2D tex, float2 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords, float(texel_off))); }
inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
//inline float4 tex2D_linearize(const sampler2D tex, const float2 tex_coords, const float2 dx, const float2 dy)
//{ return decode_input(COMPAT_TEXTURE(tex, tex_coords, dx, dy)); }
@@ -2069,7 +2068,7 @@ inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords)
{ return decode_input(textureLod(tex, tex_coords.xy, 0.0)); }
inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
/*
// tex2Dproj:
inline float4 tex2Dproj_linearize(const sampler2D tex, const float3 tex_coords)
@@ -2187,7 +2186,7 @@ inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, f
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, 0.0), gamma); }
inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, int texel_off, float3 gamma)
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, texel_off), gamma); }
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, float(texel_off)), gamma); }
#endif // GAMMA_MANAGEMENT_H
@@ -2793,17 +2792,13 @@ inline bool is_interlaced(float num_lines)
// The larger the resized tile, the fewer samples we'll need for downsizing.
// See if we can get a static min tile size > mask_min_allowed_tile_size:
static const float mask_min_allowed_tile_size = ceil(
mask_min_allowed_triad_size * mask_triads_per_tile);
static const float mask_min_expected_tile_size =
mask_min_allowed_tile_size;
#define mask_min_allowed_tile_size float(ceil( mask_min_allowed_triad_size * mask_triads_per_tile))
#define mask_min_expected_tile_size float(mask_min_allowed_tile_size)
// Limit the number of sinc resize taps by the maximum minification factor:
static const float pi_over_lobes = pi/mask_sinc_lobes;
static const float max_sinc_resize_samples_float = 2.0 * mask_sinc_lobes *
mask_resize_src_lut_size.x/mask_min_expected_tile_size;
#define pi_over_lobes float(pi/mask_sinc_lobes)
#define max_sinc_resize_samples_float float(2.0 * mask_sinc_lobes * mask_resize_src_lut_size.x/mask_min_expected_tile_size)
// Vectorized loops sample in multiples of 4. Round up to be safe:
static const float max_sinc_resize_samples_m4 = ceil(
max_sinc_resize_samples_float * 0.25) * 4.0;
#define max_sinc_resize_samples_m4 float(ceil( max_sinc_resize_samples_float * 0.25) * 4.0)
///////////////////////// RESAMPLING FUNCTION HELPERS ////////////////////////
@@ -2996,7 +2991,7 @@ float3 downsample_vertical_sinc_tiled(const sampler2D tex,
static const float input_tiles_per_texture_r = 1.0/tile_size_uv_r;
// true = vertical resize:
const float2 first_texel_tile_r_and_dist = get_first_texel_tile_uv_and_dist(
tex_uv, tex_size, dr, input_tiles_per_texture_r, samples, true);
tex_uv, tex_size, dr, input_tiles_per_texture_r, float(samples), true);
const float4 first_texel_tile_uv_rrrr = first_texel_tile_r_and_dist.xxxx;
const float4 first_dist_unscaled = first_texel_tile_r_and_dist.yyyy;
// Get the tile sample offset:
@@ -3101,7 +3096,7 @@ float3 downsample_horizontal_sinc_tiled(const sampler2D tex,
const float input_tiles_per_texture_r = 1.0/tile_size_uv_r;
// false = horizontal resize:
const float2 first_texel_tile_r_and_dist = get_first_texel_tile_uv_and_dist(
tex_uv, tex_size, dr, input_tiles_per_texture_r, samples, false);
tex_uv, tex_size, dr, input_tiles_per_texture_r, float(samples), false);
const float4 first_texel_tile_uv_rrrr = first_texel_tile_r_and_dist.xxxx;
const float4 first_dist_unscaled = first_texel_tile_r_and_dist.yyyy;
// Get the tile sample offset:
@@ -3508,7 +3503,7 @@ uniform COMPAT_PRECISION vec2 HALATION_BLURvideo_size;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
float bloom_approx_scale_x = OutputSize.x / TextureSize.y;
#define bloom_approx_scale_x (OutputSize.x / TextureSize.y)
const float max_viewport_size_x = 1080.0*1024.0*(4.0/3.0);
void main()
@@ -3606,7 +3601,7 @@ COMPAT_VARYING vec2 mask_tiles_per_screen;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
float bloom_approx_scale_x = OutputSize.x / TextureSize.y;
#define bloom_approx_scale_x (OutputSize.x / TextureSize.y)
const float max_viewport_size_x = 1080.0*1024.0*(4.0/3.0);
////////////////////////////// FRAGMENT INCLUDES //////////////////////////////
@@ -1,4 +1,8 @@
#version 130
#ifdef GL_ES
precision highp float;
precision highp int;
#endif
///////////////////////////// GPL LICENSE NOTICE /////////////////////////////
@@ -519,9 +523,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
// TileableLinearShadowMaskEDP*.png
#ifdef PHOSPHOR_MASK_GRILLE14
static const float mask_grille_avg_color = mask_grille14_avg_color;
#define mask_grille_avg_color float(mask_grille14_avg_color)
#else
static const float mask_grille_avg_color = mask_grille15_avg_color;
#define mask_grille_avg_color float(mask_grille15_avg_color)
#endif
@@ -581,10 +585,9 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Mode 2 (4x4 Gaussian resize) won't work, and mode 1 (3x3 blur) is
// inferior in most cases, so replace 2.0 with 0.0:
static const float bloom_approx_filter =
bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static > 1.5 ? 0.0 : bloom_approx_filter_static)
#else
static const float bloom_approx_filter = bloom_approx_filter_static;
#define bloom_approx_filter float(bloom_approx_filter_static)
#endif
// Disable slow runtime paths if static parameters are used. Most of these
@@ -699,12 +702,12 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#ifdef ANISOTROPIC_RESAMPLING_COMPAT_TEX2DLOD
// TODO: Take advantage of this!
#define PHOSPHOR_MASK_RESIZE_MIPMAPPED_LUT
static const float2 mask_resize_src_lut_size = mask_texture_large_size;
#define mask_resize_src_lut_size float2(mask_texture_large_size)
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
#else
static const float2 mask_resize_src_lut_size = mask_texture_small_size;
#define mask_resize_src_lut_size float2(mask_texture_small_size)
#endif
@@ -746,27 +749,25 @@ static const float mask_shadow_avg_color = 41.0/255.0;
#endif
// Anisotropic filtering adds about 0.5 to the pixel border:
#ifndef ANISOTROPIC_TILING_COMPAT_TEX2DLOD_FAMILY
static const float max_aniso_pixel_border = max_aa_base_pixel_border + 0.5;
#define max_aniso_pixel_border float(max_aa_base_pixel_border + 0.5)
#else
static const float max_aniso_pixel_border = max_aa_base_pixel_border;
#define max_aniso_pixel_border float(max_aa_base_pixel_border)
#endif
// Fixing discontinuities adds 1.0 more to the pixel border:
#ifdef ANISOTROPIC_TILING_COMPAT_FIX_DISCONTINUITIES
static const float max_tiled_pixel_border = max_aniso_pixel_border + 1.0;
#define max_tiled_pixel_border float(max_aniso_pixel_border + 1.0)
#else
static const float max_tiled_pixel_border = max_aniso_pixel_border;
#define max_tiled_pixel_border float(max_aniso_pixel_border)
#endif
// Convert the pixel border to an integer texel border. Assume same-pass
// curvature about triples the texel frequency:
#ifdef GEOMETRY_EARLY
static const float max_mask_texel_border =
ceil(max_tiled_pixel_border * 3.0);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border * 3.0))
#else
static const float max_mask_texel_border = ceil(max_tiled_pixel_border);
#define max_mask_texel_border float(ceil(max_tiled_pixel_border))
#endif
// Convert the texel border to a tile border using worst-case assumptions:
static const float max_mask_tile_border = max_mask_texel_border/
(mask_min_allowed_triad_size * mask_triads_per_tile);
#define max_mask_tile_border float(max_mask_texel_border/ (mask_min_allowed_triad_size * mask_triads_per_tile))
// Finally, set the number of resized tiles to render to MASK_RESIZE, and set
// the starting texel (inside borders) for sampling it.
@@ -790,10 +791,8 @@ static const float max_mask_tile_border = max_mask_texel_border/
// mask_resize_viewport_scale. This limits the maximum final triad size.
// Estimate the minimum number of triads we can split the screen into in each
// dimension (we'll be as correct as mask_resize_viewport_scale is):
static const float mask_resize_num_triads =
mask_resize_num_tiles * mask_triads_per_tile;
static const float2 min_allowed_viewport_triads =
float2(mask_resize_num_triads) / mask_resize_viewport_scale;
#define mask_resize_num_triads float(mask_resize_num_tiles * mask_triads_per_tile)
#define min_allowed_viewport_triads float2(float2(mask_resize_num_triads) / mask_resize_viewport_scale)
//////////////////////// COMMON MATHEMATICAL CONSTANTS ///////////////////////
@@ -1872,7 +1871,7 @@ float normalized_ligamma(const float s, const float z)
#endif
// Users might want to know if bilinear filtering will be gamma-correct:
static const bool gamma_aware_bilinear = !linearize_input;
#define gamma_aware_bilinear bool(!linearize_input)
////////////////////// COLOR ENCODING/DECODING FUNCTIONS /////////////////////
@@ -2013,10 +2012,10 @@ inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords)
{ return decode_input(COMPAT_TEXTURE(tex, tex_coords.xy)); }
inline float4 tex2D_linearize(const sampler2D tex, float2 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords, float(texel_off))); }
inline float4 tex2D_linearize(const sampler2D tex, float3 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
//inline float4 tex2D_linearize(const sampler2D tex, const float2 tex_coords, const float2 dx, const float2 dy)
//{ return decode_input(COMPAT_TEXTURE(tex, tex_coords, dx, dy)); }
@@ -2049,7 +2048,7 @@ inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords)
{ return decode_input(textureLod(tex, tex_coords.xy, 0.0)); }
inline float4 tex2Dlod_linearize(const sampler2D tex, float4 tex_coords, int texel_off)
{ return decode_input(textureLod(tex, tex_coords.xy, texel_off)); }
{ return decode_input(textureLod(tex, tex_coords.xy, float(texel_off))); }
/*
// tex2Dproj:
inline float4 tex2Dproj_linearize(const sampler2D tex, const float3 tex_coords)
@@ -2167,7 +2166,7 @@ inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, f
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, 0.0), gamma); }
inline float4 tex2Dlod_linearize_gamma(const sampler2D tex, float4 tex_coords, int texel_off, float3 gamma)
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, texel_off), gamma); }
{ return decode_gamma_input(textureLod(tex, tex_coords.xy, float(texel_off)), gamma); }
#endif // GAMMA_MANAGEMENT_H