summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2010-06-30 11:57:14 -0600
committerBrian Paul <[email protected]>2010-06-30 14:05:45 -0600
commit2b3e1ad731d2bd095a680d3120619972a7eb0242 (patch)
treeb1963207479242c9ba38c575d339424c0021d74c /src/gallium
parenteffd33071e7b10bdd2f0c198fc34210202b574cc (diff)
llvmpipe: use dummy tile when out of memory
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_rast.c12
-rw-r--r--src/gallium/drivers/llvmpipe/lp_rast_priv.h23
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup.c12
3 files changed, 33 insertions, 14 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c
index 1fadb9cca1e..1a82dd5694e 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -81,7 +81,6 @@ lp_rast_begin( struct lp_rasterizer *rast,
zsbuf->zslice,
LP_TEX_USAGE_READ_WRITE,
LP_TEX_LAYOUT_NONE);
- assert(rast->zsbuf.map);
}
lp_scene_bin_iter_begin( scene );
@@ -188,7 +187,7 @@ lp_rast_tile_begin(struct lp_rasterizer_task *task,
/* Get actual pointer to the tile data. Note that depth/stencil
* data is tiled differently than color data.
*/
- task->depth_tile = lp_rast_get_depth_block_pointer(rast, x, y);
+ task->depth_tile = lp_rast_get_depth_block_pointer(task, x, y);
assert(task->depth_tile);
}
@@ -286,7 +285,10 @@ lp_rast_clear_zstencil(struct lp_rasterizer_task *task,
dst = task->depth_tile;
- assert(dst == lp_rast_get_depth_block_pointer(rast, task->x, task->y));
+ if (lp_is_dummy_tile(dst))
+ return;
+
+ assert(dst == lp_rast_get_depth_block_pointer(task, task->x, task->y));
switch (block_size) {
case 1:
@@ -442,7 +444,7 @@ lp_rast_shade_tile(struct lp_rasterizer_task *task,
tile_x + x, tile_y + y);
/* depth buffer */
- depth = lp_rast_get_depth_block_pointer(rast, tile_x + x, tile_y + y);
+ depth = lp_rast_get_depth_block_pointer(task, tile_x + x, tile_y + y);
/* run shader on 4x4 block */
variant->jit_function[RAST_WHOLE]( &state->jit_context,
@@ -494,7 +496,7 @@ void lp_rast_shade_quads( struct lp_rasterizer_task *task,
}
/* depth buffer */
- depth = lp_rast_get_depth_block_pointer(rast, x, y);
+ depth = lp_rast_get_depth_block_pointer(task, x, y);
assert(lp_check_alignment(state->jit_context.blend_color, 16));
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
index 9bded086efc..eb4175dfa67 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
@@ -31,6 +31,7 @@
#include "os/os_thread.h"
#include "util/u_format.h"
#include "gallivm/lp_bld_debug.h"
+#include "lp_memory.h"
#include "lp_rast.h"
#include "lp_scene.h"
#include "lp_state.h"
@@ -132,18 +133,20 @@ void lp_rast_shade_quads( struct lp_rasterizer_task *task,
* \param x, y location of 4x4 block in window coords
*/
static INLINE void *
-lp_rast_get_depth_block_pointer(const struct lp_rasterizer *rast,
+lp_rast_get_depth_block_pointer(struct lp_rasterizer_task *task,
unsigned x, unsigned y)
{
+ const struct lp_rasterizer *rast = task->rast;
void *depth;
assert((x % TILE_VECTOR_WIDTH) == 0);
assert((y % TILE_VECTOR_HEIGHT) == 0);
- assert(rast->zsbuf.map || !rast->curr_scene->fb.zsbuf);
-
- if (!rast->zsbuf.map)
- return NULL;
+ if (!rast->zsbuf.map && (task->current_state->variant->key.depth.enabled ||
+ task->current_state->variant->key.stencil[0].enabled)) {
+ /* out of memory - use dummy tile memory */
+ return lp_get_dummy_tile();
+ }
depth = (rast->zsbuf.map +
rast->zsbuf.stride * y +
@@ -172,8 +175,10 @@ lp_rast_get_color_block_pointer(struct lp_rasterizer_task *task,
assert((y % TILE_VECTOR_HEIGHT) == 0);
color = task->color_tiles[buf];
- if (!color)
- return NULL;
+ if (!color) {
+ /* out of memory - use dummy tile memory */
+ return lp_get_dummy_tile();
+ }
px = x % TILE_SIZE;
py = y % TILE_SIZE;
@@ -197,7 +202,7 @@ lp_rast_shade_quads_all( struct lp_rasterizer_task *task,
const struct lp_rast_shader_inputs *inputs,
unsigned x, unsigned y )
{
- struct lp_rasterizer *rast = task->rast;
+ const struct lp_rasterizer *rast = task->rast;
const struct lp_rast_state *state = task->current_state;
struct lp_fragment_shader_variant *variant = state->variant;
uint8_t *color[PIPE_MAX_COLOR_BUFS];
@@ -208,7 +213,7 @@ lp_rast_shade_quads_all( struct lp_rasterizer_task *task,
for (i = 0; i < rast->state.nr_cbufs; i++)
color[i] = lp_rast_get_color_block_pointer(task, i, x, y);
- depth = lp_rast_get_depth_block_pointer(rast, x, y);
+ depth = lp_rast_get_depth_block_pointer(task, x, y);
/* run shader on 4x4 block */
variant->jit_function[RAST_WHOLE]( &state->jit_context,
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index 158f9e88ccf..2597fa8f71b 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -40,6 +40,7 @@
#include "util/u_memory.h"
#include "util/u_pack_color.h"
#include "lp_context.h"
+#include "lp_memory.h"
#include "lp_scene.h"
#include "lp_scene_queue.h"
#include "lp_texture.h"
@@ -622,6 +623,17 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
LP_TEX_LAYOUT_LINEAR);
jit_tex->row_stride[j] = lp_tex->row_stride[j];
jit_tex->img_stride[j] = lp_tex->img_stride[j];
+
+ if (!jit_tex->data[j]) {
+ /* out of memory - use dummy tile memory */
+ jit_tex->data[j] = lp_get_dummy_tile();
+ jit_tex->width = TILE_SIZE;
+ jit_tex->height = TILE_SIZE;
+ jit_tex->depth = 1;
+ jit_tex->last_level = 0;
+ jit_tex->row_stride[j] = 0;
+ jit_tex->img_stride[j] = 0;
+ }
}
}
else {