Commit 126bd7ab by Alexis Hetu Committed by Alexis Hétu

Warnings fix

Fixes most warnings using the Visual Studio C++ 64 bit compiler. Should be noop Bug b/132445520 Change-Id: I7844062244478b39299729cf4e4c0b647e2f5b14 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/31150Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent d188b1ad
...@@ -231,7 +231,7 @@ namespace sw ...@@ -231,7 +231,7 @@ namespace sw
for(uint32_t i = 0; i < area.extent.height; i++) for(uint32_t i = 0; i < area.extent.height; i++)
{ {
ASSERT(d < dest->end()); ASSERT(d < dest->end());
sw::clear((uint16_t*)d, packed, area.extent.width); sw::clear((uint16_t*)d, static_cast<uint16_t>(packed), area.extent.width);
d += rowPitchBytes; d += rowPitchBytes;
} }
break; break;
...@@ -1447,7 +1447,7 @@ namespace sw ...@@ -1447,7 +1447,7 @@ namespace sw
preScaled = true; preScaled = true;
} }
Float4 accum = color; Float4 accum = color;
for(int i = 1; i < state.srcSamples; i++) 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)) if(!read(color, s, state))
......
...@@ -92,19 +92,19 @@ namespace sw ...@@ -92,19 +92,19 @@ namespace sw
template<> template<>
inline Color<byte>::Color(const Color<short> &c) inline Color<byte>::Color(const Color<short> &c)
{ {
r = clamp(c.r >> 4, 0, 255); r = static_cast<byte>(clamp(c.r >> 4, 0, 255));
g = clamp(c.g >> 4, 0, 255); g = static_cast<byte>(clamp(c.g >> 4, 0, 255));
b = clamp(c.b >> 4, 0, 255); b = static_cast<byte>(clamp(c.b >> 4, 0, 255));
a = clamp(c.a >> 4, 0, 255); a = static_cast<byte>(clamp(c.a >> 4, 0, 255));
} }
template<> template<>
inline Color<byte>::Color(const Color<float> &c) inline Color<byte>::Color(const Color<float> &c)
{ {
r = ifloor(clamp(c.r * 256.0f, 0.0f, 255.0f)); r = static_cast<byte>(ifloor(clamp(c.r * 256.0f, 0.0f, 255.0f)));
g = ifloor(clamp(c.g * 256.0f, 0.0f, 255.0f)); g = static_cast<byte>(ifloor(clamp(c.g * 256.0f, 0.0f, 255.0f)));
b = ifloor(clamp(c.b * 256.0f, 0.0f, 255.0f)); b = static_cast<byte>(ifloor(clamp(c.b * 256.0f, 0.0f, 255.0f)));
a = ifloor(clamp(c.a * 256.0f, 0.0f, 255.0f)); a = static_cast<byte>(ifloor(clamp(c.a * 256.0f, 0.0f, 255.0f)));
} }
template<> template<>
...@@ -137,10 +137,10 @@ namespace sw ...@@ -137,10 +137,10 @@ namespace sw
template<> template<>
inline Color<short>::Color(const Color<float> &c) inline Color<short>::Color(const Color<float> &c)
{ {
r = iround(clamp(c.r * 4095.0f, -4096.0f, 4095.0f)); r = static_cast<short>(iround(clamp(c.r * 4095.0f, -4096.0f, 4095.0f)));
g = iround(clamp(c.g * 4095.0f, -4096.0f, 4095.0f)); g = static_cast<short>(iround(clamp(c.g * 4095.0f, -4096.0f, 4095.0f)));
b = iround(clamp(c.b * 4095.0f, -4096.0f, 4095.0f)); b = static_cast<short>(iround(clamp(c.b * 4095.0f, -4096.0f, 4095.0f)));
a = iround(clamp(c.a * 4095.0f, -4096.0f, 4095.0f)); a = static_cast<short>(iround(clamp(c.a * 4095.0f, -4096.0f, 4095.0f)));
} }
template<> template<>
......
...@@ -16,21 +16,21 @@ ...@@ -16,21 +16,21 @@
namespace namespace
{ {
inline int clampByte(int value) inline unsigned char clampByte(int value)
{ {
return (value < 0) ? 0 : ((value > 255) ? 255 : value); return static_cast<unsigned char>((value < 0) ? 0 : ((value > 255) ? 255 : value));
} }
inline int clampSByte(int value) inline signed char clampSByte(int value)
{ {
return (value < -128) ? -128 : ((value > 127) ? 127 : value); return static_cast<signed char>((value < -128) ? -128 : ((value > 127) ? 127 : value));
} }
inline short clampEAC(short value, bool isSigned) inline short clampEAC(int value, bool isSigned)
{ {
short min = isSigned ? -1023 : 0; short min = isSigned ? -1023 : 0;
short max = isSigned ? 1023 : 2047; short max = isSigned ? 1023 : 2047;
return ((value < min) ? min : ((value > max) ? max : value)) << 5; return static_cast<short>(((value < min) ? min : ((value > max) ? max : value)) << 5);
} }
struct bgra8 struct bgra8
...@@ -46,20 +46,20 @@ namespace ...@@ -46,20 +46,20 @@ namespace
inline void set(int red, int green, int blue) inline void set(int red, int green, int blue)
{ {
r = static_cast<unsigned char>(clampByte(red)); r = clampByte(red);
g = static_cast<unsigned char>(clampByte(green)); g = clampByte(green);
b = static_cast<unsigned char>(clampByte(blue)); b = clampByte(blue);
} }
inline void set(int red, int green, int blue, int alpha) inline void set(int red, int green, int blue, int alpha)
{ {
r = static_cast<unsigned char>(clampByte(red)); r = clampByte(red);
g = static_cast<unsigned char>(clampByte(green)); g = clampByte(green);
b = static_cast<unsigned char>(clampByte(blue)); b = clampByte(blue);
a = static_cast<unsigned char>(clampByte(alpha)); a = clampByte(alpha);
} }
const bgra8& addA(int alpha) const bgra8& addA(unsigned char alpha)
{ {
a = alpha; a = alpha;
return *this; return *this;
......
...@@ -67,10 +67,10 @@ namespace sw ...@@ -67,10 +67,10 @@ namespace sw
void PixelProcessor::setBlendConstant(const Color<float> &blendConstant) void PixelProcessor::setBlendConstant(const Color<float> &blendConstant)
{ {
// FIXME: Compact into generic function // FIXME: Clamp // FIXME: Compact into generic function // FIXME: Clamp
short blendConstantR = iround(65535 * blendConstant.r); short blendConstantR = static_cast<short>(iround(65535 * blendConstant.r));
short blendConstantG = iround(65535 * blendConstant.g); short blendConstantG = static_cast<short>(iround(65535 * blendConstant.g));
short blendConstantB = iround(65535 * blendConstant.b); short blendConstantB = static_cast<short>(iround(65535 * blendConstant.b));
short blendConstantA = iround(65535 * blendConstant.a); short blendConstantA = static_cast<short>(iround(65535 * blendConstant.a));
factor.blendConstant4W[0][0] = blendConstantR; factor.blendConstant4W[0][0] = blendConstantR;
factor.blendConstant4W[0][1] = blendConstantR; factor.blendConstant4W[0][1] = blendConstantR;
...@@ -93,10 +93,10 @@ namespace sw ...@@ -93,10 +93,10 @@ namespace sw
factor.blendConstant4W[3][3] = blendConstantA; factor.blendConstant4W[3][3] = blendConstantA;
// FIXME: Compact into generic function // FIXME: Clamp // FIXME: Compact into generic function // FIXME: Clamp
short invBlendConstantR = iround(65535 * (1 - blendConstant.r)); short invBlendConstantR = static_cast<short>(iround(65535 * (1 - blendConstant.r)));
short invBlendConstantG = iround(65535 * (1 - blendConstant.g)); short invBlendConstantG = static_cast<short>(iround(65535 * (1 - blendConstant.g)));
short invBlendConstantB = iround(65535 * (1 - blendConstant.b)); short invBlendConstantB = static_cast<short>(iround(65535 * (1 - blendConstant.b)));
short invBlendConstantA = iround(65535 * (1 - blendConstant.a)); short invBlendConstantA = static_cast<short>(iround(65535 * (1 - blendConstant.a)));
factor.invBlendConstant4W[0][0] = invBlendConstantR; factor.invBlendConstant4W[0][0] = invBlendConstantR;
factor.invBlendConstant4W[0][1] = invBlendConstantR; factor.invBlendConstant4W[0][1] = invBlendConstantR;
......
...@@ -52,7 +52,7 @@ namespace sw ...@@ -52,7 +52,7 @@ namespace sw
this->instanceStride = 0; this->instanceStride = 0;
} }
Stream &define(StreamType type, unsigned int count, bool normalized = false) Stream &define(StreamType type, unsigned char count, bool normalized = false)
{ {
this->type = type; this->type = type;
this->count = count; this->count = count;
...@@ -61,7 +61,7 @@ namespace sw ...@@ -61,7 +61,7 @@ namespace sw
return *this; return *this;
} }
Stream &define(const void *buffer, StreamType type, unsigned int count, bool normalized = false) Stream &define(const void *buffer, StreamType type, unsigned char count, bool normalized = false)
{ {
this->buffer = buffer; this->buffer = buffer;
this->type = type; this->type = type;
......
...@@ -1343,16 +1343,16 @@ namespace sw ...@@ -1343,16 +1343,16 @@ namespace sw
c.x = (c.x & Short4(0xF800u)); c.x = (c.x & Short4(0xF800u));
break; break;
case VK_FORMAT_B4G4R4A4_UNORM_PACK16: case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
c.w = (c.x << 12) & Short4(0xF000); c.w = (c.x << 12) & Short4(0xF000u);
c.z = (c.x) & Short4(0xF000); c.z = (c.x) & Short4(0xF000u);
c.y = (c.x << 4) & Short4(0xF000); c.y = (c.x << 4) & Short4(0xF000u);
c.x = (c.x << 8) & Short4(0xF000); c.x = (c.x << 8) & Short4(0xF000u);
break; break;
case VK_FORMAT_A1R5G5B5_UNORM_PACK16: case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
c.w = (c.x) & Short4(0x8000); c.w = (c.x) & Short4(0x8000u);
c.z = (c.x << 11) & Short4(0xF800); c.z = (c.x << 11) & Short4(0xF800u);
c.y = (c.x << 6) & Short4(0xF800); c.y = (c.x << 6) & Short4(0xF800u);
c.x = (c.x << 1) & Short4(0xF800); c.x = (c.x << 1) & Short4(0xF800u);
break; break;
default: default:
ASSERT(false); ASSERT(false);
...@@ -1408,10 +1408,10 @@ namespace sw ...@@ -1408,10 +1408,10 @@ namespace sw
if (state.textureFormat == VK_FORMAT_R8G8B8A8_SNORM) if (state.textureFormat == VK_FORMAT_R8G8B8A8_SNORM)
{ {
// TODO: avoid populating the low bits at all. // TODO: avoid populating the low bits at all.
c.x &= Short4(0xFF00); c.x &= Short4(0xFF00u);
c.y &= Short4(0xFF00); c.y &= Short4(0xFF00u);
c.z &= Short4(0xFF00); c.z &= Short4(0xFF00u);
c.w &= Short4(0xFF00); c.w &= Short4(0xFF00u);
} }
break; break;
...@@ -1483,7 +1483,7 @@ namespace sw ...@@ -1483,7 +1483,7 @@ namespace sw
case VK_FORMAT_R8_SNORM: case VK_FORMAT_R8_SNORM:
// TODO: avoid populating the low bits at all. // TODO: avoid populating the low bits at all.
c.x = Unpack(As<Byte4>(c0)); c.x = Unpack(As<Byte4>(c0));
c.x &= Short4(0xff00); c.x &= Short4(0xFF00u);
break; break;
default: default:
c.x = Unpack(As<Byte4>(c0)); c.x = Unpack(As<Byte4>(c0));
...@@ -1660,9 +1660,14 @@ namespace sw ...@@ -1660,9 +1660,14 @@ namespace sw
{ {
// Scaling and bias for studio-swing range: Y = [16 .. 235], U/V = [16 .. 240] // Scaling and bias for studio-swing range: Y = [16 .. 235], U/V = [16 .. 240]
// Scale down by 0x0101 to normalize the 8.8 samples, and up by 0x7FFF for signed 15-bit output. // Scale down by 0x0101 to normalize the 8.8 samples, and up by 0x7FFF for signed 15-bit output.
Float4 y = (Float4(Y) - Float4(state.studioSwing ? 16 * 0x0101 : 0)) * Float4(float(0x7FFF) / (state.studioSwing ? 219 * 0x0101 : 255 * 0x0101)); float yOffset = static_cast<float>(state.studioSwing ? 16 * 0x0101 : 0);
Float4 u = (Float4(Cb) - Float4(128 * 0x0101)) * Float4(float(0x7FFF) / (state.studioSwing ? 224 * 0x0101 : 255 * 0x0101)); float uvOffset = static_cast<float>(128 * 0x0101);
Float4 v = (Float4(Cr) - Float4(128 * 0x0101)) * Float4(float(0x7FFF) / (state.studioSwing ? 224 * 0x0101 : 255 * 0x0101)); float yFactor = static_cast<float>(0x7FFF) / static_cast<float>(state.studioSwing ? 219 * 0x0101 : 255 * 0x0101);
float uvFactor = static_cast<float>(0x7FFF) / static_cast<float>(state.studioSwing ? 224 * 0x0101 : 255 * 0x0101);
Float4 y = (Float4(Y) - Float4(yOffset)) * Float4(yFactor);
Float4 u = (Float4(Cb) - Float4(uvOffset)) * Float4(uvFactor);
Float4 v = (Float4(Cr) - Float4(uvOffset)) * Float4(uvFactor);
if(state.ycbcrModel == VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_IDENTITY) if(state.ycbcrModel == VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_IDENTITY)
{ {
...@@ -1936,7 +1941,7 @@ namespace sw ...@@ -1936,7 +1941,7 @@ namespace sw
bool scaled = !hasFloatTexture() && !hasUnnormalizedIntegerTexture() && !state.compareEnable; bool scaled = !hasFloatTexture() && !hasUnnormalizedIntegerTexture() && !state.compareEnable;
bool sign = !hasUnsignedTextureComponent(0); bool sign = !hasUnsignedTextureComponent(0);
Int4 float_one = scaled ? As<Int4>(Float4(sign ? 0x7FFF : 0xFFFF)) : As<Int4>(Float4(1.0f)); Int4 float_one = scaled ? As<Int4>(Float4(static_cast<float>(sign ? 0x7FFF : 0xFFFF))) : As<Int4>(Float4(1.0f));
switch(state.border) switch(state.border)
{ {
......
...@@ -135,7 +135,7 @@ namespace sw ...@@ -135,7 +135,7 @@ namespace sw
return ii * ff; return ii * ff;
} }
Float4 logarithm2(RValue<Float4> x, bool absolute, bool pp) Float4 logarithm2(RValue<Float4> x, bool pp)
{ {
Float4 x0; Float4 x0;
Float4 x1; Float4 x1;
...@@ -166,15 +166,15 @@ namespace sw ...@@ -166,15 +166,15 @@ namespace sw
return exponential2(Float4(1.44269504f) * x, pp); // 1/ln(2) return exponential2(Float4(1.44269504f) * x, pp); // 1/ln(2)
} }
Float4 logarithm(RValue<Float4> x, bool absolute, bool pp) Float4 logarithm(RValue<Float4> x, bool pp)
{ {
// FIXME: Propagate the constant // FIXME: Propagate the constant
return Float4(6.93147181e-1f) * logarithm2(x, absolute, pp); // ln(2) return Float4(6.93147181e-1f) * logarithm2(x, pp); // ln(2)
} }
Float4 power(RValue<Float4> x, RValue<Float4> y, bool pp) Float4 power(RValue<Float4> x, RValue<Float4> y, bool pp)
{ {
Float4 log = logarithm2(x, true, pp); Float4 log = logarithm2(x, pp);
log *= y; log *= y;
return exponential2(log, pp); return exponential2(log, pp);
} }
......
...@@ -55,9 +55,9 @@ namespace sw ...@@ -55,9 +55,9 @@ namespace sw
}; };
Float4 exponential2(RValue<Float4> x, bool pp = false); Float4 exponential2(RValue<Float4> x, bool pp = false);
Float4 logarithm2(RValue<Float4> x, bool abs, bool pp = false); Float4 logarithm2(RValue<Float4> x, bool pp = false);
Float4 exponential(RValue<Float4> x, bool pp = false); Float4 exponential(RValue<Float4> x, bool pp = false);
Float4 logarithm(RValue<Float4> x, bool abs, bool pp = false); Float4 logarithm(RValue<Float4> x, bool pp = false);
Float4 power(RValue<Float4> x, RValue<Float4> y, bool pp = false); Float4 power(RValue<Float4> x, RValue<Float4> y, bool pp = false);
Float4 reciprocal(RValue<Float4> x, bool pp = false, bool finite = false, bool exactAtPow2 = false); Float4 reciprocal(RValue<Float4> x, bool pp = false, bool finite = false, bool exactAtPow2 = false);
Float4 reciprocalSquareRoot(RValue<Float4> x, bool abs, bool pp = false); Float4 reciprocalSquareRoot(RValue<Float4> x, bool abs, bool pp = false);
......
...@@ -592,7 +592,7 @@ namespace sw ...@@ -592,7 +592,7 @@ namespace sw
case spv::StorageClassWorkgroup: case spv::StorageClassWorkgroup:
{ {
auto &elTy = getType(getType(typeId).element); auto &elTy = getType(getType(typeId).element);
auto sizeInBytes = elTy.sizeInComponents * sizeof(float); auto sizeInBytes = elTy.sizeInComponents * static_cast<uint32_t>(sizeof(float));
workgroupMemory.allocate(resultId, sizeInBytes); workgroupMemory.allocate(resultId, sizeInBytes);
object.kind = Object::Kind::Pointer; object.kind = Object::Kind::Pointer;
break; break;
...@@ -1379,7 +1379,7 @@ namespace sw ...@@ -1379,7 +1379,7 @@ namespace sw
break; break;
case spv::OpTypeVector: case spv::OpTypeVector:
{ {
auto elemStride = (d.InsideMatrix && d.HasRowMajor && d.RowMajor) ? d.MatrixStride : sizeof(float); auto elemStride = (d.InsideMatrix && d.HasRowMajor && d.RowMajor) ? d.MatrixStride : static_cast<int32_t>(sizeof(float));
for (auto i = 0u; i < type.definition.word(3); i++) for (auto i = 0u; i < type.definition.word(3); i++)
{ {
VisitMemoryObjectInner(type.definition.word(2), d, index, offset + elemStride * i, f); VisitMemoryObjectInner(type.definition.word(2), d, index, offset + elemStride * i, f);
...@@ -1388,7 +1388,7 @@ namespace sw ...@@ -1388,7 +1388,7 @@ namespace sw
} }
case spv::OpTypeMatrix: case spv::OpTypeMatrix:
{ {
auto columnStride = (d.HasRowMajor && d.RowMajor) ? sizeof(float) : d.MatrixStride; auto columnStride = (d.HasRowMajor && d.RowMajor) ? static_cast<int32_t>(sizeof(float)) : d.MatrixStride;
d.InsideMatrix = true; d.InsideMatrix = true;
for (auto i = 0u; i < type.definition.word(3); i++) for (auto i = 0u; i < type.definition.word(3); i++)
{ {
...@@ -1594,7 +1594,7 @@ namespace sw ...@@ -1594,7 +1594,7 @@ namespace sw
// TODO: b/127950082: Check bounds. // TODO: b/127950082: Check bounds.
ASSERT(d.HasMatrixStride); ASSERT(d.HasMatrixStride);
d.InsideMatrix = true; d.InsideMatrix = true;
auto columnStride = (d.HasRowMajor && d.RowMajor) ? sizeof(float) : d.MatrixStride; auto columnStride = (d.HasRowMajor && d.RowMajor) ? static_cast<int32_t>(sizeof(float)) : d.MatrixStride;
auto & obj = getObject(indexIds[i]); auto & obj = getObject(indexIds[i]);
if (obj.kind == Object::Kind::Constant) if (obj.kind == Object::Kind::Constant)
{ {
...@@ -1609,7 +1609,7 @@ namespace sw ...@@ -1609,7 +1609,7 @@ namespace sw
} }
case spv::OpTypeVector: case spv::OpTypeVector:
{ {
auto elemStride = (d.InsideMatrix && d.HasRowMajor && d.RowMajor) ? d.MatrixStride : sizeof(float); auto elemStride = (d.InsideMatrix && d.HasRowMajor && d.RowMajor) ? d.MatrixStride : static_cast<int32_t>(sizeof(float));
auto & obj = getObject(indexIds[i]); auto & obj = getObject(indexIds[i]);
if (obj.kind == Object::Kind::Constant) if (obj.kind == Object::Kind::Constant)
{ {
...@@ -1679,12 +1679,12 @@ namespace sw ...@@ -1679,12 +1679,12 @@ namespace sw
ASSERT(d.DescriptorSet >= 0); ASSERT(d.DescriptorSet >= 0);
ASSERT(d.Binding >= 0); ASSERT(d.Binding >= 0);
auto setLayout = routine->pipelineLayout->getDescriptorSetLayout(d.DescriptorSet); auto setLayout = routine->pipelineLayout->getDescriptorSetLayout(d.DescriptorSet);
auto stride = setLayout->getBindingStride(d.Binding); auto stride = static_cast<uint32_t>(setLayout->getBindingStride(d.Binding));
ptr.base += stride * GetConstScalarInt(indexIds[i]); ptr.base += stride * GetConstScalarInt(indexIds[i]);
} }
else else
{ {
auto stride = getType(type.element).sizeInComponents * sizeof(float); auto stride = getType(type.element).sizeInComponents * static_cast<uint32_t>(sizeof(float));
auto & obj = getObject(indexIds[i]); auto & obj = getObject(indexIds[i]);
if (obj.kind == Object::Kind::Constant) if (obj.kind == Object::Kind::Constant)
{ {
...@@ -2619,7 +2619,7 @@ namespace sw ...@@ -2619,7 +2619,7 @@ namespace sw
ASSERT(objectTy.opcode() == spv::OpTypePointer); ASSERT(objectTy.opcode() == spv::OpTypePointer);
auto base = &routine->getVariable(resultId)[0]; auto base = &routine->getVariable(resultId)[0];
auto elementTy = getType(objectTy.element); auto elementTy = getType(objectTy.element);
auto size = elementTy.sizeInComponents * sizeof(float) * SIMD::Width; auto size = elementTy.sizeInComponents * static_cast<uint32_t>(sizeof(float)) * SIMD::Width;
routine->createPointer(resultId, SIMD::Pointer(base, size)); routine->createPointer(resultId, SIMD::Pointer(base, size));
break; break;
} }
...@@ -2646,7 +2646,7 @@ namespace sw ...@@ -2646,7 +2646,7 @@ namespace sw
ASSERT(objectTy.opcode() == spv::OpTypePointer); ASSERT(objectTy.opcode() == spv::OpTypePointer);
auto base = &routine->getVariable(resultId)[0]; auto base = &routine->getVariable(resultId)[0];
auto elementTy = getType(objectTy.element); auto elementTy = getType(objectTy.element);
auto size = elementTy.sizeInComponents * sizeof(float) * SIMD::Width; auto size = elementTy.sizeInComponents * static_cast<uint32_t>(sizeof(float)) * SIMD::Width;
routine->createPointer(resultId, SIMD::Pointer(base, size)); routine->createPointer(resultId, SIMD::Pointer(base, size));
break; break;
} }
...@@ -2660,7 +2660,7 @@ namespace sw ...@@ -2660,7 +2660,7 @@ namespace sw
auto setLayout = routine->pipelineLayout->getDescriptorSetLayout(d.DescriptorSet); auto setLayout = routine->pipelineLayout->getDescriptorSetLayout(d.DescriptorSet);
if (setLayout->hasBinding(d.Binding)) if (setLayout->hasBinding(d.Binding))
{ {
size_t bindingOffset = setLayout->getBindingOffset(d.Binding, arrayIndex); uint32_t bindingOffset = static_cast<uint32_t>(setLayout->getBindingOffset(d.Binding, arrayIndex));
Pointer<Byte> set = routine->descriptorSets[d.DescriptorSet]; // DescriptorSet* Pointer<Byte> set = routine->descriptorSets[d.DescriptorSet]; // DescriptorSet*
Pointer<Byte> binding = Pointer<Byte>(set + bindingOffset); // vk::SampledImageDescriptor* Pointer<Byte> binding = Pointer<Byte>(set + bindingOffset); // vk::SampledImageDescriptor*
auto size = 0; // Not required as this pointer is not directly used by SIMD::Read or SIMD::Write. auto size = 0; // Not required as this pointer is not directly used by SIMD::Read or SIMD::Write.
......
...@@ -35,8 +35,8 @@ public: ...@@ -35,8 +35,8 @@ public:
} }
void *getPointer() const; void *getPointer() const;
uint32_t getElementCount() const { return range / Format(format).bytes(); } uint32_t getElementCount() const { return static_cast<uint32_t>(range / Format(format).bytes()); }
uint32_t getRangeInBytes() const { return range; } uint32_t getRangeInBytes() const { return static_cast<uint32_t>(range); }
VkFormat getFormat() const { return format; } VkFormat getFormat() const { return format; }
const uint32_t id = ImageView::nextID++; // ID space for sampling function cache, shared with imageviews const uint32_t id = ImageView::nextID++; // ID space for sampling function cache, shared with imageviews
......
...@@ -41,8 +41,8 @@ namespace vk ...@@ -41,8 +41,8 @@ namespace vk
struct Node struct Node
{ {
Node(VkDescriptorSet set, size_t size) : set(set), size(size) {} Node(VkDescriptorSet set, size_t size) : set(set), size(size) {}
bool operator<(const Node& node) const { return this->set < node.set; } bool operator<(const Node& node) const { return set < node.set; }
bool operator==(VkDescriptorSet set) const { return this->set == set; } bool operator==(VkDescriptorSet other) const { return set == other; }
VkDescriptorSet set = VK_NULL_HANDLE; VkDescriptorSet set = VK_NULL_HANDLE;
size_t size = 0; size_t size = 0;
......
...@@ -255,17 +255,17 @@ uint8_t* DescriptorSetLayout::getOffsetPointer(DescriptorSet *descriptorSet, uin ...@@ -255,17 +255,17 @@ uint8_t* DescriptorSetLayout::getOffsetPointer(DescriptorSet *descriptorSet, uin
return &descriptorSet->data[byteOffset]; return &descriptorSet->data[byteOffset];
} }
void SampledImageDescriptor::updateSampler(const vk::Sampler *sampler) void SampledImageDescriptor::updateSampler(const vk::Sampler *newSampler)
{ {
if(sampler) if(newSampler)
{ {
memcpy(&this->sampler, sampler, sizeof(this->sampler)); memcpy(&sampler, newSampler, sizeof(sampler));
} }
else else
{ {
// Descriptor ID's start at 1, allowing to detect descriptor update // Descriptor ID's start at 1, allowing to detect descriptor update
// bugs by checking for 0. Also avoid reading random values. // bugs by checking for 0. Also avoid reading random values.
memset(&this->sampler, 0, sizeof(this->sampler)); memset(&sampler, 0, sizeof(sampler));
} }
} }
...@@ -315,8 +315,8 @@ void DescriptorSetLayout::WriteDescriptorSet(DescriptorSet *dstSet, VkDescriptor ...@@ -315,8 +315,8 @@ void DescriptorSetLayout::WriteDescriptorSet(DescriptorSet *dstSet, VkDescriptor
imageSampler[i].arrayLayers = 1; imageSampler[i].arrayLayers = 1;
imageSampler[i].mipLevels = 1; imageSampler[i].mipLevels = 1;
imageSampler[i].sampleCount = 1; imageSampler[i].sampleCount = 1;
imageSampler[i].texture.widthWidthHeightHeight = sw::vector(numElements, numElements, 1, 1); imageSampler[i].texture.widthWidthHeightHeight = sw::vector(static_cast<float>(numElements), static_cast<float>(numElements), 1, 1);
imageSampler[i].texture.width = sw::replicate(numElements); imageSampler[i].texture.width = sw::replicate(static_cast<float>(numElements));
imageSampler[i].texture.height = sw::replicate(1); imageSampler[i].texture.height = sw::replicate(1);
imageSampler[i].texture.depth = sw::replicate(1); imageSampler[i].texture.depth = sw::replicate(1);
...@@ -448,7 +448,7 @@ void DescriptorSetLayout::WriteDescriptorSet(DescriptorSet *dstSet, VkDescriptor ...@@ -448,7 +448,7 @@ void DescriptorSetLayout::WriteDescriptorSet(DescriptorSet *dstSet, VkDescriptor
descriptor[i].slicePitchBytes = descriptor[i].samplePitchBytes * imageView->getSampleCount(); descriptor[i].slicePitchBytes = descriptor[i].samplePitchBytes * imageView->getSampleCount();
descriptor[i].arrayLayers = imageView->getSubresourceRange().layerCount; descriptor[i].arrayLayers = imageView->getSubresourceRange().layerCount;
descriptor[i].sampleCount = imageView->getSampleCount(); descriptor[i].sampleCount = imageView->getSampleCount();
descriptor[i].sizeInBytes = imageView->getImageSizeInBytes(); descriptor[i].sizeInBytes = static_cast<int>(imageView->getImageSizeInBytes());
if (imageView->getFormat().isStencil()) if (imageView->getFormat().isStencil())
{ {
...@@ -489,8 +489,8 @@ void DescriptorSetLayout::WriteDescriptorSet(DescriptorSet *dstSet, VkDescriptor ...@@ -489,8 +489,8 @@ void DescriptorSetLayout::WriteDescriptorSet(DescriptorSet *dstSet, VkDescriptor
auto update = reinterpret_cast<VkDescriptorBufferInfo const *>(src + entry.offset + entry.stride * i); auto update = reinterpret_cast<VkDescriptorBufferInfo const *>(src + entry.offset + entry.stride * i);
auto buffer = Cast(update->buffer); auto buffer = Cast(update->buffer);
descriptor[i].ptr = buffer->getOffsetPointer(update->offset); descriptor[i].ptr = buffer->getOffsetPointer(update->offset);
descriptor[i].sizeInBytes = (update->range == VK_WHOLE_SIZE) ? buffer->getSize() - update->offset : update->range; descriptor[i].sizeInBytes = static_cast<int>((update->range == VK_WHOLE_SIZE) ? buffer->getSize() - update->offset : update->range);
descriptor[i].robustnessSize = buffer->getSize() - update->offset; descriptor[i].robustnessSize = static_cast<int>(buffer->getSize() - update->offset);
} }
} }
} }
...@@ -499,25 +499,25 @@ void DescriptorSetLayout::WriteTextureLevelInfo(sw::Texture *texture, int level, ...@@ -499,25 +499,25 @@ void DescriptorSetLayout::WriteTextureLevelInfo(sw::Texture *texture, int level,
{ {
if(level == 0) if(level == 0)
{ {
texture->widthWidthHeightHeight[0] = width; texture->widthWidthHeightHeight[0] =
texture->widthWidthHeightHeight[1] = width; texture->widthWidthHeightHeight[1] = static_cast<float>(width);
texture->widthWidthHeightHeight[2] = height; texture->widthWidthHeightHeight[2] =
texture->widthWidthHeightHeight[3] = height; texture->widthWidthHeightHeight[3] = static_cast<float>(height);
texture->width[0] = width; texture->width[0] =
texture->width[1] = width; texture->width[1] =
texture->width[2] = width; texture->width[2] =
texture->width[3] = width; texture->width[3] = static_cast<float>(width);
texture->height[0] = height; texture->height[0] =
texture->height[1] = height; texture->height[1] =
texture->height[2] = height; texture->height[2] =
texture->height[3] = height; texture->height[3] = static_cast<float>(height);
texture->depth[0] = depth; texture->depth[0] =
texture->depth[1] = depth; texture->depth[1] =
texture->depth[2] = depth; texture->depth[2] =
texture->depth[3] = depth; texture->depth[3] = static_cast<float>(depth);
} }
sw::Mipmap &mipmap = texture->mipmap[level]; sw::Mipmap &mipmap = texture->mipmap[level];
...@@ -526,40 +526,40 @@ void DescriptorSetLayout::WriteTextureLevelInfo(sw::Texture *texture, int level, ...@@ -526,40 +526,40 @@ void DescriptorSetLayout::WriteTextureLevelInfo(sw::Texture *texture, int level,
short halfTexelV = 0x8000 / height; short halfTexelV = 0x8000 / height;
short halfTexelW = 0x8000 / depth; short halfTexelW = 0x8000 / depth;
mipmap.uHalf[0] = halfTexelU; mipmap.uHalf[0] =
mipmap.uHalf[1] = halfTexelU; mipmap.uHalf[1] =
mipmap.uHalf[2] = halfTexelU; mipmap.uHalf[2] =
mipmap.uHalf[3] = halfTexelU; mipmap.uHalf[3] = halfTexelU;
mipmap.vHalf[0] = halfTexelV; mipmap.vHalf[0] =
mipmap.vHalf[1] = halfTexelV; mipmap.vHalf[1] =
mipmap.vHalf[2] = halfTexelV; mipmap.vHalf[2] =
mipmap.vHalf[3] = halfTexelV; mipmap.vHalf[3] = halfTexelV;
mipmap.wHalf[0] = halfTexelW; mipmap.wHalf[0] =
mipmap.wHalf[1] = halfTexelW; mipmap.wHalf[1] =
mipmap.wHalf[2] = halfTexelW; mipmap.wHalf[2] =
mipmap.wHalf[3] = halfTexelW; mipmap.wHalf[3] = halfTexelW;
mipmap.width[0] = width; mipmap.width[0] =
mipmap.width[1] = width; mipmap.width[1] =
mipmap.width[2] = width; mipmap.width[2] =
mipmap.width[3] = width; mipmap.width[3] = width;
mipmap.height[0] = height; mipmap.height[0] =
mipmap.height[1] = height; mipmap.height[1] =
mipmap.height[2] = height; mipmap.height[2] =
mipmap.height[3] = height; mipmap.height[3] = height;
mipmap.depth[0] = depth; mipmap.depth[0] =
mipmap.depth[1] = depth; mipmap.depth[1] =
mipmap.depth[2] = depth; mipmap.depth[2] =
mipmap.depth[3] = depth; mipmap.depth[3] = depth;
mipmap.onePitchP[0] = 1; mipmap.onePitchP[0] = 1;
mipmap.onePitchP[1] = pitchP; mipmap.onePitchP[1] = static_cast<short>(pitchP);
mipmap.onePitchP[2] = 1; mipmap.onePitchP[2] = 1;
mipmap.onePitchP[3] = pitchP; mipmap.onePitchP[3] = static_cast<short>(pitchP);
mipmap.pitchP[0] = pitchP; mipmap.pitchP[0] = pitchP;
mipmap.pitchP[1] = pitchP; mipmap.pitchP[1] = pitchP;
......
...@@ -29,6 +29,8 @@ class DescriptorSet; ...@@ -29,6 +29,8 @@ class DescriptorSet;
// TODO(b/129523279): Move to the Device or Pipeline layer. // TODO(b/129523279): Move to the Device or Pipeline layer.
struct alignas(16) SampledImageDescriptor struct alignas(16) SampledImageDescriptor
{ {
~SampledImageDescriptor() = delete;
void updateSampler(const vk::Sampler *sampler); void updateSampler(const vk::Sampler *sampler);
// TODO(b/129523279): Minimize to the data actually needed. // TODO(b/129523279): Minimize to the data actually needed.
...@@ -47,6 +49,8 @@ struct alignas(16) SampledImageDescriptor ...@@ -47,6 +49,8 @@ struct alignas(16) SampledImageDescriptor
struct alignas(16) StorageImageDescriptor struct alignas(16) StorageImageDescriptor
{ {
~StorageImageDescriptor() = delete;
void *ptr; void *ptr;
VkExtent3D extent; VkExtent3D extent;
int rowPitchBytes; int rowPitchBytes;
...@@ -64,6 +68,8 @@ struct alignas(16) StorageImageDescriptor ...@@ -64,6 +68,8 @@ struct alignas(16) StorageImageDescriptor
struct alignas(16) BufferDescriptor struct alignas(16) BufferDescriptor
{ {
~BufferDescriptor() = delete;
void *ptr; void *ptr;
int sizeInBytes; // intended size of the bound region -- slides along with dynamic offsets int sizeInBytes; // intended size of the bound region -- slides along with dynamic offsets
int robustnessSize; // total accessible size from static offset -- does not move with dynamic offset int robustnessSize; // total accessible size from static offset -- does not move with dynamic offset
......
...@@ -289,7 +289,7 @@ void PhysicalDevice::getProperties(VkPhysicalDeviceIDProperties* properties) con ...@@ -289,7 +289,7 @@ void PhysicalDevice::getProperties(VkPhysicalDeviceIDProperties* properties) con
void PhysicalDevice::getProperties(VkPhysicalDeviceMaintenance3Properties* properties) const void PhysicalDevice::getProperties(VkPhysicalDeviceMaintenance3Properties* properties) const
{ {
properties->maxMemoryAllocationSize = 1 << 31; properties->maxMemoryAllocationSize = 1u << 31;
properties->maxPerSetDescriptors = 1024; properties->maxPerSetDescriptors = 1024;
} }
...@@ -718,7 +718,7 @@ void PhysicalDevice::getImageFormatProperties(Format format, VkImageType type, V ...@@ -718,7 +718,7 @@ void PhysicalDevice::getImageFormatProperties(Format format, VkImageType type, V
break; break;
} }
pImageFormatProperties->maxResourceSize = 1 << 31; // Minimum value for maxResourceSize pImageFormatProperties->maxResourceSize = 1u << 31; // Minimum value for maxResourceSize
// "Images created with tiling equal to VK_IMAGE_TILING_LINEAR have further restrictions on their limits and capabilities // "Images created with tiling equal to VK_IMAGE_TILING_LINEAR have further restrictions on their limits and capabilities
// compared to images created with tiling equal to VK_IMAGE_TILING_OPTIMAL." // compared to images created with tiling equal to VK_IMAGE_TILING_OPTIMAL."
......
...@@ -92,7 +92,7 @@ sw::StreamType getStreamType(VkFormat format) ...@@ -92,7 +92,7 @@ sw::StreamType getStreamType(VkFormat format)
return sw::STREAMTYPE_BYTE; return sw::STREAMTYPE_BYTE;
} }
uint32_t getNumberOfChannels(VkFormat format) unsigned char getNumberOfChannels(VkFormat format)
{ {
switch(format) switch(format)
{ {
......
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