From 52db21c079225c9ba7a833a9ecad0acf65c7729e Mon Sep 17 00:00:00 2001 From: hunterk Date: Tue, 29 Jan 2019 16:32:54 -0600 Subject: [PATCH] fixes for various compiler nits --- anti-aliasing/shaders/ewa_curvature.slang | 2 +- border/shaders/imgborder-gbp.slang | 2 +- border/shaders/imgborder-sgb.slang | 2 +- border/shaders/imgborder-sgba.slang | 2 +- border/shaders/imgborder.slang | 2 +- .../src/crt-royale-bloom-approx-intel.slang | 2 +- .../src/crt-royale-bloom-approx.slang | 2 +- ...t-royale-geometry-aa-last-pass-intel.slang | 2 +- .../src/crt-royale-geometry-aa-last-pass.h | 3 ++- .../crt-royale-geometry-aa-last-pass.slang | 2 +- ...yale-scanlines-horizontal-apply-mask.slang | 2 +- crt/shaders/crt-royale/src/tex2Dantialias.h | 24 +++++++++---------- handheld/shaders/gbc_pokemon_modernizer.slang | 2 +- nedi/shaders/nedi-pass0.slang | 14 +++++++---- nedi/shaders/nedi-pass1.slang | 19 +++++++++------ nedi/shaders/nedi-pass2.slang | 12 ++++++---- scalefx/shaders/old/scalefx-pass3.slang | 2 +- scalefx/shaders/old/scalefx-pass7.slang | 2 +- scalefx/shaders/scalefx-pass1.slang | 4 ++-- scalefx/shaders/scalefx-pass2.slang | 4 ++-- scalefx/shaders/scalefx-pass4-hybrid.slang | 10 ++++---- scalefx/shaders/scalefx-pass4.slang | 4 ++-- 22 files changed, 67 insertions(+), 53 deletions(-) diff --git a/anti-aliasing/shaders/ewa_curvature.slang b/anti-aliasing/shaders/ewa_curvature.slang index 07640ca..4c0eb79 100644 --- a/anti-aliasing/shaders/ewa_curvature.slang +++ b/anti-aliasing/shaders/ewa_curvature.slang @@ -77,7 +77,7 @@ float sinc(float x){ float lanczosFilter(float r2){ if (r2==0) - return 1; + return 1.; float r= sqrt(r2); return sinc(r)*sinc(r/1.3); } diff --git a/border/shaders/imgborder-gbp.slang b/border/shaders/imgborder-gbp.slang index dd1a061..34253c5 100644 --- a/border/shaders/imgborder-gbp.slang +++ b/border/shaders/imgborder-gbp.slang @@ -9,4 +9,4 @@ #pragma parameter border_zoom_x "Border Zoom X" 1.0 0.0 4.0 0.01 #pragma parameter border_zoom_y "Border Zoom Y" 1.0 0.0 4.0 0.01 -#include "imgborder.inc" \ No newline at end of file +#include "imgborder.inc" diff --git a/border/shaders/imgborder-sgb.slang b/border/shaders/imgborder-sgb.slang index bdc56cd..acc8714 100644 --- a/border/shaders/imgborder-sgb.slang +++ b/border/shaders/imgborder-sgb.slang @@ -9,4 +9,4 @@ #pragma parameter border_zoom_x "Border Zoom X" 1.0 0.0 4.0 0.01 #pragma parameter border_zoom_y "Border Zoom Y" 1.0 0.0 4.0 0.01 -#include "imgborder.inc" \ No newline at end of file +#include "imgborder.inc" diff --git a/border/shaders/imgborder-sgba.slang b/border/shaders/imgborder-sgba.slang index eac4ca9..3e04566 100644 --- a/border/shaders/imgborder-sgba.slang +++ b/border/shaders/imgborder-sgba.slang @@ -9,4 +9,4 @@ #pragma parameter border_zoom_x "Border Zoom X" 1.0 0.0 4.0 0.01 #pragma parameter border_zoom_y "Border Zoom Y" 1.0 0.0 4.0 0.01 -#include "imgborder.inc" \ No newline at end of file +#include "imgborder.inc" diff --git a/border/shaders/imgborder.slang b/border/shaders/imgborder.slang index e1d5f34..06b2f48 100644 --- a/border/shaders/imgborder.slang +++ b/border/shaders/imgborder.slang @@ -9,4 +9,4 @@ #pragma parameter border_zoom_x "Border Zoom X" 1.0 0.0 4.0 0.01 #pragma parameter border_zoom_y "Border Zoom Y" 1.0 0.0 4.0 0.01 -#include "imgborder.inc" \ No newline at end of file +#include "imgborder.inc" diff --git a/crt/shaders/crt-royale/src/crt-royale-bloom-approx-intel.slang b/crt/shaders/crt-royale/src/crt-royale-bloom-approx-intel.slang index e242024..420f527 100644 --- a/crt/shaders/crt-royale/src/crt-royale-bloom-approx-intel.slang +++ b/crt/shaders/crt-royale/src/crt-royale-bloom-approx-intel.slang @@ -1,3 +1,3 @@ #version 450 #define INTEGRATED_GRAPHICS_COMPATIBILITY_MODE -#include "crt-royale-bloom-approx.h" \ No newline at end of file +#include "crt-royale-bloom-approx.h" diff --git a/crt/shaders/crt-royale/src/crt-royale-bloom-approx.slang b/crt/shaders/crt-royale/src/crt-royale-bloom-approx.slang index 14d4e76..ce42e65 100755 --- a/crt/shaders/crt-royale/src/crt-royale-bloom-approx.slang +++ b/crt/shaders/crt-royale/src/crt-royale-bloom-approx.slang @@ -1,2 +1,2 @@ #version 450 -#include "crt-royale-bloom-approx.h" \ No newline at end of file +#include "crt-royale-bloom-approx.h" diff --git a/crt/shaders/crt-royale/src/crt-royale-geometry-aa-last-pass-intel.slang b/crt/shaders/crt-royale/src/crt-royale-geometry-aa-last-pass-intel.slang index 46a53e4..786adf9 100644 --- a/crt/shaders/crt-royale/src/crt-royale-geometry-aa-last-pass-intel.slang +++ b/crt/shaders/crt-royale/src/crt-royale-geometry-aa-last-pass-intel.slang @@ -1,4 +1,4 @@ #version 450 #define INTEGRATED_GRAPHICS_COMPATIBILITY_MODE -#include "crt-royale-geometry-aa-last-pass.h" \ No newline at end of file +#include "crt-royale-geometry-aa-last-pass.h" diff --git a/crt/shaders/crt-royale/src/crt-royale-geometry-aa-last-pass.h b/crt/shaders/crt-royale/src/crt-royale-geometry-aa-last-pass.h index 9de3d5e..12e108b 100644 --- a/crt/shaders/crt-royale/src/crt-royale-geometry-aa-last-pass.h +++ b/crt/shaders/crt-royale/src/crt-royale-geometry-aa-last-pass.h @@ -115,7 +115,8 @@ float2x2 mul_scale(float2 scale, float2x2 matrix) { //float2x2 scale_matrix = float2x2(scale.x, 0.0, 0.0, scale.y); //return mul(scale_matrix, matrix); - return float2x2(float4(matrix[0][0],matrix[0][1],matrix[1][0],matrix[1][1]) * scale.xxyy); + vec4 temp_matrix = (vec4(matrix[0][0], matrix[0][1], matrix[1][0], matrix[1][1])* scale . xxyy); + return mat2x2(temp_matrix.x, temp_matrix.y, temp_matrix.z, temp_matrix.w); } #pragma stage vertex diff --git a/crt/shaders/crt-royale/src/crt-royale-geometry-aa-last-pass.slang b/crt/shaders/crt-royale/src/crt-royale-geometry-aa-last-pass.slang index 18cd6e3..88015a1 100755 --- a/crt/shaders/crt-royale/src/crt-royale-geometry-aa-last-pass.slang +++ b/crt/shaders/crt-royale/src/crt-royale-geometry-aa-last-pass.slang @@ -1,3 +1,3 @@ #version 450 -#include "crt-royale-geometry-aa-last-pass.h" \ No newline at end of file +#include "crt-royale-geometry-aa-last-pass.h" diff --git a/crt/shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask.slang b/crt/shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask.slang index 5303e71..0c2a0b8 100755 --- a/crt/shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask.slang +++ b/crt/shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask.slang @@ -1,2 +1,2 @@ #version 450 -#include "crt-royale-scanlines-horizontal-apply-mask.h" \ No newline at end of file +#include "crt-royale-scanlines-horizontal-apply-mask.h" diff --git a/crt/shaders/crt-royale/src/tex2Dantialias.h b/crt/shaders/crt-royale/src/tex2Dantialias.h index 93fe7d4..f9b7f0d 100644 --- a/crt/shaders/crt-royale/src/tex2Dantialias.h +++ b/crt/shaders/crt-royale/src/tex2Dantialias.h @@ -565,7 +565,7 @@ float3 tex2Daa4x(const sampler2D tex, const float2 tex_uv, const float3 w_sum_inv = float3(1.0,1.0,1.0)/(w_sum); // Scale the pixel-space to texture offset matrix by the pixel diameter. const float2x2 true_pixel_to_tex_uv = - float2x2(float4(pixel_to_tex_uv * aa_pixel_diameter)); + float2x2((pixel_to_tex_uv * aa_pixel_diameter)); // Get uv sample offsets, mirror on odd frames if directed, and exploit // diagonal symmetry: const float2 frame_sign = get_frame_sign(frame); @@ -612,7 +612,7 @@ float3 tex2Daa5x(const sampler2D tex, const float2 tex_uv, const float3 w_sum_inv = float3(1.0)/(w0 + w1 + w2 + w3 + w4); // Scale the pixel-space to texture offset matrix by the pixel diameter. const float2x2 true_pixel_to_tex_uv = - float2x2(float4(pixel_to_tex_uv * aa_pixel_diameter)); + float2x2((pixel_to_tex_uv * aa_pixel_diameter)); // Get uv sample offsets, mirror on odd frames if directed, and exploit // diagonal symmetry: const float2 frame_sign = get_frame_sign(frame); @@ -665,7 +665,7 @@ float3 tex2Daa6x(const sampler2D tex, const float2 tex_uv, const float3 w_sum_inv = float3(1.0)/(w_sum); // Scale the pixel-space to texture offset matrix by the pixel diameter. const float2x2 true_pixel_to_tex_uv = - float2x2(float4(pixel_to_tex_uv * aa_pixel_diameter)); + float2x2((pixel_to_tex_uv * aa_pixel_diameter)); // Get uv sample offsets, mirror on odd frames if directed, and exploit // diagonal symmetry: const float2 frame_sign = get_frame_sign(frame); @@ -721,7 +721,7 @@ float3 tex2Daa7x(const sampler2D tex, const float2 tex_uv, const float3 w_sum_inv = float3(1.0)/(w_sum); // Scale the pixel-space to texture offset matrix by the pixel diameter. const float2x2 true_pixel_to_tex_uv = - float2x2(float4(pixel_to_tex_uv * aa_pixel_diameter)); + float2x2((pixel_to_tex_uv * aa_pixel_diameter)); // Get uv sample offsets, mirror on odd frames if directed, and exploit // diagonal symmetry: const float2 frame_sign = get_frame_sign(frame); @@ -781,7 +781,7 @@ float3 tex2Daa8x(const sampler2D tex, const float2 tex_uv, const float3 w_sum_inv = float3(1.0)/(w_sum); // Scale the pixel-space to texture offset matrix by the pixel diameter. const float2x2 true_pixel_to_tex_uv = - float2x2(float4(pixel_to_tex_uv * aa_pixel_diameter)); + float2x2((pixel_to_tex_uv * aa_pixel_diameter)); // Get uv sample offsets, and mirror on odd frames if directed: const float2 frame_sign = get_frame_sign(frame); const float2 uv_offset0 = mul(true_pixel_to_tex_uv, xy_offset0 * frame_sign); @@ -853,7 +853,7 @@ float3 tex2Daa12x(const sampler2D tex, const float2 tex_uv, const float3 w_sum_inv = float3(1.0)/w_sum; // Scale the pixel-space to texture offset matrix by the pixel diameter. const float2x2 true_pixel_to_tex_uv = - float2x2(float4(pixel_to_tex_uv * aa_pixel_diameter)); + float2x2((pixel_to_tex_uv * aa_pixel_diameter)); // Get uv sample offsets, mirror on odd frames if directed, and exploit // diagonal symmetry: const float2 frame_sign = get_frame_sign(frame); @@ -943,7 +943,7 @@ float3 tex2Daa16x(const sampler2D tex, const float2 tex_uv, const float3 w_sum_inv = float3(1.0)/(w_sum); // Scale the pixel-space to texture offset matrix by the pixel diameter. const float2x2 true_pixel_to_tex_uv = - float2x2(float4(pixel_to_tex_uv * aa_pixel_diameter)); + float2x2((pixel_to_tex_uv * aa_pixel_diameter)); // Get uv sample offsets, mirror on odd frames if directed, and exploit // diagonal symmetry: const float2 frame_sign = get_frame_sign(frame); @@ -1050,7 +1050,7 @@ float3 tex2Daa20x(const sampler2D tex, const float2 tex_uv, const float3 w_sum_inv = float3(1.0)/(w_sum); // Scale the pixel-space to texture offset matrix by the pixel diameter. const float2x2 true_pixel_to_tex_uv = - float2x2(float4(pixel_to_tex_uv * aa_pixel_diameter)); + float2x2((pixel_to_tex_uv * aa_pixel_diameter)); // Get uv sample offsets, mirror on odd frames if directed, and exploit // diagonal symmetry: const float2 frame_sign = get_frame_sign(frame); @@ -1175,7 +1175,7 @@ float3 tex2Daa24x(const sampler2D tex, const float2 tex_uv, const float3 w_sum_inv = float3(1.0)/(w_sum); // Scale the pixel-space to texture offset matrix by the pixel diameter. const float2x2 true_pixel_to_tex_uv = - float2x2(float4(pixel_to_tex_uv * aa_pixel_diameter)); + float2x2((pixel_to_tex_uv * aa_pixel_diameter)); // Get uv sample offsets, mirror on odd frames if directed, and exploit // diagonal symmetry: const float2 frame_sign = get_frame_sign(frame); @@ -1272,7 +1272,7 @@ float3 tex2Daa_debug_16x_regular(const sampler2D tex, const float2 tex_uv, const float3 w_sum_inv = float3(1.0)/(w_sum); // Scale the pixel-space to texture offset matrix by the pixel diameter. const float2x2 true_pixel_to_tex_uv = - float2x2(float4(pixel_to_tex_uv * aa_pixel_diameter)); + float2x2((pixel_to_tex_uv * aa_pixel_diameter)); // Get uv sample offsets, taking advantage of row alignment: const float2 uv_step_x = mul(true_pixel_to_tex_uv, float2(xy_step.x, 0.0)); const float2 uv_step_y = mul(true_pixel_to_tex_uv, float2(0.0, xy_step.y)); @@ -1321,7 +1321,7 @@ float3 tex2Daa_debug_dynamic(const sampler2D tex, const float2 tex_uv, const float2 sample0_filter_space_offset = -grid_radius_in_samples * filter_space_offset_step; // Compute xy sample offsets and subpixel weights: - float3 weights[grid_size * grid_size]; + float3 weights[64]; // grid_size * grid_size float3 weight_sum = float3(0.0, 0.0, 0.0); for(int i = 0; i < grid_size; ++i) { @@ -1337,7 +1337,7 @@ float3 tex2Daa_debug_dynamic(const sampler2D tex, const float2 tex_uv, } // Get uv offset vectors along x and y directions: const float2x2 true_pixel_to_tex_uv = - float2x2(float4(pixel_to_tex_uv * aa_pixel_diameter)); + float2x2((pixel_to_tex_uv * aa_pixel_diameter)); const float2 uv_offset_step_x = mul(true_pixel_to_tex_uv, float2(filter_space_offset_step.x, 0.0)); const float2 uv_offset_step_y = mul(true_pixel_to_tex_uv, diff --git a/handheld/shaders/gbc_pokemon_modernizer.slang b/handheld/shaders/gbc_pokemon_modernizer.slang index d3ab4bb..6c75fe8 100644 --- a/handheld/shaders/gbc_pokemon_modernizer.slang +++ b/handheld/shaders/gbc_pokemon_modernizer.slang @@ -35,7 +35,7 @@ layout(set = 0, binding = 2) uniform sampler2D Source; precision lowp float; -const mat3 GBCMatrix = mat3( 0.924, 0.021, 0.013, 0.048, 0.787, 0.249, 0.104, 0.09, 0.733 ) +const mat3 GBCMatrix = mat3( 0.924, 0.021, 0.013, 0.048, 0.787, 0.249, 0.104, 0.09, 0.733 ); void main() { diff --git a/nedi/shaders/nedi-pass0.slang b/nedi/shaders/nedi-pass0.slang index d09ff95..fdd520b 100644 --- a/nedi/shaders/nedi-pass0.slang +++ b/nedi/shaders/nedi-pass0.slang @@ -133,14 +133,18 @@ float2 tex = vTexCoord + float2(0.0, 0.25*params.SourceSize.w); */ //Define window and directions - original - float2 dir[4] = {{-1,-1},{1,1},{-1,1},{1,-1}}; - float4x2 wind[4] = {{{-1,-1},{1,1},{-1,1},{1,-1}},{{-3,-1},{3,1},{-1,3},{1,-3}},{{-3,1},{3,-1},{1,3},{-1,-3}},{{-3,-3},{ 3,3},{-3, 3},{3,-3}}}; + vec2 dir[4] = vec2[4](vec2(-1,-1),vec2(1,1),vec2(-1,1),vec2(1,-1)); + mat4x2 wind1 = mat4x2(vec2(-1,-1),vec2(1,1),vec2(-1,1),vec2(1,-1)); + mat4x2 wind2 = mat4x2(vec2(-3,-1),vec2(3,1),vec2(-1,3),vec2(1,-3)); + mat4x2 wind3 = mat4x2(vec2(-3,1),vec2(3,-1),vec2(1,3),vec2(-1,-3)); + mat4x2 wind4 = mat4x2(vec2(-3,-3),vec2( 3,3),vec2(-3, 3),vec2(3,-3)); + mat4x2 wind[4] = mat4x2[4](wind1, wind2, wind3, wind4); //Initialization - float2x2 R = float2x2(0.0); - float2 r = float2(0.0); + float2x2 R = float2x2(0.,0.,0.,0.); + float2 r = float2(0.,0.); - float m[4] = {NEDI_WEIGHT, 1.0, 1.0, 1.0}; + float m[4] = float[4](NEDI_WEIGHT, 1.0, 1.0, 1.0); //Calculate (local) autocorrelation coefficients for (int k = 0; k min(a.y, b.y) + a.y ? diff : -diff), 0, 1); - return (params.SFX_SAA == 1 || 2*d < a.x + a.y) ? (wght1 * wght2) * (a.x * a.y) : 0; + float wght2 = clamp((1-d) + (min(a.x, b.x) + a.x > min(a.y, b.y) + a.y ? diff : -diff), 0., 1.); + return (params.SFX_SAA == 1. || 2.*d < a.x + a.y) ? (wght1 * wght2) * (a.x * a.y) : 0.; } diff --git a/scalefx/shaders/scalefx-pass2.slang b/scalefx/shaders/scalefx-pass2.slang index dd53d25..60676d3 100644 --- a/scalefx/shaders/scalefx-pass2.slang +++ b/scalefx/shaders/scalefx-pass2.slang @@ -60,7 +60,7 @@ layout(location = 0) out vec2 vTexCoord; void main() { gl_Position = global.MVP * Position; - vTexCoord = TexCoord*1.0001;; + vTexCoord = TexCoord*1.0001; } @@ -84,7 +84,7 @@ vec4 dom(vec3 x, vec3 y, vec3 z, vec3 w){ // necessary but not sufficient junction condition for orthogonal edges float clear(vec2 crn, vec2 a, vec2 b){ - return (crn.x >= max(min(a.x, a.y), min(b.x, b.y))) && (crn.y >= max(min(a.x, b.y), min(b.x, a.y))) ? 1 : 0; + return (crn.x >= max(min(a.x, a.y), min(b.x, b.y))) && (crn.y >= max(min(a.x, b.y), min(b.x, a.y))) ? 1. : 0.; } diff --git a/scalefx/shaders/scalefx-pass4-hybrid.slang b/scalefx/shaders/scalefx-pass4-hybrid.slang index d8c80da..5548501 100644 --- a/scalefx/shaders/scalefx-pass4-hybrid.slang +++ b/scalefx/shaders/scalefx-pass4-hybrid.slang @@ -139,12 +139,12 @@ void main() vec3 D0 = TEX(-1, 0), D1 = TEX(-2, 0), F0 = TEX( 1, 0), F1 = TEX( 2, 0); // output coordinate - 0 = E0, 1 = D0, 2 = D1, 3 = F0, 4 = F1, 5 = B0, 6 = B1, 7 = H0, 8 = H1 - vec3 sfx = res.x == 1 ? D0 : res.x == 2 ? D1 : res.x == 3 ? F0 : res.x == 4 ? F1 : res.x == 5 ? B0 : res.x == 6 ? B1 : res.x == 7 ? H0 : H1; + vec3 sfx = res.x == 1. ? D0 : res.x == 2. ? D1 : res.x == 3. ? F0 : res.x == 4. ? F1 : res.x == 5. ? B0 : res.x == 6. ? B1 : res.x == 7. ? H0 : H1; // rAA weight - vec2 w = 2 * fc - 1; - w.x = res.y == 0 ? w.x : 0; - w.y = res.z == 0 ? w.y : 0; + vec2 w = 2. * fc - 1.; + w.x = res.y == 0. ? w.x : 0.; + w.y = res.z == 0. ? w.y : 0.; // rAA filter vec3 t1 = res2x(D1, D0, E0, F0, F1); @@ -155,5 +155,5 @@ void main() vec3 raa = clamp(E0 + w.x*t1 + w.y*t2, a, b); // hybrid output - FragColor = vec4((res.x != 0) ? sfx : raa, 0); + FragColor = vec4((res.x != 0.) ? sfx : raa, 0.); } diff --git a/scalefx/shaders/scalefx-pass4.slang b/scalefx/shaders/scalefx-pass4.slang index f69329e..f717969 100644 --- a/scalefx/shaders/scalefx-pass4.slang +++ b/scalefx/shaders/scalefx-pass4.slang @@ -104,10 +104,10 @@ void main() // determine subpixel vec2 fp = floor(3.0 * fract(vTexCoord * params.SourceSize.xy)); - float sp = fp.y == 0 ? (fp.x == 0 ? crn.x : fp.x == 1 ? mid.x : crn.y) : (fp.y == 1 ? (fp.x == 0 ? mid.w : fp.x == 1 ? 0 : mid.y) : (fp.x == 0 ? crn.w : fp.x == 1 ? mid.z : crn.z)); + float sp = fp.y == 0. ? (fp.x == 0. ? crn.x : fp.x == 1. ? mid.x : crn.y) : (fp.y == 1. ? (fp.x == 0. ? mid.w : fp.x == 1. ? 0. : mid.y) : (fp.x == 0. ? crn.w : fp.x == 1. ? mid.z : crn.z)); // output coordinate - 0 = E, 1 = D, 2 = D0, 3 = F, 4 = F0, 5 = B, 6 = B0, 7 = H, 8 = H0 - vec2 res = sp == 0 ? vec2(0,0) : sp == 1 ? vec2(-1,0) : sp == 2 ? vec2(-2,0) : sp == 3 ? vec2(1,0) : sp == 4 ? vec2(2,0) : sp == 5 ? vec2(0,-1) : sp == 6 ? vec2(0,-2) : sp == 7 ? vec2(0,1) : vec2(0,2); + vec2 res = sp == 0. ? vec2(0,0) : sp == 1. ? vec2(-1,0) : sp == 2. ? vec2(-2,0) : sp == 3. ? vec2(1,0) : sp == 4. ? vec2(2,0) : sp == 5. ? vec2(0,-1) : sp == 6. ? vec2(0,-2) : sp == 7. ? vec2(0,1) : vec2(0,2); // ouput FragColor = texture(refpass, vTexCoord + res / params.SourceSize.xy);