From 1d33c8decb9ad28778eb7efe4a7eca9bd6d6cce1 Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Tue, 23 Feb 2016 23:04:48 +0100 Subject: [PATCH] Use textureLodOffset. Save some ALU! --- crt/cubic.slang | 4 +--- crt/scanline.slang | 2 +- crt/sinc.slang | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/crt/cubic.slang b/crt/cubic.slang index 888ddc1..641ae1f 100644 --- a/crt/cubic.slang +++ b/crt/cubic.slang @@ -24,15 +24,13 @@ layout(location = 0) in vec2 vTexCoord; layout(location = 0) out vec4 FragColor; layout(set = 0, binding = 2) uniform sampler2D Source; -#define PI 3.1415926535 - void main() { float u = vTexCoord.x * global.SourceSize.x - 0.5; float a = fract(u); vec2 tex = vec2((floor(u) + 0.5) * global.SourceSize.z, vTexCoord.y); -#define TEX(x, y) textureLod(Source, tex + vec2(x * global.SourceSize.z, 0.0), 0.0).rgb +#define TEX(x, y) textureLodOffset(Source, tex, 0.0, ivec2(x, y)).rgb vec3 i0 = TEX(-1, 0); vec3 i1 = TEX( 0, 0); diff --git a/crt/scanline.slang b/crt/scanline.slang index c70031d..061d8f1 100644 --- a/crt/scanline.slang +++ b/crt/scanline.slang @@ -42,7 +42,7 @@ void main() tex.y = floor(tex.y) + 0.5; tex = tex * global.SourceSize.zw; -#define TEX(x, y) textureLod(Source, tex + vec2(0, y * global.SourceSize.w), 0.0).rgb +#define TEX(x, y) textureLodOffset(Source, tex, 0.0, ivec2(x, y)).rgb vec3 l0 = TEX(0, -1); vec3 l1 = TEX(0, 0); vec3 l2 = TEX(0, 1); diff --git a/crt/sinc.slang b/crt/sinc.slang index 01bd5ee..1269a24 100644 --- a/crt/sinc.slang +++ b/crt/sinc.slang @@ -43,7 +43,7 @@ void main() float a = fract(u); vec2 tex = vec2((floor(u) + 0.5) * global.SourceSize.z, vTexCoord.y); -#define TEX(x, y) textureLod(Source, tex + vec2(x * global.SourceSize.z, 0.0), 0.0).rgb +#define TEX(x, y) textureLodOffset(Source, tex, 0.0, ivec2(x, y)).rgb vec3 color = kernel(a + 1.0) * TEX(-1, 0) +