diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackendState.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLBackendState.cpp index 5da32f39df..0c2c0ae744 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackendState.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackendState.cpp @@ -204,10 +204,7 @@ void GLBackend::do_setStateDepthTest(State::DepthTest test) { glDepthFunc(COMPARISON_TO_GL[test.getFunction()]); } if (CHECK_GL_ERROR()) { - qCDebug(gpulogging) << "DepthTest" << (test.isEnabled() ? "Enabled" : "Disabled") - << "Mask=" << (test.getWriteMask() ? "Write" : "no Write") - << "Func=" << (uint16_t)test.getFunction() - << "Raw=" << test.getRaw(); + qCDebug(gpulogging) << "DepthTest = " << test; } _pipeline._stateCache.depthTest = test; } diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLState.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLState.cpp index 89ba80031b..3236fa05e7 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLState.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLState.cpp @@ -119,7 +119,7 @@ void generateDepthBias(GLState::Commands& commands, const State& state) { } void generateDepthTest(GLState::Commands& commands, const State::DepthTest& test) { - commands.push_back(std::make_shared(&GLBackend::do_setStateDepthTest, int32(test.getRaw()))); + commands.push_back(std::make_shared(&GLBackend::do_setStateDepthTest, test)); } void generateStencil(GLState::Commands& commands, const State& state) { diff --git a/libraries/gpu/src/gpu/State.cpp b/libraries/gpu/src/gpu/State.cpp index fab0438f75..81a43f87ae 100755 --- a/libraries/gpu/src/gpu/State.cpp +++ b/libraries/gpu/src/gpu/State.cpp @@ -94,20 +94,3 @@ static std::string hex(T t) { stream << std::hex << t; return stream.str(); } - -std::string State::getKey() const { - std::string key; - key = hex(*(int*)&_values.depthBias); - key += ":" + hex(*(int*)&_values.depthBiasSlopeScale); - key += ":" + hex(_values.depthTest.getRaw()); - key += ":" + hex(_values.stencilActivation.getRaw()); - key += ":" + hex(_values.stencilTestFront.getRaw()); - key += ":" + hex(_values.stencilTestBack.getRaw()); - key += ":" + hex(_values.blendFunction.getRaw()); - key += ":" + hex(_values.sampleMask); - // fillMode, cullMode, colorMaskWrite and the flags consume 32 bits alltogether - static_assert(0 == offsetof(State::Data, fillMode) % 4, "Validate fillMode offset"); - key += ":" + hex(*(int*)&_values.fillMode); - return key; -} - diff --git a/libraries/gpu/src/gpu/State.h b/libraries/gpu/src/gpu/State.h index 7467d86ac6..30c3bbdc05 100755 --- a/libraries/gpu/src/gpu/State.h +++ b/libraries/gpu/src/gpu/State.h @@ -18,6 +18,7 @@ #include #include #include +#include // Why a macro and not a fancy template you will ask me ? // Because some of the fields are bool packed tightly in the State::Cache class @@ -134,10 +135,19 @@ public: ComparisonFunction getFunction() const { return function; } uint8 getWriteMask() const { return writeMask; } - int32 getRaw() const { return *(reinterpret_cast(this)); } - DepthTest(int32 raw) { *(reinterpret_cast(this)) = raw; } - bool operator==(const DepthTest& right) const { return getRaw() == right.getRaw(); } - bool operator!=(const DepthTest& right) const { return getRaw() != right.getRaw(); } + bool operator==(const DepthTest& right) const { + return writeMask == right.writeMask && enabled == right.enabled && function == right.function; + } + + bool operator!=(const DepthTest& right) const { + return writeMask != right.writeMask || enabled != right.enabled || function != right.function; + } + + operator QString() const { + return QString("{ writeMask = %1, enabled = %2, function = %3 }").arg(writeMask).arg(enabled).arg(function); + + } + }; struct StencilTest { @@ -280,8 +290,6 @@ public: Flags flags; }; - std::string getKey() const; - // The unique default values for all the fields static const Data DEFAULT; void setFillMode(FillMode fill) { SET_FIELD(FILL_MODE, fillMode, fill); }