From ee3ec3fe1ac4570d78e2ddd63d43030033c8579c Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Mon, 30 Mar 2015 17:28:58 -0700 Subject: [PATCH] found the issue brekaing the render, i didn't do the Blend enable sync properly --- interface/src/Environment.cpp | 4 +-- libraries/gpu/src/gpu/GLBackend.h | 4 ++- libraries/gpu/src/gpu/GLBackendPipeline.cpp | 10 +++++++- libraries/gpu/src/gpu/GLBackendState.cpp | 27 +++++++++++++++------ 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/interface/src/Environment.cpp b/interface/src/Environment.cpp index 5389c81137..4547cacf83 100644 --- a/interface/src/Environment.cpp +++ b/interface/src/Environment.cpp @@ -261,12 +261,12 @@ void Environment::renderAtmosphere(Camera& camera, const EnvironmentData& data) program->setUniformValue(locations[G_LOCATION], -0.990f); program->setUniformValue(locations[G2_LOCATION], -0.990f * -0.990f); + glFrontFace(GL_CCW); glDepthMask(GL_FALSE); + glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); - // glDisable(GL_DEPTH_TEST); DependencyManager::get()->renderSphere(1.0f, 100, 50, glm::vec4(1.0f, 1.0f, 1.0f, 1.0f)); //Draw a unit sphere glDepthMask(GL_TRUE); -// glEnable(GL_CULL_FACE); program->release(); diff --git a/libraries/gpu/src/gpu/GLBackend.h b/libraries/gpu/src/gpu/GLBackend.h index 7e5c6c775f..5f6ae3957d 100644 --- a/libraries/gpu/src/gpu/GLBackend.h +++ b/libraries/gpu/src/gpu/GLBackend.h @@ -260,8 +260,10 @@ protected: void updatePipeline(); // Force to reset all the state fields indicated by the 'toBeReset" signature void resetPipelineState(State::Signature toBeReset); - // Synchronize the state cache of this Backend with the actual real state of the GL Context + // Synchronize the state cache of this Backend with the actual real state of the GL Context void syncPipelineStateCache(); + // Grab the actual gl state into it's gpu::State equivalent. THis is used by the above call syncPipleineStateCache() + void getCurrentGLState(State::Cache& state); struct PipelineStageState { diff --git a/libraries/gpu/src/gpu/GLBackendPipeline.cpp b/libraries/gpu/src/gpu/GLBackendPipeline.cpp index 13051b68cb..6a66f9aa99 100755 --- a/libraries/gpu/src/gpu/GLBackendPipeline.cpp +++ b/libraries/gpu/src/gpu/GLBackendPipeline.cpp @@ -65,7 +65,7 @@ void GLBackend::do_setPipeline(Batch& batch, uint32 paramOffset) { } if (_pipeline._needStateSync) { - // syncPipelineStateCache(); + syncPipelineStateCache(); _pipeline._needStateSync = false; } @@ -109,6 +109,14 @@ void GLBackend::do_setPipeline(Batch& batch, uint32 paramOffset) { } void GLBackend::updatePipeline() { +#ifdef DEBUG_GLSTATE + if (_pipeline._needStateSync) { + State::Cache state; + getCurrentGLState(state); + State::Signature signature = State::evalSignature(state); + } +#endif + if (_pipeline._invalidProgram) { // doing it here is aproblem for calls to glUniform.... so will do it on assing... glUseProgram(_pipeline._program); diff --git a/libraries/gpu/src/gpu/GLBackendState.cpp b/libraries/gpu/src/gpu/GLBackendState.cpp index 809f4177c8..d06ba06d63 100644 --- a/libraries/gpu/src/gpu/GLBackendState.cpp +++ b/libraries/gpu/src/gpu/GLBackendState.cpp @@ -331,9 +331,7 @@ State::BlendArg blendArgFromGL(GLenum blendArg) { return State::ONE; } - -void GLBackend::syncPipelineStateCache() { - State::Cache state; +void GLBackend::getCurrentGLState(State::Cache& state) { { GLint modes[2]; glGetIntegerv(GL_POLYGON_MODE, modes); @@ -418,8 +416,11 @@ void GLBackend::syncPipelineStateCache() { state.stencilTestBack = State::StencilTest(backRef, backReadMask, comparisonFuncFromGL(backFunc), stencilOpFromGL(backFail), stencilOpFromGL(backDepthFail), stencilOpFromGL(backPass)); } { - GLint mask; - glGetIntegerv(GL_SAMPLE_COVERAGE, &mask); + GLint mask = 0xFFFFFFFF; + if (glIsEnabled(GL_SAMPLE_MASK)) { + glGetIntegerv(GL_SAMPLE_MASK, &mask); + state.sampleMask = mask; + } state.sampleMask = mask; } { @@ -441,7 +442,7 @@ void GLBackend::syncPipelineStateCache() { glGetIntegerv(GL_BLEND_EQUATION_RGB, &opRGB); glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &opA); - state.blendFunction = State::BlendFunction(false, + state.blendFunction = State::BlendFunction(isEnabled, blendArgFromGL(srcRGB), blendOpFromGL(opRGB), blendArgFromGL(dstRGB), blendArgFromGL(srcA), blendOpFromGL(opA), blendArgFromGL(dstA)); } @@ -454,8 +455,13 @@ void GLBackend::syncPipelineStateCache() { | (mask[3] ? State::WRITE_ALPHA : 0); } - CHECK_GL_ERROR(); + CHECK_GL_ERROR(); +} +void GLBackend::syncPipelineStateCache() { + State::Cache state; + + getCurrentGLState(state); State::Signature signature = State::evalSignature(state); _pipeline._stateCache = state; @@ -645,7 +651,12 @@ void GLBackend::do_setStateAlphaToCoverageEnable(bool enable) { void GLBackend::do_setStateSampleMask(uint32 mask) { if (_pipeline._stateCache.sampleMask != mask) { - // TODO + if (mask == 0xFFFFFFFF) { + glDisable(GL_SAMPLE_MASK); + } else { + glEnable(GL_SAMPLE_MASK); + glSampleMaski(0, mask); + } _pipeline._stateCache.sampleMask = mask; } }