Module: Mesa Branch: 7.11 Commit: 521819f29c852634814aba45fe10b4378e7b343e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=521819f29c852634814aba45fe10b4378e7b343e
Author: Marek Olšák <[email protected]> Date: Fri Oct 21 00:31:06 2011 +0200 r300g: don't return NULL in resource_from_handle if the resource is too small The DDX may allocate a buffer with a too small size. Instead of failing, let's pretend everything's alright. Such bugs should be fixed in the DDX, of course. NOTE: This is a candidate for the stable branches. (cherry picked from commit a04f8c361211dda6a27c5577070492e17a2f4743) Conflicts: src/gallium/drivers/r300/r300_texture.c src/gallium/drivers/r300/r300_texture.h src/gallium/drivers/r300/r300_texture_desc.c --- src/gallium/drivers/r300/r300_texture.c | 22 ++++++---------------- src/gallium/drivers/r300/r300_texture.h | 8 ++++---- src/gallium/drivers/r300/r300_texture_desc.c | 20 +++++++++++--------- src/gallium/drivers/r300/r300_texture_desc.h | 6 +++--- 4 files changed, 24 insertions(+), 32 deletions(-) diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 62c2f1f..00ca1ad 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -824,10 +824,10 @@ static void r300_texture_setup_fb_state(struct r300_surface *surf) } } -boolean r300_resource_set_properties(struct pipe_screen *screen, - struct pipe_resource *tex, - unsigned offset, - const struct pipe_resource *new_properties) +void r300_resource_set_properties(struct pipe_screen *screen, + struct pipe_resource *tex, + unsigned offset, + const struct pipe_resource *new_properties) { struct r300_screen *rscreen = r300_screen(screen); struct r300_resource *res = r300_resource(tex); @@ -837,14 +837,9 @@ boolean r300_resource_set_properties(struct pipe_screen *screen, util_format_short_name(tex->format), util_format_short_name(new_properties->format)); - if (!r300_texture_desc_init(rscreen, res, new_properties)) { - fprintf(stderr, "r300: ERROR: Cannot set texture properties.\n"); - return FALSE; - } + r300_texture_desc_init(rscreen, res, new_properties); res->tex_offset = offset; r300_texture_setup_format_state(rscreen, res, 0, &res->tx_format); - - return TRUE; } static void r300_texture_destroy(struct pipe_screen *screen, @@ -915,12 +910,7 @@ r300_texture_create_object(struct r300_screen *rscreen, RADEON_DOMAIN_VRAM | RADEON_DOMAIN_GTT; tex->buf_size = max_buffer_size; - if (!r300_resource_set_properties(&rscreen->screen, &tex->b.b.b, 0, base)) { - if (buffer) - pb_reference(&buffer, NULL); - FREE(tex); - return NULL; - } + r300_resource_set_properties(&rscreen->screen, &tex->b.b.b, 0, base); /* Create the backing buffer if needed. */ if (!buffer) { diff --git a/src/gallium/drivers/r300/r300_texture.h b/src/gallium/drivers/r300/r300_texture.h index 4586bb2..911b609 100644 --- a/src/gallium/drivers/r300/r300_texture.h +++ b/src/gallium/drivers/r300/r300_texture.h @@ -50,10 +50,10 @@ uint32_t r300_translate_texformat(enum pipe_format format, uint32_t r500_tx_format_msb_bit(enum pipe_format format); -boolean r300_resource_set_properties(struct pipe_screen *screen, - struct pipe_resource *tex, - unsigned offset, - const struct pipe_resource *new_properties); +void r300_resource_set_properties(struct pipe_screen *screen, + struct pipe_resource *tex, + unsigned offset, + const struct pipe_resource *new_properties); boolean r300_is_colorbuffer_format_supported(enum pipe_format format); diff --git a/src/gallium/drivers/r300/r300_texture_desc.c b/src/gallium/drivers/r300/r300_texture_desc.c index da5778b..ae4f45a 100644 --- a/src/gallium/drivers/r300/r300_texture_desc.c +++ b/src/gallium/drivers/r300/r300_texture_desc.c @@ -473,9 +473,9 @@ static void r300_tex_print_info(struct r300_resource *tex, util_format_short_name(tex->b.b.b.format)); } -boolean r300_texture_desc_init(struct r300_screen *rscreen, - struct r300_resource *tex, - const struct pipe_resource *base) +void r300_texture_desc_init(struct r300_screen *rscreen, + struct r300_resource *tex, + const struct pipe_resource *base) { tex->b.b.b.target = base->target; tex->b.b.b.format = base->format; @@ -518,11 +518,15 @@ boolean r300_texture_desc_init(struct r300_screen *rscreen, if (tex->buf_size) { /* Make sure the buffer we got is large enough. */ if (tex->tex.size_in_bytes > tex->buf_size) { - fprintf(stderr, "r300: texture_desc_init: The buffer is not " - "large enough. Got: %i, Need: %i, Info:\n", - tex->buf_size, tex->tex.size_in_bytes); + fprintf(stderr, + "r300: I got a pre-allocated buffer to use it as a texture " + "storage, but the buffer is too small. I'll use the buffer " + "anyway, because I can't crash here, but it's dangerous. " + "This can be a DDX bug. Got: %iB, Need: %iB, Info:\n", + tex->buf_size, tex->tex.size_in_bytes); r300_tex_print_info(tex, "texture_desc_init"); - return FALSE; + /* Ooops, what now. Apps will break if we fail this, + * so just pretend everything's okay. */ } tex->tex.buffer_size_in_bytes = tex->buf_size; @@ -532,8 +536,6 @@ boolean r300_texture_desc_init(struct r300_screen *rscreen, if (SCREEN_DBG_ON(rscreen, DBG_TEX)) r300_tex_print_info(tex, "texture_desc_init"); - - return TRUE; } unsigned r300_texture_get_offset(struct r300_resource *tex, diff --git a/src/gallium/drivers/r300/r300_texture_desc.h b/src/gallium/drivers/r300/r300_texture_desc.h index a84d6fa..591592d 100644 --- a/src/gallium/drivers/r300/r300_texture_desc.h +++ b/src/gallium/drivers/r300/r300_texture_desc.h @@ -43,9 +43,9 @@ unsigned r300_get_pixel_alignment(enum pipe_format format, enum radeon_bo_layout macrotile, enum r300_dim dim, boolean is_rs690); -boolean r300_texture_desc_init(struct r300_screen *rscreen, - struct r300_resource *tex, - const struct pipe_resource *base); +void r300_texture_desc_init(struct r300_screen *rscreen, + struct r300_resource *tex, + const struct pipe_resource *base); unsigned r300_texture_get_offset(struct r300_resource *tex, unsigned level, unsigned layer); _______________________________________________ mesa-commit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-commit
