/*
* Mesa 3-D graphics library
- * Version: 7.8
*
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
*
#include "glheader.h"
#include "condrender.h"
#include "enums.h"
+#include "mtypes.h"
#include "queryobj.h"
-GLAPI void GLAPIENTRY
+void GLAPIENTRY
_mesa_BeginConditionalRender(GLuint queryId, GLenum mode)
{
struct gl_query_object *q;
GET_CURRENT_CONTEXT(ctx);
- if (ctx->Query.CondRenderQuery) {
+ if (!ctx->Extensions.NV_conditional_render || ctx->Query.CondRenderQuery ||
+ queryId == 0) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glBeginConditionalRender()");
return;
}
}
ASSERT(q->Id == queryId);
- if (q->Target != GL_SAMPLES_PASSED) {
+ if (q->Target != GL_SAMPLES_PASSED || q->Active) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glBeginConditionalRender()");
return;
}
}
-GLAPI void APIENTRY
+void APIENTRY
_mesa_EndConditionalRender(void)
{
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Query.CondRenderQuery) {
+ FLUSH_VERTICES(ctx, 0x0);
+
+ if (!ctx->Extensions.NV_conditional_render || !ctx->Query.CondRenderQuery) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glEndConditionalRender()");
return;
}
/**
- * This function is called by software rendering commands to determine if
- * subsequent drawing commands should be executed or discarded depending
- * on the current conditional rendering state.
- * Ideally, this check would be implemented by the GPU when doing hardware
- * rendering.
- * XXX should this function be called via a new driver hook?
+ * This function is called by software rendering commands (all point,
+ * line triangle drawing, glClear, glDrawPixels, glCopyPixels, and
+ * glBitmap, glBlitFramebuffer) to determine if subsequent drawing
+ * commands should be
+ * executed or discarded depending on the current conditional
+ * rendering state. Ideally, this check would be implemented by the
+ * GPU when doing hardware rendering. XXX should this function be
+ * called via a new driver hook?
*
* \return GL_TRUE if we should render, GL_FALSE if we should discard
*/
GLboolean
-_mesa_check_conditional_render(GLcontext *ctx)
+_mesa_check_conditional_render(struct gl_context *ctx)
{
struct gl_query_object *q = ctx->Query.CondRenderQuery;
case GL_QUERY_BY_REGION_NO_WAIT:
/* fall-through */
case GL_QUERY_NO_WAIT:
+ if (!q->Ready)
+ ctx->Driver.CheckQuery(ctx, q);
return q->Ready ? (q->Result > 0) : GL_TRUE;
default:
_mesa_problem(ctx, "Bad cond render mode %s in "