From 56e41a5383055fa44b6176f0c57352171a30a1f2 Mon Sep 17 00:00:00 2001 From: Stuart Carnie Date: Sat, 14 Jul 2018 15:59:59 -0700 Subject: [PATCH] fix(mdapt): Rename and + or functions for SPIRV-Cross compatibility --- .../shaders/mdapt/passes/mdapt-pass0.slang | 4 ++-- .../shaders/mdapt/passes/mdapt-pass1.slang | 18 +++++++------- .../shaders/mdapt/passes/mdapt-pass3.slang | 14 +++++------ .../shaders/mdapt/passes/mdapt-pass4.slang | 24 +++++++++---------- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/dithering/shaders/mdapt/passes/mdapt-pass0.slang b/dithering/shaders/mdapt/passes/mdapt-pass0.slang index 350c08e..6b0f43b 100644 --- a/dithering/shaders/mdapt/passes/mdapt-pass0.slang +++ b/dithering/shaders/mdapt/passes/mdapt-pass0.slang @@ -40,7 +40,7 @@ float eq(vec3 A, vec3 B) return pow( smoothstep(3.0, 0.0, sqrt(diff.x + diff.y + diff.z)), params.PWR ); } -float and(float a, float b, float c, float d, float e, float f){ +float and_(float a, float b, float c, float d, float e, float f){ return min(a, min(b, min(c, min(d, min(e,f))))); } @@ -87,7 +87,7 @@ void main() res.x = dot(dCL, dCR) * eq(L,R); res.y = dot(dCU, dCD) * eq(U,D); - res.z = and(res.x, res.y, dot(dCL, dCU) * eq(L,U), dot(dCL, dCD) * eq(L,D), dot(dCR, dCU) * eq(R,U), dot(dCR, dCD) * eq(R,D)); + res.z = and_(res.x, res.y, dot(dCL, dCU) * eq(L,U), dot(dCL, dCD) * eq(L,D), dot(dCR, dCU) * eq(R,U), dot(dCR, dCD) * eq(R,D)); } FragColor = vec4(res, 1.0); diff --git a/dithering/shaders/mdapt/passes/mdapt-pass1.slang b/dithering/shaders/mdapt/passes/mdapt-pass1.slang index 8798a2c..95313b7 100644 --- a/dithering/shaders/mdapt/passes/mdapt-pass1.slang +++ b/dithering/shaders/mdapt/passes/mdapt-pass1.slang @@ -19,19 +19,19 @@ layout(push_constant) uniform Push #define TEX(dx,dy) texture(Source, vTexCoord+vec2((dx),(dy))*params.SourceSize.zw) -float and(float a, float b){ +float and_(float a, float b){ return min(a,b); } -float and(float a, float b, float c){ +float and_(float a, float b, float c){ return min(a, min(b,c)); } -float or(float a, float b){ +float or_(float a, float b){ return max(a,b); } -float or(float a, float b, float c, float d, float e){ +float or_(float a, float b, float c, float d, float e){ return max(a, max(b, max(c, max(d,e)))); } @@ -76,10 +76,10 @@ void main() float DR = TEX( 1., 1.).z; // Checkerboard Pattern Completion - float prCB = or(C.z, - and(L.z, R.z, or(U.x, D.x)), - and(U.z, D.z, or(L.y, R.y)), - and(C.x, or(and(UL, UR), and(DL, DR))), - and(C.y, or(and(UL, DL), and(UR, DR)))); + float prCB = or_(C.z, + and_(L.z, R.z, or_(U.x, D.x)), + and_(U.z, D.z, or_(L.y, R.y)), + and_(C.x, or_(and_(UL, UR), and_(DL, DR))), + and_(C.y, or_(and_(UL, DL), and_(UR, DR)))); FragColor = vec4(C.x, prCB, 0.0, 0.0); } \ No newline at end of file diff --git a/dithering/shaders/mdapt/passes/mdapt-pass3.slang b/dithering/shaders/mdapt/passes/mdapt-pass3.slang index 251a120..bfab708 100644 --- a/dithering/shaders/mdapt/passes/mdapt-pass3.slang +++ b/dithering/shaders/mdapt/passes/mdapt-pass3.slang @@ -28,23 +28,23 @@ bool eq(vec3 A, vec3 B){ return (A == B); } -float and(float a, float b){ +float and_(float a, float b){ return min(a,b); } -float or(float a, float b, float c, float d, float e, float f, float g, float h, float i){ +float or_(float a, float b, float c, float d, float e, float f, float g, float h, float i){ return max(a, max(b, max(c, max(d, max(e, max(f, max(g, max(h,i)))))))); } -vec2 and(vec2 a, vec2 b){ +vec2 and_(vec2 a, vec2 b){ return min(a,b); } -vec2 or(vec2 a, vec2 b){ +vec2 or_(vec2 a, vec2 b){ return max(a,b); } -vec2 or(vec2 a, vec2 b, vec2 c, vec2 d){ +vec2 or_(vec2 a, vec2 b, vec2 c, vec2 d){ return max(a, max(b, max(c,d))); } @@ -84,10 +84,10 @@ void main() float DR = TEX( 1., 1.).y; vec3 dr = TEXt0( 1., 1.).xyz; // Backpropagation - C.xy = or(C.xy, and(C.zw, or(L, R, U, D))); + C.xy = or_(C.xy, and_(C.zw, or_(L, R, U, D))); // Checkerboard Smoothing - C.y = or(C.y, min(U.y, float(eq(c,u))), min(D.y, float(eq(c,d))), min(L.y, float(eq(c,l))), min(R.y, float(eq(c,r))), min(UL, float(eq(c,ul))), min(UR, float(eq(c,ur))), min(DL, float(eq(c,dl))), min(DR, float(eq(c,dr)))); + C.y = or_(C.y, min(U.y, float(eq(c,u))), min(D.y, float(eq(c,d))), min(L.y, float(eq(c,l))), min(R.y, float(eq(c,r))), min(UL, float(eq(c,ul))), min(UR, float(eq(c,ur))), min(DL, float(eq(c,dl))), min(DR, float(eq(c,dr)))); FragColor = vec4(C); } \ No newline at end of file diff --git a/dithering/shaders/mdapt/passes/mdapt-pass4.slang b/dithering/shaders/mdapt/passes/mdapt-pass4.slang index a26ce68..5954079 100644 --- a/dithering/shaders/mdapt/passes/mdapt-pass4.slang +++ b/dithering/shaders/mdapt/passes/mdapt-pass4.slang @@ -64,27 +64,27 @@ bool eq(vec3 A, vec3 B){ return (A == B); } -float and(float a, float b){ +float and_(float a, float b){ return min(a,b); } -float or(float a, float b){ +float or_(float a, float b){ return max(a,b); } -float or(float a, float b, float c, float d, float e, float f, float g, float h, float i){ +float or_(float a, float b, float c, float d, float e, float f, float g, float h, float i){ return max(a, max(b, max(c, max(d, max(e, max(f, max(g, max(h,i)))))))); } -vec2 and(vec2 a, vec2 b){ +vec2 and_(vec2 a, vec2 b){ return min(a,b); } -vec2 or(vec2 a, vec2 b){ +vec2 or_(vec2 a, vec2 b){ return max(a,b); } -vec2 or(vec2 a, vec2 b, vec2 c, vec2 d){ +vec2 or_(vec2 a, vec2 b, vec2 c, vec2 d){ return max(a, max(b, max(c,d))); } @@ -107,7 +107,7 @@ void main() // Backpropagation - C.xy = or(C.xy, and(C.zw, or(L.xy, R.xy, U.xy, D.xy))); + C.xy = or_(C.xy, and_(C.zw, or_(L.xy, R.xy, U.xy, D.xy))); if(params.VL > 0.5){ @@ -130,10 +130,10 @@ void main() float eqCU = float(eq(c,u)); float eqCD = float(eq(c,d)); - float prU = or(U.y, eqCU); - float prD = or(D.y, eqCD); - float prL = or(L.y, eqCL); - float prR = or(R.y, eqCR); + float prU = or_(U.y, eqCU); + float prD = or_(D.y, eqCD); + float prL = or_(L.y, eqCL); + float prR = or_(R.y, eqCR); float prSum = prU + prD + prL + prR; @@ -151,7 +151,7 @@ void main() float DR = TEX( 1., 1.).y; vec3 dr = TEXt0( 1., 1.).xyz; // Checkerboard Smoothing - prCB = or(C.y, and(L.y, eqCL), and(R.y, eqCR), and(U.y, eqCU), and(D.y, eqCD), and(UL, float(eq(c,ul))), and(UR, float(eq(c,ur))), and(DL, float(eq(c,dl))), and(DR, float(eq(c,dr)))); + prCB = or_(C.y, and_(L.y, eqCL), and_(R.y, eqCR), and_(U.y, eqCU), and_(D.y, eqCD), and_(UL, float(eq(c,ul))), and_(UR, float(eq(c,ur))), and_(DL, float(eq(c,dl))), and_(DR, float(eq(c,dr)))); } if(params.DEBUG > 0.5)