diff options
author | Tom Stellard <[email protected]> | 2012-07-09 11:42:25 -0400 |
---|---|---|
committer | Tom Stellard <[email protected]> | 2012-07-09 12:14:07 -0400 |
commit | 9b00edc79a49bd9fdef9102e3d74828d93ee185e (patch) | |
tree | fa43411d05ff8011bc2a2844b00968d23fb9b451 /src/gallium/drivers | |
parent | 76b44034b9b234d3db4012342f0fae677d4f10f6 (diff) |
r600g: Don't create a texture for the memory_pool during screen init
This fixes a segfault in r600_screen_create() introduced by
eb065f5d9d1159af3a88a64a7606c9b6d67dc3
Reported by tilman on irc.
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/r600/compute_memory_pool.c | 30 | ||||
-rw-r--r-- | src/gallium/drivers/r600/r600_pipe.c | 2 |
2 files changed, 24 insertions, 8 deletions
diff --git a/src/gallium/drivers/r600/compute_memory_pool.c b/src/gallium/drivers/r600/compute_memory_pool.c index 648219b9eb9..0f8bee6e1cd 100644 --- a/src/gallium/drivers/r600/compute_memory_pool.c +++ b/src/gallium/drivers/r600/compute_memory_pool.c @@ -48,6 +48,9 @@ static struct r600_resource_texture * create_pool_texture(struct r600_screen * s struct pipe_resource templ; struct r600_resource_texture * tex; + if (size_in_dw == 0) { + return NULL; + } memset(&templ, 0, sizeof(templ)); templ.target = PIPE_TEXTURE_1D; templ.format = PIPE_FORMAT_R32_UINT; @@ -93,8 +96,10 @@ struct compute_memory_pool* compute_memory_pool_new( void compute_memory_pool_delete(struct compute_memory_pool* pool) { free(pool->shadow); - pool->screen->screen.resource_destroy((struct pipe_screen *) + if (pool->bo) { + pool->screen->screen.resource_destroy((struct pipe_screen *) pool->screen, (struct pipe_resource *)pool->bo); + } free(pool); } @@ -167,15 +172,24 @@ void compute_memory_grow_pool(struct compute_memory_pool* pool, new_size_in_dw += 1024 - (new_size_in_dw % 1024); - compute_memory_shadow(pool, pipe, 1); + if (pool->bo) { + compute_memory_shadow(pool, pipe, 1); + } pool->shadow = (uint32_t*)realloc(pool->shadow, new_size_in_dw*4); pool->size_in_dw = new_size_in_dw; - pool->screen->screen.resource_destroy( - (struct pipe_screen *)pool->screen, - (struct pipe_resource *)pool->bo); - pool->bo = (struct r600_resource*)create_pool_texture(pool->screen, + if (pool->bo) { + pool->screen->screen.resource_destroy( + (struct pipe_screen *)pool->screen, + (struct pipe_resource *)pool->bo); + pool->bo = (struct r600_resource*)create_pool_texture( + pool->screen, pool->size_in_dw); - compute_memory_shadow(pool, pipe, 0); + compute_memory_shadow(pool, pipe, 0); + } else { + pool->bo = (struct r600_resource*)create_pool_texture( + pool->screen, + pool->size_in_dw); + } } /** @@ -383,6 +397,8 @@ void compute_memory_transfer( struct pipe_transfer *xfer; uint32_t *map; + assert(gart); + if (device_to_host) { xfer = pipe->get_transfer(pipe, gart, 0, PIPE_TRANSFER_READ, diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c index 675834ed048..b354baecf65 100644 --- a/src/gallium/drivers/r600/r600_pipe.c +++ b/src/gallium/drivers/r600/r600_pipe.c @@ -952,7 +952,7 @@ struct pipe_screen *r600_screen_create(struct radeon_winsys *ws) rscreen->use_surface_alloc = debug_get_bool_option("R600_SURF", TRUE); rscreen->glsl_feature_level = debug_get_bool_option("R600_GLSL130", TRUE) ? 130 : 120; - rscreen->global_pool = compute_memory_pool_new(1024*16, rscreen); + rscreen->global_pool = compute_memory_pool_new(0, rscreen); return &rscreen->screen; } |