found the issue brekaing the render, i didn't do the Blend enable sync properly

This commit is contained in:
Sam Gateau 2015-03-30 17:28:58 -07:00
parent ab9be0cb41
commit ee3ec3fe1a
4 changed files with 33 additions and 12 deletions

View file

@ -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<GeometryCache>()->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();

View file

@ -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 {

View file

@ -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);

View file

@ -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;
}
}