From ba2985727366f4d2d8292f7c55f55738b90bc126 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Mon, 4 Jul 2011 23:03:07 +0200 Subject: [PATCH 2/2] Workaround for Blender's manipulators not working --- src/mesa/main/enable.c | 7 +++++-- src/mesa/main/feedback.c | 13 +++++-------- src/mesa/state_tracker/st_cb_feedback.c | 5 +++++ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index aac8b9c..68fb8f4 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -341,8 +341,11 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) case GL_DEPTH_TEST: if (ctx->Depth.Test == state) return; - FLUSH_VERTICES(ctx, _NEW_DEPTH); - ctx->Depth.Test = state; + /* depth mode selection is only valid in GL_RENDER mode */ + if (ctx->RenderMode == GL_RENDER) { + FLUSH_VERTICES(ctx, _NEW_DEPTH); + ctx->Depth.Test = state; + } break; case GL_DITHER: if (ctx->Color.DitherFlag == state) diff --git a/src/mesa/main/feedback.c b/src/mesa/main/feedback.c index 6627f3f..01f9454 100644 --- a/src/mesa/main/feedback.c +++ b/src/mesa/main/feedback.c @@ -117,7 +117,7 @@ _mesa_init_select_emulation(struct gl_context* ctx) { if (ctx->Select._OffscreenSurface == 0) { - ctx->Select._OffscreenSurfaceWidth = ctx->Select._OffscreenSurfaceHeight = 1; + ctx->Select._OffscreenSurfaceWidth = ctx->Select._OffscreenSurfaceHeight = 128; ctx->Select._OffscreenSurface = _mesa_init_select_fbo(ctx); } @@ -351,7 +351,7 @@ void _mesa_select_clear_fbo(struct gl_context *ctx) _mesa_Scissor(0, 0, ctx->Select.BatchSize * ctx->Select._OffscreenSurfaceWidth, ctx->Select._OffscreenSurfaceHeight); _mesa_ClearDepth(1.0f); - _mesa_Clear(GL_DEPTH_BUFFER_BIT); + _mesa_Clear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); /* clear upper part which holds maxZ */ _mesa_Scissor( @@ -384,17 +384,16 @@ _mesa_exec_select_batch(struct gl_context *ctx) /* gather query result */ GLint queryResult; _mesa_GetQueryObjectivARB(ctx->Select._Queries[i], GL_QUERY_RESULT_ARB, &queryResult); - if (queryResult) { + if (queryResult) { fprintf(stderr, "query_result[%d]: %d\n", i, queryResult); int count = 0; int xOffset = ctx->Select._OffscreenSurfaceWidth * i; - float minZ = 1, maxZ = -1; + float minZ = 1, maxZ = 0; for(int y=0; ySelect._OffscreenSurfaceHeight /*&& count < queryResult*/; y++) { for(int x=0; xSelect._OffscreenSurfaceWidth /*&& count < queryResult*/; x++) { { float z = buffer[y * fboW + xOffset + x]; - // fprintf(stderr, " %.1f", z); if (z < 1.0) { if (z < minZ) minZ = z; @@ -403,7 +402,6 @@ _mesa_exec_select_batch(struct gl_context *ctx) } { float z = buffer[(y + ctx->Select._OffscreenSurfaceHeight) * fboW + xOffset + x]; - // fprintf(stderr, " %.3f", z); if (z > 0.0) { if (z > maxZ) maxZ = z; @@ -411,9 +409,8 @@ _mesa_exec_select_batch(struct gl_context *ctx) } } } - //fprintf(stderr, "\n"); } - if (count) { + if (queryResult || count) { fprintf(stderr, "count[%d]: %d\n", i, count); write_hit_record(ctx, minZ, maxZ, ctx->Select.SelectBatch[i].NameStackDepth, diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c index b10f8b7..f83041f 100644 --- a/src/mesa/state_tracker/st_cb_feedback.c +++ b/src/mesa/state_tracker/st_cb_feedback.c @@ -277,6 +277,7 @@ GLuint depthSave; struct gl_viewport_attrib vpSave; struct gl_scissor_attrib scissorSave; GLenum depthFuncSave; +GLboolean depthMaskSave; GLclampd depthClearSave; static void @@ -294,8 +295,10 @@ init_select_mode(struct gl_context *ctx) depthClearSave = ctx->Depth.Clear; depthFuncSave = ctx->Depth.Func; + depthMaskSave= ctx->Depth.Mask; _mesa_set_enable(ctx, GL_DEPTH_TEST, GL_TRUE); _mesa_set_enable(ctx, GL_SCISSOR_TEST, GL_FALSE); + _mesa_DepthMask(GL_TRUE); //_mesa_update_state(ctx); stateSaved = true; @@ -315,6 +318,7 @@ exit_select_mode(struct gl_context *ctx) _mesa_set_enable(ctx, GL_DEPTH_TEST, depthSave); _mesa_DepthFunc(depthFuncSave); _mesa_ClearDepth(depthClearSave); + _mesa_DepthMask(depthMaskSave); } stateSaved = false; _mesa_update_state(ctx); @@ -345,6 +349,7 @@ select_draw_func (struct gl_context *ctx, /* called once par object */ assert(ctx->ReadBuffer->Name == ctx->Select._OffscreenSurface); assert(ctx->DrawBuffer->Name == ctx->Select._OffscreenSurface); + assert(ctx->Depth.Mask == GL_TRUE); /* draw object for minZ*/ assert(ctx->Select.BatchEntryCount > 0); -- 1.7.5.4