Commit fccfc566 by Ben Clayton

clang-format the src/Device directory

Bug: b/144825072 Change-Id: I2e9c18aa5e3d394d18f86ca597aed6d6dc8dfe93 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/39654 Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent d4e6447c
...@@ -14,14 +14,13 @@ ...@@ -14,14 +14,13 @@
#include "BC_Decoder.hpp" #include "BC_Decoder.hpp"
namespace namespace {
{ static constexpr int BlockWidth = 4;
static constexpr int BlockWidth = 4; static constexpr int BlockHeight = 4;
static constexpr int BlockHeight = 4;
struct BC_color struct BC_color
{ {
void decode(unsigned char* dst, int x, int y, int dstW, int dstH, int dstPitch, int dstBpp, bool hasAlphaChannel, bool hasSeparateAlpha) const void decode(unsigned char *dst, int x, int y, int dstW, int dstH, int dstPitch, int dstBpp, bool hasAlphaChannel, bool hasSeparateAlpha) const
{ {
Color c[4]; Color c[4];
c[0].extract565(c0); c[0].extract565(c0);
...@@ -46,12 +45,12 @@ namespace ...@@ -46,12 +45,12 @@ namespace
int idxOffset = j * BlockHeight; int idxOffset = j * BlockHeight;
for(int i = 0; i < BlockWidth && (x + i) < dstW; i++, idxOffset++, dstOffset += dstBpp) for(int i = 0; i < BlockWidth && (x + i) < dstW; i++, idxOffset++, dstOffset += dstBpp)
{ {
*reinterpret_cast<unsigned int*>(dst + dstOffset) = c[getIdx(idxOffset)].pack8888(); *reinterpret_cast<unsigned int *>(dst + dstOffset) = c[getIdx(idxOffset)].pack8888();
} }
} }
} }
private: private:
struct Color struct Color
{ {
Color() Color()
...@@ -107,7 +106,7 @@ namespace ...@@ -107,7 +106,7 @@ namespace
return res; return res;
} }
Color operator+(Color const& obj) const Color operator+(Color const &obj) const
{ {
Color res; Color res;
for(int i = 0; i < 4; ++i) for(int i = 0; i < 4; ++i)
...@@ -130,11 +129,11 @@ namespace ...@@ -130,11 +129,11 @@ namespace
unsigned short c0; unsigned short c0;
unsigned short c1; unsigned short c1;
unsigned int idx; unsigned int idx;
}; };
struct BC_channel struct BC_channel
{ {
void decode(unsigned char* dst, int x, int y, int dstW, int dstH, int dstPitch, int dstBpp, int channel, bool isSigned) const void decode(unsigned char *dst, int x, int y, int dstW, int dstH, int dstPitch, int dstBpp, int channel, bool isSigned) const
{ {
int c[8] = { 0 }; int c[8] = { 0 };
...@@ -175,7 +174,7 @@ namespace ...@@ -175,7 +174,7 @@ namespace
} }
} }
private: private:
unsigned char getIdx(int i) const unsigned char getIdx(int i) const
{ {
int offset = i * 3 + 16; int offset = i * 3 + 16;
...@@ -183,16 +182,16 @@ namespace ...@@ -183,16 +182,16 @@ namespace
} }
unsigned long long data; unsigned long long data;
}; };
struct BC_alpha struct BC_alpha
{ {
void decode(unsigned char* dst, int x, int y, int dstW, int dstH, int dstPitch, int dstBpp) const void decode(unsigned char *dst, int x, int y, int dstW, int dstH, int dstPitch, int dstBpp) const
{ {
dst += 3; // Write only to alpha (channel 3) dst += 3; // Write only to alpha (channel 3)
for(int j = 0; j < BlockHeight && (y + j) < dstH; j++, dst += dstPitch) for(int j = 0; j < BlockHeight && (y + j) < dstH; j++, dst += dstPitch)
{ {
unsigned char* dstRow = dst; unsigned char *dstRow = dst;
for(int i = 0; i < BlockWidth && (x + i) < dstW; i++, dstRow += dstBpp) for(int i = 0; i < BlockWidth && (x + i) < dstW; i++, dstRow += dstBpp)
{ {
*dstRow = getAlpha(j * BlockHeight + i); *dstRow = getAlpha(j * BlockHeight + i);
...@@ -200,7 +199,7 @@ namespace ...@@ -200,7 +199,7 @@ namespace
} }
} }
private: private:
unsigned char getAlpha(int i) const unsigned char getAlpha(int i) const
{ {
int offset = i << 2; int offset = i << 2;
...@@ -209,11 +208,11 @@ namespace ...@@ -209,11 +208,11 @@ namespace
} }
unsigned long long data; unsigned long long data;
}; };
} // end namespace } // end namespace
// Decodes 1 to 4 channel images to 8 bit output // Decodes 1 to 4 channel images to 8 bit output
bool BC_Decoder::Decode(const unsigned char* src, unsigned char* dst, int w, int h, int dstW, int dstH, int dstPitch, int dstBpp, int n, bool isNoAlphaU) bool BC_Decoder::Decode(const unsigned char *src, unsigned char *dst, int w, int h, int dstW, int dstH, int dstPitch, int dstBpp, int n, bool isNoAlphaU)
{ {
static_assert(sizeof(BC_color) == 8, "BC_color must be 8 bytes"); static_assert(sizeof(BC_color) == 8, "BC_color must be 8 bytes");
static_assert(sizeof(BC_channel) == 8, "BC_channel must be 8 bytes"); static_assert(sizeof(BC_channel) == 8, "BC_channel must be 8 bytes");
...@@ -228,10 +227,10 @@ bool BC_Decoder::Decode(const unsigned char* src, unsigned char* dst, int w, int ...@@ -228,10 +227,10 @@ bool BC_Decoder::Decode(const unsigned char* src, unsigned char* dst, int w, int
{ {
case 1: // BC1 case 1: // BC1
{ {
const BC_color* color = reinterpret_cast<const BC_color*>(src); const BC_color *color = reinterpret_cast<const BC_color *>(src);
for(int y = 0; y < h; y += BlockHeight, dst += dy) for(int y = 0; y < h; y += BlockHeight, dst += dy)
{ {
unsigned char* dstRow = dst; unsigned char *dstRow = dst;
for(int x = 0; x < w; x += BlockWidth, ++color, dstRow += dx) for(int x = 0; x < w; x += BlockWidth, ++color, dstRow += dx)
{ {
color->decode(dstRow, x, y, dstW, dstH, dstPitch, dstBpp, isAlpha, false); color->decode(dstRow, x, y, dstW, dstH, dstPitch, dstBpp, isAlpha, false);
...@@ -241,11 +240,11 @@ bool BC_Decoder::Decode(const unsigned char* src, unsigned char* dst, int w, int ...@@ -241,11 +240,11 @@ bool BC_Decoder::Decode(const unsigned char* src, unsigned char* dst, int w, int
break; break;
case 2: // BC2 case 2: // BC2
{ {
const BC_alpha* alpha = reinterpret_cast<const BC_alpha*>(src); const BC_alpha *alpha = reinterpret_cast<const BC_alpha *>(src);
const BC_color* color = reinterpret_cast<const BC_color*>(src + 8); const BC_color *color = reinterpret_cast<const BC_color *>(src + 8);
for(int y = 0; y < h; y += BlockHeight, dst += dy) for(int y = 0; y < h; y += BlockHeight, dst += dy)
{ {
unsigned char* dstRow = dst; unsigned char *dstRow = dst;
for(int x = 0; x < w; x += BlockWidth, alpha += 2, color += 2, dstRow += dx) for(int x = 0; x < w; x += BlockWidth, alpha += 2, color += 2, dstRow += dx)
{ {
color->decode(dstRow, x, y, dstW, dstH, dstPitch, dstBpp, isAlpha, true); color->decode(dstRow, x, y, dstW, dstH, dstPitch, dstBpp, isAlpha, true);
...@@ -256,11 +255,11 @@ bool BC_Decoder::Decode(const unsigned char* src, unsigned char* dst, int w, int ...@@ -256,11 +255,11 @@ bool BC_Decoder::Decode(const unsigned char* src, unsigned char* dst, int w, int
break; break;
case 3: // BC3 case 3: // BC3
{ {
const BC_channel* alpha = reinterpret_cast<const BC_channel*>(src); const BC_channel *alpha = reinterpret_cast<const BC_channel *>(src);
const BC_color* color = reinterpret_cast<const BC_color*>(src + 8); const BC_color *color = reinterpret_cast<const BC_color *>(src + 8);
for(int y = 0; y < h; y += BlockHeight, dst += dy) for(int y = 0; y < h; y += BlockHeight, dst += dy)
{ {
unsigned char* dstRow = dst; unsigned char *dstRow = dst;
for(int x = 0; x < w; x += BlockWidth, alpha += 2, color += 2, dstRow += dx) for(int x = 0; x < w; x += BlockWidth, alpha += 2, color += 2, dstRow += dx)
{ {
color->decode(dstRow, x, y, dstW, dstH, dstPitch, dstBpp, isAlpha, true); color->decode(dstRow, x, y, dstW, dstH, dstPitch, dstBpp, isAlpha, true);
...@@ -271,10 +270,10 @@ bool BC_Decoder::Decode(const unsigned char* src, unsigned char* dst, int w, int ...@@ -271,10 +270,10 @@ bool BC_Decoder::Decode(const unsigned char* src, unsigned char* dst, int w, int
break; break;
case 4: // BC4 case 4: // BC4
{ {
const BC_channel* red = reinterpret_cast<const BC_channel*>(src); const BC_channel *red = reinterpret_cast<const BC_channel *>(src);
for(int y = 0; y < h; y += BlockHeight, dst += dy) for(int y = 0; y < h; y += BlockHeight, dst += dy)
{ {
unsigned char* dstRow = dst; unsigned char *dstRow = dst;
for(int x = 0; x < w; x += BlockWidth, ++red, dstRow += dx) for(int x = 0; x < w; x += BlockWidth, ++red, dstRow += dx)
{ {
red->decode(dstRow, x, y, dstW, dstH, dstPitch, dstBpp, 0, isSigned); red->decode(dstRow, x, y, dstW, dstH, dstPitch, dstBpp, 0, isSigned);
...@@ -284,11 +283,11 @@ bool BC_Decoder::Decode(const unsigned char* src, unsigned char* dst, int w, int ...@@ -284,11 +283,11 @@ bool BC_Decoder::Decode(const unsigned char* src, unsigned char* dst, int w, int
break; break;
case 5: // BC5 case 5: // BC5
{ {
const BC_channel* red = reinterpret_cast<const BC_channel*>(src); const BC_channel *red = reinterpret_cast<const BC_channel *>(src);
const BC_channel* green = reinterpret_cast<const BC_channel*>(src + 8); const BC_channel *green = reinterpret_cast<const BC_channel *>(src + 8);
for(int y = 0; y < h; y += BlockHeight, dst += dy) for(int y = 0; y < h; y += BlockHeight, dst += dy)
{ {
unsigned char* dstRow = dst; unsigned char *dstRow = dst;
for(int x = 0; x < w; x += BlockWidth, red += 2, green += 2, dstRow += dx) for(int x = 0; x < w; x += BlockWidth, red += 2, green += 2, dstRow += dx)
{ {
red->decode(dstRow, x, y, dstW, dstH, dstPitch, dstBpp, 0, isSigned); red->decode(dstRow, x, y, dstW, dstH, dstPitch, dstBpp, 0, isSigned);
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
class BC_Decoder class BC_Decoder
{ {
public: public:
/// BCn_Decoder::Decode - Decodes 1 to 4 channel images to 8 bit output /// BCn_Decoder::Decode - Decodes 1 to 4 channel images to 8 bit output
/// @param src Pointer to BCn encoded image /// @param src Pointer to BCn encoded image
/// @param dst Pointer to decoded output image /// @param dst Pointer to decoded output image
...@@ -29,5 +28,5 @@ public: ...@@ -29,5 +28,5 @@ public:
/// @param isNoAlphaU BC1: true if RGB, BC2/BC3: unused, BC4/BC5: true if unsigned /// @param isNoAlphaU BC1: true if RGB, BC2/BC3: unused, BC4/BC5: true if unsigned
/// @return true if the decoding was performed /// @return true if the decoding was performed
static bool Decode(const unsigned char* src, unsigned char* dst, int w, int h, int dstW, int dstH, int dstPitch, int dstBpp, int n, bool isNoAlphaU); static bool Decode(const unsigned char *src, unsigned char *dst, int w, int h, int dstW, int dstH, int dstPitch, int dstBpp, int n, bool isNoAlphaU);
}; };
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
#include "Reactor/Reactor.hpp" #include "Reactor/Reactor.hpp"
#include "Vulkan/VkFormat.h" #include "Vulkan/VkFormat.h"
#include <mutex>
#include <cstring> #include <cstring>
#include <mutex>
namespace vk { namespace vk {
...@@ -38,9 +38,19 @@ class Blitter ...@@ -38,9 +38,19 @@ class Blitter
{ {
explicit Options() = default; explicit Options() = default;
explicit Options(bool filter, bool allowSRGBConversion) explicit Options(bool filter, bool allowSRGBConversion)
: writeMask(0xF), clearOperation(false), filter(filter), allowSRGBConversion(allowSRGBConversion), clampToEdge(false) {} : writeMask(0xF)
, clearOperation(false)
, filter(filter)
, allowSRGBConversion(allowSRGBConversion)
, clampToEdge(false)
{}
explicit Options(unsigned int writeMask) explicit Options(unsigned int writeMask)
: writeMask(writeMask), clearOperation(true), filter(false), allowSRGBConversion(true), clampToEdge(false) {} : writeMask(writeMask)
, clearOperation(true)
, filter(false)
, allowSRGBConversion(true)
, clampToEdge(false)
{}
union union
{ {
...@@ -63,10 +73,21 @@ class Blitter ...@@ -63,10 +73,21 @@ class Blitter
struct State : Memset<State>, Options struct State : Memset<State>, Options
{ {
State() : Memset(this, 0) {} State()
State(const Options &options) : Memset(this, 0), Options(options) {} : Memset(this, 0)
State(vk::Format sourceFormat, vk::Format destFormat, int srcSamples, int destSamples, const Options &options) : {}
Memset(this, 0), Options(options), sourceFormat(sourceFormat), destFormat(destFormat), srcSamples(srcSamples), destSamples(destSamples) {} State(const Options &options)
: Memset(this, 0)
, Options(options)
{}
State(vk::Format sourceFormat, vk::Format destFormat, int srcSamples, int destSamples, const Options &options)
: Memset(this, 0)
, Options(options)
, sourceFormat(sourceFormat)
, destFormat(destFormat)
, srcSamples(srcSamples)
, destSamples(destSamples)
{}
bool operator==(const State &state) const bool operator==(const State &state) const
{ {
...@@ -115,18 +136,24 @@ public: ...@@ -115,18 +136,24 @@ public:
Blitter(); Blitter();
virtual ~Blitter(); virtual ~Blitter();
void clear(void *pixel, vk::Format format, vk::Image *dest, const vk::Format& viewFormat, const VkImageSubresourceRange& subresourceRange, const VkRect2D* renderArea = nullptr); void clear(void *pixel, vk::Format format, vk::Image *dest, const vk::Format &viewFormat, const VkImageSubresourceRange &subresourceRange, const VkRect2D *renderArea = nullptr);
void blit(const vk::Image *src, vk::Image *dst, VkImageBlit region, VkFilter filter); void blit(const vk::Image *src, vk::Image *dst, VkImageBlit region, VkFilter filter);
void blitToBuffer(const vk::Image *src, VkImageSubresourceLayers subresource, VkOffset3D offset, VkExtent3D extent, uint8_t *dst, int bufferRowPitch, int bufferSlicePitch); void blitToBuffer(const vk::Image *src, VkImageSubresourceLayers subresource, VkOffset3D offset, VkExtent3D extent, uint8_t *dst, int bufferRowPitch, int bufferSlicePitch);
void blitFromBuffer(const vk::Image *dst, VkImageSubresourceLayers subresource, VkOffset3D offset, VkExtent3D extent, uint8_t *src, int bufferRowPitch, int bufferSlicePitch); void blitFromBuffer(const vk::Image *dst, VkImageSubresourceLayers subresource, VkOffset3D offset, VkExtent3D extent, uint8_t *src, int bufferRowPitch, int bufferSlicePitch);
void updateBorders(vk::Image* image, const VkImageSubresourceLayers& subresourceLayers); void updateBorders(vk::Image *image, const VkImageSubresourceLayers &subresourceLayers);
private: private:
enum Edge { TOP, BOTTOM, RIGHT, LEFT }; enum Edge
{
TOP,
BOTTOM,
RIGHT,
LEFT
};
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);
Float4 readFloat4(Pointer<Byte> element, const State &state); Float4 readFloat4(Pointer<Byte> element, const State &state);
void write(Float4 &color, Pointer<Byte> element, const State &state); void write(Float4 &color, Pointer<Byte> element, const State &state);
...@@ -137,20 +164,20 @@ private: ...@@ -137,20 +164,20 @@ private:
static Float4 LinearToSRGB(Float4 &color); static Float4 LinearToSRGB(Float4 &color);
static Float4 sRGBtoLinear(Float4 &color); static Float4 sRGBtoLinear(Float4 &color);
using BlitFunction = FunctionT<void(const BlitData*)>; using BlitFunction = FunctionT<void(const BlitData *)>;
using BlitRoutineType = BlitFunction::RoutineType; using BlitRoutineType = BlitFunction::RoutineType;
BlitRoutineType getBlitRoutine(const State &state); BlitRoutineType getBlitRoutine(const State &state);
BlitRoutineType generate(const State &state); BlitRoutineType generate(const State &state);
using CornerUpdateFunction = FunctionT<void(const CubeBorderData*)>; using CornerUpdateFunction = FunctionT<void(const CubeBorderData *)>;
using CornerUpdateRoutineType = CornerUpdateFunction::RoutineType; using CornerUpdateRoutineType = CornerUpdateFunction::RoutineType;
CornerUpdateRoutineType getCornerUpdateRoutine(const State &state); CornerUpdateRoutineType getCornerUpdateRoutine(const State &state);
CornerUpdateRoutineType generateCornerUpdate(const State& state); CornerUpdateRoutineType generateCornerUpdate(const State &state);
void computeCubeCorner(Pointer<Byte>& layer, Int& x0, Int& x1, Int& y0, Int& y1, Int& pitchB, const State& state); void computeCubeCorner(Pointer<Byte> &layer, Int &x0, Int &x1, Int &y0, Int &y1, Int &pitchB, const State &state);
void copyCubeEdge(vk::Image* image, void copyCubeEdge(vk::Image *image,
const VkImageSubresourceLayers& dstSubresourceLayers, Edge dstEdge, const VkImageSubresourceLayers &dstSubresourceLayers, Edge dstEdge,
const VkImageSubresourceLayers& srcSubresourceLayers, Edge srcEdge); const VkImageSubresourceLayers &srcSubresourceLayers, Edge srcEdge);
std::mutex blitMutex; std::mutex blitMutex;
RoutineCacheT<State, BlitFunction::CFunctionType> blitCache; // guarded by blitMutex RoutineCacheT<State, BlitFunction::CFunctionType> blitCache; // guarded by blitMutex
......
...@@ -277,17 +277,26 @@ bool Clipper::Clip(Polygon &polygon, int clipFlagsOr, const DrawCall &draw) ...@@ -277,17 +277,26 @@ bool Clipper::Clip(Polygon &polygon, int clipFlagsOr, const DrawCall &draw)
if(clipFlagsOr & CLIP_FRUSTUM) if(clipFlagsOr & CLIP_FRUSTUM)
{ {
if(clipFlagsOr & CLIP_NEAR) clipNear(polygon); if(clipFlagsOr & CLIP_NEAR) clipNear(polygon);
if(polygon.n >= 3) { if(polygon.n >= 3)
{
if(clipFlagsOr & CLIP_FAR) clipFar(polygon); if(clipFlagsOr & CLIP_FAR) clipFar(polygon);
if(polygon.n >= 3) { if(polygon.n >= 3)
{
if(clipFlagsOr & CLIP_LEFT) clipLeft(polygon); if(clipFlagsOr & CLIP_LEFT) clipLeft(polygon);
if(polygon.n >= 3) { if(polygon.n >= 3)
{
if(clipFlagsOr & CLIP_RIGHT) clipRight(polygon); if(clipFlagsOr & CLIP_RIGHT) clipRight(polygon);
if(polygon.n >= 3) { if(polygon.n >= 3)
{
if(clipFlagsOr & CLIP_TOP) clipTop(polygon); if(clipFlagsOr & CLIP_TOP) clipTop(polygon);
if(polygon.n >= 3) { if(polygon.n >= 3)
{
if(clipFlagsOr & CLIP_BOTTOM) clipBottom(polygon); if(clipFlagsOr & CLIP_BOTTOM) clipBottom(polygon);
}}}}} }
}
}
}
}
} }
return polygon.n >= 3; return polygon.n >= 3;
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
#ifndef sw_Color_hpp #ifndef sw_Color_hpp
#define sw_Color_hpp #define sw_Color_hpp
#include "System/Types.hpp"
#include "System/Math.hpp" #include "System/Math.hpp"
#include "System/Types.hpp"
namespace sw { namespace sw {
...@@ -44,7 +44,7 @@ struct Color ...@@ -44,7 +44,7 @@ struct Color
Color<T> operator+() const; Color<T> operator+() const;
Color<T> operator-() const; Color<T> operator-() const;
Color<T>& operator=(const Color<T>& c); Color<T> &operator=(const Color<T> &c);
Color<T> &operator+=(const Color<T> &c); Color<T> &operator+=(const Color<T> &c);
Color<T> &operator*=(float l); Color<T> &operator*=(float l);
...@@ -69,7 +69,7 @@ struct Color ...@@ -69,7 +69,7 @@ struct Color
T b; T b;
T a; T a;
}; };
} } // namespace sw
#include "System/Math.hpp" #include "System/Math.hpp"
...@@ -340,7 +340,7 @@ inline Color<T> Color<T>::operator-() const ...@@ -340,7 +340,7 @@ inline Color<T> Color<T>::operator-() const
} }
template<class T> template<class T>
inline Color<T> &Color<T>::operator=(const Color& c) inline Color<T> &Color<T>::operator=(const Color &c)
{ {
r = c.r; r = c.r;
g = c.g; g = c.g;
......
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
#include "Context.hpp" #include "Context.hpp"
#include "Primitive.hpp" #include "Primitive.hpp"
#include "Pipeline/SpirvShader.hpp"
#include "System/Memory.hpp" #include "System/Memory.hpp"
#include "Vulkan/VkDebug.hpp" #include "Vulkan/VkDebug.hpp"
#include "Vulkan/VkImageView.hpp" #include "Vulkan/VkImageView.hpp"
#include "Pipeline/SpirvShader.hpp"
#include <string.h> #include <string.h>
......
...@@ -15,12 +15,12 @@ ...@@ -15,12 +15,12 @@
#ifndef sw_Context_hpp #ifndef sw_Context_hpp
#define sw_Context_hpp #define sw_Context_hpp
#include "Vulkan/VkConfig.h"
#include "Vulkan/VkDescriptorSet.hpp"
#include "Config.hpp" #include "Config.hpp"
#include "Memset.hpp" #include "Memset.hpp"
#include "Stream.hpp" #include "Stream.hpp"
#include "System/Types.hpp" #include "System/Types.hpp"
#include "Vulkan/VkConfig.h"
#include "Vulkan/VkDescriptorSet.hpp"
namespace vk { namespace vk {
...@@ -40,7 +40,9 @@ struct PushConstantStorage ...@@ -40,7 +40,9 @@ struct PushConstantStorage
struct BlendState : Memset<BlendState> struct BlendState : Memset<BlendState>
{ {
BlendState() : Memset(this, 0) {} BlendState()
: Memset(this, 0)
{}
BlendState(bool alphaBlendEnable, BlendState(bool alphaBlendEnable,
VkBlendFactor sourceBlendFactor, VkBlendFactor sourceBlendFactor,
...@@ -48,15 +50,15 @@ struct BlendState : Memset<BlendState> ...@@ -48,15 +50,15 @@ struct BlendState : Memset<BlendState>
VkBlendOp blendOperation, VkBlendOp blendOperation,
VkBlendFactor sourceBlendFactorAlpha, VkBlendFactor sourceBlendFactorAlpha,
VkBlendFactor destBlendFactorAlpha, VkBlendFactor destBlendFactorAlpha,
VkBlendOp blendOperationAlpha) : VkBlendOp blendOperationAlpha)
Memset(this, 0), : Memset(this, 0)
alphaBlendEnable(alphaBlendEnable), , alphaBlendEnable(alphaBlendEnable)
sourceBlendFactor(sourceBlendFactor), , sourceBlendFactor(sourceBlendFactor)
destBlendFactor(destBlendFactor), , destBlendFactor(destBlendFactor)
blendOperation(blendOperation), , blendOperation(blendOperation)
sourceBlendFactorAlpha(sourceBlendFactorAlpha), , sourceBlendFactorAlpha(sourceBlendFactorAlpha)
destBlendFactorAlpha(destBlendFactorAlpha), , destBlendFactorAlpha(destBlendFactorAlpha)
blendOperationAlpha(blendOperationAlpha) , blendOperationAlpha(blendOperationAlpha)
{} {}
bool alphaBlendEnable; bool alphaBlendEnable;
......
...@@ -14,27 +14,26 @@ ...@@ -14,27 +14,26 @@
#include "ETC_Decoder.hpp" #include "ETC_Decoder.hpp"
namespace namespace {
inline unsigned char clampByte(int value)
{ {
inline unsigned char clampByte(int value)
{
return static_cast<unsigned char>((value < 0) ? 0 : ((value > 255) ? 255 : value)); return static_cast<unsigned char>((value < 0) ? 0 : ((value > 255) ? 255 : value));
} }
inline signed char clampSByte(int value) inline signed char clampSByte(int value)
{ {
return static_cast<signed char>((value < -128) ? -128 : ((value > 127) ? 127 : value)); return static_cast<signed char>((value < -128) ? -128 : ((value > 127) ? 127 : value));
} }
inline short clampEAC(int 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 static_cast<short>(((value < min) ? min : ((value > max) ? max : value)) << 5); return static_cast<short>(((value < min) ? min : ((value > max) ? max : value)) << 5);
} }
struct bgra8 struct bgra8
{ {
unsigned char b; unsigned char b;
unsigned char g; unsigned char g;
unsigned char r; unsigned char r;
...@@ -59,43 +58,43 @@ namespace ...@@ -59,43 +58,43 @@ namespace
a = clampByte(alpha); a = clampByte(alpha);
} }
const bgra8& addA(unsigned char alpha) const bgra8 &addA(unsigned char alpha)
{ {
a = alpha; a = alpha;
return *this; return *this;
} }
}; };
inline int extend_4to8bits(int x) inline int extend_4to8bits(int x)
{ {
return (x << 4) | x; return (x << 4) | x;
} }
inline int extend_5to8bits(int x) inline int extend_5to8bits(int x)
{ {
return (x << 3) | (x >> 2); return (x << 3) | (x >> 2);
} }
inline int extend_6to8bits(int x) inline int extend_6to8bits(int x)
{ {
return (x << 2) | (x >> 4); return (x << 2) | (x >> 4);
} }
inline int extend_7to8bits(int x) inline int extend_7to8bits(int x)
{ {
return (x << 1) | (x >> 6); return (x << 1) | (x >> 6);
} }
struct ETC2 struct ETC2
{ {
// Decodes unsigned single or dual channel block to bytes // Decodes unsigned single or dual channel block to bytes
static void DecodeBlock(const ETC2** sources, unsigned char *dest, int nbChannels, int x, int y, int w, int h, int pitch, bool isSigned, bool isEAC) static void DecodeBlock(const ETC2 **sources, unsigned char *dest, int nbChannels, int x, int y, int w, int h, int pitch, bool isSigned, bool isEAC)
{ {
if(isEAC) if(isEAC)
{ {
for(int j = 0; j < 4 && (y + j) < h; j++) for(int j = 0; j < 4 && (y + j) < h; j++)
{ {
short* sDst = reinterpret_cast<short*>(dest); short *sDst = reinterpret_cast<short *>(dest);
for(int i = 0; i < 4 && (x + i) < w; i++) for(int i = 0; i < 4 && (x + i) < w; i++)
{ {
for(int c = nbChannels - 1; c >= 0; c--) for(int c = nbChannels - 1; c >= 0; c--)
...@@ -110,7 +109,7 @@ namespace ...@@ -110,7 +109,7 @@ namespace
{ {
if(isSigned) if(isSigned)
{ {
signed char* sDst = reinterpret_cast<signed char*>(dest); signed char *sDst = reinterpret_cast<signed char *>(dest);
for(int j = 0; j < 4 && (y + j) < h; j++) for(int j = 0; j < 4 && (y + j) < h; j++)
{ {
for(int i = 0; i < 4 && (x + i) < w; i++) for(int i = 0; i < 4 && (x + i) < w; i++)
...@@ -175,7 +174,7 @@ namespace ...@@ -175,7 +174,7 @@ namespace
} }
} }
private: private:
struct struct
{ {
union union
...@@ -386,8 +385,7 @@ namespace ...@@ -386,8 +385,7 @@ namespace
void decodeIndividualOrDifferentialBlock(unsigned char *dest, int x, int y, int w, int h, int pitch, int r1, int g1, int b1, int r2, int g2, int b2, unsigned char alphaValues[4][4], bool nonOpaquePunchThroughAlpha) const void decodeIndividualOrDifferentialBlock(unsigned char *dest, int x, int y, int w, int h, int pitch, int r1, int g1, int b1, int r2, int g2, int b2, unsigned char alphaValues[4][4], bool nonOpaquePunchThroughAlpha) const
{ {
// Table 3.17.2 sorted according to table 3.17.3 // Table 3.17.2 sorted according to table 3.17.3
static const int intensityModifierDefault[8][4] = static const int intensityModifierDefault[8][4] = {
{
{ 2, 8, -2, -8 }, { 2, 8, -2, -8 },
{ 5, 17, -5, -17 }, { 5, 17, -5, -17 },
{ 9, 29, -9, -29 }, { 9, 29, -9, -29 },
...@@ -399,8 +397,7 @@ namespace ...@@ -399,8 +397,7 @@ namespace
}; };
// Table C.12, intensity modifier for non opaque punchthrough alpha // Table C.12, intensity modifier for non opaque punchthrough alpha
static const int intensityModifierNonOpaque[8][4] = static const int intensityModifierNonOpaque[8][4] = {
{
{ 0, 8, 0, -8 }, { 0, 8, 0, -8 },
{ 0, 17, 0, -17 }, { 0, 17, 0, -17 },
{ 0, 29, 0, -29 }, { 0, 29, 0, -29 },
...@@ -436,13 +433,13 @@ namespace ...@@ -436,13 +433,13 @@ namespace
subblockColors1[2].set(r2 + i22, g2 + i22, b2 + i22); subblockColors1[2].set(r2 + i22, g2 + i22, b2 + i22);
subblockColors1[3].set(r2 + i23, g2 + i23, b2 + i23); subblockColors1[3].set(r2 + i23, g2 + i23, b2 + i23);
unsigned char* destStart = dest; unsigned char *destStart = dest;
if(flipbit) if(flipbit)
{ {
for(int j = 0; j < 2 && (y + j) < h; j++) for(int j = 0; j < 2 && (y + j) < h; j++)
{ {
bgra8* color = (bgra8*)dest; bgra8 *color = (bgra8 *)dest;
if((x + 0) < w) color[0] = subblockColors0[getIndex(0, j)].addA(alphaValues[j][0]); if((x + 0) < w) color[0] = subblockColors0[getIndex(0, j)].addA(alphaValues[j][0]);
if((x + 1) < w) color[1] = subblockColors0[getIndex(1, j)].addA(alphaValues[j][1]); if((x + 1) < w) color[1] = subblockColors0[getIndex(1, j)].addA(alphaValues[j][1]);
if((x + 2) < w) color[2] = subblockColors0[getIndex(2, j)].addA(alphaValues[j][2]); if((x + 2) < w) color[2] = subblockColors0[getIndex(2, j)].addA(alphaValues[j][2]);
...@@ -452,7 +449,7 @@ namespace ...@@ -452,7 +449,7 @@ namespace
for(int j = 2; j < 4 && (y + j) < h; j++) for(int j = 2; j < 4 && (y + j) < h; j++)
{ {
bgra8* color = (bgra8*)dest; bgra8 *color = (bgra8 *)dest;
if((x + 0) < w) color[0] = subblockColors1[getIndex(0, j)].addA(alphaValues[j][0]); if((x + 0) < w) color[0] = subblockColors1[getIndex(0, j)].addA(alphaValues[j][0]);
if((x + 1) < w) color[1] = subblockColors1[getIndex(1, j)].addA(alphaValues[j][1]); if((x + 1) < w) color[1] = subblockColors1[getIndex(1, j)].addA(alphaValues[j][1]);
if((x + 2) < w) color[2] = subblockColors1[getIndex(2, j)].addA(alphaValues[j][2]); if((x + 2) < w) color[2] = subblockColors1[getIndex(2, j)].addA(alphaValues[j][2]);
...@@ -464,7 +461,7 @@ namespace ...@@ -464,7 +461,7 @@ namespace
{ {
for(int j = 0; j < 4 && (y + j) < h; j++) for(int j = 0; j < 4 && (y + j) < h; j++)
{ {
bgra8* color = (bgra8*)dest; bgra8 *color = (bgra8 *)dest;
if((x + 0) < w) color[0] = subblockColors0[getIndex(0, j)].addA(alphaValues[j][0]); if((x + 0) < w) color[0] = subblockColors0[getIndex(0, j)].addA(alphaValues[j][0]);
if((x + 1) < w) color[1] = subblockColors0[getIndex(1, j)].addA(alphaValues[j][1]); if((x + 1) < w) color[1] = subblockColors0[getIndex(1, j)].addA(alphaValues[j][1]);
if((x + 2) < w) color[2] = subblockColors1[getIndex(2, j)].addA(alphaValues[j][2]); if((x + 2) < w) color[2] = subblockColors1[getIndex(2, j)].addA(alphaValues[j][2]);
...@@ -501,11 +498,11 @@ namespace ...@@ -501,11 +498,11 @@ namespace
paintColors[2].set(r2, g2, b2); paintColors[2].set(r2, g2, b2);
paintColors[3].set(r2 - d, g2 - d, b2 - d); paintColors[3].set(r2 - d, g2 - d, b2 - d);
unsigned char* destStart = dest; unsigned char *destStart = dest;
for(int j = 0; j < 4 && (y + j) < h; j++) for(int j = 0; j < 4 && (y + j) < h; j++)
{ {
bgra8* color = (bgra8*)dest; bgra8 *color = (bgra8 *)dest;
if((x + 0) < w) color[0] = paintColors[getIndex(0, j)].addA(alphaValues[j][0]); if((x + 0) < w) color[0] = paintColors[getIndex(0, j)].addA(alphaValues[j][0]);
if((x + 1) < w) color[1] = paintColors[getIndex(1, j)].addA(alphaValues[j][1]); if((x + 1) < w) color[1] = paintColors[getIndex(1, j)].addA(alphaValues[j][1]);
if((x + 2) < w) color[2] = paintColors[getIndex(2, j)].addA(alphaValues[j][2]); if((x + 2) < w) color[2] = paintColors[getIndex(2, j)].addA(alphaValues[j][2]);
...@@ -541,11 +538,11 @@ namespace ...@@ -541,11 +538,11 @@ namespace
paintColors[2].set(r2 + d, g2 + d, b2 + d); paintColors[2].set(r2 + d, g2 + d, b2 + d);
paintColors[3].set(r2 - d, g2 - d, b2 - d); paintColors[3].set(r2 - d, g2 - d, b2 - d);
unsigned char* destStart = dest; unsigned char *destStart = dest;
for(int j = 0; j < 4 && (y + j) < h; j++) for(int j = 0; j < 4 && (y + j) < h; j++)
{ {
bgra8* color = (bgra8*)dest; bgra8 *color = (bgra8 *)dest;
if((x + 0) < w) color[0] = paintColors[getIndex(0, j)].addA(alphaValues[j][0]); if((x + 0) < w) color[0] = paintColors[getIndex(0, j)].addA(alphaValues[j][0]);
if((x + 1) < w) color[1] = paintColors[getIndex(1, j)].addA(alphaValues[j][1]); if((x + 1) < w) color[1] = paintColors[getIndex(1, j)].addA(alphaValues[j][1]);
if((x + 2) < w) color[2] = paintColors[getIndex(2, j)].addA(alphaValues[j][2]); if((x + 2) < w) color[2] = paintColors[getIndex(2, j)].addA(alphaValues[j][2]);
...@@ -580,7 +577,7 @@ namespace ...@@ -580,7 +577,7 @@ namespace
int by = j * (bv - bo) + 2; int by = j * (bv - bo) + 2;
for(int i = 0; i < 4 && (x + i) < w; i++) for(int i = 0; i < 4 && (x + i) < w; i++)
{ {
((bgra8*)(dest))[i].set(((i * (rh - ro) + ry) >> 2) + ro, ((bgra8 *)(dest))[i].set(((i * (rh - ro) + ry) >> 2) + ro,
((i * (gh - go) + gy) >> 2) + go, ((i * (gh - go) + gy) >> 2) + go,
((i * (bh - bo) + by) >> 2) + bo, ((i * (bh - bo) + by) >> 2) + bo,
alphaValues[j][i]); alphaValues[j][i]);
...@@ -608,7 +605,7 @@ namespace ...@@ -608,7 +605,7 @@ namespace
{ {
if(getIndex(i, j) == 2) // msb == 1 && lsb == 0 if(getIndex(i, j) == 2) // msb == 1 && lsb == 0
{ {
((bgra8*)dest)[i].set(0, 0, 0, 0); ((bgra8 *)dest)[i].set(0, 0, 0, 0);
} }
} }
dest += pitch; dest += pitch;
...@@ -619,11 +616,7 @@ namespace ...@@ -619,11 +616,7 @@ namespace
inline int getSingleChannel(int x, int y, bool isSigned, bool isEAC) const inline int getSingleChannel(int x, int y, bool isSigned, bool isEAC) const
{ {
int codeword = isSigned ? signed_base_codeword : base_codeword; int codeword = isSigned ? signed_base_codeword : base_codeword;
return isEAC ? return isEAC ? ((multiplier == 0) ? (codeword * 8 + 4 + getSingleChannelModifier(x, y)) : (codeword * 8 + 4 + getSingleChannelModifier(x, y) * multiplier * 8)) : codeword + getSingleChannelModifier(x, y) * multiplier;
((multiplier == 0) ?
(codeword * 8 + 4 + getSingleChannelModifier(x, y)) :
(codeword * 8 + 4 + getSingleChannelModifier(x, y) * multiplier * 8)) :
codeword + getSingleChannelModifier(x, y) * multiplier;
} }
inline int getSingleChannelIndex(int x, int y) const inline int getSingleChannelIndex(int x, int y) const
...@@ -670,14 +663,14 @@ namespace ...@@ -670,14 +663,14 @@ namespace
return modifierTable[table_index][getSingleChannelIndex(x, y)]; return modifierTable[table_index][getSingleChannelIndex(x, y)];
} }
}; };
} } // namespace
// Decodes 1 to 4 channel images to 8 bit output // Decodes 1 to 4 channel images to 8 bit output
bool ETC_Decoder::Decode(const unsigned char* src, unsigned char *dst, int w, int h, int dstW, int dstH, int dstPitch, int dstBpp, InputType inputType) bool ETC_Decoder::Decode(const unsigned char *src, unsigned char *dst, int w, int h, int dstW, int dstH, int dstPitch, int dstBpp, InputType inputType)
{ {
const ETC2* sources[2]; const ETC2 *sources[2];
sources[0] = (const ETC2*)src; sources[0] = (const ETC2 *)src;
unsigned char alphaValues[4][4] = { { 255, 255, 255, 255 }, { 255, 255, 255, 255 }, { 255, 255, 255, 255 }, { 255, 255, 255, 255 } }; unsigned char alphaValues[4][4] = { { 255, 255, 255, 255 }, { 255, 255, 255, 255 }, { 255, 255, 255, 255 }, { 255, 255, 255, 255 } };
......
...@@ -37,5 +37,5 @@ public: ...@@ -37,5 +37,5 @@ public:
/// @param dstBpp dst image bytes per pixel /// @param dstBpp dst image bytes per pixel
/// @param inputType src's format /// @param inputType src's format
/// @return true if the decoding was performed /// @return true if the decoding was performed
static bool Decode(const unsigned char* src, unsigned char *dst, int w, int h, int dstW, int dstH, int dstPitch, int dstBpp, InputType inputType); static bool Decode(const unsigned char *src, unsigned char *dst, int w, int h, int dstW, int dstH, int dstPitch, int dstBpp, InputType inputType);
}; };
...@@ -33,8 +33,8 @@ public: ...@@ -33,8 +33,8 @@ public:
Data query(const Key &key) const; Data query(const Key &key) const;
virtual Data add(const Key &key, const Data &data); virtual Data add(const Key &key, const Data &data);
int getSize() {return size;} int getSize() { return size; }
Key &getKey(int i) {return key[i];} Key &getKey(int i) { return key[i]; }
protected: protected:
int size; int size;
...@@ -51,18 +51,21 @@ template<class Key, class Data, class Hasher = std::hash<Key>> ...@@ -51,18 +51,21 @@ template<class Key, class Data, class Hasher = std::hash<Key>>
class LRUConstCache : public LRUCache<Key, Data> class LRUConstCache : public LRUCache<Key, Data>
{ {
using LRUBase = LRUCache<Key, Data>; using LRUBase = LRUCache<Key, Data>;
public: public:
LRUConstCache(int n) : LRUBase(n) {} LRUConstCache(int n)
: LRUBase(n)
{}
~LRUConstCache() { clearConstCache(); } ~LRUConstCache() { clearConstCache(); }
Data add(const Key &key, const Data& data) override Data add(const Key &key, const Data &data) override
{ {
constCacheNeedsUpdate = true; constCacheNeedsUpdate = true;
return LRUBase::add(key, data); return LRUBase::add(key, data);
} }
void updateConstCache(); void updateConstCache();
const Data& queryConstCache(const Key &key) const; const Data &queryConstCache(const Key &key) const;
private: private:
void clearConstCache(); void clearConstCache();
...@@ -75,15 +78,15 @@ private: ...@@ -75,15 +78,15 @@ private:
template<typename T> template<typename T>
struct is_memcmparable struct is_memcmparable
{ {
// std::is_trivially_copyable is not available in older GCC versions. // std::is_trivially_copyable is not available in older GCC versions.
#if !defined(__GNUC__) || __GNUC__ > 5 #if !defined(__GNUC__) || __GNUC__ > 5
static const bool value = std::is_trivially_copyable<T>::value; static const bool value = std::is_trivially_copyable<T>::value;
#else #else
// At least check it doesn't have virtual methods. // At least check it doesn't have virtual methods.
static const bool value = !std::is_polymorphic<T>::value; static const bool value = !std::is_polymorphic<T>::value;
#endif #endif
}; };
} } // namespace sw
namespace sw { namespace sw {
...@@ -96,7 +99,7 @@ LRUCache<Key, Data>::LRUCache(int n) ...@@ -96,7 +99,7 @@ LRUCache<Key, Data>::LRUCache(int n)
fill = 0; fill = 0;
key = new Key[size]; key = new Key[size];
ref = new Key*[size]; ref = new Key *[size];
data = new Data[size]; data = new Data[size];
for(int i = 0; i < size; i++) for(int i = 0; i < size; i++)
...@@ -188,7 +191,7 @@ void LRUConstCache<Key, Data, Hasher>::updateConstCache() ...@@ -188,7 +191,7 @@ void LRUConstCache<Key, Data, Hasher>::updateConstCache()
} }
template<class Key, class Data, class Hasher> template<class Key, class Data, class Hasher>
const Data& LRUConstCache<Key, Data, Hasher>::queryConstCache(const Key &key) const const Data &LRUConstCache<Key, Data, Hasher>::queryConstCache(const Key &key) const
{ {
auto it = constCache.find(key); auto it = constCache.find(key);
static Data null = {}; static Data null = {};
......
...@@ -27,7 +27,7 @@ Matrix Matrix::diag(float m11, float m22, float m33, float m44) ...@@ -27,7 +27,7 @@ Matrix Matrix::diag(float m11, float m22, float m33, float m44)
0, 0, 0, m44); 0, 0, 0, m44);
} }
Matrix::operator float*() Matrix::operator float *()
{ {
return &(*this)(1, 1); return &(*this)(1, 1);
} }
...@@ -115,10 +115,22 @@ Matrix &Matrix::operator+=(const Matrix &N) ...@@ -115,10 +115,22 @@ Matrix &Matrix::operator+=(const Matrix &N)
{ {
Matrix &M = *this; Matrix &M = *this;
M(1, 1) += N(1, 1); M(1, 2) += N(1, 2); M(1, 3) += N(1, 3); M(1, 4) += N(1, 4); M(1, 1) += N(1, 1);
M(2, 1) += N(2, 1); M(2, 2) += N(2, 2); M(2, 3) += N(2, 3); M(2, 4) += N(2, 4); M(1, 2) += N(1, 2);
M(3, 1) += N(3, 1); M(3, 2) += N(3, 2); M(3, 3) += N(3, 3); M(3, 4) += N(3, 4); M(1, 3) += N(1, 3);
M(4, 1) += N(4, 1); M(4, 2) += N(4, 2); M(4, 3) += N(4, 3); M(4, 4) += N(4, 4); M(1, 4) += N(1, 4);
M(2, 1) += N(2, 1);
M(2, 2) += N(2, 2);
M(2, 3) += N(2, 3);
M(2, 4) += N(2, 4);
M(3, 1) += N(3, 1);
M(3, 2) += N(3, 2);
M(3, 3) += N(3, 3);
M(3, 4) += N(3, 4);
M(4, 1) += N(4, 1);
M(4, 2) += N(4, 2);
M(4, 3) += N(4, 3);
M(4, 4) += N(4, 4);
return M; return M;
} }
...@@ -127,10 +139,22 @@ Matrix &Matrix::operator-=(const Matrix &N) ...@@ -127,10 +139,22 @@ Matrix &Matrix::operator-=(const Matrix &N)
{ {
Matrix &M = *this; Matrix &M = *this;
M(1, 1) -= N(1, 1); M(1, 2) -= N(1, 2); M(1, 3) -= N(1, 3); M(1, 4) -= N(1, 4); M(1, 1) -= N(1, 1);
M(2, 1) -= N(2, 1); M(2, 2) -= N(2, 2); M(2, 3) -= N(2, 3); M(2, 4) -= N(2, 4); M(1, 2) -= N(1, 2);
M(3, 1) -= N(3, 1); M(3, 2) -= N(3, 2); M(3, 3) -= N(3, 3); M(3, 4) -= N(3, 4); M(1, 3) -= N(1, 3);
M(4, 1) -= N(4, 1); M(4, 2) -= N(4, 2); M(4, 3) -= N(4, 3); M(4, 4) -= N(4, 4); M(1, 4) -= N(1, 4);
M(2, 1) -= N(2, 1);
M(2, 2) -= N(2, 2);
M(2, 3) -= N(2, 3);
M(2, 4) -= N(2, 4);
M(3, 1) -= N(3, 1);
M(3, 2) -= N(3, 2);
M(3, 3) -= N(3, 3);
M(3, 4) -= N(3, 4);
M(4, 1) -= N(4, 1);
M(4, 2) -= N(4, 2);
M(4, 3) -= N(4, 3);
M(4, 4) -= N(4, 4);
return M; return M;
} }
...@@ -139,10 +163,22 @@ Matrix &Matrix::operator*=(float s) ...@@ -139,10 +163,22 @@ Matrix &Matrix::operator*=(float s)
{ {
Matrix &M = *this; Matrix &M = *this;
M(1, 1) *= s; M(1, 2) *= s; M(1, 3) *= s; M(1, 4) *= s; M(1, 1) *= s;
M(2, 1) *= s; M(2, 2) *= s; M(2, 3) *= s; M(2, 4) *= s; M(1, 2) *= s;
M(3, 1) *= s; M(3, 2) *= s; M(3, 3) *= s; M(3, 4) *= s; M(1, 3) *= s;
M(4, 1) *= s; M(4, 2) *= s; M(4, 3) *= s; M(4, 4) *= s; M(1, 4) *= s;
M(2, 1) *= s;
M(2, 2) *= s;
M(2, 3) *= s;
M(2, 4) *= s;
M(3, 1) *= s;
M(3, 2) *= s;
M(3, 3) *= s;
M(3, 4) *= s;
M(4, 1) *= s;
M(4, 2) *= s;
M(4, 3) *= s;
M(4, 4) *= s;
return M; return M;
} }
...@@ -236,7 +272,7 @@ float4 Matrix::operator*(const float4 &v) const ...@@ -236,7 +272,7 @@ float4 Matrix::operator*(const float4 &v) const
float Mz = M(3, 1) * v.x + M(3, 2) * v.y + M(3, 3) * v.z + M(3, 4) * v.w; float Mz = M(3, 1) * v.x + M(3, 2) * v.y + M(3, 3) * v.z + M(3, 4) * v.w;
float Mw = M(4, 1) * v.x + M(4, 2) * v.y + M(4, 3) * v.z + M(4, 4) * v.w; float Mw = M(4, 1) * v.x + M(4, 2) * v.y + M(4, 3) * v.z + M(4, 4) * v.w;
return {Mx, My, Mz, Mw}; return { Mx, My, Mz, Mw };
} }
float Matrix::det(const Matrix &M) float Matrix::det(const Matrix &M)
...@@ -327,9 +363,15 @@ Matrix &Matrix::orthogonalise() ...@@ -327,9 +363,15 @@ Matrix &Matrix::orthogonalise()
v2 /= Vector::N(v2); v2 /= Vector::N(v2);
v3 /= Vector::N(v3); v3 /= Vector::N(v3);
M(1, 1) = v1.x; M(1, 2) = v2.x; M(1, 3) = v3.x; M(1, 1) = v1.x;
M(2, 1) = v1.y; M(2, 2) = v2.y; M(2, 3) = v3.y; M(1, 2) = v2.x;
M(3, 1) = v1.z; M(3, 2) = v2.z; M(3, 3) = v3.z; M(1, 3) = v3.x;
M(2, 1) = v1.y;
M(2, 2) = v2.y;
M(2, 3) = v3.y;
M(3, 1) = v1.z;
M(3, 2) = v2.z;
M(3, 3) = v3.z;
return *this; return *this;
} }
......
...@@ -44,7 +44,7 @@ struct Matrix ...@@ -44,7 +44,7 @@ struct Matrix
static Matrix diag(float m11, float m22, float m33, float m44); static Matrix diag(float m11, float m22, float m33, float m44);
operator float*(); operator float *();
Matrix operator+() const; Matrix operator+() const;
Matrix operator-() const; Matrix operator-() const;
...@@ -105,7 +105,7 @@ struct Matrix ...@@ -105,7 +105,7 @@ struct Matrix
static Matrix lookAt(const Vector &v); static Matrix lookAt(const Vector &v);
static Matrix lookAt(float x, float y, float z); static Matrix lookAt(float x, float y, float z);
}; };
} } // namespace sw
#include "Vector.hpp" #include "Vector.hpp"
...@@ -121,30 +121,66 @@ inline Matrix::Matrix(const int i) ...@@ -121,30 +121,66 @@ inline Matrix::Matrix(const int i)
Matrix &M = *this; Matrix &M = *this;
M(1, 1) = s; M(1, 2) = 0; M(1, 3) = 0; M(1, 4) = 0; M(1, 1) = s;
M(2, 1) = 0; M(2, 2) = s; M(2, 3) = 0; M(2, 4) = 0; M(1, 2) = 0;
M(3, 1) = 0; M(3, 2) = 0; M(3, 3) = s; M(3, 4) = 0; M(1, 3) = 0;
M(4, 1) = 0; M(4, 2) = 0; M(4, 3) = 0; M(4, 4) = s; M(1, 4) = 0;
M(2, 1) = 0;
M(2, 2) = s;
M(2, 3) = 0;
M(2, 4) = 0;
M(3, 1) = 0;
M(3, 2) = 0;
M(3, 3) = s;
M(3, 4) = 0;
M(4, 1) = 0;
M(4, 2) = 0;
M(4, 3) = 0;
M(4, 4) = s;
} }
inline Matrix::Matrix(const float m[16]) inline Matrix::Matrix(const float m[16])
{ {
Matrix &M = *this; Matrix &M = *this;
M(1, 1) = m[0]; M(1, 2) = m[1]; M(1, 3) = m[2]; M(1, 4) = m[3]; M(1, 1) = m[0];
M(2, 1) = m[4]; M(2, 2) = m[5]; M(2, 3) = m[6]; M(2, 4) = m[7]; M(1, 2) = m[1];
M(3, 1) = m[8]; M(3, 2) = m[8]; M(3, 3) = m[10]; M(3, 4) = m[11]; M(1, 3) = m[2];
M(4, 1) = m[12]; M(4, 2) = m[13]; M(4, 3) = m[14]; M(4, 4) = m[15]; M(1, 4) = m[3];
M(2, 1) = m[4];
M(2, 2) = m[5];
M(2, 3) = m[6];
M(2, 4) = m[7];
M(3, 1) = m[8];
M(3, 2) = m[8];
M(3, 3) = m[10];
M(3, 4) = m[11];
M(4, 1) = m[12];
M(4, 2) = m[13];
M(4, 3) = m[14];
M(4, 4) = m[15];
} }
inline Matrix::Matrix(const float m[4][4]) inline Matrix::Matrix(const float m[4][4])
{ {
Matrix &M = *this; Matrix &M = *this;
M[0][0] = m[0][0]; M[0][1] = m[0][1]; M[0][2] = m[0][2]; M[0][3] = m[0][3]; M[0][0] = m[0][0];
M[1][0] = m[1][0]; M[1][1] = m[1][1]; M[1][2] = m[1][2]; M[1][3] = m[1][3]; M[0][1] = m[0][1];
M[2][0] = m[2][0]; M[2][1] = m[2][1]; M[2][2] = m[2][2]; M[2][3] = m[2][3]; M[0][2] = m[0][2];
M[3][0] = m[3][0]; M[3][1] = m[3][1]; M[3][2] = m[3][2]; M[3][3] = m[3][3]; M[0][3] = m[0][3];
M[1][0] = m[1][0];
M[1][1] = m[1][1];
M[1][2] = m[1][2];
M[1][3] = m[1][3];
M[2][0] = m[2][0];
M[2][1] = m[2][1];
M[2][2] = m[2][2];
M[2][3] = m[2][3];
M[3][0] = m[3][0];
M[3][1] = m[3][1];
M[3][2] = m[3][2];
M[3][3] = m[3][3];
} }
inline Matrix::Matrix(float m11, float m12, float m13, inline Matrix::Matrix(float m11, float m12, float m13,
...@@ -153,10 +189,22 @@ inline Matrix::Matrix(float m11, float m12, float m13, ...@@ -153,10 +189,22 @@ inline Matrix::Matrix(float m11, float m12, float m13,
{ {
Matrix &M = *this; Matrix &M = *this;
M(1, 1) = m11; M(1, 2) = m12; M(1, 3) = m13; M(1, 4) = 0; M(1, 1) = m11;
M(2, 1) = m21; M(2, 2) = m22; M(2, 3) = m23; M(2, 4) = 0; M(1, 2) = m12;
M(3, 1) = m31; M(3, 2) = m32; M(3, 3) = m33; M(3, 4) = 0; M(1, 3) = m13;
M(4, 1) = 0; M(4, 2) = 0; M(4, 3) = 0; M(4, 4) = 1; M(1, 4) = 0;
M(2, 1) = m21;
M(2, 2) = m22;
M(2, 3) = m23;
M(2, 4) = 0;
M(3, 1) = m31;
M(3, 2) = m32;
M(3, 3) = m33;
M(3, 4) = 0;
M(4, 1) = 0;
M(4, 2) = 0;
M(4, 3) = 0;
M(4, 4) = 1;
} }
inline Matrix::Matrix(float m11, float m12, float m13, float m14, inline Matrix::Matrix(float m11, float m12, float m13, float m14,
...@@ -166,30 +214,66 @@ inline Matrix::Matrix(float m11, float m12, float m13, float m14, ...@@ -166,30 +214,66 @@ inline Matrix::Matrix(float m11, float m12, float m13, float m14,
{ {
Matrix &M = *this; Matrix &M = *this;
M(1, 1) = m11; M(1, 2) = m12; M(1, 3) = m13; M(1, 4) = m14; M(1, 1) = m11;
M(2, 1) = m21; M(2, 2) = m22; M(2, 3) = m23; M(2, 4) = m24; M(1, 2) = m12;
M(3, 1) = m31; M(3, 2) = m32; M(3, 3) = m33; M(3, 4) = m34; M(1, 3) = m13;
M(4, 1) = m41; M(4, 2) = m42; M(4, 3) = m43; M(4, 4) = m44; M(1, 4) = m14;
M(2, 1) = m21;
M(2, 2) = m22;
M(2, 3) = m23;
M(2, 4) = m24;
M(3, 1) = m31;
M(3, 2) = m32;
M(3, 3) = m33;
M(3, 4) = m34;
M(4, 1) = m41;
M(4, 2) = m42;
M(4, 3) = m43;
M(4, 4) = m44;
} }
inline Matrix::Matrix(const Vector &v1, const Vector &v2, const Vector &v3) inline Matrix::Matrix(const Vector &v1, const Vector &v2, const Vector &v3)
{ {
Matrix &M = *this; Matrix &M = *this;
M(1, 1) = v1.x; M(1, 2) = v2.x; M(1, 3) = v3.x; M(1, 4) = 0; M(1, 1) = v1.x;
M(2, 1) = v1.y; M(2, 2) = v2.y; M(2, 3) = v3.y; M(2, 4) = 0; M(1, 2) = v2.x;
M(3, 1) = v1.z; M(3, 2) = v2.z; M(3, 3) = v3.z; M(3, 4) = 0; M(1, 3) = v3.x;
M(4, 1) = 0; M(4, 2) = 0; M(4, 3) = 0; M(4, 4) = 1; M(1, 4) = 0;
M(2, 1) = v1.y;
M(2, 2) = v2.y;
M(2, 3) = v3.y;
M(2, 4) = 0;
M(3, 1) = v1.z;
M(3, 2) = v2.z;
M(3, 3) = v3.z;
M(3, 4) = 0;
M(4, 1) = 0;
M(4, 2) = 0;
M(4, 3) = 0;
M(4, 4) = 1;
} }
inline Matrix &Matrix::operator=(const Matrix &N) inline Matrix &Matrix::operator=(const Matrix &N)
{ {
Matrix &M = *this; Matrix &M = *this;
M(1, 1) = N(1, 1); M(1, 2) = N(1, 2); M(1, 3) = N(1, 3); M(1, 4) = N(1, 4); M(1, 1) = N(1, 1);
M(2, 1) = N(2, 1); M(2, 2) = N(2, 2); M(2, 3) = N(2, 3); M(2, 4) = N(2, 4); M(1, 2) = N(1, 2);
M(3, 1) = N(3, 1); M(3, 2) = N(3, 2); M(3, 3) = N(3, 3); M(3, 4) = N(3, 4); M(1, 3) = N(1, 3);
M(4, 1) = N(4, 1); M(4, 2) = N(4, 2); M(4, 3) = N(4, 3); M(4, 4) = N(4, 4); M(1, 4) = N(1, 4);
M(2, 1) = N(2, 1);
M(2, 2) = N(2, 2);
M(2, 3) = N(2, 3);
M(2, 4) = N(2, 4);
M(3, 1) = N(3, 1);
M(3, 2) = N(3, 2);
M(3, 3) = N(3, 3);
M(3, 4) = N(3, 4);
M(4, 1) = N(4, 1);
M(4, 2) = N(4, 2);
M(4, 3) = N(4, 3);
M(4, 4) = N(4, 4);
return M; return M;
} }
......
...@@ -30,20 +30,20 @@ struct Memset ...@@ -30,20 +30,20 @@ struct Memset
{ {
static_assert(std::is_base_of<Memset<T>, T>::value, "Memset<T> must only clear the memory of a type of which it is a base class"); static_assert(std::is_base_of<Memset<T>, T>::value, "Memset<T> must only clear the memory of a type of which it is a base class");
// GCC 8+ warns that // GCC 8+ warns that
// "‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘T’; // "‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘T’;
// use assignment or value-initialization instead [-Werror=class-memaccess]" // use assignment or value-initialization instead [-Werror=class-memaccess]"
// This is benign iff it happens before any of the base or member constructrs are called. // This is benign iff it happens before any of the base or member constructrs are called.
#if defined(__GNUC__) && (__GNUC__ >= 8) #if defined(__GNUC__) && (__GNUC__ >= 8)
#pragma GCC diagnostic push # pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess" # pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif #endif
memset(object, 0, sizeof(T)); memset(object, 0, sizeof(T));
#if defined(__GNUC__) && (__GNUC__ >= 8) #if defined(__GNUC__) && (__GNUC__ >= 8)
#pragma GCC diagnostic pop # pragma GCC diagnostic pop
#endif #endif
} }
}; };
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
#include "PixelProcessor.hpp" #include "PixelProcessor.hpp"
#include "Primitive.hpp" #include "Primitive.hpp"
#include "Pipeline/PixelProgram.hpp"
#include "Pipeline/Constants.hpp" #include "Pipeline/Constants.hpp"
#include "Pipeline/PixelProgram.hpp"
#include "Vulkan/VkDebug.hpp" #include "Vulkan/VkDebug.hpp"
#include "Vulkan/VkImageView.hpp" #include "Vulkan/VkImageView.hpp"
...@@ -26,7 +26,7 @@ namespace sw { ...@@ -26,7 +26,7 @@ namespace sw {
uint32_t PixelProcessor::States::computeHash() uint32_t PixelProcessor::States::computeHash()
{ {
uint32_t *state = reinterpret_cast<uint32_t*>(this); uint32_t *state = reinterpret_cast<uint32_t *>(this);
uint32_t hash = 0; uint32_t hash = 0;
for(unsigned int i = 0; i < sizeof(States) / sizeof(uint32_t); i++) for(unsigned int i = 0; i < sizeof(States) / sizeof(uint32_t); i++)
...@@ -45,7 +45,7 @@ bool PixelProcessor::State::operator==(const State &state) const ...@@ -45,7 +45,7 @@ bool PixelProcessor::State::operator==(const State &state) const
} }
static_assert(is_memcmparable<State>::value, "Cannot memcmp State"); static_assert(is_memcmparable<State>::value, "Cannot memcmp State");
return memcmp(static_cast<const States*>(this), static_cast<const States*>(&state), sizeof(States)) == 0; return memcmp(static_cast<const States *>(this), static_cast<const States *>(&state), sizeof(States)) == 0;
} }
PixelProcessor::PixelProcessor() PixelProcessor::PixelProcessor()
...@@ -90,7 +90,7 @@ void PixelProcessor::setRoutineCacheSize(int cacheSize) ...@@ -90,7 +90,7 @@ void PixelProcessor::setRoutineCacheSize(int cacheSize)
routineCache = new RoutineCacheType(clamp(cacheSize, 1, 65536)); routineCache = new RoutineCacheType(clamp(cacheSize, 1, 65536));
} }
const PixelProcessor::State PixelProcessor::update(const Context* context) const const PixelProcessor::State PixelProcessor::update(const Context *context) const
{ {
State state; State state;
......
...@@ -28,7 +28,7 @@ struct Texture; ...@@ -28,7 +28,7 @@ struct Texture;
struct DrawData; struct DrawData;
struct Primitive; struct Primitive;
using RasterizerFunction = FunctionT<void(const Primitive* primitive, int count, int cluster, int clusterCount, DrawData* draw)>; using RasterizerFunction = FunctionT<void(const Primitive *primitive, int count, int cluster, int clusterCount, DrawData *draw)>;
class PixelProcessor class PixelProcessor
{ {
...@@ -57,7 +57,9 @@ public: ...@@ -57,7 +57,9 @@ public:
} }
}; };
States() : Memset(this, 0) {} States()
: Memset(this, 0)
{}
uint32_t computeHash(); uint32_t computeHash();
...@@ -150,7 +152,7 @@ public: ...@@ -150,7 +152,7 @@ public:
void setBlendConstant(const Color<float> &blendConstant); void setBlendConstant(const Color<float> &blendConstant);
protected: protected:
const State update(const Context* context) const; const State update(const Context *context) const;
RoutineType routine(const State &state, vk::PipelineLayout const *pipelineLayout, RoutineType routine(const State &state, vk::PipelineLayout const *pipelineLayout,
SpirvShader const *pixelShader, const vk::DescriptorSet::Bindings &descriptorSets); SpirvShader const *pixelShader, const vk::DescriptorSet::Bindings &descriptorSets);
void setRoutineCacheSize(int routineCacheSize); void setRoutineCacheSize(int routineCacheSize);
......
...@@ -56,7 +56,7 @@ struct Point ...@@ -56,7 +56,7 @@ struct Point
friend Vector operator-(const Point &P, const Point &Q); friend Vector operator-(const Point &P, const Point &Q);
friend Point operator*(const Matrix &M, const Point& P); friend Point operator*(const Matrix &M, const Point &P);
friend Point operator*(const Point &P, const Matrix &M); friend Point operator*(const Point &P, const Matrix &M);
friend Point &operator*=(Point &P, const Matrix &M); friend Point &operator*=(Point &P, const Matrix &M);
......
...@@ -22,13 +22,16 @@ ...@@ -22,13 +22,16 @@
namespace sw { namespace sw {
struct Triangle MEMORY_SANITIZER_ONLY(: Memset<Triangle>) struct Triangle MEMORY_SANITIZER_ONLY(
: Memset<Triangle>)
{ {
#if MEMORY_SANITIZER_ENABLED #if MEMORY_SANITIZER_ENABLED
// Memory sanitizer cannot 'see' writes from JIT'd code, and can raise // Memory sanitizer cannot 'see' writes from JIT'd code, and can raise
// false-positives when read. By clearing the struct in the constructor, // false-positives when read. By clearing the struct in the constructor,
// we can avoid triggering these false-positives. // we can avoid triggering these false-positives.
inline Triangle() : Memset<Triangle>(this, 0) {} inline Triangle()
: Memset<Triangle>(this, 0)
{}
#endif // MEMORY_SANITIZER_ENABLED #endif // MEMORY_SANITIZER_ENABLED
Vertex v0; Vertex v0;
...@@ -43,13 +46,16 @@ struct PlaneEquation // z = A * x + B * y + C ...@@ -43,13 +46,16 @@ struct PlaneEquation // z = A * x + B * y + C
float4 C; float4 C;
}; };
struct Primitive MEMORY_SANITIZER_ONLY(: Memset<Primitive>) struct Primitive MEMORY_SANITIZER_ONLY(
: Memset<Primitive>)
{ {
#if MEMORY_SANITIZER_ENABLED #if MEMORY_SANITIZER_ENABLED
// Memory sanitizer cannot 'see' writes from JIT'd code, and can raise // Memory sanitizer cannot 'see' writes from JIT'd code, and can raise
// false-positives when read. By clearing the struct in the constructor, // false-positives when read. By clearing the struct in the constructor,
// we can avoid triggering these false-positives. // we can avoid triggering these false-positives.
inline Primitive() : Memset<Primitive>(this, 0) {} inline Primitive()
: Memset<Primitive>(this, 0)
{}
#endif // MEMORY_SANITIZER_ENABLED #endif // MEMORY_SANITIZER_ENABLED
int yMin; int yMin;
......
...@@ -22,7 +22,9 @@ ...@@ -22,7 +22,9 @@
namespace sw { namespace sw {
QuadRasterizer::QuadRasterizer(const PixelProcessor::State &state, SpirvShader const *spirvShader) : state(state), spirvShader{spirvShader} QuadRasterizer::QuadRasterizer(const PixelProcessor::State &state, SpirvShader const *spirvShader)
: state(state)
, spirvShader{ spirvShader }
{ {
} }
...@@ -32,13 +34,13 @@ QuadRasterizer::~QuadRasterizer() ...@@ -32,13 +34,13 @@ QuadRasterizer::~QuadRasterizer()
void QuadRasterizer::generate() void QuadRasterizer::generate()
{ {
constants = *Pointer<Pointer<Byte>>(data + OFFSET(DrawData,constants)); constants = *Pointer<Pointer<Byte>>(data + OFFSET(DrawData, constants));
occlusion = 0; occlusion = 0;
Do Do
{ {
Int yMin = *Pointer<Int>(primitive + OFFSET(Primitive,yMin)); Int yMin = *Pointer<Int>(primitive + OFFSET(Primitive, yMin));
Int yMax = *Pointer<Int>(primitive + OFFSET(Primitive,yMax)); Int yMax = *Pointer<Int>(primitive + OFFSET(Primitive, yMax));
Int cluster2 = cluster + cluster; Int cluster2 = cluster + cluster;
yMin += clusterCount * 2 - 2 - cluster2; yMin += clusterCount * 2 - 2 - cluster2;
...@@ -57,9 +59,9 @@ void QuadRasterizer::generate() ...@@ -57,9 +59,9 @@ void QuadRasterizer::generate()
if(state.occlusionEnabled) if(state.occlusionEnabled)
{ {
UInt clusterOcclusion = *Pointer<UInt>(data + OFFSET(DrawData,occlusion) + 4 * cluster); UInt clusterOcclusion = *Pointer<UInt>(data + OFFSET(DrawData, occlusion) + 4 * cluster);
clusterOcclusion += occlusion; clusterOcclusion += occlusion;
*Pointer<UInt>(data + OFFSET(DrawData,occlusion) + 4 * cluster) = clusterOcclusion; *Pointer<UInt>(data + OFFSET(DrawData, occlusion) + 4 * cluster) = clusterOcclusion;
} }
Return(); Return();
...@@ -77,49 +79,49 @@ void QuadRasterizer::rasterize(Int &yMin, Int &yMax) ...@@ -77,49 +79,49 @@ void QuadRasterizer::rasterize(Int &yMin, Int &yMax)
{ {
if(state.colorWriteActive(index)) if(state.colorWriteActive(index))
{ {
cBuffer[index] = *Pointer<Pointer<Byte>>(data + OFFSET(DrawData,colorBuffer[index])) + yMin * *Pointer<Int>(data + OFFSET(DrawData,colorPitchB[index])); cBuffer[index] = *Pointer<Pointer<Byte>>(data + OFFSET(DrawData, colorBuffer[index])) + yMin * *Pointer<Int>(data + OFFSET(DrawData, colorPitchB[index]));
} }
} }
if(state.depthTestActive) if(state.depthTestActive)
{ {
zBuffer = *Pointer<Pointer<Byte>>(data + OFFSET(DrawData,depthBuffer)) + yMin * *Pointer<Int>(data + OFFSET(DrawData,depthPitchB)); zBuffer = *Pointer<Pointer<Byte>>(data + OFFSET(DrawData, depthBuffer)) + yMin * *Pointer<Int>(data + OFFSET(DrawData, depthPitchB));
} }
if(state.stencilActive) if(state.stencilActive)
{ {
sBuffer = *Pointer<Pointer<Byte>>(data + OFFSET(DrawData,stencilBuffer)) + yMin * *Pointer<Int>(data + OFFSET(DrawData,stencilPitchB)); sBuffer = *Pointer<Pointer<Byte>>(data + OFFSET(DrawData, stencilBuffer)) + yMin * *Pointer<Int>(data + OFFSET(DrawData, stencilPitchB));
} }
Int y = yMin; Int y = yMin;
Do Do
{ {
Int x0a = Int(*Pointer<Short>(primitive + OFFSET(Primitive,outline->left) + (y + 0) * sizeof(Primitive::Span))); Int x0a = Int(*Pointer<Short>(primitive + OFFSET(Primitive, outline->left) + (y + 0) * sizeof(Primitive::Span)));
Int x0b = Int(*Pointer<Short>(primitive + OFFSET(Primitive,outline->left) + (y + 1) * sizeof(Primitive::Span))); Int x0b = Int(*Pointer<Short>(primitive + OFFSET(Primitive, outline->left) + (y + 1) * sizeof(Primitive::Span)));
Int x0 = Min(x0a, x0b); Int x0 = Min(x0a, x0b);
for(unsigned int q = 1; q < state.multiSample; q++) for(unsigned int q = 1; q < state.multiSample; q++)
{ {
x0a = Int(*Pointer<Short>(primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->left) + (y + 0) * sizeof(Primitive::Span))); x0a = Int(*Pointer<Short>(primitive + q * sizeof(Primitive) + OFFSET(Primitive, outline->left) + (y + 0) * sizeof(Primitive::Span)));
x0b = Int(*Pointer<Short>(primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->left) + (y + 1) * sizeof(Primitive::Span))); x0b = Int(*Pointer<Short>(primitive + q * sizeof(Primitive) + OFFSET(Primitive, outline->left) + (y + 1) * sizeof(Primitive::Span)));
x0 = Min(x0, Min(x0a, x0b)); x0 = Min(x0, Min(x0a, x0b));
} }
x0 &= 0xFFFFFFFE; x0 &= 0xFFFFFFFE;
Int x1a = Int(*Pointer<Short>(primitive + OFFSET(Primitive,outline->right) + (y + 0) * sizeof(Primitive::Span))); Int x1a = Int(*Pointer<Short>(primitive + OFFSET(Primitive, outline->right) + (y + 0) * sizeof(Primitive::Span)));
Int x1b = Int(*Pointer<Short>(primitive + OFFSET(Primitive,outline->right) + (y + 1) * sizeof(Primitive::Span))); Int x1b = Int(*Pointer<Short>(primitive + OFFSET(Primitive, outline->right) + (y + 1) * sizeof(Primitive::Span)));
Int x1 = Max(x1a, x1b); Int x1 = Max(x1a, x1b);
for(unsigned int q = 1; q < state.multiSample; q++) for(unsigned int q = 1; q < state.multiSample; q++)
{ {
x1a = Int(*Pointer<Short>(primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->right) + (y + 0) * sizeof(Primitive::Span))); x1a = Int(*Pointer<Short>(primitive + q * sizeof(Primitive) + OFFSET(Primitive, outline->right) + (y + 0) * sizeof(Primitive::Span)));
x1b = Int(*Pointer<Short>(primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->right) + (y + 1) * sizeof(Primitive::Span))); x1b = Int(*Pointer<Short>(primitive + q * sizeof(Primitive) + OFFSET(Primitive, outline->right) + (y + 1) * sizeof(Primitive::Span)));
x1 = Max(x1, Max(x1a, x1b)); x1 = Max(x1, Max(x1a, x1b));
} }
Float4 yyyy = Float4(Float(y)) + *Pointer<Float4>(primitive + OFFSET(Primitive,yQuad), 16); Float4 yyyy = Float4(Float(y)) + *Pointer<Float4>(primitive + OFFSET(Primitive, yQuad), 16);
if(interpolateZ()) if(interpolateZ())
{ {
...@@ -129,10 +131,10 @@ void QuadRasterizer::rasterize(Int &yMin, Int &yMax) ...@@ -129,10 +131,10 @@ void QuadRasterizer::rasterize(Int &yMin, Int &yMax)
if(state.multiSample > 1) if(state.multiSample > 1)
{ {
y -= *Pointer<Float4>(constants + OFFSET(Constants,Y) + q * sizeof(float4)); y -= *Pointer<Float4>(constants + OFFSET(Constants, Y) + q * sizeof(float4));
} }
Dz[q] = *Pointer<Float4>(primitive + OFFSET(Primitive,z.C), 16) + y * *Pointer<Float4>(primitive + OFFSET(Primitive,z.B), 16); Dz[q] = *Pointer<Float4>(primitive + OFFSET(Primitive, z.C), 16) + y * *Pointer<Float4>(primitive + OFFSET(Primitive, z.B), 16);
} }
} }
...@@ -140,7 +142,7 @@ void QuadRasterizer::rasterize(Int &yMin, Int &yMax) ...@@ -140,7 +142,7 @@ void QuadRasterizer::rasterize(Int &yMin, Int &yMax)
{ {
if(interpolateW()) if(interpolateW())
{ {
Dw = *Pointer<Float4>(primitive + OFFSET(Primitive,w.C), 16) + yyyy * *Pointer<Float4>(primitive + OFFSET(Primitive,w.B), 16); Dw = *Pointer<Float4>(primitive + OFFSET(Primitive, w.C), 16) + yyyy * *Pointer<Float4>(primitive + OFFSET(Primitive, w.B), 16);
} }
if(spirvShader) if(spirvShader)
...@@ -176,7 +178,7 @@ void QuadRasterizer::rasterize(Int &yMin, Int &yMax) ...@@ -176,7 +178,7 @@ void QuadRasterizer::rasterize(Int &yMin, Int &yMax)
for(unsigned int q = 0; q < state.multiSample; q++) for(unsigned int q = 0; q < state.multiSample; q++)
{ {
xLeft[q] = *Pointer<Short4>(primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline) + y * sizeof(Primitive::Span)); xLeft[q] = *Pointer<Short4>(primitive + q * sizeof(Primitive) + OFFSET(Primitive, outline) + y * sizeof(Primitive::Span));
xRight[q] = xLeft[q]; xRight[q] = xLeft[q];
xLeft[q] = Swizzle(xLeft[q], 0x0022) - Short4(1, 2, 1, 2); xLeft[q] = Swizzle(xLeft[q], 0x0022) - Short4(1, 2, 1, 2);
...@@ -190,7 +192,7 @@ void QuadRasterizer::rasterize(Int &yMin, Int &yMax) ...@@ -190,7 +192,7 @@ void QuadRasterizer::rasterize(Int &yMin, Int &yMax)
for(unsigned int q = 0; q < state.multiSample; q++) for(unsigned int q = 0; q < state.multiSample; q++)
{ {
if(state.multiSampleMask & (1<<q)) if(state.multiSampleMask & (1 << q))
{ {
unsigned int i = state.multiSampledBresenham ? 0 : q; unsigned int i = state.multiSampledBresenham ? 0 : q;
Short4 mask = CmpGT(xxxx, xLeft[i]) & CmpGT(xRight[i], xxxx); Short4 mask = CmpGT(xxxx, xLeft[i]) & CmpGT(xRight[i], xxxx);
...@@ -210,18 +212,18 @@ void QuadRasterizer::rasterize(Int &yMin, Int &yMax) ...@@ -210,18 +212,18 @@ void QuadRasterizer::rasterize(Int &yMin, Int &yMax)
{ {
if(state.colorWriteActive(index)) if(state.colorWriteActive(index))
{ {
cBuffer[index] += *Pointer<Int>(data + OFFSET(DrawData,colorPitchB[index])) << (1 + clusterCountLog2); // FIXME: Precompute cBuffer[index] += *Pointer<Int>(data + OFFSET(DrawData, colorPitchB[index])) << (1 + clusterCountLog2); // FIXME: Precompute
} }
} }
if(state.depthTestActive) if(state.depthTestActive)
{ {
zBuffer += *Pointer<Int>(data + OFFSET(DrawData,depthPitchB)) << (1 + clusterCountLog2); // FIXME: Precompute zBuffer += *Pointer<Int>(data + OFFSET(DrawData, depthPitchB)) << (1 + clusterCountLog2); // FIXME: Precompute
} }
if(state.stencilActive) if(state.stencilActive)
{ {
sBuffer += *Pointer<Int>(data + OFFSET(DrawData,stencilPitchB)) << (1 + clusterCountLog2); // FIXME: Precompute sBuffer += *Pointer<Int>(data + OFFSET(DrawData, stencilPitchB)) << (1 + clusterCountLog2); // FIXME: Precompute
} }
y += 2 * clusterCount; y += 2 * clusterCount;
......
...@@ -24,7 +24,13 @@ namespace sw { ...@@ -24,7 +24,13 @@ namespace sw {
class Rasterizer : public RasterizerFunction class Rasterizer : public RasterizerFunction
{ {
public: public:
Rasterizer() : primitive(Arg<0>()), count(Arg<1>()), cluster(Arg<2>()), clusterCount(Arg<3>()), data(Arg<4>()) {} Rasterizer()
: primitive(Arg<0>())
, count(Arg<1>())
, cluster(Arg<2>())
, clusterCount(Arg<3>())
, data(Arg<4>())
{}
virtual ~Rasterizer() {} virtual ~Rasterizer() {}
protected: protected:
......
...@@ -15,17 +15,17 @@ ...@@ -15,17 +15,17 @@
#ifndef sw_Renderer_hpp #ifndef sw_Renderer_hpp
#define sw_Renderer_hpp #define sw_Renderer_hpp
#include "VertexProcessor.hpp" #include "Blitter.hpp"
#include "PixelProcessor.hpp" #include "PixelProcessor.hpp"
#include "SetupProcessor.hpp"
#include "Plane.hpp" #include "Plane.hpp"
#include "Primitive.hpp" #include "Primitive.hpp"
#include "Blitter.hpp" #include "SetupProcessor.hpp"
#include "VertexProcessor.hpp"
#include "Device/Config.hpp" #include "Device/Config.hpp"
#include "Vulkan/VkDescriptorSet.hpp" #include "Vulkan/VkDescriptorSet.hpp"
#include "marl/pool.h"
#include "marl/finally.h" #include "marl/finally.h"
#include "marl/pool.h"
#include "marl/ticket.h" #include "marl/ticket.h"
#include <atomic> #include <atomic>
...@@ -131,15 +131,15 @@ struct DrawCall ...@@ -131,15 +131,15 @@ struct DrawCall
}; };
using Pool = marl::BoundedPool<DrawCall, MaxDrawCount, marl::PoolPolicy::Preserve>; using Pool = marl::BoundedPool<DrawCall, MaxDrawCount, marl::PoolPolicy::Preserve>;
using SetupFunction = int(*)(Triangle *triangles, Primitive *primitives, const DrawCall *drawCall, int count); using SetupFunction = int (*)(Triangle *triangles, Primitive *primitives, const DrawCall *drawCall, int count);
DrawCall(); DrawCall();
~DrawCall(); ~DrawCall();
static void run(const marl::Loan<DrawCall>& draw, marl::Ticket::Queue* tickets, marl::Ticket::Queue clusterQueues[MaxClusterCount]); static void run(const marl::Loan<DrawCall> &draw, marl::Ticket::Queue *tickets, marl::Ticket::Queue clusterQueues[MaxClusterCount]);
static void processVertices(DrawCall* draw, BatchData* batch); static void processVertices(DrawCall *draw, BatchData *batch);
static void processPrimitives(DrawCall* draw, BatchData* batch); static void processPrimitives(DrawCall *draw, BatchData *batch);
static void processPixels(const marl::Loan<DrawCall>& draw, const marl::Loan<BatchData>& batch, const std::shared_ptr<marl::Finally>& finally); static void processPixels(const marl::Loan<DrawCall> &draw, const marl::Loan<BatchData> &batch, const std::shared_ptr<marl::Finally> &finally);
void setup(); void setup();
void teardown(); void teardown();
...@@ -167,7 +167,7 @@ struct DrawCall ...@@ -167,7 +167,7 @@ struct DrawCall
vk::ImageView *stencilBuffer; vk::ImageView *stencilBuffer;
TaskEvents *events; TaskEvents *events;
vk::Query* occlusionQuery; vk::Query *occlusionQuery;
DrawData *data; DrawData *data;
...@@ -180,9 +180,9 @@ struct DrawCall ...@@ -180,9 +180,9 @@ struct DrawCall
VkPrimitiveTopology topology, VkPrimitiveTopology topology,
VkProvokingVertexModeEXT provokingVertexMode); VkProvokingVertexModeEXT provokingVertexMode);
static int setupSolidTriangles(Triangle* triangles, Primitive* primitives, const DrawCall* drawCall, int count); static int setupSolidTriangles(Triangle *triangles, Primitive *primitives, const DrawCall *drawCall, int count);
static int setupWireframeTriangles(Triangle* triangles, Primitive* primitives, const DrawCall* drawCall, int count); static int setupWireframeTriangles(Triangle *triangles, Primitive *primitives, const DrawCall *drawCall, int count);
static int setupPointTriangles(Triangle* triangles, Primitive* primitives, const DrawCall* drawCall, int count); static int setupPointTriangles(Triangle *triangles, Primitive *primitives, const DrawCall *drawCall, int count);
static int setupLines(Triangle *triangles, Primitive *primitives, const DrawCall *drawCall, int count); static int setupLines(Triangle *triangles, Primitive *primitives, const DrawCall *drawCall, int count);
static int setupPoints(Triangle *triangles, Primitive *primitives, const DrawCall *drawCall, int count); static int setupPoints(Triangle *triangles, Primitive *primitives, const DrawCall *drawCall, int count);
...@@ -193,18 +193,18 @@ struct DrawCall ...@@ -193,18 +193,18 @@ struct DrawCall
class alignas(16) Renderer : public VertexProcessor, public PixelProcessor, public SetupProcessor class alignas(16) Renderer : public VertexProcessor, public PixelProcessor, public SetupProcessor
{ {
public: public:
Renderer(vk::Device* device); Renderer(vk::Device *device);
virtual ~Renderer(); virtual ~Renderer();
void* operator new(size_t size); void *operator new(size_t size);
void operator delete(void* mem); void operator delete(void *mem);
bool hasOcclusionQuery() const { return occlusionQuery != nullptr; } bool hasOcclusionQuery() const { return occlusionQuery != nullptr; }
void draw(const sw::Context* context, VkIndexType indexType, unsigned int count, int baseVertex, void draw(const sw::Context *context, VkIndexType indexType, unsigned int count, int baseVertex,
TaskEvents *events, int instanceID, int viewID, void *indexBuffer, const VkExtent3D& framebufferExtent, TaskEvents *events, int instanceID, int viewID, void *indexBuffer, const VkExtent3D &framebufferExtent,
PushConstantStorage const & pushConstants, bool update = true); PushConstantStorage const &pushConstants, bool update = true);
// Viewport & Clipper // Viewport & Clipper
void setViewport(const VkViewport &viewport); void setViewport(const VkViewport &viewport);
...@@ -213,7 +213,7 @@ public: ...@@ -213,7 +213,7 @@ public:
void addQuery(vk::Query *query); void addQuery(vk::Query *query);
void removeQuery(vk::Query *query); void removeQuery(vk::Query *query);
void advanceInstanceAttributes(Stream* inputs); void advanceInstanceAttributes(Stream *inputs);
void synchronize(); void synchronize();
...@@ -224,7 +224,7 @@ private: ...@@ -224,7 +224,7 @@ private:
DrawCall::Pool drawCallPool; DrawCall::Pool drawCallPool;
DrawCall::BatchData::Pool batchDataPool; DrawCall::BatchData::Pool batchDataPool;
std::atomic<int> nextDrawID = {0}; std::atomic<int> nextDrawID = { 0 };
vk::Query *occlusionQuery = nullptr; vk::Query *occlusionQuery = nullptr;
marl::Ticket::Queue drawTickets; marl::Ticket::Queue drawTickets;
...@@ -238,7 +238,7 @@ private: ...@@ -238,7 +238,7 @@ private:
SetupProcessor::RoutineType setupRoutine; SetupProcessor::RoutineType setupRoutine;
PixelProcessor::RoutineType pixelRoutine; PixelProcessor::RoutineType pixelRoutine;
vk::Device* device; vk::Device *device;
}; };
} // namespace sw } // namespace sw
......
...@@ -29,6 +29,6 @@ using RoutineCache = LRUCache<State, std::shared_ptr<Routine>>; ...@@ -29,6 +29,6 @@ using RoutineCache = LRUCache<State, std::shared_ptr<Routine>>;
template<class State, class FunctionType> template<class State, class FunctionType>
using RoutineCacheT = LRUCache<State, RoutineT<FunctionType>>; using RoutineCacheT = LRUCache<State, RoutineT<FunctionType>>;
} } // namespace sw
#endif // sw_RoutineCache_hpp #endif // sw_RoutineCache_hpp
...@@ -20,7 +20,9 @@ ...@@ -20,7 +20,9 @@
#include "System/Types.hpp" #include "System/Types.hpp"
#include "Vulkan/VkFormat.h" #include "Vulkan/VkFormat.h"
namespace vk { class Image; } namespace vk {
class Image;
}
namespace sw { namespace sw {
......
...@@ -14,14 +14,14 @@ ...@@ -14,14 +14,14 @@
#include "SetupProcessor.hpp" #include "SetupProcessor.hpp"
#include "Primitive.hpp"
#include "Polygon.hpp"
#include "Context.hpp" #include "Context.hpp"
#include "Polygon.hpp"
#include "Primitive.hpp"
#include "Renderer.hpp" #include "Renderer.hpp"
#include "Pipeline/SetupRoutine.hpp"
#include "Pipeline/Constants.hpp" #include "Pipeline/Constants.hpp"
#include "Vulkan/VkDebug.hpp" #include "Pipeline/SetupRoutine.hpp"
#include "Pipeline/SpirvShader.hpp" #include "Pipeline/SpirvShader.hpp"
#include "Vulkan/VkDebug.hpp"
#include <cstring> #include <cstring>
...@@ -29,7 +29,7 @@ namespace sw { ...@@ -29,7 +29,7 @@ namespace sw {
uint32_t SetupProcessor::States::computeHash() uint32_t SetupProcessor::States::computeHash()
{ {
uint32_t *state = reinterpret_cast<uint32_t*>(this); uint32_t *state = reinterpret_cast<uint32_t *>(this);
uint32_t hash = 0; uint32_t hash = 0;
for(unsigned int i = 0; i < sizeof(States) / sizeof(uint32_t); i++) for(unsigned int i = 0; i < sizeof(States) / sizeof(uint32_t); i++)
...@@ -48,7 +48,7 @@ bool SetupProcessor::State::operator==(const State &state) const ...@@ -48,7 +48,7 @@ bool SetupProcessor::State::operator==(const State &state) const
} }
static_assert(is_memcmparable<State>::value, "Cannot memcmp States"); static_assert(is_memcmparable<State>::value, "Cannot memcmp States");
return memcmp(static_cast<const States*>(this), static_cast<const States*>(&state), sizeof(States)) == 0; return memcmp(static_cast<const States *>(this), static_cast<const States *>(&state), sizeof(States)) == 0;
} }
SetupProcessor::SetupProcessor() SetupProcessor::SetupProcessor()
...@@ -63,7 +63,7 @@ SetupProcessor::~SetupProcessor() ...@@ -63,7 +63,7 @@ SetupProcessor::~SetupProcessor()
routineCache = nullptr; routineCache = nullptr;
} }
SetupProcessor::State SetupProcessor::update(const sw::Context* context) const SetupProcessor::State SetupProcessor::update(const sw::Context *context) const
{ {
State state; State state;
......
...@@ -15,11 +15,11 @@ ...@@ -15,11 +15,11 @@
#ifndef sw_SetupProcessor_hpp #ifndef sw_SetupProcessor_hpp
#define sw_SetupProcessor_hpp #define sw_SetupProcessor_hpp
#include <Pipeline/SpirvShader.hpp>
#include "Context.hpp" #include "Context.hpp"
#include "Memset.hpp" #include "Memset.hpp"
#include "RoutineCache.hpp" #include "RoutineCache.hpp"
#include "System/Types.hpp" #include "System/Types.hpp"
#include <Pipeline/SpirvShader.hpp>
namespace sw { namespace sw {
...@@ -30,14 +30,16 @@ struct Vertex; ...@@ -30,14 +30,16 @@ struct Vertex;
struct DrawCall; struct DrawCall;
struct DrawData; struct DrawData;
using SetupFunction = FunctionT<int(Primitive* primitive, const Triangle* triangle, const Polygon* polygon, const DrawData* draw)>; using SetupFunction = FunctionT<int(Primitive *primitive, const Triangle *triangle, const Polygon *polygon, const DrawData *draw)>;
class SetupProcessor class SetupProcessor
{ {
public: public:
struct States : Memset<States> struct States : Memset<States>
{ {
States() : Memset(this, 0) {} States()
: Memset(this, 0)
{}
uint32_t computeHash(); uint32_t computeHash();
...@@ -71,7 +73,7 @@ public: ...@@ -71,7 +73,7 @@ public:
~SetupProcessor(); ~SetupProcessor();
protected: protected:
State update(const sw::Context* context) const; State update(const sw::Context *context) const;
RoutineType routine(const State &state); RoutineType routine(const State &state);
void setRoutineCacheSize(int cacheSize); void setRoutineCacheSize(int cacheSize);
......
...@@ -81,7 +81,7 @@ bool operator!=(const Vector &U, const Vector &v) ...@@ -81,7 +81,7 @@ bool operator!=(const Vector &U, const Vector &v)
bool operator>(const Vector &u, const Vector &v) bool operator>(const Vector &u, const Vector &v)
{ {
if((u^2) > (v^2)) if((u ^ 2) > (v ^ 2))
return true; return true;
else else
return false; return false;
...@@ -89,7 +89,7 @@ bool operator>(const Vector &u, const Vector &v) ...@@ -89,7 +89,7 @@ bool operator>(const Vector &u, const Vector &v)
bool operator<(const Vector &u, const Vector &v) bool operator<(const Vector &u, const Vector &v)
{ {
if((u^2) < (v^2)) if((u ^ 2) < (v ^ 2))
return true; return true;
else else
return false; return false;
...@@ -158,12 +158,12 @@ Vector &operator*=(Vector &v, const Matrix &M) ...@@ -158,12 +158,12 @@ Vector &operator*=(Vector &v, const Matrix &M)
float Vector::N(const Vector &v) float Vector::N(const Vector &v)
{ {
return sqrt(v.x*v.x + v.y*v.y + v.z*v.z); return sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
} }
float Vector::N2(const Vector &v) float Vector::N2(const Vector &v)
{ {
return v.x*v.x + v.y*v.y + v.z*v.z; return v.x * v.x + v.y * v.y + v.z * v.z;
} }
Vector lerp(const Vector &u, const Vector &v, float t) Vector lerp(const Vector &u, const Vector &v, float t)
......
...@@ -69,7 +69,7 @@ struct Vector ...@@ -69,7 +69,7 @@ struct Vector
friend float operator^(const Vector &u, const Vector &v); // Angle between vectors friend float operator^(const Vector &u, const Vector &v); // Angle between vectors
friend Vector operator%(const Vector &u, const Vector &v); // Cross product friend Vector operator%(const Vector &u, const Vector &v); // Cross product
friend Vector operator*(const Matrix &M, const Vector& v); friend Vector operator*(const Matrix &M, const Vector &v);
friend Vector operator*(const Vector &v, const Matrix &M); friend Vector operator*(const Vector &v, const Matrix &M);
friend Vector &operator*=(Vector &v, const Matrix &M); friend Vector &operator*=(Vector &v, const Matrix &M);
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
#define Vertex_hpp #define Vertex_hpp
#include "Color.hpp" #include "Color.hpp"
#include "System/Types.hpp"
#include "Device/Config.hpp" #include "Device/Config.hpp"
#include "System/Types.hpp"
namespace sw { namespace sw {
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
#include "VertexProcessor.hpp" #include "VertexProcessor.hpp"
#include "Pipeline/VertexProgram.hpp"
#include "Pipeline/Constants.hpp" #include "Pipeline/Constants.hpp"
#include "Pipeline/VertexProgram.hpp"
#include "System/Math.hpp" #include "System/Math.hpp"
#include "Vulkan/VkDebug.hpp" #include "Vulkan/VkDebug.hpp"
...@@ -33,7 +33,7 @@ void VertexCache::clear() ...@@ -33,7 +33,7 @@ void VertexCache::clear()
uint32_t VertexProcessor::States::computeHash() uint32_t VertexProcessor::States::computeHash()
{ {
uint32_t *state = reinterpret_cast<uint32_t*>(this); uint32_t *state = reinterpret_cast<uint32_t *>(this);
uint32_t hash = 0; uint32_t hash = 0;
for(unsigned int i = 0; i < sizeof(States) / sizeof(uint32_t); i++) for(unsigned int i = 0; i < sizeof(States) / sizeof(uint32_t); i++)
...@@ -78,7 +78,7 @@ bool VertexProcessor::State::operator==(const State &state) const ...@@ -78,7 +78,7 @@ bool VertexProcessor::State::operator==(const State &state) const
} }
static_assert(is_memcmparable<State>::value, "Cannot memcmp States"); static_assert(is_memcmparable<State>::value, "Cannot memcmp States");
return memcmp(static_cast<const States*>(this), static_cast<const States*>(&state), sizeof(States)) == 0; return memcmp(static_cast<const States *>(this), static_cast<const States *>(&state), sizeof(States)) == 0;
} }
VertexProcessor::VertexProcessor() VertexProcessor::VertexProcessor()
...@@ -99,7 +99,7 @@ void VertexProcessor::setRoutineCacheSize(int cacheSize) ...@@ -99,7 +99,7 @@ void VertexProcessor::setRoutineCacheSize(int cacheSize)
routineCache = new RoutineCacheType(clamp(cacheSize, 1, 65536)); routineCache = new RoutineCacheType(clamp(cacheSize, 1, 65536));
} }
const VertexProcessor::State VertexProcessor::update(const sw::Context* context) const VertexProcessor::State VertexProcessor::update(const sw::Context *context)
{ {
State state; State state;
...@@ -114,7 +114,7 @@ const VertexProcessor::State VertexProcessor::update(const sw::Context* context) ...@@ -114,7 +114,7 @@ const VertexProcessor::State VertexProcessor::update(const sw::Context* context)
state.input[i].normalized = context->input[i].normalized; state.input[i].normalized = context->input[i].normalized;
// TODO: get rid of attribType -- just keep the VK format all the way through, this fully determines // TODO: get rid of attribType -- just keep the VK format all the way through, this fully determines
// how to handle the attribute. // how to handle the attribute.
state.input[i].attribType = context->vertexShader->inputs[i*4].Type; state.input[i].attribType = context->vertexShader->inputs[i * 4].Type;
} }
state.hash = state.computeHash(); state.hash = state.computeHash();
......
...@@ -50,14 +50,16 @@ struct VertexTask ...@@ -50,14 +50,16 @@ struct VertexTask
VertexCache vertexCache; VertexCache vertexCache;
}; };
using VertexRoutineFunction = FunctionT<void(Vertex* output, unsigned int* batch, VertexTask* vertextask, DrawData* draw)>; using VertexRoutineFunction = FunctionT<void(Vertex *output, unsigned int *batch, VertexTask *vertextask, DrawData *draw)>;
class VertexProcessor class VertexProcessor
{ {
public: public:
struct States : Memset<States> struct States : Memset<States>
{ {
States() : Memset(this, 0) {} States()
: Memset(this, 0)
{}
uint32_t computeHash(); uint32_t computeHash();
...@@ -97,7 +99,7 @@ public: ...@@ -97,7 +99,7 @@ public:
virtual ~VertexProcessor(); virtual ~VertexProcessor();
protected: protected:
const State update(const sw::Context* context); const State update(const sw::Context *context);
RoutineType routine(const State &state, vk::PipelineLayout const *pipelineLayout, RoutineType routine(const State &state, vk::PipelineLayout const *pipelineLayout,
SpirvShader const *vertexShader, const vk::DescriptorSet::Bindings &descriptorSets); SpirvShader const *vertexShader, const vk::DescriptorSet::Bindings &descriptorSets);
......
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