diff options
author | Charmaine Lee <[email protected]> | 2014-08-12 07:37:12 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2014-08-12 08:03:24 -0600 |
commit | 0c065270c0ff063edba03516b22d734023cac912 (patch) | |
tree | 33a6cf749f9a93cf1f24c3c9c747f659d28c3e97 /src/gallium/drivers/svga/svga_resource.c | |
parent | d839be24b3b53717fcc153c3d00afb1c516d926e (diff) |
svga: Add a limit to the maximum surface size
This patch adds a limit to the maximum surface size which is
based on the maximum size of a single mob. If this value is not
available, the maximum surface size is by default set to 128 MB.
Reviewed-by: Thomas Hellstrom <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/gallium/drivers/svga/svga_resource.c')
-rw-r--r-- | src/gallium/drivers/svga/svga_resource.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/gallium/drivers/svga/svga_resource.c b/src/gallium/drivers/svga/svga_resource.c index 79951b34db5..b295b44ea37 100644 --- a/src/gallium/drivers/svga/svga_resource.c +++ b/src/gallium/drivers/svga/svga_resource.c @@ -30,6 +30,7 @@ #include "svga_resource_texture.h" #include "svga_context.h" #include "svga_screen.h" +#include "svga_format.h" static struct pipe_resource * @@ -55,6 +56,47 @@ svga_resource_from_handle(struct pipe_screen * screen, } +/** + * Check if a resource (texture, buffer) of the given size + * and format can be created. + * \Return TRUE if OK, FALSE if too large. + */ +static boolean +svga_can_create_resource(struct pipe_screen *screen, + const struct pipe_resource *res) +{ + struct svga_screen *svgascreen = svga_screen(screen); + struct svga_winsys_screen *sws = svgascreen->sws; + SVGA3dSurfaceFormat format; + SVGA3dSize base_level_size; + uint32 numFaces; + uint32 numMipLevels; + + if (res->target == PIPE_BUFFER) { + format = SVGA3D_BUFFER; + base_level_size.width = res->width0; + base_level_size.height = 1; + base_level_size.depth = 1; + numFaces = 1; + numMipLevels = 1; + + } else { + format = svga_translate_format(svgascreen, res->format, res->bind); + if (format == SVGA3D_FORMAT_INVALID) + return FALSE; + + base_level_size.width = res->width0; + base_level_size.height = res->height0; + base_level_size.depth = res->depth0; + numFaces = (res->target == PIPE_TEXTURE_CUBE) ? 6 : 1; + numMipLevels = res->last_level + 1; + } + + return sws->surface_can_create(sws, format, base_level_size, + numFaces, numMipLevels); +} + + void svga_init_resource_functions(struct svga_context *svga) { @@ -71,4 +113,5 @@ svga_init_screen_resource_functions(struct svga_screen *is) is->screen.resource_from_handle = svga_resource_from_handle; is->screen.resource_get_handle = u_resource_get_handle_vtbl; is->screen.resource_destroy = u_resource_destroy_vtbl; + is->screen.can_create_resource = svga_can_create_resource; } |