From 741c22c0acc1d7937e28ed7247e49b6197e396ec Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 12 Jan 2016 15:25:11 -0800 Subject: [PATCH] Move SimpleProgramKey to cpp --- libraries/render-utils/src/GeometryCache.cpp | 47 ++++++++++++-- libraries/render-utils/src/GeometryCache.h | 64 +------------------- 2 files changed, 44 insertions(+), 67 deletions(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 6c669d3d1d..35773e8748 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -1736,15 +1736,54 @@ void GeometryCache::useSimpleDrawPipeline(gpu::Batch& batch, bool noBlend) { +class SimpleProgramKey { +public: + enum FlagBit { + IS_TEXTURED_FLAG = 0, + IS_CULLED_FLAG, + IS_EMISSIVE_FLAG, + HAS_DEPTH_BIAS_FLAG, + + NUM_FLAGS, + }; + + enum Flag { + IS_TEXTURED = (1 << IS_TEXTURED_FLAG), + IS_CULLED = (1 << IS_CULLED_FLAG), + IS_EMISSIVE = (1 << IS_EMISSIVE_FLAG), + HAS_DEPTH_BIAS = (1 << HAS_DEPTH_BIAS_FLAG), + }; + typedef unsigned short Flags; + + bool isFlag(short flagNum) const { return bool((_flags & flagNum) != 0); } + + bool isTextured() const { return isFlag(IS_TEXTURED); } + bool isCulled() const { return isFlag(IS_CULLED); } + bool isEmissive() const { return isFlag(IS_EMISSIVE); } + bool hasDepthBias() const { return isFlag(HAS_DEPTH_BIAS); } + + Flags _flags = 0; + short _spare = 0; + + int getRaw() const { return *reinterpret_cast(this); } + SimpleProgramKey(bool textured = false, bool culled = true, + bool emissive = false, bool depthBias = false) { + _flags = (textured ? IS_TEXTURED : 0) | (culled ? IS_CULLED : 0) | + (emissive ? IS_EMISSIVE : 0) | (depthBias ? HAS_DEPTH_BIAS : 0); + } + SimpleProgramKey(int bitmask) : _flags(bitmask) {} +}; +inline uint qHash(const SimpleProgramKey& key, uint seed) { + return qHash(key.getRaw(), seed); +} - - - - +inline bool operator==(const SimpleProgramKey& a, const SimpleProgramKey& b) { + return a.getRaw() == b.getRaw(); +} gpu::PipelinePointer GeometryCache::getPipeline(SimpleProgramKey config) { static std::once_flag once; diff --git a/libraries/render-utils/src/GeometryCache.h b/libraries/render-utils/src/GeometryCache.h index 4c16680622..90ba3be978 100644 --- a/libraries/render-utils/src/GeometryCache.h +++ b/libraries/render-utils/src/GeometryCache.h @@ -364,20 +364,7 @@ private: QHash > _networkGeometry; - - - - - - - - - - - - - - + gpu::PipelinePointer getPipeline(SimpleProgramKey config); gpu::ShaderPointer _simpleShader; @@ -385,53 +372,4 @@ private: QHash _simplePrograms; }; -class SimpleProgramKey { -public: - enum FlagBit { - IS_TEXTURED_FLAG = 0, - IS_CULLED_FLAG, - IS_EMISSIVE_FLAG, - HAS_DEPTH_BIAS_FLAG, - - NUM_FLAGS, - }; - - enum Flag { - IS_TEXTURED = (1 << IS_TEXTURED_FLAG), - IS_CULLED = (1 << IS_CULLED_FLAG), - IS_EMISSIVE = (1 << IS_EMISSIVE_FLAG), - HAS_DEPTH_BIAS = (1 << HAS_DEPTH_BIAS_FLAG), - }; - typedef unsigned short Flags; - - bool isFlag(short flagNum) const { return bool((_flags & flagNum) != 0); } - - bool isTextured() const { return isFlag(IS_TEXTURED); } - bool isCulled() const { return isFlag(IS_CULLED); } - bool isEmissive() const { return isFlag(IS_EMISSIVE); } - bool hasDepthBias() const { return isFlag(HAS_DEPTH_BIAS); } - - Flags _flags = 0; - short _spare = 0; - - int getRaw() const { return *reinterpret_cast(this); } - - - SimpleProgramKey(bool textured = false, bool culled = true, - bool emissive = false, bool depthBias = false) { - _flags = (textured ? IS_TEXTURED : 0) | (culled ? IS_CULLED : 0) | - (emissive ? IS_EMISSIVE : 0) | (depthBias ? HAS_DEPTH_BIAS : 0); - } - - SimpleProgramKey(int bitmask) : _flags(bitmask) {} -}; - -inline uint qHash(const SimpleProgramKey& key, uint seed) { - return qHash(key.getRaw(), seed); -} - -inline bool operator==(const SimpleProgramKey& a, const SimpleProgramKey& b) { - return a.getRaw() == b.getRaw(); -} - #endif // hifi_GeometryCache_h