Commit 9651718a by Alexis Hetu Committed by Alexis Hétu

Renamed Vector4i to Vector4s

The current Vector4i was a vector of shorts and OpenGL ES 3.0 actually requires vectors of ints and uints, so I renamed Vector4i to Vector4s so that I may later add Vector4i and Vector4u with the proper internal representation. Change-Id: I9d413c459154c7ef9ddafc46b9fb7fa6186633b8 Reviewed-on: https://swiftshader-review.googlesource.com/2851Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent b14178b6
......@@ -20,7 +20,7 @@ namespace sw
{
}
void SamplerCore::sampleTexture(Pointer<Byte> &texture, Vector4i &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy, bool bias, bool fixed12, bool gradients, bool lodProvided)
void SamplerCore::sampleTexture(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy, bool bias, bool fixed12, bool gradients, bool lodProvided)
{
#if PERF_PROFILE
AddAtomic(Pointer<Long>(&profiler.texOperations), 4);
......@@ -257,26 +257,26 @@ namespace sw
}
else
{
Vector4i ci;
Vector4s cs;
sampleTexture(texture, ci, u, v, w, q, dsx, dsy, bias, false, gradients, lodProvided);
sampleTexture(texture, cs, u, v, w, q, dsx, dsy, bias, false, gradients, lodProvided);
for(int component = 0; component < textureComponentCount(); component++)
{
if(state.sRGB && isRGBComponent(component))
{
sRGBtoLinear16_12(ci[component]); // FIXME: Perform linearization at surface level for read-only textures
convertSigned12(c[component], ci[component]);
sRGBtoLinear16_12(cs[component]); // FIXME: Perform linearization at surface level for read-only textures
convertSigned12(c[component], cs[component]);
}
else
{
if(hasUnsignedTextureComponent(component))
{
convertUnsigned16(c[component], ci[component]);
convertUnsigned16(c[component], cs[component]);
}
else
{
convertSigned15(c[component], ci[component]);
convertSigned15(c[component], cs[component]);
}
}
}
......@@ -381,7 +381,7 @@ namespace sw
return uvw;
}
void SamplerCore::sampleFilter(Pointer<Byte> &texture, Vector4i &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool lodProvided)
void SamplerCore::sampleFilter(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool lodProvided)
{
bool volumeTexture = state.textureType == TEXTURE_3D;
......@@ -389,7 +389,7 @@ namespace sw
if(state.mipmapFilter > MIPMAP_POINT)
{
Vector4i cc;
Vector4s cc;
sampleAniso(texture, cc, u, v, w, lod, anisotropy, uDelta, vDelta, face, true, lodProvided);
......@@ -479,7 +479,7 @@ namespace sw
}
}
void SamplerCore::sampleAniso(Pointer<Byte> &texture, Vector4i &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool secondLOD, bool lodProvided)
void SamplerCore::sampleAniso(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool secondLOD, bool lodProvided)
{
if(state.textureFilter != FILTER_ANISOTROPIC || lodProvided)
{
......@@ -489,7 +489,7 @@ namespace sw
{
Int a = RoundInt(anisotropy);
Vector4i cSum;
Vector4s cSum;
cSum.x = Short4(0, 0, 0, 0);
cSum.y = Short4(0, 0, 0, 0);
......@@ -535,7 +535,7 @@ namespace sw
}
}
void SamplerCore::sampleQuad(Pointer<Byte> &texture, Vector4i &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Int face[4], bool secondLOD)
void SamplerCore::sampleQuad(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Int face[4], bool secondLOD)
{
if(state.textureType != TEXTURE_3D)
{
......@@ -547,7 +547,7 @@ namespace sw
}
}
void SamplerCore::sampleQuad2D(Pointer<Byte> &texture, Vector4i &c, Float4 &u, Float4 &v, Float &lod, Int face[4], bool secondLOD)
void SamplerCore::sampleQuad2D(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float &lod, Int face[4], bool secondLOD)
{
int componentCount = textureComponentCount();
bool gather = state.textureFilter == FILTER_GATHER;
......@@ -569,10 +569,10 @@ namespace sw
}
else
{
Vector4i c0;
Vector4i c1;
Vector4i c2;
Vector4i c3;
Vector4s c0;
Vector4s c1;
Vector4s c2;
Vector4s c3;
Short4 uuuu0 = offsetSample(uuuu, mipmap, OFFSET(Mipmap,uHalf), state.addressingModeU == ADDRESSING_WRAP, gather ? 0 : -1);
Short4 vvvv0 = offsetSample(vvvv, mipmap, OFFSET(Mipmap,vHalf), state.addressingModeV == ADDRESSING_WRAP, gather ? 0 : -1);
......@@ -754,7 +754,7 @@ namespace sw
}
}
void SamplerCore::sample3D(Pointer<Byte> &texture, Vector4i &c_, Float4 &u_, Float4 &v_, Float4 &w_, Float &lod, bool secondLOD)
void SamplerCore::sample3D(Pointer<Byte> &texture, Vector4s &c_, Float4 &u_, Float4 &v_, Float4 &w_, Float &lod, bool secondLOD)
{
int componentCount = textureComponentCount();
......@@ -778,7 +778,7 @@ namespace sw
}
else
{
Vector4i c[2][2][2];
Vector4s c[2][2][2];
Short4 u[2][2][2];
Short4 v[2][2][2];
......@@ -1471,7 +1471,7 @@ namespace sw
index[3] = Extract(As<Int2>(uuu2), 1);
}
void SamplerCore::sampleTexel(Vector4i &c, Short4 &uuuu, Short4 &vvvv, Short4 &wwww, Pointer<Byte> &mipmap, Pointer<Byte> buffer[4])
void SamplerCore::sampleTexel(Vector4s &c, Short4 &uuuu, Short4 &vvvv, Short4 &wwww, Pointer<Byte> &mipmap, Pointer<Byte> buffer[4])
{
Int index[4];
......@@ -1746,40 +1746,40 @@ namespace sw
}
}
void SamplerCore::convertFixed12(Short4 &ci, Float4 &cf)
void SamplerCore::convertFixed12(Short4 &cs, Float4 &cf)
{
ci = RoundShort4(cf * Float4(0x1000));
cs = RoundShort4(cf * Float4(0x1000));
}
void SamplerCore::convertFixed12(Vector4i &ci, Vector4f &cf)
void SamplerCore::convertFixed12(Vector4s &cs, Vector4f &cf)
{
convertFixed12(ci.x, cf.x);
convertFixed12(ci.y, cf.y);
convertFixed12(ci.z, cf.z);
convertFixed12(ci.w, cf.w);
convertFixed12(cs.x, cf.x);
convertFixed12(cs.y, cf.y);
convertFixed12(cs.z, cf.z);
convertFixed12(cs.w, cf.w);
}
void SamplerCore::convertSigned12(Float4 &cf, Short4 &ci)
void SamplerCore::convertSigned12(Float4 &cf, Short4 &cs)
{
cf = Float4(ci) * Float4(1.0f / 0x0FFE);
cf = Float4(cs) * Float4(1.0f / 0x0FFE);
}
// void SamplerCore::convertSigned12(Vector4f &cf, Vector4i &ci)
// void SamplerCore::convertSigned12(Vector4f &cf, Vector4s &cs)
// {
// convertSigned12(cf.x, ci.x);
// convertSigned12(cf.y, ci.y);
// convertSigned12(cf.z, ci.z);
// convertSigned12(cf.w, ci.w);
// convertSigned12(cf.x, cs.x);
// convertSigned12(cf.y, cs.y);
// convertSigned12(cf.z, cs.z);
// convertSigned12(cf.w, cs.w);
// }
void SamplerCore::convertSigned15(Float4 &cf, Short4 &ci)
void SamplerCore::convertSigned15(Float4 &cf, Short4 &cs)
{
cf = Float4(ci) * Float4(1.0f / 0x7FFF);
cf = Float4(cs) * Float4(1.0f / 0x7FFF);
}
void SamplerCore::convertUnsigned16(Float4 &cf, Short4 &ci)
void SamplerCore::convertUnsigned16(Float4 &cf, Short4 &cs)
{
cf = Float4(As<UShort4>(ci)) * Float4(1.0f / 0xFFFF);
cf = Float4(As<UShort4>(cs)) * Float4(1.0f / 0xFFFF);
}
void SamplerCore::sRGBtoLinear16_12(Short4 &c)
......
......@@ -22,18 +22,18 @@ namespace sw
public:
SamplerCore(Pointer<Byte> &r, const Sampler::State &state);
void sampleTexture(Pointer<Byte> &texture, Vector4i &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy, bool bias = false, bool fixed12 = true, bool gradients = false, bool lodProvided = false);
void sampleTexture(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy, bool bias = false, bool fixed12 = true, bool gradients = false, bool lodProvided = false);
void sampleTexture(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy, bool bias = false, bool gradients = false, bool lodProvided = false);
private:
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);
void sampleFilter(Pointer<Byte> &texture, Vector4i &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool lodProvided);
void sampleAniso(Pointer<Byte> &texture, Vector4i &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool secondLOD, bool lodProvided);
void sampleQuad(Pointer<Byte> &texture, Vector4i &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Int face[4], bool secondLOD);
void sampleQuad2D(Pointer<Byte> &texture, Vector4i &c, Float4 &u, Float4 &v, Float &lod, Int face[4], bool secondLOD);
void sample3D(Pointer<Byte> &texture, Vector4i &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, bool secondLOD);
void sampleFilter(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool lodProvided);
void sampleAniso(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool secondLOD, bool lodProvided);
void sampleQuad(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Int face[4], bool secondLOD);
void sampleQuad2D(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float &lod, Int face[4], bool secondLOD);
void sample3D(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, bool secondLOD);
void sampleFloatFilter(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool lodProvided);
void sampleFloatAniso(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool secondLOD, bool lodProvided);
void sampleFloat(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Int face[4], bool secondLOD);
......@@ -43,13 +43,13 @@ namespace sw
void computeLod3D(Pointer<Byte> &texture, Float &lod, Float4 &u, Float4 &v, Float4 &w, const Float &lodBias, Vector4f &dsx, Vector4f &dsy, bool bias, bool gradients, bool lodProvided);
void cubeFace(Int face[4], Float4 &U, Float4 &V, Float4 &lodU, Float4 &lodV, Float4 &x, Float4 &y, Float4 &z);
void computeIndices(Int index[4], Short4 uuuu, Short4 vvvv, Short4 wwww, const Pointer<Byte> &mipmap);
void sampleTexel(Vector4i &c, Short4 &u, Short4 &v, Short4 &s, Pointer<Byte> &mipmap, Pointer<Byte> buffer[4]);
void sampleTexel(Vector4s &c, Short4 &u, Short4 &v, Short4 &s, Pointer<Byte> &mipmap, Pointer<Byte> buffer[4]);
void sampleTexel(Vector4f &c, Short4 &u, Short4 &v, Short4 &s, Float4 &z, Pointer<Byte> &mipmap, Pointer<Byte> buffer[4]);
void selectMipmap(Pointer<Byte> &texture, Pointer<Byte> buffer[4], Pointer<Byte> &mipmap, Float &lod, Int face[4], bool secondLOD);
void address(Short4 &uuuu, Float4 &uw, AddressingMode addressingMode);
void convertFixed12(Short4 &ci, Float4 &cf);
void convertFixed12(Vector4i &ci, Vector4f &cf);
void convertFixed12(Vector4s &cs, Vector4f &cf);
void convertSigned12(Float4 &cf, Short4 &ci);
void convertSigned15(Float4 &cf, Short4 &ci);
void convertUnsigned16(Float4 &cf, Short4 &ci);
......
......@@ -21,11 +21,11 @@ namespace sw
extern TranscendentalPrecision rcpPrecision;
extern TranscendentalPrecision rsqPrecision;
Vector4i::Vector4i()
Vector4s::Vector4s()
{
}
Vector4i::Vector4i(unsigned short x, unsigned short y, unsigned short z, unsigned short w)
Vector4s::Vector4s(unsigned short x, unsigned short y, unsigned short z, unsigned short w)
{
this->x = Short4(x);
this->y = Short4(y);
......@@ -33,7 +33,7 @@ namespace sw
this->w = Short4(w);
}
Vector4i::Vector4i(const Vector4i &rhs)
Vector4s::Vector4s(const Vector4s &rhs)
{
x = rhs.x;
y = rhs.y;
......@@ -41,7 +41,7 @@ namespace sw
w = rhs.w;
}
Vector4i &Vector4i::operator=(const Vector4i &rhs)
Vector4s &Vector4s::operator=(const Vector4s &rhs)
{
x = rhs.x;
y = rhs.y;
......@@ -51,7 +51,7 @@ namespace sw
return *this;
}
Short4 &Vector4i::operator[](int i)
Short4 &Vector4s::operator[](int i)
{
switch(i)
{
......
......@@ -18,15 +18,15 @@
namespace sw
{
class Vector4i
class Vector4s
{
public:
Vector4i();
Vector4i(unsigned short x, unsigned short y, unsigned short z, unsigned short w);
Vector4i(const Vector4i &rhs);
Vector4s();
Vector4s(unsigned short x, unsigned short y, unsigned short z, unsigned short w);
Vector4s(const Vector4s &rhs);
Short4 &operator[](int i);
Vector4i &operator=(const Vector4i &rhs);
Vector4s &operator=(const Vector4s &rhs);
Short4 x;
Short4 y;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment