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
...@@ -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,27 +164,27 @@ private: ...@@ -137,27 +164,27 @@ 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
std::mutex cornerUpdateMutex; std::mutex cornerUpdateMutex;
RoutineCacheT<State, CornerUpdateFunction::CFunctionType> cornerUpdateCache; // guarded by cornerUpdateMutex RoutineCacheT<State, CornerUpdateFunction::CFunctionType> cornerUpdateCache; // guarded by cornerUpdateMutex
}; };
} // namespace sw } // namespace sw
#endif // sw_Blitter_hpp #endif // sw_Blitter_hpp
...@@ -263,31 +263,40 @@ namespace sw { ...@@ -263,31 +263,40 @@ namespace sw {
unsigned int Clipper::ComputeClipFlags(const float4 &v) unsigned int Clipper::ComputeClipFlags(const float4 &v)
{ {
return ((v.x > v.w) ? CLIP_RIGHT : 0) | return ((v.x > v.w) ? CLIP_RIGHT : 0) |
((v.y > v.w) ? CLIP_TOP : 0) | ((v.y > v.w) ? CLIP_TOP : 0) |
((v.z > v.w) ? CLIP_FAR : 0) | ((v.z > v.w) ? CLIP_FAR : 0) |
((v.x < -v.w) ? CLIP_LEFT : 0) | ((v.x < -v.w) ? CLIP_LEFT : 0) |
((v.y < -v.w) ? CLIP_BOTTOM : 0) | ((v.y < -v.w) ? CLIP_BOTTOM : 0) |
((v.z < 0) ? CLIP_NEAR : 0) | ((v.z < 0) ? CLIP_NEAR : 0) |
Clipper::CLIP_FINITE; // FIXME: xyz finite Clipper::CLIP_FINITE; // FIXME: xyz finite
} }
bool Clipper::Clip(Polygon &polygon, int clipFlagsOr, const DrawCall &draw) 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(polygon.n >= 3) { if(clipFlagsOr & CLIP_FAR) clipFar(polygon);
if(clipFlagsOr & CLIP_LEFT) clipLeft(polygon); if(polygon.n >= 3)
if(polygon.n >= 3) { {
if(clipFlagsOr & CLIP_RIGHT) clipRight(polygon); if(clipFlagsOr & CLIP_LEFT) clipLeft(polygon);
if(polygon.n >= 3) { if(polygon.n >= 3)
if(clipFlagsOr & CLIP_TOP) clipTop(polygon); {
if(polygon.n >= 3) { if(clipFlagsOr & CLIP_RIGHT) clipRight(polygon);
if(clipFlagsOr & CLIP_BOTTOM) clipBottom(polygon); if(polygon.n >= 3)
}}}}} {
if(clipFlagsOr & CLIP_TOP) clipTop(polygon);
if(polygon.n >= 3)
{
if(clipFlagsOr & CLIP_BOTTOM) clipBottom(polygon);
}
}
}
}
}
} }
return polygon.n >= 3; return polygon.n >= 3;
......
...@@ -27,16 +27,16 @@ struct Clipper ...@@ -27,16 +27,16 @@ struct Clipper
enum ClipFlags enum ClipFlags
{ {
// Indicates the vertex is outside the respective frustum plane // Indicates the vertex is outside the respective frustum plane
CLIP_RIGHT = 1 << 0, CLIP_RIGHT = 1 << 0,
CLIP_TOP = 1 << 1, CLIP_TOP = 1 << 1,
CLIP_FAR = 1 << 2, CLIP_FAR = 1 << 2,
CLIP_LEFT = 1 << 3, CLIP_LEFT = 1 << 3,
CLIP_BOTTOM = 1 << 4, CLIP_BOTTOM = 1 << 4,
CLIP_NEAR = 1 << 5, CLIP_NEAR = 1 << 5,
CLIP_FRUSTUM = 0x003F, CLIP_FRUSTUM = 0x003F,
CLIP_FINITE = 1 << 7, // All position coordinates are finite CLIP_FINITE = 1 << 7, // All position coordinates are finite
}; };
static unsigned int ComputeClipFlags(const float4 &v); static unsigned int ComputeClipFlags(const float4 &v);
...@@ -45,4 +45,4 @@ struct Clipper ...@@ -45,4 +45,4 @@ struct Clipper
} // namespace sw } // namespace sw
#endif // sw_Clipper_hpp #endif // sw_Clipper_hpp
...@@ -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 {
...@@ -28,12 +28,12 @@ struct Color ...@@ -28,12 +28,12 @@ struct Color
Color(const Color<byte> &c); Color(const Color<byte> &c);
Color(const Color<short> &c); Color(const Color<short> &c);
Color(const Color<float> &c); Color(const Color<float> &c);
Color(int c); Color(int c);
Color(unsigned short c); Color(unsigned short c);
Color(unsigned long c); Color(unsigned long c);
Color(unsigned int c); Color(unsigned int c);
Color(T r, T g, T b, T a = 1); Color(T r, T g, T b, T a = 1);
operator unsigned int() const; operator unsigned int() const;
...@@ -44,13 +44,13 @@ struct Color ...@@ -44,13 +44,13 @@ 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);
static Color<T> gradient(const Color<T> &c1, const Color<T> &c2, float d); static Color<T> gradient(const Color<T> &c1, const Color<T> &c2, float d);
static Color<T> shade(const Color<T> &c1, const Color<T> &c2, float d); static Color<T> shade(const Color<T> &c1, const Color<T> &c2, float d);
template<class S> template<class S>
friend Color<S> operator+(const Color<S> &c1, const Color<S> &c2); friend Color<S> operator+(const Color<S> &c1, const Color<S> &c2);
...@@ -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"
...@@ -312,7 +312,7 @@ inline Color<byte>::operator unsigned int() const ...@@ -312,7 +312,7 @@ inline Color<byte>::operator unsigned int() const
return (b << 0) + return (b << 0) +
(g << 8) + (g << 8) +
(r << 16) + (r << 16) +
(a << 24); (a << 24);
} }
template<class T> template<class T>
...@@ -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;
...@@ -375,7 +375,7 @@ inline Color<T> operator+(const Color<T> &c1, const Color<T> &c2) ...@@ -375,7 +375,7 @@ inline Color<T> operator+(const Color<T> &c1, const Color<T> &c2)
return Color<T>(c1.r + c2.r, return Color<T>(c1.r + c2.r,
c1.g + c2.g, c1.g + c2.g,
c1.b + c2.b, c1.b + c2.b,
c1.a + c2.a); c1.a + c2.a);
} }
template<class T> template<class T>
...@@ -384,7 +384,7 @@ inline Color<T> operator-(const Color<T> &c1, const Color<T> &c2) ...@@ -384,7 +384,7 @@ inline Color<T> operator-(const Color<T> &c1, const Color<T> &c2)
return Color<T>(c1.r - c2.r, return Color<T>(c1.r - c2.r,
c1.g - c2.g, c1.g - c2.g,
c1.b - c2.b, c1.b - c2.b,
c1.a - c2.a); c1.a - c2.a);
} }
template<class T> template<class T>
...@@ -434,7 +434,7 @@ inline Color<byte> operator*(const Color<byte> &c1, const Color<byte> &c2) ...@@ -434,7 +434,7 @@ inline Color<byte> operator*(const Color<byte> &c1, const Color<byte> &c2)
template<class T> template<class T>
inline Color<T> operator/(const Color<T> &c, float l) inline Color<T> operator/(const Color<T> &c, float l)
{ {
l = 1.0f / l; l = 1.0f / l;
T r = (T)(l * c.r); T r = (T)(l * c.r);
T g = (T)(l * c.g); T g = (T)(l * c.g);
...@@ -447,7 +447,7 @@ inline Color<T> operator/(const Color<T> &c, float l) ...@@ -447,7 +447,7 @@ inline Color<T> operator/(const Color<T> &c, float l)
template<class T> template<class T>
inline Color<T> Color<T>::gradient(const Color<T> &c1, const Color<T> &c2, float d) inline Color<T> Color<T>::gradient(const Color<T> &c1, const Color<T> &c2, float d)
{ {
d = 1.0f / d; d = 1.0f / d;
T r = (c2.r - c1.r) * d; T r = (c2.r - c1.r) * d;
T g = (c2.g - c1.g) * d; T g = (c2.g - c1.g) * d;
...@@ -458,7 +458,7 @@ inline Color<T> Color<T>::gradient(const Color<T> &c1, const Color<T> &c2, float ...@@ -458,7 +458,7 @@ inline Color<T> Color<T>::gradient(const Color<T> &c1, const Color<T> &c2, float
} }
template<class T> template<class T>
inline Color<T> Color<T>::shade(const Color<T> &c1, const Color<T> &c2, float d) inline Color<T> Color<T>::shade(const Color<T> &c1, const Color<T> &c2, float d)
{ {
T r = c1.r + (T)(d * (c2.r - c1.r)); T r = c1.r + (T)(d * (c2.r - c1.r));
T g = c1.g + (T)(d * (c2.g - c1.g)); T g = c1.g + (T)(d * (c2.g - c1.g));
...@@ -470,4 +470,4 @@ inline Color<T> Color<T>::shade(const Color<T> &c1, const Color<T> &c2, float d ...@@ -470,4 +470,4 @@ inline Color<T> Color<T>::shade(const Color<T> &c1, const Color<T> &c2, float d
} // namespace sw } // namespace sw
#endif // sw_Color_hpp #endif // sw_Color_hpp
...@@ -47,7 +47,7 @@ extern Profiler profiler; ...@@ -47,7 +47,7 @@ extern Profiler profiler;
enum enum
{ {
OUTLINE_RESOLUTION = 8192, // Maximum vertical resolution of the render target OUTLINE_RESOLUTION = 8192, // Maximum vertical resolution of the render target
MIPMAP_LEVELS = 14, MIPMAP_LEVELS = 14,
MAX_UNIFORM_BLOCK_SIZE = 16384, MAX_UNIFORM_BLOCK_SIZE = 16384,
MAX_CLIP_DISTANCES = 8, MAX_CLIP_DISTANCES = 8,
...@@ -56,11 +56,11 @@ enum ...@@ -56,11 +56,11 @@ enum
MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS = 64, MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS = 64,
MIN_TEXEL_OFFSET = -8, MIN_TEXEL_OFFSET = -8,
MAX_TEXEL_OFFSET = 7, MAX_TEXEL_OFFSET = 7,
MAX_TEXTURE_LOD = MIPMAP_LEVELS - 2, // Trilinear accesses lod+1 MAX_TEXTURE_LOD = MIPMAP_LEVELS - 2, // Trilinear accesses lod+1
RENDERTARGETS = 8, RENDERTARGETS = 8,
MAX_INTERFACE_COMPONENTS = 32 * 4, // Must be multiple of 4 for 16-byte alignment. MAX_INTERFACE_COMPONENTS = 32 * 4, // Must be multiple of 4 for 16-byte alignment.
}; };
} // namespace sw } // namespace sw
#endif // sw_Config_hpp #endif // sw_Config_hpp
...@@ -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;
...@@ -133,7 +135,7 @@ public: ...@@ -133,7 +135,7 @@ public:
float lineWidth; float lineWidth;
int colorWriteMask[RENDERTARGETS]; // RGBA int colorWriteMask[RENDERTARGETS]; // RGBA
unsigned int sampleMask; unsigned int sampleMask;
unsigned int multiSampleMask; unsigned int multiSampleMask;
int sampleCount; int sampleCount;
...@@ -157,4 +159,4 @@ private: ...@@ -157,4 +159,4 @@ private:
} // namespace sw } // namespace sw
#endif // sw_Context_hpp #endif // sw_Context_hpp
...@@ -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++)
...@@ -147,7 +150,7 @@ Data LRUCache<Key, Data>::query(const Key &key) const ...@@ -147,7 +150,7 @@ Data LRUCache<Key, Data>::query(const Key &key) const
} }
} }
return {}; // Not found return {}; // Not found
} }
template<class Key, class Data> template<class Key, class Data>
...@@ -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 = {};
...@@ -197,4 +200,4 @@ const Data& LRUConstCache<Key, Data, Hasher>::queryConstCache(const Key &key) co ...@@ -197,4 +200,4 @@ const Data& LRUConstCache<Key, Data, Hasher>::queryConstCache(const Key &key) co
} // namespace sw } // namespace sw
#endif // sw_LRUCache_hpp #endif // sw_LRUCache_hpp
...@@ -35,7 +35,7 @@ struct Matrix ...@@ -35,7 +35,7 @@ struct Matrix
float m21, float m22, float m23, float m24, float m21, float m22, float m23, float m24,
float m31, float m32, float m33, float m34, float m31, float m32, float m33, float m34,
float m41, float m42, float m43, float m44); float m41, float m42, float m43, float m44);
Matrix(const Vector &v1, const Vector &v2, const Vector &v3); // Column vectors Matrix(const Vector &v1, const Vector &v2, const Vector &v3); // Column vectors
Matrix &operator=(const Matrix &N); Matrix &operator=(const Matrix &N);
...@@ -44,13 +44,13 @@ struct Matrix ...@@ -44,13 +44,13 @@ 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;
Matrix operator!() const; // Inverse Matrix operator!() const; // Inverse
Matrix operator~() const; // Transpose Matrix operator~() const; // Transpose
Matrix &operator+=(const Matrix &N); Matrix &operator+=(const Matrix &N);
Matrix &operator-=(const Matrix &N); Matrix &operator-=(const Matrix &N);
...@@ -58,10 +58,10 @@ struct Matrix ...@@ -58,10 +58,10 @@ struct Matrix
Matrix &operator*=(const Matrix &N); Matrix &operator*=(const Matrix &N);
Matrix &operator/=(float s); Matrix &operator/=(float s);
float *operator[](int i); // Access element [row][col], starting with [0][0] float *operator[](int i); // Access element [row][col], starting with [0][0]
const float *operator[](int i) const; const float *operator[](int i) const;
float &operator()(int i, int j); // Access element (row, col), starting with (1, 1) float &operator()(int i, int j); // Access element (row, col), starting with (1, 1)
const float &operator()(int i, int j) const; const float &operator()(int i, int j) const;
friend bool operator==(const Matrix &M, const Matrix &N); friend bool operator==(const Matrix &M, const Matrix &N);
...@@ -91,21 +91,21 @@ struct Matrix ...@@ -91,21 +91,21 @@ struct Matrix
static float tr(const Matrix &M); static float tr(const Matrix &M);
Matrix &orthogonalise(); // Gram-Schmidt orthogonalisation of 3x3 submatrix Matrix &orthogonalise(); // Gram-Schmidt orthogonalisation of 3x3 submatrix
static Matrix eulerRotate(const Vector &v); static Matrix eulerRotate(const Vector &v);
static Matrix eulerRotate(float x, float y, float z); static Matrix eulerRotate(float x, float y, float z);
static Matrix translate(const Vector &v); static Matrix translate(const Vector &v);
static Matrix translate(float x, float y, float z); static Matrix translate(float x, float y, float z);
static Matrix scale(const Vector &v); static Matrix scale(const Vector &v);
static Matrix scale(float x, float y, float z); static Matrix scale(float x, float y, float z);
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,75 +121,159 @@ inline Matrix::Matrix(const int i) ...@@ -121,75 +121,159 @@ 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,
float m21, float m22, float m23, float m21, float m22, float m23,
float m31, float m32, float m33) float m31, float m32, float m33)
{ {
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,
float m21, float m22, float m23, float m24, float m21, float m22, float m23, float m24,
float m31, float m32, float m33, float m34, float m31, float m32, float m33, float m34,
float m41, float m42, float m43, float m44) float m41, float m42, float m43, float m44)
{ {
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;
} }
...@@ -216,4 +300,4 @@ inline const float &Matrix::operator()(int i, int j) const ...@@ -216,4 +300,4 @@ inline const float &Matrix::operator()(int i, int j) const
} // namespace sw } // namespace sw
#endif // Matrix_hpp #endif // Matrix_hpp
...@@ -30,23 +30,23 @@ struct Memset ...@@ -30,23 +30,23 @@ 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
} }
}; };
} // namespace sw } // namespace sw
#endif // sw_Memset_hpp #endif // sw_Memset_hpp
\ No newline at end of file \ No newline at end of file
...@@ -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;
...@@ -151,9 +151,9 @@ const PixelProcessor::State PixelProcessor::update(const Context* context) const ...@@ -151,9 +151,9 @@ const PixelProcessor::State PixelProcessor::update(const Context* context) const
} }
PixelProcessor::RoutineType PixelProcessor::routine(const State &state, PixelProcessor::RoutineType PixelProcessor::routine(const State &state,
vk::PipelineLayout const *pipelineLayout, vk::PipelineLayout const *pipelineLayout,
SpirvShader const *pixelShader, SpirvShader const *pixelShader,
const vk::DescriptorSet::Bindings &descriptorSets) const vk::DescriptorSet::Bindings &descriptorSets)
{ {
auto routine = routineCache->query(state); auto routine = routineCache->query(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
{ {
...@@ -39,25 +39,27 @@ public: ...@@ -39,25 +39,27 @@ public:
// (it doesn't require a different program to be generated) // (it doesn't require a different program to be generated)
struct StencilOpState struct StencilOpState
{ {
VkStencilOp failOp; VkStencilOp failOp;
VkStencilOp passOp; VkStencilOp passOp;
VkStencilOp depthFailOp; VkStencilOp depthFailOp;
VkCompareOp compareOp; VkCompareOp compareOp;
uint32_t compareMask; uint32_t compareMask;
uint32_t writeMask; uint32_t writeMask;
void operator=(const VkStencilOpState &rhs) void operator=(const VkStencilOpState &rhs)
{ {
failOp = rhs.failOp; failOp = rhs.failOp;
passOp = rhs.passOp; passOp = rhs.passOp;
depthFailOp = rhs.depthFailOp; depthFailOp = rhs.depthFailOp;
compareOp = rhs.compareOp; compareOp = rhs.compareOp;
compareMask = rhs.compareMask; compareMask = rhs.compareMask;
writeMask = rhs.writeMask; writeMask = rhs.writeMask;
} }
}; };
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);
...@@ -165,4 +167,4 @@ private: ...@@ -165,4 +167,4 @@ private:
} // namespace sw } // namespace sw
#endif // sw_PixelProcessor_hpp #endif // sw_PixelProcessor_hpp
...@@ -29,13 +29,13 @@ struct Plane ...@@ -29,13 +29,13 @@ struct Plane
float D; float D;
Plane(); Plane();
Plane(float A, float B, float C, float D); // Plane equation Plane(float A, float B, float C, float D); // Plane equation
Plane(const float ABCD[4]); Plane(const float ABCD[4]);
friend Plane operator*(const Plane &p, const Matrix &A); // Transform plane by matrix (post-multiply) friend Plane operator*(const Plane &p, const Matrix &A); // Transform plane by matrix (post-multiply)
friend Plane operator*(const Matrix &A, const Plane &p); // Transform plane by matrix (pre-multiply) friend Plane operator*(const Matrix &A, const Plane &p); // Transform plane by matrix (pre-multiply)
}; };
} // namespace sw } // namespace sw
#endif // Plane_hpp #endif // Plane_hpp
...@@ -35,7 +35,7 @@ struct Point ...@@ -35,7 +35,7 @@ struct Point
float p[3]; float p[3];
struct struct
{ {
float x; float x;
float y; float y;
float z; float z;
...@@ -56,15 +56,15 @@ struct Point ...@@ -56,15 +56,15 @@ 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);
float d(const Point &P) const; // Distance between two points float d(const Point &P) const; // Distance between two points
float d2(const Point &P) const; // Squared distance between two points float d2(const Point &P) const; // Squared distance between two points
static float d(const Point &P, const Point &Q); // Distance between two points static float d(const Point &P, const Point &Q); // Distance between two points
static float d2(const Point &P, const Point &Q); // Squared distance between two points static float d2(const Point &P, const Point &Q); // Squared distance between two points
}; };
} // namespace sw } // namespace sw
...@@ -138,4 +138,4 @@ inline const float &Point::operator[](int i) const ...@@ -138,4 +138,4 @@ inline const float &Point::operator[](int i) const
} // namespace sw } // namespace sw
#endif // Point_hpp #endif // Point_hpp
...@@ -44,14 +44,14 @@ struct Polygon ...@@ -44,14 +44,14 @@ struct Polygon
this->b = 0; this->b = 0;
} }
float4 B[16]; // Buffer for clipped vertices float4 B[16]; // Buffer for clipped vertices
const float4 *P[16][16]; // Pointers to clipped polygon's vertices const float4 *P[16][16]; // Pointers to clipped polygon's vertices
int n; // Number of vertices int n; // Number of vertices
int i; // Level of P to use int i; // Level of P to use
int b; // Next available new vertex int b; // Next available new vertex
}; };
} // namespace sw } // namespace sw
#endif // sw_Polygon_hpp #endif // sw_Polygon_hpp
...@@ -22,35 +22,41 @@ ...@@ -22,35 +22,41 @@
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()
#endif // MEMORY_SANITIZER_ENABLED : Memset<Triangle>(this, 0)
{}
#endif // MEMORY_SANITIZER_ENABLED
Vertex v0; Vertex v0;
Vertex v1; Vertex v1;
Vertex v2; Vertex v2;
}; };
struct PlaneEquation // z = A * x + B * y + C struct PlaneEquation // z = A * x + B * y + C
{ {
float4 A; float4 A;
float4 B; float4 B;
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()
#endif // MEMORY_SANITIZER_ENABLED : Memset<Primitive>(this, 0)
{}
#endif // MEMORY_SANITIZER_ENABLED
int yMin; int yMin;
int yMax; int yMax;
...@@ -87,4 +93,4 @@ struct Primitive MEMORY_SANITIZER_ONLY(: Memset<Primitive>) ...@@ -87,4 +93,4 @@ struct Primitive MEMORY_SANITIZER_ONLY(: Memset<Primitive>)
} // namespace sw } // namespace sw
#endif // sw_Primitive_hpp #endif // sw_Primitive_hpp
...@@ -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)
...@@ -154,20 +156,20 @@ void QuadRasterizer::rasterize(Int &yMin, Int &yMax) ...@@ -154,20 +156,20 @@ void QuadRasterizer::rasterize(Int &yMin, Int &yMax)
if(!spirvShader->inputs[interpolant].Flat) if(!spirvShader->inputs[interpolant].Flat)
{ {
Dv[interpolant] += Dv[interpolant] +=
yyyy * *Pointer<Float4>(primitive + OFFSET(Primitive, V[interpolant].B), 16); yyyy * *Pointer<Float4>(primitive + OFFSET(Primitive, V[interpolant].B), 16);
} }
} }
for(unsigned int i = 0; i < state.numClipDistances; i++) for(unsigned int i = 0; i < state.numClipDistances; i++)
{ {
DclipDistance[i] = *Pointer<Float4>(primitive + OFFSET(Primitive, clipDistance[i].C), 16) + DclipDistance[i] = *Pointer<Float4>(primitive + OFFSET(Primitive, clipDistance[i].C), 16) +
yyyy * *Pointer<Float4>(primitive + OFFSET(Primitive, clipDistance[i].B), 16); yyyy * *Pointer<Float4>(primitive + OFFSET(Primitive, clipDistance[i].B), 16);
} }
for(unsigned int i = 0; i < state.numCullDistances; i++) for(unsigned int i = 0; i < state.numCullDistances; i++)
{ {
DcullDistance[i] = *Pointer<Float4>(primitive + OFFSET(Primitive, cullDistance[i].C), 16) + DcullDistance[i] = *Pointer<Float4>(primitive + OFFSET(Primitive, cullDistance[i].C), 16) +
yyyy * *Pointer<Float4>(primitive + OFFSET(Primitive, cullDistance[i].B), 16); yyyy * *Pointer<Float4>(primitive + OFFSET(Primitive, cullDistance[i].B), 16);
} }
} }
...@@ -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;
......
...@@ -57,4 +57,4 @@ private: ...@@ -57,4 +57,4 @@ private:
} // namespace sw } // namespace sw
#endif // sw_QuadRasterizer_hpp #endif // sw_QuadRasterizer_hpp
...@@ -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:
...@@ -37,4 +43,4 @@ protected: ...@@ -37,4 +43,4 @@ protected:
} // namespace sw } // namespace sw
#endif // sw_Rasterizer_hpp #endif // sw_Rasterizer_hpp
...@@ -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>
...@@ -76,9 +76,9 @@ struct DrawData ...@@ -76,9 +76,9 @@ struct DrawData
float lineWidth; float lineWidth;
int viewID; int viewID;
PixelProcessor::Stencil stencil[2]; // clockwise, counterclockwise PixelProcessor::Stencil stencil[2]; // clockwise, counterclockwise
PixelProcessor::Factor factor; PixelProcessor::Factor factor;
unsigned int occlusion[MaxClusterCount]; // Number of pixels passing depth test unsigned int occlusion[MaxClusterCount]; // Number of pixels passing depth test
float4 WxF; float4 WxF;
float4 HxF; float4 HxF;
...@@ -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,22 +167,22 @@ struct DrawCall ...@@ -167,22 +167,22 @@ struct DrawCall
vk::ImageView *stencilBuffer; vk::ImageView *stencilBuffer;
TaskEvents *events; TaskEvents *events;
vk::Query* occlusionQuery; vk::Query *occlusionQuery;
DrawData *data; DrawData *data;
static void processPrimitiveVertices( static void processPrimitiveVertices(
unsigned int triangleIndicesOut[MaxBatchSize + 1][3], unsigned int triangleIndicesOut[MaxBatchSize + 1][3],
const void *primitiveIndices, const void *primitiveIndices,
VkIndexType indexType, VkIndexType indexType,
unsigned int start, unsigned int start,
unsigned int triangleCount, unsigned int triangleCount,
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,9 +238,9 @@ private: ...@@ -238,9 +238,9 @@ private:
SetupProcessor::RoutineType setupRoutine; SetupProcessor::RoutineType setupRoutine;
PixelProcessor::RoutineType pixelRoutine; PixelProcessor::RoutineType pixelRoutine;
vk::Device* device; vk::Device *device;
}; };
} // namespace sw } // namespace sw
#endif // sw_Renderer_hpp #endif // sw_Renderer_hpp
...@@ -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 {
...@@ -79,10 +81,10 @@ enum AddressingMode ENUM_UNDERLYING_TYPE_UNSIGNED_INT ...@@ -79,10 +81,10 @@ enum AddressingMode ENUM_UNDERLYING_TYPE_UNSIGNED_INT
ADDRESSING_CLAMP, ADDRESSING_CLAMP,
ADDRESSING_MIRROR, ADDRESSING_MIRROR,
ADDRESSING_MIRRORONCE, ADDRESSING_MIRRORONCE,
ADDRESSING_BORDER, // Single color ADDRESSING_BORDER, // Single color
ADDRESSING_SEAMLESS, // Border of pixels ADDRESSING_SEAMLESS, // Border of pixels
ADDRESSING_CUBEFACE, // Cube face layer ADDRESSING_CUBEFACE, // Cube face layer
ADDRESSING_LAYER, // Array layer ADDRESSING_LAYER, // Array layer
ADDRESSING_TEXELFETCH, ADDRESSING_TEXELFETCH,
ADDRESSING_LAST = ADDRESSING_TEXELFETCH ADDRESSING_LAST = ADDRESSING_TEXELFETCH
...@@ -114,4 +116,4 @@ struct Sampler ...@@ -114,4 +116,4 @@ struct Sampler
} // namespace sw } // namespace sw
#endif // sw_Sampler_hpp #endif // sw_Sampler_hpp
...@@ -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,29 +30,31 @@ struct Vertex; ...@@ -30,29 +30,31 @@ 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();
bool isDrawPoint : 1; bool isDrawPoint : 1;
bool isDrawLine : 1; bool isDrawLine : 1;
bool isDrawTriangle : 1; bool isDrawTriangle : 1;
bool applySlopeDepthBias : 1; bool applySlopeDepthBias : 1;
bool interpolateZ : 1; bool interpolateZ : 1;
bool interpolateW : 1; bool interpolateW : 1;
VkFrontFace frontFace : BITS(VK_FRONT_FACE_MAX_ENUM); VkFrontFace frontFace : BITS(VK_FRONT_FACE_MAX_ENUM);
VkCullModeFlags cullMode : BITS(VK_CULL_MODE_FLAG_BITS_MAX_ENUM); VkCullModeFlags cullMode : BITS(VK_CULL_MODE_FLAG_BITS_MAX_ENUM);
unsigned int multiSample : 3; // 1, 2 or 4 unsigned int multiSample : 3; // 1, 2 or 4
bool rasterizerDiscard : 1; bool rasterizerDiscard : 1;
unsigned int numClipDistances : 4; // [0 - 8] unsigned int numClipDistances : 4; // [0 - 8]
unsigned int numCullDistances : 4; // [0 - 8] unsigned int numCullDistances : 4; // [0 - 8]
SpirvShader::InterfaceComponent gradient[MAX_INTERFACE_COMPONENTS]; SpirvShader::InterfaceComponent gradient[MAX_INTERFACE_COMPONENTS];
}; };
...@@ -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);
...@@ -83,4 +85,4 @@ private: ...@@ -83,4 +85,4 @@ private:
} // namespace sw } // namespace sw
#endif // sw_SetupProcessor_hpp #endif // sw_SetupProcessor_hpp
...@@ -21,15 +21,15 @@ namespace sw { ...@@ -21,15 +21,15 @@ namespace sw {
enum StreamType ENUM_UNDERLYING_TYPE_UNSIGNED_INT enum StreamType ENUM_UNDERLYING_TYPE_UNSIGNED_INT
{ {
STREAMTYPE_COLOR, // 4 normalized unsigned bytes, ZYXW order STREAMTYPE_COLOR, // 4 normalized unsigned bytes, ZYXW order
STREAMTYPE_FLOAT, // Normalization ignored STREAMTYPE_FLOAT, // Normalization ignored
STREAMTYPE_BYTE, STREAMTYPE_BYTE,
STREAMTYPE_SBYTE, STREAMTYPE_SBYTE,
STREAMTYPE_SHORT, STREAMTYPE_SHORT,
STREAMTYPE_USHORT, STREAMTYPE_USHORT,
STREAMTYPE_INT, STREAMTYPE_INT,
STREAMTYPE_UINT, STREAMTYPE_UINT,
STREAMTYPE_HALF, // Normalization ignored STREAMTYPE_HALF, // Normalization ignored
STREAMTYPE_2_10_10_10_INT, STREAMTYPE_2_10_10_10_INT,
STREAMTYPE_2_10_10_10_UINT, STREAMTYPE_2_10_10_10_UINT,
...@@ -51,4 +51,4 @@ struct Stream ...@@ -51,4 +51,4 @@ struct Stream
} // namespace sw } // namespace sw
#endif // sw_Stream_hpp #endif // sw_Stream_hpp
...@@ -28,4 +28,4 @@ struct Triangle ...@@ -28,4 +28,4 @@ struct Triangle
} // namespace sw } // namespace sw
#endif // sw_Triangle_hpp #endif // sw_Triangle_hpp
...@@ -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)
......
...@@ -62,19 +62,19 @@ struct Vector ...@@ -62,19 +62,19 @@ struct Vector
friend Vector operator+(const Vector &u, const Vector &v); friend Vector operator+(const Vector &u, const Vector &v);
friend Vector operator-(const Vector &u, const Vector &v); friend Vector operator-(const Vector &u, const Vector &v);
friend float operator*(const Vector &u, const Vector &v); // Dot product friend float operator*(const Vector &u, const Vector &v); // Dot product
friend Vector operator*(float s, const Vector &v); friend Vector operator*(float s, const Vector &v);
friend Vector operator*(const Vector &v, float s); friend Vector operator*(const Vector &v, float s);
friend Vector operator/(const Vector &v, float s); friend Vector operator/(const Vector &v, float s);
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);
static float N(const Vector &v); // Norm static float N(const Vector &v); // Norm
static float N2(const Vector &v); // Squared norm static float N2(const Vector &v); // Squared norm
static Vector mirror(const Vector &v, const Plane &p); static Vector mirror(const Vector &v, const Plane &p);
static Vector reflect(const Vector &v, const Plane &p); static Vector reflect(const Vector &v, const Plane &p);
...@@ -154,4 +154,4 @@ inline const float &Vector::operator[](int i) const ...@@ -154,4 +154,4 @@ inline const float &Vector::operator[](int i) const
} // namespace sw } // namespace sw
#endif // Vector_hpp #endif // Vector_hpp
...@@ -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 {
...@@ -58,4 +58,4 @@ static_assert((sizeof(Vertex) & 0x0000000F) == 0, "Vertex size not a multiple of ...@@ -58,4 +58,4 @@ static_assert((sizeof(Vertex) & 0x0000000F) == 0, "Vertex size not a multiple of
} // namespace sw } // namespace sw
#endif // Vertex_hpp #endif // Vertex_hpp
...@@ -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++)
...@@ -48,23 +48,23 @@ unsigned int VertexProcessor::States::Input::bytesPerAttrib() const ...@@ -48,23 +48,23 @@ unsigned int VertexProcessor::States::Input::bytesPerAttrib() const
{ {
switch(type) switch(type)
{ {
case STREAMTYPE_FLOAT: case STREAMTYPE_FLOAT:
case STREAMTYPE_INT: case STREAMTYPE_INT:
case STREAMTYPE_UINT: case STREAMTYPE_UINT:
return count * sizeof(uint32_t); return count * sizeof(uint32_t);
case STREAMTYPE_HALF: case STREAMTYPE_HALF:
case STREAMTYPE_SHORT: case STREAMTYPE_SHORT:
case STREAMTYPE_USHORT: case STREAMTYPE_USHORT:
return count * sizeof(uint16_t); return count * sizeof(uint16_t);
case STREAMTYPE_BYTE: case STREAMTYPE_BYTE:
case STREAMTYPE_SBYTE: case STREAMTYPE_SBYTE:
return count * sizeof(uint8_t); return count * sizeof(uint8_t);
case STREAMTYPE_COLOR: case STREAMTYPE_COLOR:
case STREAMTYPE_2_10_10_10_INT: case STREAMTYPE_2_10_10_10_INT:
case STREAMTYPE_2_10_10_10_UINT: case STREAMTYPE_2_10_10_10_UINT:
return sizeof(int); return sizeof(int);
default: default:
UNSUPPORTED("stream.type %d", int(type)); UNSUPPORTED("stream.type %d", int(type));
} }
return 0; return 0;
...@@ -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();
...@@ -129,7 +129,7 @@ VertexProcessor::RoutineType VertexProcessor::routine(const State &state, ...@@ -129,7 +129,7 @@ VertexProcessor::RoutineType VertexProcessor::routine(const State &state,
{ {
auto routine = routineCache->query(state); auto routine = routineCache->query(state);
if(!routine) // Create one if(!routine) // Create one
{ {
VertexRoutine *generator = new VertexProgram(state, pipelineLayout, vertexShader, descriptorSets); VertexRoutine *generator = new VertexProgram(state, pipelineLayout, vertexShader, descriptorSets);
generator->generate(); generator->generate();
......
...@@ -29,7 +29,7 @@ struct DrawData; ...@@ -29,7 +29,7 @@ struct DrawData;
// Basic direct mapped vertex cache. // Basic direct mapped vertex cache.
struct VertexCache struct VertexCache
{ {
static constexpr uint32_t SIZE = 64; // TODO: Variable size? static constexpr uint32_t SIZE = 64; // TODO: Variable size?
static constexpr uint32_t TAG_MASK = SIZE - 1; // Size must be power of 2. static constexpr uint32_t TAG_MASK = SIZE - 1; // Size must be power of 2.
void clear(); void clear();
...@@ -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();
...@@ -65,16 +67,16 @@ public: ...@@ -65,16 +67,16 @@ public:
struct Input struct Input
{ {
operator bool() const // Returns true if stream contains data operator bool() const // Returns true if stream contains data
{ {
return count != 0; return count != 0;
} }
unsigned int bytesPerAttrib() const; unsigned int bytesPerAttrib() const;
StreamType type : BITS(STREAMTYPE_LAST); StreamType type : BITS(STREAMTYPE_LAST);
unsigned int count : 3; unsigned int count : 3;
bool normalized : 1; bool normalized : 1;
unsigned int attribType : BITS(SpirvShader::ATTRIBTYPE_LAST); unsigned int attribType : BITS(SpirvShader::ATTRIBTYPE_LAST);
}; };
...@@ -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);
...@@ -110,4 +112,4 @@ private: ...@@ -110,4 +112,4 @@ private:
} // namespace sw } // namespace sw
#endif // sw_VertexProcessor_hpp #endif // sw_VertexProcessor_hpp
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