diff options
author | Brian Paul <[email protected]> | 2012-09-16 19:44:07 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2012-09-17 19:49:27 -0600 |
commit | 7d624799b9db3a4a6e52682ad94928202d961f5b (patch) | |
tree | 186810a38e6010f0c33826ce3b278f7b105eb874 /src/gallium/drivers/softpipe/sp_texture.c | |
parent | b9e88c55927b9d62c48ed034baae1d3ac09713b0 (diff) |
softpipe: implement the new can_create_resource() function
And define a SP_MAX_TEXTURE_SIZE value as we do in llvmpipe.
Reviewed-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src/gallium/drivers/softpipe/sp_texture.c')
-rw-r--r-- | src/gallium/drivers/softpipe/sp_texture.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index 978fbe1fe67..50137fe6227 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -52,7 +52,8 @@ */ static boolean softpipe_resource_layout(struct pipe_screen *screen, - struct softpipe_resource *spr) + struct softpipe_resource *spr, + boolean allocate) { struct pipe_resource *pt = &spr->base; unsigned level; @@ -83,9 +84,31 @@ softpipe_resource_layout(struct pipe_screen *screen, depth = u_minify(depth, 1); } - spr->data = align_malloc(buffer_size, 16); + if (buffer_size > SP_MAX_TEXTURE_SIZE) + return FALSE; + + if (allocate) { + spr->data = align_malloc(buffer_size, 16); + return spr->data != NULL; + } + else { + return TRUE; + } +} - return spr->data != NULL; + +/** + * Check the size of the texture specified by 'res'. + * \return TRUE if OK, FALSE if too large. + */ +static boolean +softpipe_can_create_resource(struct pipe_screen *screen, + const struct pipe_resource *res) +{ + struct softpipe_resource spr; + memset(&spr, 0, sizeof(spr)); + spr.base = *res; + return softpipe_resource_layout(screen, &spr, FALSE); } @@ -140,7 +163,7 @@ softpipe_resource_create(struct pipe_screen *screen, goto fail; } else { - if (!softpipe_resource_layout(screen, spr)) + if (!softpipe_resource_layout(screen, spr, TRUE)) goto fail; } @@ -506,4 +529,5 @@ softpipe_init_screen_texture_funcs(struct pipe_screen *screen) screen->resource_destroy = softpipe_resource_destroy; screen->resource_from_handle = softpipe_resource_from_handle; screen->resource_get_handle = softpipe_resource_get_handle; + screen->can_create_resource = softpipe_can_create_resource; } |