Combine sampler method and option into a structure.
Change-Id: Ie3caecf275ffb51fbd512560cb66fcf2a32b3bbe
Reviewed-on: https://swiftshader-review.googlesource.com/5595
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Meng-Lin Wu <marleymoo@google.com>
Tested-by: Meng-Lin Wu <marleymoo@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/Shader/PixelProgram.cpp b/src/Shader/PixelProgram.cpp
index 567561a..5c04196 100644
--- a/src/Shader/PixelProgram.cpp
+++ b/src/Shader/PixelProgram.cpp
@@ -676,13 +676,13 @@
}
}
- void PixelProgram::sampleTexture(Vector4f &c, const Src &sampler, Vector4f &uvwq, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, SamplerMethod method, unsigned int options)
+ void PixelProgram::sampleTexture(Vector4f &c, const Src &sampler, Vector4f &uvwq, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, SamplerFunction function)
{
Vector4f tmp;
if(sampler.type == Shader::PARAMETER_SAMPLER && sampler.rel.type == Shader::PARAMETER_VOID)
{
- sampleTexture(tmp, sampler.index, uvwq, dsx, dsy, offset, method, options);
+ sampleTexture(tmp, sampler.index, uvwq, dsx, dsy, offset, function);
}
else
{
@@ -694,7 +694,7 @@
{
If(index == i)
{
- sampleTexture(tmp, i, uvwq, dsx, dsy, offset, method, options);
+ sampleTexture(tmp, i, uvwq, dsx, dsy, offset, function);
// FIXME: When the sampler states are the same, we could use one sampler and just index the texture
}
}
@@ -707,14 +707,14 @@
c.w = tmp[(sampler.swizzle >> 6) & 0x3];
}
- void PixelProgram::sampleTexture(Vector4f &c, int samplerIndex, Vector4f &uvwq, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, SamplerMethod method, unsigned int options)
+ void PixelProgram::sampleTexture(Vector4f &c, int samplerIndex, Vector4f &uvwq, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, SamplerFunction function)
{
#if PERF_PROFILE
Long texTime = Ticks();
#endif
Pointer<Byte> texture = data + OFFSET(DrawData, mipmap) + samplerIndex * sizeof(Texture);
- sampler[samplerIndex]->sampleTexture(texture, c, uvwq.x, uvwq.y, uvwq.z, uvwq.w, dsx, dsy, offset, options, method);
+ sampler[samplerIndex]->sampleTexture(texture, c, uvwq.x, uvwq.y, uvwq.z, uvwq.w, dsx, dsy, offset, function);
#if PERF_PROFILE
cycles[PERF_TEX] += Ticks() - texTime;
@@ -1103,52 +1103,52 @@
proj.y = src0.y * rw;
proj.z = src0.z * rw;
- sampleTexture(dst, src1, proj, src0, src0, src0, Implicit, None);
+ sampleTexture(dst, src1, proj, src0, src0, src0, Implicit);
}
else
{
- sampleTexture(dst, src1, src0, src0, src0, src0, bias ? Bias : Implicit, None);
+ sampleTexture(dst, src1, src0, src0, src0, src0, bias ? Bias : Implicit);
}
}
void PixelProgram::TEXOFFSET(Vector4f &dst, Vector4f &src0, const Src &src1, Vector4f &src2, bool bias)
{
- sampleTexture(dst, src1, src0, src0, src0, src2, bias ? Bias : Implicit, Offset);
+ sampleTexture(dst, src1, src0, src0, src0, src2, {bias ? Bias : Implicit, Offset});
}
void PixelProgram::TEXLDL(Vector4f &dst, Vector4f &src0, const Src &src1, Vector4f &offset, bool bias)
{
- sampleTexture(dst, src1, src0, src0, src0, offset, Lod, Offset);
+ sampleTexture(dst, src1, src0, src0, src0, offset, {Lod, Offset});
}
void PixelProgram::TEXELFETCH(Vector4f &dst, Vector4f &src0, const Src& src1)
{
- sampleTexture(dst, src1, src0, src0, src0, src0, Lod, Fetch);
+ sampleTexture(dst, src1, src0, src0, src0, src0, Fetch);
}
void PixelProgram::TEXELFETCH(Vector4f &dst, Vector4f &src0, const Src& src1, Vector4f &offset)
{
- sampleTexture(dst, src1, src0, src0, src0, offset, Lod, Fetch | Offset);
+ sampleTexture(dst, src1, src0, src0, src0, offset, {Fetch, Offset});
}
void PixelProgram::TEXGRAD(Vector4f &dst, Vector4f &src0, const Src& src1, Vector4f &src2, Vector4f &src3)
{
- sampleTexture(dst, src1, src0, src2, src3, src0, Grad, None);
+ sampleTexture(dst, src1, src0, src2, src3, src0, Grad);
}
void PixelProgram::TEXGRAD(Vector4f &dst, Vector4f &src0, const Src& src1, Vector4f &src2, Vector4f &src3, Vector4f &offset)
{
- sampleTexture(dst, src1, src0, src2, src3, offset, Grad, Offset);
+ sampleTexture(dst, src1, src0, src2, src3, offset, {Grad, Offset});
}
void PixelProgram::TEXLDD(Vector4f &dst, Vector4f &src0, const Src &src1, Vector4f &src2, Vector4f &src3)
{
- sampleTexture(dst, src1, src0, src2, src3, src0, Grad, None);
+ sampleTexture(dst, src1, src0, src2, src3, src0, Grad);
}
void PixelProgram::TEXLDL(Vector4f &dst, Vector4f &src0, const Src &src1)
{
- sampleTexture(dst, src1, src0, src0, src0, src0, Lod, None);
+ sampleTexture(dst, src1, src0, src0, src0, src0, Lod);
}
void PixelProgram::TEXSIZE(Vector4f &dst, Float4 &lod, const Src &src1)
diff --git a/src/Shader/PixelProgram.hpp b/src/Shader/PixelProgram.hpp
index 6b60cc0..965be33 100644
--- a/src/Shader/PixelProgram.hpp
+++ b/src/Shader/PixelProgram.hpp
@@ -82,8 +82,8 @@
Int4 enableContinue;
Int4 enableLeave;
- void sampleTexture(Vector4f &c, const Src &sampler, Vector4f &uvwq, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, SamplerMethod method, unsigned int options);
- void sampleTexture(Vector4f &c, int samplerIndex, Vector4f &uvwq, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, SamplerMethod method, unsigned int options);
+ void sampleTexture(Vector4f &c, const Src &sampler, Vector4f &uvwq, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, SamplerFunction function);
+ void sampleTexture(Vector4f &c, int samplerIndex, Vector4f &uvwq, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, SamplerFunction function);
// Raster operations
void clampColor(Vector4f oC[RENDERTARGETS]);
diff --git a/src/Shader/SamplerCore.cpp b/src/Shader/SamplerCore.cpp
index 6c5e304..7c03dd4 100644
--- a/src/Shader/SamplerCore.cpp
+++ b/src/Shader/SamplerCore.cpp
@@ -56,10 +56,10 @@
void SamplerCore::sampleTexture(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy)
{
- sampleTexture(texture, c, u, v, w, q, dsx, dsy, dsx, None, Implicit, true);
+ sampleTexture(texture, c, u, v, w, q, dsx, dsy, dsx, Implicit, true);
}
- void SamplerCore::sampleTexture(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, unsigned int options, SamplerMethod method, bool fixed12)
+ void SamplerCore::sampleTexture(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, SamplerFunction function, bool fixed12)
{
#if PERF_PROFILE
AddAtomic(Pointer<Long>(&profiler.texOperations), 4);
@@ -105,33 +105,33 @@
Float anisotropy;
Float4 uDelta;
Float4 vDelta;
- Float lodBias = (options & Fetch) ? Float4(As<Int4>(q)).x : q.x;
+ Float lodBias = (function == Fetch) ? Float4(As<Int4>(q)).x : q.x;
if(state.textureType != TEXTURE_3D)
{
if(state.textureType != TEXTURE_CUBE)
{
- computeLod(texture, lod, anisotropy, uDelta, vDelta, uuuu, vvvv, lodBias, dsx, dsy, method);
+ computeLod(texture, lod, anisotropy, uDelta, vDelta, uuuu, vvvv, lodBias, dsx, dsy, function);
}
else
{
- computeLodCube(texture, lod, lodX, lodY, lodZ, lodBias, dsx, dsy, method);
+ computeLodCube(texture, lod, lodX, lodY, lodZ, lodBias, dsx, dsy, function);
}
}
else
{
- computeLod3D(texture, lod, uuuu, vvvv, wwww, lodBias, dsx, dsy, method);
+ computeLod3D(texture, lod, uuuu, vvvv, wwww, lodBias, dsx, dsy, function);
}
if(!hasFloatTexture())
{
- sampleFilter(texture, c, uuuu, vvvv, wwww, offset, lod, anisotropy, uDelta, vDelta, face, options, method);
+ sampleFilter(texture, c, uuuu, vvvv, wwww, offset, lod, anisotropy, uDelta, vDelta, face, function);
}
else
{
Vector4f cf;
- sampleFloatFilter(texture, cf, uuuu, vvvv, wwww, offset, lod, anisotropy, uDelta, vDelta, face, options, method);
+ sampleFloatFilter(texture, cf, uuuu, vvvv, wwww, offset, lod, anisotropy, uDelta, vDelta, face, function);
convertFixed12(c, cf);
}
@@ -294,7 +294,7 @@
}
}
- void SamplerCore::sampleTexture(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, unsigned int options, SamplerMethod method)
+ void SamplerCore::sampleTexture(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, SamplerFunction function)
{
#if PERF_PROFILE
AddAtomic(Pointer<Long>(&profiler.texOperations), 4);
@@ -334,31 +334,31 @@
Float anisotropy;
Float4 uDelta;
Float4 vDelta;
- Float lodBias = (options & Fetch) ? Float4(As<Int4>(q)).x : q.x;
+ Float lodBias = (function == Fetch) ? Float4(As<Int4>(q)).x : q.x;
if(state.textureType != TEXTURE_3D)
{
if(state.textureType != TEXTURE_CUBE)
{
- computeLod(texture, lod, anisotropy, uDelta, vDelta, uuuu, vvvv, lodBias, dsx, dsy, method);
+ computeLod(texture, lod, anisotropy, uDelta, vDelta, uuuu, vvvv, lodBias, dsx, dsy, function);
}
else
{
- computeLodCube(texture, lod, lodX, lodY, lodZ, lodBias, dsx, dsy, method);
+ computeLodCube(texture, lod, lodX, lodY, lodZ, lodBias, dsx, dsy, function);
}
}
else
{
- computeLod3D(texture, lod, uuuu, vvvv, wwww, lodBias, dsx, dsy, method);
+ computeLod3D(texture, lod, uuuu, vvvv, wwww, lodBias, dsx, dsy, function);
}
- sampleFloatFilter(texture, c, uuuu, vvvv, wwww, offset, lod, anisotropy, uDelta, vDelta, face, options, method);
+ sampleFloatFilter(texture, c, uuuu, vvvv, wwww, offset, lod, anisotropy, uDelta, vDelta, face, function);
}
else
{
Vector4s cs;
- sampleTexture(texture, cs, u, v, w, q, dsx, dsy, offset, options, method, false);
+ sampleTexture(texture, cs, u, v, w, q, dsx, dsy, offset, function, false);
for(int component = 0; component < textureComponentCount(); component++)
{
@@ -611,11 +611,11 @@
return uvw;
}
- void SamplerCore::sampleFilter(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], unsigned int options, SamplerMethod method)
+ void SamplerCore::sampleFilter(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], SamplerFunction function)
{
- sampleAniso(texture, c, u, v, w, offset, lod, anisotropy, uDelta, vDelta, face, false, options, method);
+ sampleAniso(texture, c, u, v, w, offset, lod, anisotropy, uDelta, vDelta, face, false, function);
- if(options & Fetch)
+ if(function == Fetch)
{
return;
}
@@ -624,7 +624,7 @@
{
Vector4s cc;
- sampleAniso(texture, cc, u, v, w, offset, lod, anisotropy, uDelta, vDelta, face, true, options, method);
+ sampleAniso(texture, cc, u, v, w, offset, lod, anisotropy, uDelta, vDelta, face, true, function);
lod *= Float(1 << 16);
@@ -712,11 +712,11 @@
}
}
- void SamplerCore::sampleAniso(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool secondLOD, unsigned int options, SamplerMethod method)
+ void SamplerCore::sampleAniso(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool secondLOD, SamplerFunction function)
{
- if(state.textureFilter != FILTER_ANISOTROPIC || method == Lod || options & Fetch)
+ if(state.textureFilter != FILTER_ANISOTROPIC || function == Lod || function == Fetch)
{
- sampleQuad(texture, c, u, v, w, offset, lod, face, secondLOD, options);
+ sampleQuad(texture, c, u, v, w, offset, lod, face, secondLOD, function);
}
else
{
@@ -747,7 +747,7 @@
Do
{
- sampleQuad(texture, c, u0, v0, w, offset, lod, face, secondLOD, options);
+ sampleQuad(texture, c, u0, v0, w, offset, lod, face, secondLOD, function);
u0 += du;
v0 += dv;
@@ -768,19 +768,19 @@
}
}
- void SamplerCore::sampleQuad(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Int face[4], bool secondLOD, unsigned int options)
+ void SamplerCore::sampleQuad(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Int face[4], bool secondLOD, SamplerFunction function)
{
if(state.textureType != TEXTURE_3D)
{
- sampleQuad2D(texture, c, u, v, w, offset, lod, face, secondLOD, options);
+ sampleQuad2D(texture, c, u, v, w, offset, lod, face, secondLOD, function);
}
else
{
- sample3D(texture, c, u, v, w, offset, lod, secondLOD, options);
+ sample3D(texture, c, u, v, w, offset, lod, secondLOD, function);
}
}
- void SamplerCore::sampleQuad2D(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Int face[4], bool secondLOD, unsigned int options)
+ void SamplerCore::sampleQuad2D(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Int face[4], bool secondLOD, SamplerFunction function)
{
int componentCount = textureComponentCount();
bool gather = state.textureFilter == FILTER_GATHER;
@@ -790,7 +790,7 @@
selectMipmap(texture, buffer, mipmap, lod, face, secondLOD);
- bool texelFetch = (options & Fetch) != 0;
+ bool texelFetch = (function == Fetch);
Short4 uuuu = texelFetch ? Short4(As<Int4>(u)) : address(u, state.addressingModeU, mipmap);
Short4 vvvv = texelFetch ? Short4(As<Int4>(v)) : address(v, state.addressingModeV, mipmap);
@@ -798,7 +798,7 @@
if(state.textureFilter == FILTER_POINT || texelFetch)
{
- sampleTexel(c, uuuu, vvvv, wwww, offset, mipmap, buffer, options);
+ sampleTexel(c, uuuu, vvvv, wwww, offset, mipmap, buffer, function);
}
else
{
@@ -812,10 +812,10 @@
Short4 uuuu1 = offsetSample(uuuu, mipmap, OFFSET(Mipmap,uHalf), state.addressingModeU == ADDRESSING_WRAP, gather ? 2 : +1, lod);
Short4 vvvv1 = offsetSample(vvvv, mipmap, OFFSET(Mipmap,vHalf), state.addressingModeV == ADDRESSING_WRAP, gather ? 2 : +1, lod);
- sampleTexel(c0, uuuu0, vvvv0, wwww, offset, mipmap, buffer, options);
- sampleTexel(c1, uuuu1, vvvv0, wwww, offset, mipmap, buffer, options);
- sampleTexel(c2, uuuu0, vvvv1, wwww, offset, mipmap, buffer, options);
- sampleTexel(c3, uuuu1, vvvv1, wwww, offset, mipmap, buffer, options);
+ sampleTexel(c0, uuuu0, vvvv0, wwww, offset, mipmap, buffer, function);
+ sampleTexel(c1, uuuu1, vvvv0, wwww, offset, mipmap, buffer, function);
+ sampleTexel(c2, uuuu0, vvvv1, wwww, offset, mipmap, buffer, function);
+ sampleTexel(c3, uuuu1, vvvv1, wwww, offset, mipmap, buffer, function);
if(!gather) // Blend
{
@@ -987,7 +987,7 @@
}
}
- void SamplerCore::sample3D(Pointer<Byte> &texture, Vector4s &c_, Float4 &u_, Float4 &v_, Float4 &w_, Vector4f &offset, Float &lod, bool secondLOD, unsigned int options)
+ void SamplerCore::sample3D(Pointer<Byte> &texture, Vector4s &c_, Float4 &u_, Float4 &v_, Float4 &w_, Vector4f &offset, Float &lod, bool secondLOD, SamplerFunction function)
{
int componentCount = textureComponentCount();
@@ -997,7 +997,7 @@
selectMipmap(texture, buffer, mipmap, lod, face, secondLOD);
- bool texelFetch = (options & Fetch) != 0;
+ bool texelFetch = (function == Fetch);
Short4 uuuu = texelFetch ? Short4(As<Int4>(u_)) : address(u_, state.addressingModeU, mipmap);
Short4 vvvv = texelFetch ? Short4(As<Int4>(v_)) : address(v_, state.addressingModeV, mipmap);
@@ -1005,7 +1005,7 @@
if(state.textureFilter == FILTER_POINT || texelFetch)
{
- sampleTexel(c_, uuuu, vvvv, wwww, offset, mipmap, buffer, options);
+ sampleTexel(c_, uuuu, vvvv, wwww, offset, mipmap, buffer, function);
}
else
{
@@ -1089,7 +1089,7 @@
{
for(int k = 0; k < 2; k++)
{
- sampleTexel(c[i][j][k], u[i][j][k], v[i][j][k], s[i][j][k], offset, mipmap, buffer, options);
+ sampleTexel(c[i][j][k], u[i][j][k], v[i][j][k], s[i][j][k], offset, mipmap, buffer, function);
if(componentCount >= 1) { if(hasUnsignedTextureComponent(0)) c[i][j][k].x = MulHigh(As<UShort4>(c[i][j][k].x), f[1 - i][1 - j][1 - k]); else c[i][j][k].x = MulHigh(c[i][j][k].x, fs[1 - i][1 - j][1 - k]); }
if(componentCount >= 2) { if(hasUnsignedTextureComponent(1)) c[i][j][k].y = MulHigh(As<UShort4>(c[i][j][k].y), f[1 - i][1 - j][1 - k]); else c[i][j][k].y = MulHigh(c[i][j][k].y, fs[1 - i][1 - j][1 - k]); }
@@ -1120,11 +1120,11 @@
}
}
- void SamplerCore::sampleFloatFilter(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], unsigned int options, SamplerMethod method)
+ void SamplerCore::sampleFloatFilter(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], SamplerFunction function)
{
- sampleFloatAniso(texture, c, u, v, w, offset, lod, anisotropy, uDelta, vDelta, face, false, options, method);
-
- if(options & Fetch)
+ sampleFloatAniso(texture, c, u, v, w, offset, lod, anisotropy, uDelta, vDelta, face, false, function);
+
+ if(function == Fetch)
{
return;
}
@@ -1133,7 +1133,7 @@
{
Vector4f cc;
- sampleFloatAniso(texture, cc, u, v, w, offset, lod, anisotropy, uDelta, vDelta, face, true, options, method);
+ sampleFloatAniso(texture, cc, u, v, w, offset, lod, anisotropy, uDelta, vDelta, face, true, function);
Float4 lod4 = Float4(Frac(lod));
@@ -1200,11 +1200,11 @@
}
}
- void SamplerCore::sampleFloatAniso(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool secondLOD, unsigned int options, SamplerMethod method)
+ void SamplerCore::sampleFloatAniso(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool secondLOD, SamplerFunction function)
{
- if (state.textureFilter != FILTER_ANISOTROPIC || method == Lod || options & Fetch)
+ if(state.textureFilter != FILTER_ANISOTROPIC || function == Lod || function == Fetch)
{
- sampleFloat(texture, c, u, v, w, offset, lod, face, secondLOD, options);
+ sampleFloat(texture, c, u, v, w, offset, lod, face, secondLOD, function);
}
else
{
@@ -1233,7 +1233,7 @@
Do
{
- sampleFloat(texture, c, u0, v0, w, offset, lod, face, secondLOD, options);
+ sampleFloat(texture, c, u0, v0, w, offset, lod, face, secondLOD, function);
u0 += du;
v0 += dv;
@@ -1254,19 +1254,19 @@
}
}
- void SamplerCore::sampleFloat(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Int face[4], bool secondLOD, unsigned int options)
+ void SamplerCore::sampleFloat(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Int face[4], bool secondLOD, SamplerFunction function)
{
if(state.textureType != TEXTURE_3D)
{
- sampleFloat2D(texture, c, u, v, w, offset, lod, face, secondLOD, options);
+ sampleFloat2D(texture, c, u, v, w, offset, lod, face, secondLOD, function);
}
else
{
- sampleFloat3D(texture, c, u, v, w, offset, lod, secondLOD, options);
+ sampleFloat3D(texture, c, u, v, w, offset, lod, secondLOD, function);
}
}
- void SamplerCore::sampleFloat2D(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Int face[4], bool secondLOD, unsigned int options)
+ void SamplerCore::sampleFloat2D(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Int face[4], bool secondLOD, SamplerFunction function)
{
int componentCount = textureComponentCount();
bool gather = state.textureFilter == FILTER_GATHER;
@@ -1276,7 +1276,7 @@
selectMipmap(texture, buffer, mipmap, lod, face, secondLOD);
- bool texelFetch = (options & Fetch) != 0;
+ bool texelFetch = (function == Fetch);
Short4 uuuu = texelFetch ? Short4(As<Int4>(u)) : address(u, state.addressingModeU, mipmap);
Short4 vvvv = texelFetch ? Short4(As<Int4>(v)) : address(v, state.addressingModeV, mipmap);
@@ -1284,7 +1284,7 @@
if(state.textureFilter == FILTER_POINT || texelFetch)
{
- sampleTexel(c, uuuu, vvvv, wwww, offset, w, mipmap, buffer, options);
+ sampleTexel(c, uuuu, vvvv, wwww, offset, w, mipmap, buffer, function);
}
else
{
@@ -1298,10 +1298,10 @@
Short4 uuuu1 = offsetSample(uuuu, mipmap, OFFSET(Mipmap,uHalf), state.addressingModeU == ADDRESSING_WRAP, gather ? 2 : +1, lod);
Short4 vvvv1 = offsetSample(vvvv, mipmap, OFFSET(Mipmap,vHalf), state.addressingModeV == ADDRESSING_WRAP, gather ? 2 : +1, lod);
- sampleTexel(c0, uuuu0, vvvv0, wwww, offset, w, mipmap, buffer, options);
- sampleTexel(c1, uuuu1, vvvv0, wwww, offset, w, mipmap, buffer, options);
- sampleTexel(c2, uuuu0, vvvv1, wwww, offset, w, mipmap, buffer, options);
- sampleTexel(c3, uuuu1, vvvv1, wwww, offset, w, mipmap, buffer, options);
+ sampleTexel(c0, uuuu0, vvvv0, wwww, offset, w, mipmap, buffer, function);
+ sampleTexel(c1, uuuu1, vvvv0, wwww, offset, w, mipmap, buffer, function);
+ sampleTexel(c2, uuuu0, vvvv1, wwww, offset, w, mipmap, buffer, function);
+ sampleTexel(c3, uuuu1, vvvv1, wwww, offset, w, mipmap, buffer, function);
if(!gather) // Blend
{
@@ -1334,7 +1334,7 @@
}
}
- void SamplerCore::sampleFloat3D(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, bool secondLOD, unsigned int options)
+ void SamplerCore::sampleFloat3D(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, bool secondLOD, SamplerFunction function)
{
int componentCount = textureComponentCount();
@@ -1344,7 +1344,7 @@
selectMipmap(texture, buffer, mipmap, lod, face, secondLOD);
- bool texelFetch = (options & Fetch) != 0;
+ bool texelFetch = (function == Fetch);
Short4 uuuu = texelFetch ? Short4(As<Int4>(u)) : address(u, state.addressingModeU, mipmap);
Short4 vvvv = texelFetch ? Short4(As<Int4>(v)) : address(v, state.addressingModeV, mipmap);
@@ -1352,7 +1352,7 @@
if(state.textureFilter == FILTER_POINT || texelFetch)
{
- sampleTexel(c, uuuu, vvvv, wwww, offset, w, mipmap, buffer, options);
+ sampleTexel(c, uuuu, vvvv, wwww, offset, w, mipmap, buffer, function);
}
else
{
@@ -1372,14 +1372,14 @@
Short4 vvvv1 = offsetSample(vvvv, mipmap, OFFSET(Mipmap,vHalf), state.addressingModeV == ADDRESSING_WRAP, +1, lod);
Short4 wwww1 = offsetSample(wwww, mipmap, OFFSET(Mipmap,wHalf), state.addressingModeW == ADDRESSING_WRAP, +1, lod);
- sampleTexel(c0, uuuu0, vvvv0, wwww0, offset, w, mipmap, buffer, options);
- sampleTexel(c1, uuuu1, vvvv0, wwww0, offset, w, mipmap, buffer, options);
- sampleTexel(c2, uuuu0, vvvv1, wwww0, offset, w, mipmap, buffer, options);
- sampleTexel(c3, uuuu1, vvvv1, wwww0, offset, w, mipmap, buffer, options);
- sampleTexel(c4, uuuu0, vvvv0, wwww1, offset, w, mipmap, buffer, options);
- sampleTexel(c5, uuuu1, vvvv0, wwww1, offset, w, mipmap, buffer, options);
- sampleTexel(c6, uuuu0, vvvv1, wwww1, offset, w, mipmap, buffer, options);
- sampleTexel(c7, uuuu1, vvvv1, wwww1, offset, w, mipmap, buffer, options);
+ sampleTexel(c0, uuuu0, vvvv0, wwww0, offset, w, mipmap, buffer, function);
+ sampleTexel(c1, uuuu1, vvvv0, wwww0, offset, w, mipmap, buffer, function);
+ sampleTexel(c2, uuuu0, vvvv1, wwww0, offset, w, mipmap, buffer, function);
+ sampleTexel(c3, uuuu1, vvvv1, wwww0, offset, w, mipmap, buffer, function);
+ sampleTexel(c4, uuuu0, vvvv0, wwww1, offset, w, mipmap, buffer, function);
+ sampleTexel(c5, uuuu1, vvvv0, wwww1, offset, w, mipmap, buffer, function);
+ sampleTexel(c6, uuuu0, vvvv1, wwww1, offset, w, mipmap, buffer, function);
+ sampleTexel(c7, uuuu1, vvvv1, wwww1, offset, w, mipmap, buffer, function);
// Fractions
Float4 fu = Frac(Float4(As<UShort4>(uuuu0)) * *Pointer<Float4>(mipmap + OFFSET(Mipmap,fWidth)));
@@ -1426,13 +1426,13 @@
}
}
- void SamplerCore::computeLod(Pointer<Byte> &texture, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Float4 &uuuu, Float4 &vvvv, const Float &lodBias, Vector4f &dsx, Vector4f &dsy, SamplerMethod method)
+ void SamplerCore::computeLod(Pointer<Byte> &texture, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Float4 &uuuu, Float4 &vvvv, const Float &lodBias, Vector4f &dsx, Vector4f &dsy, SamplerFunction function)
{
- if(method != Lod)
+ if(function != Lod && function != Fetch)
{
Float4 duvdxy;
- if(method != Grad)
+ if(function != Grad)
{
duvdxy = Float4(uuuu.yz, vvvv.yz) - Float4(uuuu.xx, vvvv.xx);
}
@@ -1476,7 +1476,7 @@
lod -= Float(0x3F800000);
lod *= As<Float>(Int(0x33800000));
- if(method == Bias)
+ if(function == Bias)
{
lod += lodBias;
}
@@ -1490,11 +1490,11 @@
lod = Min(lod, *Pointer<Float>(texture + OFFSET(Texture, maxLod)));
}
- void SamplerCore::computeLodCube(Pointer<Byte> &texture, Float &lod, Float4 &u, Float4 &v, Float4 &s, const Float &lodBias, Vector4f &dsx, Vector4f &dsy, SamplerMethod method)
+ void SamplerCore::computeLodCube(Pointer<Byte> &texture, Float &lod, Float4 &u, Float4 &v, Float4 &s, const Float &lodBias, Vector4f &dsx, Vector4f &dsy, SamplerFunction function)
{
- if(method != Lod)
+ if(function != Lod && function != Fetch)
{
- if(method != Grad)
+ if(function != Grad)
{
Float4 dudxy = u.ywyw - u;
Float4 dvdxy = v.ywyw - v;
@@ -1535,7 +1535,7 @@
lod -= Float(0x3F800000);
lod *= As<Float>(Int(0x33800000));
- if(method == Bias)
+ if(function == Bias)
{
lod += lodBias;
}
@@ -1549,20 +1549,20 @@
lod = Min(lod, *Pointer<Float>(texture + OFFSET(Texture, maxLod)));
}
- void SamplerCore::computeLod3D(Pointer<Byte> &texture, Float &lod, Float4 &uuuu, Float4 &vvvv, Float4 &wwww, const Float &lodBias, Vector4f &dsx, Vector4f &dsy, SamplerMethod method)
+ void SamplerCore::computeLod3D(Pointer<Byte> &texture, Float &lod, Float4 &uuuu, Float4 &vvvv, Float4 &wwww, const Float &lodBias, Vector4f &dsx, Vector4f &dsy, SamplerFunction function)
{
if(state.mipmapFilter == MIPMAP_NONE)
{
}
else // Point and linear filter
{
- if(method != Lod)
+ if(function != Lod && function != Fetch)
{
Float4 dudxy;
Float4 dvdxy;
Float4 dsdxy;
- if(method != Grad)
+ if(function != Grad)
{
dudxy = uuuu.ywyw - uuuu;
dvdxy = vvvv.ywyw - vvvv;
@@ -1602,7 +1602,7 @@
lod -= Float(0x3F800000);
lod *= As<Float>(Int(0x33800000));
- if(method == Bias)
+ if(function == Bias)
{
lod += lodBias;
}
@@ -1697,12 +1697,12 @@
return As<Short4>(UShort4(tmp));
}
- void SamplerCore::computeIndices(Int index[4], Short4 uuuu, Short4 vvvv, Short4 wwww, Vector4f &offset, const Pointer<Byte> &mipmap, unsigned int options)
+ void SamplerCore::computeIndices(Int index[4], Short4 uuuu, Short4 vvvv, Short4 wwww, Vector4f &offset, const Pointer<Byte> &mipmap, SamplerFunction function)
{
Short4 uuu2;
- bool texelFetch = (options & Fetch) != 0;
- bool hasOffset = (options & Offset) != 0;
+ bool texelFetch = (function == Fetch);
+ bool hasOffset = (function.option == Offset);
if(!state.hasNPOTTexture && !hasFloatTexture() && !hasOffset)
{
@@ -1782,11 +1782,11 @@
}
}
- void SamplerCore::sampleTexel(Vector4s &c, Short4 &uuuu, Short4 &vvvv, Short4 &wwww, Vector4f &offset, Pointer<Byte> &mipmap, Pointer<Byte> buffer[4], unsigned int options)
+ void SamplerCore::sampleTexel(Vector4s &c, Short4 &uuuu, Short4 &vvvv, Short4 &wwww, Vector4f &offset, Pointer<Byte> &mipmap, Pointer<Byte> buffer[4], SamplerFunction function)
{
Int index[4];
- computeIndices(index, uuuu, vvvv, wwww, offset, mipmap, options);
+ computeIndices(index, uuuu, vvvv, wwww, offset, mipmap, function);
int f0 = state.textureType == TEXTURE_CUBE ? 0 : 0;
int f1 = state.textureType == TEXTURE_CUBE ? 1 : 0;
@@ -2022,7 +2022,7 @@
c0 = c0 | (c1 << 8) | (c2 << 16) | (c3 << 24);
UShort4 Y = As<UShort4>(Unpack(As<Byte4>(c0)));
- computeIndices(index, uuuu, vvvv, wwww, offset, mipmap + sizeof(Mipmap), options);
+ computeIndices(index, uuuu, vvvv, wwww, offset, mipmap + sizeof(Mipmap), function);
c0 = Int(*Pointer<Byte>(buffer[1] + index[0]));
c1 = Int(*Pointer<Byte>(buffer[1] + index[1]));
c2 = Int(*Pointer<Byte>(buffer[1] + index[2]));
@@ -2059,11 +2059,11 @@
else ASSERT(false);
}
- void SamplerCore::sampleTexel(Vector4f &c, Short4 &uuuu, Short4 &vvvv, Short4 &wwww, Vector4f &offset, Float4 &z, Pointer<Byte> &mipmap, Pointer<Byte> buffer[4], unsigned int options)
+ void SamplerCore::sampleTexel(Vector4f &c, Short4 &uuuu, Short4 &vvvv, Short4 &wwww, Vector4f &offset, Float4 &z, Pointer<Byte> &mipmap, Pointer<Byte> buffer[4], SamplerFunction function)
{
Int index[4];
- computeIndices(index, uuuu, vvvv, wwww, offset, mipmap, options);
+ computeIndices(index, uuuu, vvvv, wwww, offset, mipmap, function);
int f0 = state.textureType == TEXTURE_CUBE ? 0 : 0;
int f1 = state.textureType == TEXTURE_CUBE ? 1 : 0;
diff --git a/src/Shader/SamplerCore.hpp b/src/Shader/SamplerCore.hpp
index 17322b9..491d349 100644
--- a/src/Shader/SamplerCore.hpp
+++ b/src/Shader/SamplerCore.hpp
@@ -25,49 +25,58 @@
Implicit,
Bias,
Lod,
- Grad
+ Grad,
+ Fetch
};
- enum TextureFunction
+ enum SamplerOption
{
- None = 0x00,
- Offset = 0x01,
- Fetch = 0x02
+ None,
+ Offset
};
+ struct SamplerFunction
+ {
+ SamplerFunction(SamplerMethod method, SamplerOption option = None) : method(method), option(option) {}
+ operator SamplerMethod() { return method; }
+
+ const SamplerMethod method;
+ const SamplerOption option;
+ };
+
class SamplerCore
{
public:
SamplerCore(Pointer<Byte> &r, const Sampler::State &state);
void sampleTexture(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy);
- void sampleTexture(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, unsigned int options, SamplerMethod method);
+ void sampleTexture(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, SamplerFunction function);
void textureSize(Pointer<Byte> &mipmap, Vector4f &size, Float4 &lod);
private:
- void sampleTexture(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, unsigned int options, SamplerMethod method, bool fixed12);
+ void sampleTexture(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, SamplerFunction function, bool fixed12);
void border(Short4 &mask, Float4 &coordinates);
void border(Int4 &mask, Float4 &coordinates);
Short4 offsetSample(Short4 &uvw, Pointer<Byte> &mipmap, int halfOffset, bool wrap, int count, Float &lod);
- void sampleFilter(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], unsigned int options, SamplerMethod method);
- void sampleAniso(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool secondLOD, unsigned int options, SamplerMethod method);
- void sampleQuad(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Int face[4], bool secondLOD, unsigned int options);
- void sampleQuad2D(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Int face[4], bool secondLOD, unsigned int options);
- void sample3D(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, bool secondLOD, unsigned int options);
- void sampleFloatFilter(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], unsigned int options, SamplerMethod method);
- void sampleFloatAniso(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool secondLOD, unsigned int options, SamplerMethod method);
- void sampleFloat(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Int face[4], bool secondLOD, unsigned int options);
- void sampleFloat2D(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Int face[4], bool secondLOD, unsigned int options);
- void sampleFloat3D(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, bool secondLOD, unsigned int options);
- void computeLod(Pointer<Byte> &texture, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Float4 &u, Float4 &v, const Float &lodBias, Vector4f &dsx, Vector4f &dsy, SamplerMethod method);
- void computeLodCube(Pointer<Byte> &texture, Float &lod, Float4 &x, Float4 &y, Float4 &z, const Float &lodBias, Vector4f &dsx, Vector4f &dsy, SamplerMethod method);
- void computeLod3D(Pointer<Byte> &texture, Float &lod, Float4 &u, Float4 &v, Float4 &w, const Float &lodBias, Vector4f &dsx, Vector4f &dsy, SamplerMethod method);
+ void sampleFilter(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], SamplerFunction function);
+ void sampleAniso(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool secondLOD, SamplerFunction function);
+ void sampleQuad(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Int face[4], bool secondLOD, SamplerFunction function);
+ void sampleQuad2D(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Int face[4], bool secondLOD, SamplerFunction function);
+ void sample3D(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, bool secondLOD, SamplerFunction function);
+ void sampleFloatFilter(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], SamplerFunction function);
+ void sampleFloatAniso(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool secondLOD, SamplerFunction function);
+ void sampleFloat(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Int face[4], bool secondLOD, SamplerFunction function);
+ void sampleFloat2D(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, Int face[4], bool secondLOD, SamplerFunction function);
+ void sampleFloat3D(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Vector4f &offset, Float &lod, bool secondLOD, SamplerFunction function);
+ void computeLod(Pointer<Byte> &texture, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Float4 &u, Float4 &v, const Float &lodBias, Vector4f &dsx, Vector4f &dsy, SamplerFunction function);
+ void computeLodCube(Pointer<Byte> &texture, Float &lod, Float4 &x, Float4 &y, Float4 &z, const Float &lodBias, Vector4f &dsx, Vector4f &dsy, SamplerFunction function);
+ void computeLod3D(Pointer<Byte> &texture, Float &lod, Float4 &u, Float4 &v, Float4 &w, const Float &lodBias, Vector4f &dsx, Vector4f &dsy, SamplerFunction function);
void cubeFace(Int face[4], Float4 &U, Float4 &V, Float4 &lodX, Float4 &lodY, Float4 &lodZ, Float4 &x, Float4 &y, Float4 &z);
Short4 applyOffset(Short4 &uvw, Float4 &offset, const Int4 &whd, AddressingMode mode);
- void computeIndices(Int index[4], Short4 uuuu, Short4 vvvv, Short4 wwww, Vector4f &offset, const Pointer<Byte> &mipmap, unsigned int options);
- void sampleTexel(Vector4s &c, Short4 &u, Short4 &v, Short4 &s, Vector4f &offset, Pointer<Byte> &mipmap, Pointer<Byte> buffer[4], unsigned int options);
- void sampleTexel(Vector4f &c, Short4 &u, Short4 &v, Short4 &s, Vector4f &offset, Float4 &z, Pointer<Byte> &mipmap, Pointer<Byte> buffer[4], unsigned int options);
+ void computeIndices(Int index[4], Short4 uuuu, Short4 vvvv, Short4 wwww, Vector4f &offset, const Pointer<Byte> &mipmap, SamplerFunction function);
+ void sampleTexel(Vector4s &c, Short4 &u, Short4 &v, Short4 &s, Vector4f &offset, Pointer<Byte> &mipmap, Pointer<Byte> buffer[4], SamplerFunction function);
+ void sampleTexel(Vector4f &c, Short4 &u, Short4 &v, Short4 &s, Vector4f &offset, Float4 &z, Pointer<Byte> &mipmap, Pointer<Byte> buffer[4], SamplerFunction function);
void selectMipmap(Pointer<Byte> &texture, Pointer<Byte> buffer[4], Pointer<Byte> &mipmap, Float &lod, Int face[4], bool secondLOD);
Short4 address(Float4 &uw, AddressingMode addressingMode, Pointer<Byte>& mipmap);
diff --git a/src/Shader/VertexProgram.cpp b/src/Shader/VertexProgram.cpp
index 6d789a9..5fda7e7 100644
--- a/src/Shader/VertexProgram.cpp
+++ b/src/Shader/VertexProgram.cpp
@@ -1533,44 +1533,44 @@
void VertexProgram::TEXLDL(Vector4f &dst, Vector4f &src0, const Src &src1)
{
- sampleTexture(dst, src1, src0, a0, a0, src0, Lod, None);
+ sampleTexture(dst, src1, src0, a0, a0, src0, Lod);
}
void VertexProgram::TEX(Vector4f &dst, Vector4f &src0, const Src &src1)
{
src0.w = Float(0.0f);
- sampleTexture(dst, src1, src0, a0, a0, src0, Lod, None);
+ sampleTexture(dst, src1, src0, a0, a0, src0, Lod);
}
void VertexProgram::TEXOFFSET(Vector4f &dst, Vector4f &src0, const Src& src1, Vector4f &src2)
{
src0.w = Float(0.0f);
- sampleTexture(dst, src1, src0, a0, a0, src2, Lod, Offset);
+ sampleTexture(dst, src1, src0, a0, a0, src2, {Lod, Offset});
}
void VertexProgram::TEXLDL(Vector4f &dst, Vector4f &src0, const Src& src1, Vector4f &offset)
{
- sampleTexture(dst, src1, src0, a0, a0, offset, Lod, Offset);
+ sampleTexture(dst, src1, src0, a0, a0, offset, {Lod, Offset});
}
void VertexProgram::TEXELFETCH(Vector4f &dst, Vector4f &src0, const Src& src1)
{
- sampleTexture(dst, src1, src0, src0, src0, src0, Lod, Fetch);
+ sampleTexture(dst, src1, src0, src0, src0, src0, Fetch);
}
void VertexProgram::TEXELFETCH(Vector4f &dst, Vector4f &src0, const Src& src1, Vector4f &offset)
{
- sampleTexture(dst, src1, src0, src0, src0, offset, Lod, Fetch | Offset);
+ sampleTexture(dst, src1, src0, src0, src0, offset, {Fetch, Offset});
}
void VertexProgram::TEXGRAD(Vector4f &dst, Vector4f &src0, const Src& src1, Vector4f &src2, Vector4f &src3)
{
- sampleTexture(dst, src1, src0, src2, src3, src0, Grad, None);
+ sampleTexture(dst, src1, src0, src2, src3, src0, Grad);
}
void VertexProgram::TEXGRAD(Vector4f &dst, Vector4f &src0, const Src& src1, Vector4f &src2, Vector4f &src3, Vector4f &offset)
{
- sampleTexture(dst, src1, src0, src2, src3, offset, Grad, Offset);
+ sampleTexture(dst, src1, src0, src2, src3, offset, {Grad, Offset});
}
void VertexProgram::TEXSIZE(Vector4f &dst, Float4 &lod, const Src &src1)
@@ -1579,14 +1579,14 @@
sampler[src1.index]->textureSize(texture, dst, lod);
}
- void VertexProgram::sampleTexture(Vector4f &c, const Src &s, Vector4f &uvwq, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, SamplerMethod method, unsigned int options)
+ void VertexProgram::sampleTexture(Vector4f &c, const Src &s, Vector4f &uvwq, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, SamplerFunction function)
{
Vector4f tmp;
if(s.type == Shader::PARAMETER_SAMPLER && s.rel.type == Shader::PARAMETER_VOID)
{
Pointer<Byte> texture = data + OFFSET(DrawData, mipmap[TEXTURE_IMAGE_UNITS]) + s.index * sizeof(Texture);
- sampler[s.index]->sampleTexture(texture, tmp, uvwq.x, uvwq.y, uvwq.z, uvwq.w, dsx, dsy, offset, options, method);
+ sampler[s.index]->sampleTexture(texture, tmp, uvwq.x, uvwq.y, uvwq.z, uvwq.w, dsx, dsy, offset, function);
}
else
{
@@ -1599,7 +1599,7 @@
If(index == i)
{
Pointer<Byte> texture = data + OFFSET(DrawData, mipmap[TEXTURE_IMAGE_UNITS]) + i * sizeof(Texture);
- sampler[i]->sampleTexture(texture, tmp, uvwq.x, uvwq.y, uvwq.z, uvwq.w, dsx, dsy, offset, options, method);
+ sampler[i]->sampleTexture(texture, tmp, uvwq.x, uvwq.y, uvwq.z, uvwq.w, dsx, dsy, offset, function);
// FIXME: When the sampler states are the same, we could use one sampler and just index the texture
}
}
diff --git a/src/Shader/VertexProgram.hpp b/src/Shader/VertexProgram.hpp
index fcde4e6..4d73fa9 100644
--- a/src/Shader/VertexProgram.hpp
+++ b/src/Shader/VertexProgram.hpp
@@ -116,7 +116,7 @@
void TEXGRAD(Vector4f &dst, Vector4f &src, const Src&, Vector4f &src2, Vector4f &src3, Vector4f &src4);
void TEXSIZE(Vector4f &dst, Float4 &lod, const Src&);
- void sampleTexture(Vector4f &c, const Src &s, Vector4f &uvwq, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, SamplerMethod method, unsigned int options);
+ void sampleTexture(Vector4f &c, const Src &s, Vector4f &uvwq, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, SamplerFunction function);
SamplerCore *sampler[VERTEX_TEXTURE_IMAGE_UNITS];