Mesa (master): glhd: Add query protection.
Corbin Simpson
csimpson at kemper.freedesktop.org
Wed Jun 23 07:12:51 UTC 2010
Module: Mesa
Branch: master
Commit: a6cc91487446f8e1e72e4f67823a359c0b3a41d6
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a6cc91487446f8e1e72e4f67823a359c0b3a41d6
Author: Corbin Simpson <MostAwesomeDude at gmail.com>
Date: Tue Jun 22 23:11:01 2010 -0700
glhd: Add query protection.
Not quite copied from r300g. This is slightly more API-compliant.
---
src/gallium/drivers/galahad/glhd_context.c | 10 ++++++++++
src/gallium/drivers/r300/r300_query.c | 4 +++-
2 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/src/gallium/drivers/galahad/glhd_context.c b/src/gallium/drivers/galahad/glhd_context.c
index 7a856ef..5531f57 100644
--- a/src/gallium/drivers/galahad/glhd_context.c
+++ b/src/gallium/drivers/galahad/glhd_context.c
@@ -119,6 +119,16 @@ galahad_create_query(struct pipe_context *_pipe,
struct galahad_context *glhd_pipe = galahad_context(_pipe);
struct pipe_context *pipe = glhd_pipe->pipe;
+ if (query_type == PIPE_QUERY_OCCLUSION_COUNTER &&
+ !pipe->screen->get_param(pipe->screen, PIPE_CAP_OCCLUSION_QUERY)) {
+ glhd_error("Occlusion query requested but not supported");
+ }
+
+ if (query_type == PIPE_QUERY_TIME_ELAPSED &&
+ !pipe->screen->get_param(pipe->screen, PIPE_CAP_TIMER_QUERY)) {
+ glhd_error("Timer query requested but not supported");
+ }
+
return pipe->create_query(pipe,
query_type);
}
diff --git a/src/gallium/drivers/r300/r300_query.c b/src/gallium/drivers/r300/r300_query.c
index 10cb468..10086ee 100644
--- a/src/gallium/drivers/r300/r300_query.c
+++ b/src/gallium/drivers/r300/r300_query.c
@@ -37,7 +37,9 @@ static struct pipe_query *r300_create_query(struct pipe_context *pipe,
struct r300_screen *r300screen = r300->screen;
struct r300_query *q;
- assert(query_type == PIPE_QUERY_OCCLUSION_COUNTER);
+ if (query_type != PIPE_QUERY_OCCLUSION_COUNTER) {
+ return NULL;
+ }
q = CALLOC_STRUCT(r300_query);
if (!q)
More information about the mesa-commit
mailing list