From 2b897106001b03f98963ef9d31afe8f5f83b0d3d Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 8 Aug 2020 18:05:58 +0900 Subject: [PATCH] graphicsdriver/metal: Refactoring --- internal/graphicsdriver/metal/graphics.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/internal/graphicsdriver/metal/graphics.go b/internal/graphicsdriver/metal/graphics.go index 4923313ae..d85464bba 100644 --- a/internal/graphicsdriver/metal/graphics.go +++ b/internal/graphicsdriver/metal/graphics.go @@ -116,11 +116,12 @@ inline float2 AdjustTexelByAddress(float2 p, float4 source_regio template struct ColorFromTexel; +constexpr sampler texture_sampler{filter::nearest}; + template<> struct ColorFromTexel { inline float4 Do(VertexOut v, texture2d texture, constant float2& source_size, float scale, constant float4& source_region) { float2 p = v.tex; - constexpr sampler texture_sampler(filter::nearest); return texture.sample(texture_sampler, p); } }; @@ -133,7 +134,6 @@ struct ColorFromTexel { source_region[1] <= p.y && p.x < source_region[2] && p.y < source_region[3]) { - constexpr sampler texture_sampler(filter::nearest); return texture.sample(texture_sampler, p); } return 0.0; @@ -143,7 +143,6 @@ struct ColorFromTexel { template<> struct ColorFromTexel { inline float4 Do(VertexOut v, texture2d texture, constant float2& source_size, float scale, constant float4& source_region) { - constexpr sampler texture_sampler(filter::nearest); const float2 texel_size = 1 / source_size; // Shift 1/512 [texel] to avoid the tie-breaking issue. @@ -164,7 +163,6 @@ struct ColorFromTexel { template struct ColorFromTexel { inline float4 Do(VertexOut v, texture2d texture, constant float2& source_size, float scale, constant float4& source_region) { - constexpr sampler texture_sampler(filter::nearest); const float2 texel_size = 1 / source_size; // Shift 1/512 [texel] to avoid the tie-breaking issue. @@ -204,7 +202,6 @@ struct ColorFromTexel { template struct ColorFromTexel { inline float4 Do(VertexOut v, texture2d texture, constant float2& source_size, float scale, constant float4& source_region) { - constexpr sampler texture_sampler(filter::nearest); const float2 texel_size = 1 / source_size; float2 p0 = v.tex - texel_size / 2.0 / scale + (texel_size / 512.0);