aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2011-09-09 13:59:20 -0600
committerBrian Paul <[email protected]>2011-09-09 14:00:55 -0600
commit023ca40d80670ac0eee8c755ca5f54b1e7c2712e (patch)
tree60d74f33b72ddc79e742e39719f93b331ab91301
parente12b4752ef3cbc181d84c1eba672760f120ad346 (diff)
llvmpipe: add some null pointer checks
It's not clear if these are acceptable cases so issue a one-time warning in debug builds when we hit them. Fixes segfault in piglit fbo-mipmap-copypix test. Reviewed-by: José Fonseca <[email protected]>
-rw-r--r--src/gallium/drivers/llvmpipe/lp_rast.c26
-rw-r--r--src/gallium/drivers/llvmpipe/lp_rast_debug.c10
2 files changed, 35 insertions, 1 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c
index dafadc1ea9b..2bb61fcc7c4 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -339,6 +339,15 @@ lp_rast_shade_tile(struct lp_rasterizer_task *task,
const unsigned tile_x = task->x, tile_y = task->y;
unsigned x, y;
+ if (!variant) {
+ static boolean warned = FALSE;
+ if (!warned) {
+ debug_warning("null variant pointer");
+ warned = TRUE;
+ }
+ return;
+ }
+
if (inputs->disable) {
/* This command was partially binned and has been disabled */
return;
@@ -391,6 +400,19 @@ lp_rast_shade_tile_opaque(struct lp_rasterizer_task *task,
const struct lp_scene *scene = task->scene;
unsigned i;
+ if (!task->state) {
+ /* This indicates that some sort of rendering command was queued
+ * before we set up the rasterization state. Just returning here
+ * allows the piglit fbo-mipmap-copypix test to run/pass.
+ */
+ static boolean warned = FALSE;
+ if (!warned) {
+ debug_warning("null state pointer");
+ warned = TRUE;
+ }
+ return;
+ }
+
LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__);
/* this will prevent converting the layout from tiled to linear */
@@ -785,6 +807,10 @@ static PIPE_THREAD_ROUTINE( thread_func, init_data )
boolean debug = false;
while (1) {
+ /* make sure these pointers aren't pointing to old data */
+ task->scene = NULL;
+ task->state = NULL;
+
/* wait for work */
if (debug)
debug_printf("thread %d waiting for work\n", task->thread_index);
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_debug.c b/src/gallium/drivers/llvmpipe/lp_rast_debug.c
index 03e67dc8177..b7568ec99c0 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_debug.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast_debug.c
@@ -62,6 +62,9 @@ get_variant( const struct lp_rast_state *state,
const struct cmd_block *block,
int k )
{
+ if (!state)
+ return NULL;
+
if (block->cmd[k] == LP_RAST_OP_SHADE_TILE ||
block->cmd[k] == LP_RAST_OP_SHADE_TILE_OPAQUE ||
block->cmd[k] == LP_RAST_OP_TRIANGLE_1 ||
@@ -140,9 +143,14 @@ debug_shade_tile(int x, int y,
char val)
{
const struct lp_rast_shader_inputs *inputs = arg.shade_tile;
- boolean blend = tile->state->variant->key.blend.rt[0].blend_enable;
+ boolean blend;
unsigned i,j;
+ if (!tile->state)
+ return 0;
+
+ blend = tile->state->variant->key.blend.rt[0].blend_enable;
+
if (inputs->disable)
return 0;