internal/graphicsdriver/opengl, metal, directx: refactoring: clean up the built-in shaders

This commit is contained in:
Hajime Hoshi 2022-10-01 14:35:26 +09:00
parent 9d06875243
commit a10f3d1dad
3 changed files with 5 additions and 5 deletions

View File

@ -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)

View File

@ -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<ADDRESS_REPEAT>(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<uint8_t filter, uint8_t address>

View File

@ -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)