Commit 88ac367c by Nicolas Capens Committed by Nicolas Capens

Remove idle Blitter fallbacks

For Vulkan we must support all blittable formats natively, so there's no fallback to C++ code. Also, if by error an unsupported format is used we don't have to immediately abort routine generation but can continue with something that's benign. This change simplifies the code, makes it more readable/maintainable, and marks other formats as unsupported instead of unimplemented. Bug: b/138944025 Bug: b/131243109 Change-Id: I4d246cdd280c5a352f18341996c92111a5144d96 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/34588 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarBen Clayton <bclayton@google.com>
parent 30857ca2
...@@ -257,9 +257,9 @@ namespace sw ...@@ -257,9 +257,9 @@ namespace sw
return true; return true;
} }
bool Blitter::read(Float4 &c, Pointer<Byte> element, const State &state) Float4 Blitter::readFloat4(Pointer<Byte> element, const State &state)
{ {
c = Float4(0.0f, 0.0f, 0.0f, 1.0f); Float4 c(0.0f, 0.0f, 0.0f, 1.0f);
switch(state.sourceFormat) switch(state.sourceFormat)
{ {
...@@ -448,13 +448,13 @@ namespace sw ...@@ -448,13 +448,13 @@ namespace sw
c.x = Float(Int(*Pointer<Byte>(element))); c.x = Float(Int(*Pointer<Byte>(element)));
break; break;
default: default:
return false; UNSUPPORTED("Blitter source format %d", (int)state.sourceFormat);
} }
return true; return c;
} }
bool Blitter::write(Float4 &c, Pointer<Byte> element, const State &state) void Blitter::write(Float4 &c, Pointer<Byte> element, const State &state)
{ {
bool writeR = state.writeRed; bool writeR = state.writeRed;
bool writeG = state.writeGreen; bool writeG = state.writeGreen;
...@@ -983,14 +983,14 @@ namespace sw ...@@ -983,14 +983,14 @@ namespace sw
*Pointer<Byte>(element) = Byte(RoundInt(Float(c.x))); *Pointer<Byte>(element) = Byte(RoundInt(Float(c.x)));
break; break;
default: default:
return false; UNSUPPORTED("Blitter destination format %d", (int)state.destFormat);
break;
} }
return true;
} }
bool Blitter::read(Int4 &c, Pointer<Byte> element, const State &state) Int4 Blitter::readInt4(Pointer<Byte> element, const State &state)
{ {
c = Int4(0, 0, 0, 1); Int4 c(0, 0, 0, 1);
switch(state.sourceFormat) switch(state.sourceFormat)
{ {
...@@ -1046,13 +1046,13 @@ namespace sw ...@@ -1046,13 +1046,13 @@ namespace sw
c = Insert(c, *Pointer<Int>(element), 0); c = Insert(c, *Pointer<Int>(element), 0);
break; break;
default: default:
return false; UNSUPPORTED("Blitter source format %d", (int)state.sourceFormat);
} }
return true; return c;
} }
bool Blitter::write(Int4 &c, Pointer<Byte> element, const State &state) void Blitter::write(Int4 &c, Pointer<Byte> element, const State &state)
{ {
bool writeR = state.writeRed; bool writeR = state.writeRed;
bool writeG = state.writeGreen; bool writeG = state.writeGreen;
...@@ -1273,15 +1273,14 @@ namespace sw ...@@ -1273,15 +1273,14 @@ namespace sw
if(writeR) { *Pointer<UInt>(element) = As<UInt>(Extract(c, 0)); } if(writeR) { *Pointer<UInt>(element) = As<UInt>(Extract(c, 0)); }
break; break;
default: default:
return false; UNSUPPORTED("Blitter destination format %d", (int)state.destFormat);
} }
return true;
} }
bool Blitter::ApplyScaleAndClamp(Float4 &value, const State &state, bool preScaled) void Blitter::ApplyScaleAndClamp(Float4 &value, const State &state, bool preScaled)
{ {
float4 scale, unscale; float4 scale, unscale;
if(state.clearOperation && if(state.clearOperation &&
state.sourceFormat.isNonNormalizedInteger() && state.sourceFormat.isNonNormalizedInteger() &&
!state.destFormat.isNonNormalizedInteger()) !state.destFormat.isNonNormalizedInteger())
...@@ -1297,18 +1296,15 @@ namespace sw ...@@ -1297,18 +1296,15 @@ namespace sw
unscale = replicate(static_cast<float>(0xFFFFFFFF)); unscale = replicate(static_cast<float>(0xFFFFFFFF));
break; break;
default: default:
return false; UNSUPPORTED("Blitter source format %d", (int)state.sourceFormat);
} }
} }
else if(!state.sourceFormat.getScale(unscale)) else
{ {
return false; unscale = state.sourceFormat.getScale();
} }
if(!state.destFormat.getScale(scale)) scale = state.destFormat.getScale();
{
return false;
}
bool srcSRGB = state.sourceFormat.isSRGBformat(); bool srcSRGB = state.sourceFormat.isSRGBformat();
bool dstSRGB = state.destFormat.isSRGBformat(); bool dstSRGB = state.destFormat.isSRGBformat();
...@@ -1334,8 +1330,6 @@ namespace sw ...@@ -1334,8 +1330,6 @@ namespace sw
state.destFormat.isUnsignedComponent(2) ? 0.0f : -scale.z, state.destFormat.isUnsignedComponent(2) ? 0.0f : -scale.z,
state.destFormat.isUnsignedComponent(3) ? 0.0f : -scale.w)); state.destFormat.isUnsignedComponent(3) ? 0.0f : -scale.w));
} }
return true;
} }
Int Blitter::ComputeOffset(Int &x, Int &y, Int &pitchB, int bytes, bool quadLayout) Int Blitter::ComputeOffset(Int &x, Int &y, Int &pitchB, int bytes, bool quadLayout)
...@@ -1416,24 +1410,15 @@ namespace sw ...@@ -1416,24 +1410,15 @@ namespace sw
{ {
if(intBoth) // Integer types if(intBoth) // Integer types
{ {
if(!read(constantColorI, source, state)) constantColorI = readInt4(source, state);
{
return nullptr;
}
hasConstantColorI = true; hasConstantColorI = true;
} }
else else
{ {
if(!read(constantColorF, source, state)) constantColorF = readFloat4(source, state);
{
return nullptr;
}
hasConstantColorF = true; hasConstantColorF = true;
if(!ApplyScaleAndClamp(constantColorF, state)) ApplyScaleAndClamp(constantColorF, state);
{
return nullptr;
}
} }
} }
...@@ -1449,26 +1434,19 @@ namespace sw ...@@ -1449,26 +1434,19 @@ namespace sw
if(hasConstantColorI) if(hasConstantColorI)
{ {
if(!write(constantColorI, d, state)) write(constantColorI, d, state);
{
return nullptr;
}
} }
else if(hasConstantColorF) else if(hasConstantColorF)
{ {
for(int s = 0; s < state.destSamples; s++) for(int s = 0; s < state.destSamples; s++)
{ {
if(!write(constantColorF, d, state)) write(constantColorF, d, state);
{
return nullptr;
}
d += *Pointer<Int>(blit + OFFSET(BlitData, dSliceB)); d += *Pointer<Int>(blit + OFFSET(BlitData, dSliceB));
} }
} }
else if(intBoth) // Integer types do not support filtering else if(intBoth) // Integer types do not support filtering
{ {
Int4 color; // When both formats are true integer types, we don't go to float to avoid losing precision
Int X = Int(x); Int X = Int(x);
Int Y = Int(y); Int Y = Int(y);
...@@ -1480,15 +1458,9 @@ namespace sw ...@@ -1480,15 +1458,9 @@ namespace sw
Pointer<Byte> s = source + ComputeOffset(X, Y, sPitchB, srcBytes, srcQuadLayout); Pointer<Byte> s = source + ComputeOffset(X, Y, sPitchB, srcBytes, srcQuadLayout);
if(!read(color, s, state)) // When both formats are true integer types, we don't go to float to avoid losing precision
{ Int4 color = readInt4(s, state);
return nullptr; write(color, d, state);
}
if(!write(color, d, state))
{
return nullptr;
}
} }
else else
{ {
...@@ -1508,29 +1480,24 @@ namespace sw ...@@ -1508,29 +1480,24 @@ namespace sw
Pointer<Byte> s = source + ComputeOffset(X, Y, sPitchB, srcBytes, srcQuadLayout); Pointer<Byte> s = source + ComputeOffset(X, Y, sPitchB, srcBytes, srcQuadLayout);
if(!read(color, s, state)) color = readFloat4(s, state);
{
return nullptr;
}
if(state.srcSamples > 1) // Resolve multisampled source if(state.srcSamples > 1) // Resolve multisampled source
{ {
if(state.convertSRGB && state.sourceFormat.isSRGBformat()) // sRGB -> RGB if(state.convertSRGB && state.sourceFormat.isSRGBformat()) // sRGB -> RGB
{ {
if(!ApplyScaleAndClamp(color, state)) return nullptr; ApplyScaleAndClamp(color, state);
preScaled = true; preScaled = true;
} }
Float4 accum = color; Float4 accum = color;
for(int sample = 1; sample < state.srcSamples; sample++) for(int sample = 1; sample < state.srcSamples; sample++)
{ {
s += *Pointer<Int>(blit + OFFSET(BlitData, sSliceB)); s += *Pointer<Int>(blit + OFFSET(BlitData, sSliceB));
if(!read(color, s, state)) color = readFloat4(s, state);
{
return nullptr;
}
if(state.convertSRGB && state.sourceFormat.isSRGBformat()) // sRGB -> RGB if(state.convertSRGB && state.sourceFormat.isSRGBformat()) // sRGB -> RGB
{ {
if(!ApplyScaleAndClamp(color, state)) return nullptr; ApplyScaleAndClamp(color, state);
preScaled = true; preScaled = true;
} }
accum += color; accum += color;
...@@ -1565,17 +1532,17 @@ namespace sw ...@@ -1565,17 +1532,17 @@ namespace sw
Pointer<Byte> s10 = source + ComputeOffset(X0, Y1, sPitchB, srcBytes, srcQuadLayout); Pointer<Byte> s10 = source + ComputeOffset(X0, Y1, sPitchB, srcBytes, srcQuadLayout);
Pointer<Byte> s11 = source + ComputeOffset(X1, Y1, sPitchB, srcBytes, srcQuadLayout); Pointer<Byte> s11 = source + ComputeOffset(X1, Y1, sPitchB, srcBytes, srcQuadLayout);
Float4 c00; if(!read(c00, s00, state)) return nullptr; Float4 c00 = readFloat4(s00, state);
Float4 c01; if(!read(c01, s01, state)) return nullptr; Float4 c01 = readFloat4(s01, state);
Float4 c10; if(!read(c10, s10, state)) return nullptr; Float4 c10 = readFloat4(s10, state);
Float4 c11; if(!read(c11, s11, state)) return nullptr; Float4 c11 = readFloat4(s11, state);
if(state.convertSRGB && state.sourceFormat.isSRGBformat()) // sRGB -> RGB if(state.convertSRGB && state.sourceFormat.isSRGBformat()) // sRGB -> RGB
{ {
if(!ApplyScaleAndClamp(c00, state)) return nullptr; ApplyScaleAndClamp(c00, state);
if(!ApplyScaleAndClamp(c01, state)) return nullptr; ApplyScaleAndClamp(c01, state);
if(!ApplyScaleAndClamp(c10, state)) return nullptr; ApplyScaleAndClamp(c10, state);
if(!ApplyScaleAndClamp(c11, state)) return nullptr; ApplyScaleAndClamp(c11, state);
preScaled = true; preScaled = true;
} }
...@@ -1588,17 +1555,11 @@ namespace sw ...@@ -1588,17 +1555,11 @@ namespace sw
(c10 * ix + c11 * fx) * fy; (c10 * ix + c11 * fx) * fy;
} }
if(!ApplyScaleAndClamp(color, state, preScaled)) ApplyScaleAndClamp(color, state, preScaled);
{
return nullptr;
}
for(int s = 0; s < state.destSamples; s++) for(int s = 0; s < state.destSamples; s++)
{ {
if(!write(color, d, state)) write(color, d, state);
{
return nullptr;
}
d += *Pointer<Int>(blit + OFFSET(BlitData,dSliceB)); d += *Pointer<Int>(blit + OFFSET(BlitData,dSliceB));
} }
...@@ -1618,13 +1579,6 @@ namespace sw ...@@ -1618,13 +1579,6 @@ namespace sw
if(!blitRoutine) if(!blitRoutine)
{ {
blitRoutine = generate(state); blitRoutine = generate(state);
if(!blitRoutine)
{
UNIMPLEMENTED("blitRoutine");
return nullptr;
}
blitCache.add(state, blitRoutine); blitCache.add(state, blitRoutine);
} }
...@@ -1639,13 +1593,6 @@ namespace sw ...@@ -1639,13 +1593,6 @@ namespace sw
if(!cornerUpdateRoutine) if(!cornerUpdateRoutine)
{ {
cornerUpdateRoutine = generateCornerUpdate(state); cornerUpdateRoutine = generateCornerUpdate(state);
if(!cornerUpdateRoutine)
{
UNIMPLEMENTED("cornerUpdateRoutine");
return nullptr;
}
cornerUpdateCache.add(state, cornerUpdateRoutine); cornerUpdateCache.add(state, cornerUpdateRoutine);
} }
...@@ -1918,15 +1865,13 @@ namespace sw ...@@ -1918,15 +1865,13 @@ namespace sw
int bytes = state.sourceFormat.bytes(); int bytes = state.sourceFormat.bytes();
bool quadLayout = state.sourceFormat.hasQuadLayout(); bool quadLayout = state.sourceFormat.hasQuadLayout();
Float4 c0; Float4 c = readFloat4(layer + ComputeOffset(x0, y1, pitchB, bytes, quadLayout), state) +
read(c0, layer + ComputeOffset(x0, y1, pitchB, bytes, quadLayout), state); readFloat4(layer + ComputeOffset(x1, y0, pitchB, bytes, quadLayout), state) +
Float4 c1; readFloat4(layer + ComputeOffset(x1, y1, pitchB, bytes, quadLayout), state);
read(c1, layer + ComputeOffset(x1, y0, pitchB, bytes, quadLayout), state);
c0 += c1; c *= Float4(1.0f / 3.0f);
read(c1, layer + ComputeOffset(x1, y1, pitchB, bytes, quadLayout), state);
c0 += c1; write(c, layer + ComputeOffset(x0, y0, pitchB, bytes, quadLayout), state);
c0 *= Float4(1.0f / 3.0f);
write(c0, layer + ComputeOffset(x0, y0, pitchB, bytes, quadLayout), state);
} }
std::shared_ptr<Routine> Blitter::generateCornerUpdate(const State& state) std::shared_ptr<Routine> Blitter::generateCornerUpdate(const State& state)
...@@ -2082,7 +2027,7 @@ namespace sw ...@@ -2082,7 +2027,7 @@ namespace sw
int h = extent.height; int h = extent.height;
if(w != h) if(w != h)
{ {
UNIMPLEMENTED("Cube doesn't have square faces : (%d, %d)", w, h); UNSUPPORTED("Cube doesn't have square faces : (%d, %d)", w, h);
} }
// Src is expressed in the regular [0, width-1], [0, height-1] space // Src is expressed in the regular [0, width-1], [0, height-1] space
......
...@@ -126,11 +126,11 @@ namespace sw ...@@ -126,11 +126,11 @@ namespace sw
bool fastClear(void *pixel, vk::Format format, vk::Image *dest, const vk::Format& viewFormat, const VkImageSubresourceRange& subresourceRange, const VkRect2D* renderArea); bool fastClear(void *pixel, vk::Format format, vk::Image *dest, const vk::Format& viewFormat, const VkImageSubresourceRange& subresourceRange, const VkRect2D* renderArea);
bool read(Float4 &color, Pointer<Byte> element, const State &state); Float4 readFloat4(Pointer<Byte> element, const State &state);
bool write(Float4 &color, Pointer<Byte> element, const State &state); void write(Float4 &color, Pointer<Byte> element, const State &state);
bool read(Int4 &color, Pointer<Byte> element, const State &state); Int4 readInt4(Pointer<Byte> element, const State &state);
bool write(Int4 &color, Pointer<Byte> element, const State &state); void write(Int4 &color, Pointer<Byte> element, const State &state);
static bool ApplyScaleAndClamp(Float4 &value, const State &state, bool preScaled = false); static void ApplyScaleAndClamp(Float4 &value, const State &state, bool preScaled = false);
static Int ComputeOffset(Int &x, Int &y, Int &pitchB, int bytes, bool quadLayout); static Int ComputeOffset(Int &x, Int &y, Int &pitchB, int bytes, bool quadLayout);
static Float4 LinearToSRGB(Float4 &color); static Float4 LinearToSRGB(Float4 &color);
static Float4 sRGBtoLinear(Float4 &color); static Float4 sRGBtoLinear(Float4 &color);
......
...@@ -3508,6 +3508,18 @@ namespace rr ...@@ -3508,6 +3508,18 @@ namespace rr
return T(Type_v2f32); return T(Type_v2f32);
} }
RValue<Float> Exp2(RValue<Float> v)
{
auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::exp2, { T(Float::getType()) } );
return RValue<Float>(V(jit->builder->CreateCall(func, V(v.value))));
}
RValue<Float> Log2(RValue<Float> v)
{
auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::log2, { T(Float::getType()) } );
return RValue<Float>(V(jit->builder->CreateCall(func, V(v.value))));
}
Float4::Float4(RValue<Float> rhs) : XYZW(this) Float4::Float4(RValue<Float> rhs) : XYZW(this)
{ {
RR_DEBUG_INFO_UPDATE_LOC(); RR_DEBUG_INFO_UPDATE_LOC();
......
...@@ -2092,11 +2092,38 @@ namespace rr ...@@ -2092,11 +2092,38 @@ namespace rr
RValue<Float> Rcp_pp(RValue<Float> val, bool exactAtPow2 = false); RValue<Float> Rcp_pp(RValue<Float> val, bool exactAtPow2 = false);
RValue<Float> RcpSqrt_pp(RValue<Float> val); RValue<Float> RcpSqrt_pp(RValue<Float> val);
RValue<Float> Sqrt(RValue<Float> x); RValue<Float> Sqrt(RValue<Float> x);
RValue<Float> Round(RValue<Float> val);
RValue<Float> Trunc(RValue<Float> val); // RValue<Int4> IsInf(RValue<Float> x);
RValue<Float> Frac(RValue<Float> val); // RValue<Int4> IsNan(RValue<Float> x);
RValue<Float> Floor(RValue<Float> val); RValue<Float> Round(RValue<Float> x);
RValue<Float> Ceil(RValue<Float> val); RValue<Float> Trunc(RValue<Float> x);
RValue<Float> Frac(RValue<Float> x);
RValue<Float> Floor(RValue<Float> x);
RValue<Float> Ceil(RValue<Float> x);
// Trigonometric functions
// TODO: Currently unimplemented for Subzero.
// RValue<Float> Sin(RValue<Float> x);
// RValue<Float> Cos(RValue<Float> x);
// RValue<Float> Tan(RValue<Float> x);
// RValue<Float> Asin(RValue<Float> x);
// RValue<Float> Acos(RValue<Float> x);
// RValue<Float> Atan(RValue<Float> x);
// RValue<Float> Sinh(RValue<Float> x);
// RValue<Float> Cosh(RValue<Float> x);
// RValue<Float> Tanh(RValue<Float> x);
// RValue<Float> Asinh(RValue<Float> x);
// RValue<Float> Acosh(RValue<Float> x);
// RValue<Float> Atanh(RValue<Float> x);
// RValue<Float> Atan2(RValue<Float> x, RValue<Float> y);
// Exponential functions
// TODO: Currently unimplemented for Subzero.
// RValue<Float> Pow(RValue<Float> x, RValue<Float> y);
// RValue<Float> Exp(RValue<Float> x);
// RValue<Float> Log(RValue<Float> x);
RValue<Float> Exp2(RValue<Float> x);
RValue<Float> Log2(RValue<Float> x);
class Float2 : public LValue<Float2> class Float2 : public LValue<Float2>
{ {
...@@ -2264,7 +2291,7 @@ namespace rr ...@@ -2264,7 +2291,7 @@ namespace rr
RValue<Float4> Ceil(RValue<Float4> x); RValue<Float4> Ceil(RValue<Float4> x);
// Trigonometric functions // Trigonometric functions
// TODO: Currentlhy unimplemented for Subzero. // TODO: Currently unimplemented for Subzero.
RValue<Float4> Sin(RValue<Float4> x); RValue<Float4> Sin(RValue<Float4> x);
RValue<Float4> Cos(RValue<Float4> x); RValue<Float4> Cos(RValue<Float4> x);
RValue<Float4> Tan(RValue<Float4> x); RValue<Float4> Tan(RValue<Float4> x);
...@@ -2280,7 +2307,7 @@ namespace rr ...@@ -2280,7 +2307,7 @@ namespace rr
RValue<Float4> Atan2(RValue<Float4> x, RValue<Float4> y); RValue<Float4> Atan2(RValue<Float4> x, RValue<Float4> y);
// Exponential functions // Exponential functions
// TODO: Currentlhy unimplemented for Subzero. // TODO: Currently unimplemented for Subzero.
RValue<Float4> Pow(RValue<Float4> x, RValue<Float4> y); RValue<Float4> Pow(RValue<Float4> x, RValue<Float4> y);
RValue<Float4> Exp(RValue<Float4> x); RValue<Float4> Exp(RValue<Float4> x);
RValue<Float4> Log(RValue<Float4> x); RValue<Float4> Log(RValue<Float4> x);
...@@ -2288,7 +2315,7 @@ namespace rr ...@@ -2288,7 +2315,7 @@ namespace rr
RValue<Float4> Log2(RValue<Float4> x); RValue<Float4> Log2(RValue<Float4> x);
// Bit Manipulation functions. // Bit Manipulation functions.
// TODO: Currentlhy unimplemented for Subzero. // TODO: Currently unimplemented for Subzero.
// Count leading zeros. // Count leading zeros.
// Returns 32 when: isZeroUndef && x == 0. // Returns 32 when: isZeroUndef && x == 0.
......
...@@ -3522,6 +3522,8 @@ namespace rr ...@@ -3522,6 +3522,8 @@ namespace rr
void Nucleus::createMaskedStore(Value *ptr, Value *val, Value *mask, unsigned int alignment) { UNIMPLEMENTED("Subzero createMaskedStore()"); } void Nucleus::createMaskedStore(Value *ptr, Value *val, Value *mask, unsigned int alignment) { UNIMPLEMENTED("Subzero createMaskedStore()"); }
Value *Nucleus::createGather(Value *base, Type *elTy, Value *offsets, Value *mask, unsigned int alignment, bool zeroMaskedLanes) { UNIMPLEMENTED("Subzero createGather()"); return nullptr; } Value *Nucleus::createGather(Value *base, Type *elTy, Value *offsets, Value *mask, unsigned int alignment, bool zeroMaskedLanes) { UNIMPLEMENTED("Subzero createGather()"); return nullptr; }
void Nucleus::createScatter(Value *base, Value *val, Value *offsets, Value *mask, unsigned int alignment) { UNIMPLEMENTED("Subzero createScatter()"); } void Nucleus::createScatter(Value *base, Value *val, Value *offsets, Value *mask, unsigned int alignment) { UNIMPLEMENTED("Subzero createScatter()"); }
RValue<Float> Exp2(RValue<Float> x) { UNIMPLEMENTED("Subzero Exp2()"); return Float(0); }
RValue<Float> Log2(RValue<Float> x) { UNIMPLEMENTED("Subzero Log2()"); return Float(0); }
RValue<Float4> Sin(RValue<Float4> x) { UNIMPLEMENTED("Subzero Sin()"); return Float4(0); } RValue<Float4> Sin(RValue<Float4> x) { UNIMPLEMENTED("Subzero Sin()"); return Float4(0); }
RValue<Float4> Cos(RValue<Float4> x) { UNIMPLEMENTED("Subzero Cos()"); return Float4(0); } RValue<Float4> Cos(RValue<Float4> x) { UNIMPLEMENTED("Subzero Cos()"); return Float4(0); }
RValue<Float4> Tan(RValue<Float4> x) { UNIMPLEMENTED("Subzero Tan()"); return Float4(0); } RValue<Float4> Tan(RValue<Float4> x) { UNIMPLEMENTED("Subzero Tan()"); return Float4(0); }
......
...@@ -1724,15 +1724,14 @@ int Format::sliceB(int width, int height, int border, bool target) const ...@@ -1724,15 +1724,14 @@ int Format::sliceB(int width, int height, int border, bool target) const
return sw::align<16>(sliceBUnpadded(width, height, border, target) + 15); return sw::align<16>(sliceBUnpadded(width, height, border, target) + 15);
} }
bool Format::getScale(sw::float4 &scale) const sw::float4 Format::getScale() const
{ {
switch(format) switch(format)
{ {
case VK_FORMAT_R4G4_UNORM_PACK8: case VK_FORMAT_R4G4_UNORM_PACK8:
case VK_FORMAT_R4G4B4A4_UNORM_PACK16: case VK_FORMAT_R4G4B4A4_UNORM_PACK16:
case VK_FORMAT_B4G4R4A4_UNORM_PACK16: case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
scale = sw::vector(0xF, 0xF, 0xF, 0xF); return sw::vector(0xF, 0xF, 0xF, 0xF);
break;
case VK_FORMAT_R8_UNORM: case VK_FORMAT_R8_UNORM:
case VK_FORMAT_R8G8_UNORM: case VK_FORMAT_R8G8_UNORM:
case VK_FORMAT_R8G8B8_UNORM: case VK_FORMAT_R8G8B8_UNORM:
...@@ -1747,8 +1746,7 @@ bool Format::getScale(sw::float4 &scale) const ...@@ -1747,8 +1746,7 @@ bool Format::getScale(sw::float4 &scale) const
case VK_FORMAT_A8B8G8R8_SRGB_PACK32: case VK_FORMAT_A8B8G8R8_SRGB_PACK32:
case VK_FORMAT_R8G8B8A8_SRGB: case VK_FORMAT_R8G8B8A8_SRGB:
case VK_FORMAT_B8G8R8A8_SRGB: case VK_FORMAT_B8G8R8A8_SRGB:
scale = sw::vector(0xFF, 0xFF, 0xFF, 0xFF); return sw::vector(0xFF, 0xFF, 0xFF, 0xFF);
break;
case VK_FORMAT_R8_SNORM: case VK_FORMAT_R8_SNORM:
case VK_FORMAT_R8G8_SNORM: case VK_FORMAT_R8G8_SNORM:
case VK_FORMAT_R8G8B8_SNORM: case VK_FORMAT_R8G8B8_SNORM:
...@@ -1756,20 +1754,17 @@ bool Format::getScale(sw::float4 &scale) const ...@@ -1756,20 +1754,17 @@ bool Format::getScale(sw::float4 &scale) const
case VK_FORMAT_A8B8G8R8_SNORM_PACK32: case VK_FORMAT_A8B8G8R8_SNORM_PACK32:
case VK_FORMAT_R8G8B8A8_SNORM: case VK_FORMAT_R8G8B8A8_SNORM:
case VK_FORMAT_B8G8R8A8_SNORM: case VK_FORMAT_B8G8R8A8_SNORM:
scale = sw::vector(0x7F, 0x7F, 0x7F, 0x7F); return sw::vector(0x7F, 0x7F, 0x7F, 0x7F);
break;
case VK_FORMAT_R16_UNORM: case VK_FORMAT_R16_UNORM:
case VK_FORMAT_R16G16_UNORM: case VK_FORMAT_R16G16_UNORM:
case VK_FORMAT_R16G16B16_UNORM: case VK_FORMAT_R16G16B16_UNORM:
case VK_FORMAT_R16G16B16A16_UNORM: case VK_FORMAT_R16G16B16A16_UNORM:
scale = sw::vector(0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF); return sw::vector(0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF);
break;
case VK_FORMAT_R16_SNORM: case VK_FORMAT_R16_SNORM:
case VK_FORMAT_R16G16_SNORM: case VK_FORMAT_R16G16_SNORM:
case VK_FORMAT_R16G16B16_SNORM: case VK_FORMAT_R16G16B16_SNORM:
case VK_FORMAT_R16G16B16A16_SNORM: case VK_FORMAT_R16G16B16A16_SNORM:
scale = sw::vector(0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF); return sw::vector(0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF);
break;
case VK_FORMAT_R8_SINT: case VK_FORMAT_R8_SINT:
case VK_FORMAT_R8_UINT: case VK_FORMAT_R8_UINT:
case VK_FORMAT_R8G8_SINT: case VK_FORMAT_R8G8_SINT:
...@@ -1838,42 +1833,35 @@ bool Format::getScale(sw::float4 &scale) const ...@@ -1838,42 +1833,35 @@ bool Format::getScale(sw::float4 &scale) const
case VK_FORMAT_A2B10G10R10_SSCALED_PACK32: case VK_FORMAT_A2B10G10R10_SSCALED_PACK32:
case VK_FORMAT_A2B10G10R10_UINT_PACK32: case VK_FORMAT_A2B10G10R10_UINT_PACK32:
case VK_FORMAT_A2B10G10R10_SINT_PACK32: case VK_FORMAT_A2B10G10R10_SINT_PACK32:
scale = sw::vector(1.0f, 1.0f, 1.0f, 1.0f); return sw::vector(1.0f, 1.0f, 1.0f, 1.0f);
break;
case VK_FORMAT_R5G5B5A1_UNORM_PACK16: case VK_FORMAT_R5G5B5A1_UNORM_PACK16:
case VK_FORMAT_B5G5R5A1_UNORM_PACK16: case VK_FORMAT_B5G5R5A1_UNORM_PACK16:
case VK_FORMAT_A1R5G5B5_UNORM_PACK16: case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
scale = sw::vector(0x1F, 0x1F, 0x1F, 0x01); return sw::vector(0x1F, 0x1F, 0x1F, 0x01);
break;
case VK_FORMAT_R5G6B5_UNORM_PACK16: case VK_FORMAT_R5G6B5_UNORM_PACK16:
case VK_FORMAT_B5G6R5_UNORM_PACK16: case VK_FORMAT_B5G6R5_UNORM_PACK16:
scale = sw::vector(0x1F, 0x3F, 0x1F, 1.0f); return sw::vector(0x1F, 0x3F, 0x1F, 1.0f);
break;
case VK_FORMAT_A2R10G10B10_UNORM_PACK32: case VK_FORMAT_A2R10G10B10_UNORM_PACK32:
case VK_FORMAT_A2B10G10R10_UNORM_PACK32: case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
scale = sw::vector(0x3FF, 0x3FF, 0x3FF, 0x03); return sw::vector(0x3FF, 0x3FF, 0x3FF, 0x03);
break;
case VK_FORMAT_A2R10G10B10_SNORM_PACK32: case VK_FORMAT_A2R10G10B10_SNORM_PACK32:
case VK_FORMAT_A2B10G10R10_SNORM_PACK32: case VK_FORMAT_A2B10G10R10_SNORM_PACK32:
scale = sw::vector(0x1FF, 0x1FF, 0x1FF, 0x01); return sw::vector(0x1FF, 0x1FF, 0x1FF, 0x01);
break;
case VK_FORMAT_D16_UNORM: case VK_FORMAT_D16_UNORM:
scale = sw::vector(0xFFFF, 0.0f, 0.0f, 0.0f); return sw::vector(0xFFFF, 0.0f, 0.0f, 0.0f);
break;
case VK_FORMAT_D24_UNORM_S8_UINT: case VK_FORMAT_D24_UNORM_S8_UINT:
case VK_FORMAT_X8_D24_UNORM_PACK32: case VK_FORMAT_X8_D24_UNORM_PACK32:
scale = sw::vector(0xFFFFFF, 0.0f, 0.0f, 0.0f); return sw::vector(0xFFFFFF, 0.0f, 0.0f, 0.0f);
break;
case VK_FORMAT_D32_SFLOAT: case VK_FORMAT_D32_SFLOAT:
case VK_FORMAT_D32_SFLOAT_S8_UINT: case VK_FORMAT_D32_SFLOAT_S8_UINT:
case VK_FORMAT_S8_UINT: case VK_FORMAT_S8_UINT:
scale = sw::vector(1.0f, 1.0f, 1.0f, 1.0f); return sw::vector(1.0f, 1.0f, 1.0f, 1.0f);
break;
default: default:
return false; UNSUPPORTED("format %d", int(format));
break;
} }
return true; return sw::vector(1.0f, 1.0f, 1.0f, 1.0f);
} }
bool Format::has16bitTextureFormat() const bool Format::has16bitTextureFormat() const
......
...@@ -60,7 +60,7 @@ public: ...@@ -60,7 +60,7 @@ public:
int pitchB(int width, int border, bool target) const; int pitchB(int width, int border, bool target) const;
int sliceB(int width, int height, int border, bool target) const; int sliceB(int width, int height, int border, bool target) const;
bool getScale(sw::float4 &scale) const; sw::float4 getScale() const;
// Texture sampling utilities // Texture sampling utilities
bool has16bitTextureFormat() const; bool has16bitTextureFormat() const;
......
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