diff --git a/internal/graphicsdriver/directx/pipeline_windows.go b/internal/graphicsdriver/directx/pipeline_windows.go index 70a5a4c47..5fe13386b 100644 --- a/internal/graphicsdriver/directx/pipeline_windows.go +++ b/internal/graphicsdriver/directx/pipeline_windows.go @@ -132,7 +132,7 @@ PSInput VSMain(float2 position : POSITION, float2 tex : TEXCOORD, float4 color : Texture2D tex : register(t0); SamplerState samp : register(s0); -float euclideanMod(float x, float y) { +float2 euclideanMod(float2 x, float2 y) { // Assume that y is always positive. return x - y * floor(x/y); } @@ -145,7 +145,7 @@ float2 adjustTexelByAddress(float2 p, float4 source_region) { #if defined(ADDRESS_REPEAT) float2 o = float2(source_region[0], source_region[1]); float2 size = float2(source_region[2] - source_region[0], source_region[3] - source_region[1]); - return float2(euclideanMod((p.x - o.x), size.x) + o.x, euclideanMod((p.y - o.y), size.y) + o.y); + return euclideanMod((p - o), size) + o; #endif #if defined(ADDRESS_UNSAFE) diff --git a/internal/graphicsdriver/metal/graphics_darwin.go b/internal/graphicsdriver/metal/graphics_darwin.go index 11091dca4..30df6d051 100644 --- a/internal/graphicsdriver/metal/graphics_darwin.go +++ b/internal/graphicsdriver/metal/graphics_darwin.go @@ -77,7 +77,7 @@ vertex VertexOut VertexShader( return out; } -float EuclideanMod(float x, float y) { +float2 EuclideanMod(float2 x, float2 y) { // Assume that y is always positive. return x - y * floor(x/y); } @@ -94,7 +94,7 @@ template<> inline float2 AdjustTexelByAddress(float2 p, float4 source_region) { float2 o = float2(source_region[0], source_region[1]); float2 size = float2(source_region[2] - source_region[0], source_region[3] - source_region[1]); - return float2(EuclideanMod((p.x - o.x), size.x) + o.x, EuclideanMod((p.y - o.y), size.y) + o.y); + return EuclideanMod((p - o), size) + o; } template diff --git a/internal/graphicsdriver/opengl/defaultshader.go b/internal/graphicsdriver/opengl/defaultshader.go index eb3c51364..9b0cf1ae6 100644 --- a/internal/graphicsdriver/opengl/defaultshader.go +++ b/internal/graphicsdriver/opengl/defaultshader.go @@ -160,7 +160,7 @@ highp vec2 adjustTexelByAddress(highp vec2 p, highp vec4 source_region) { #if defined(ADDRESS_REPEAT) highp vec2 o = vec2(source_region[0], source_region[1]); highp vec2 size = vec2(source_region[2] - source_region[0], source_region[3] - source_region[1]); - return vec2(mod((p.x - o.x), size.x) + o.x, mod((p.y - o.y), size.y) + o.y); + return mod((p - o), size) + o; #endif #if defined(ADDRESS_UNSAFE)