diff options
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/auxiliary/vl/vl_idct.c | 25 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c | 65 |
2 files changed, 55 insertions, 35 deletions
diff --git a/src/gallium/auxiliary/vl/vl_idct.c b/src/gallium/auxiliary/vl/vl_idct.c index bc00ad79378..edc100d4a29 100644 --- a/src/gallium/auxiliary/vl/vl_idct.c +++ b/src/gallium/auxiliary/vl/vl_idct.c @@ -338,21 +338,21 @@ xfer_buffers_unmap(struct vl_idct *idct) static bool init_shaders(struct vl_idct *idct) { - assert(idct); - assert(idct->vs = create_vert_shader(idct)); assert(idct->transpose_fs = create_transpose_frag_shader(idct)); assert(idct->matrix_fs = create_matrix_frag_shader(idct)); assert(idct->eb_fs = create_empty_block_frag_shader(idct)); - return true; + return + idct->vs != NULL && + idct->transpose_fs != NULL && + idct->matrix_fs != NULL && + idct->eb_fs != NULL; } static void cleanup_shaders(struct vl_idct *idct) { - assert(idct); - idct->pipe->delete_vs_state(idct->pipe, idct->vs); idct->pipe->delete_fs_state(idct->pipe, idct->transpose_fs); idct->pipe->delete_fs_state(idct->pipe, idct->matrix_fs); @@ -365,14 +365,13 @@ init_buffers(struct vl_idct *idct) struct pipe_resource template; struct pipe_sampler_view sampler_view; struct pipe_vertex_element vertex_elems[2]; + unsigned i; idct->max_blocks = align(idct->destination->width0, BLOCK_WIDTH) / BLOCK_WIDTH * align(idct->destination->height0, BLOCK_HEIGHT) / BLOCK_HEIGHT * idct->destination->depth0; - unsigned i; - memset(&template, 0, sizeof(struct pipe_resource)); template.target = PIPE_TEXTURE_2D; template.format = PIPE_FORMAT_R16_SNORM; @@ -398,6 +397,9 @@ init_buffers(struct vl_idct *idct) idct->textures.individual.intermediate = idct->pipe->screen->resource_create(idct->pipe->screen, &template); for (i = 0; i < 4; ++i) { + if(idct->textures.all[i] == NULL) + return false; /* a texture failed to allocate */ + u_sampler_view_default_template(&sampler_view, idct->textures.all[i], idct->textures.all[i]->format); idct->sampler_views.all[i] = idct->pipe->create_sampler_view(idct->pipe, idct->textures.all[i], &sampler_view); } @@ -412,6 +414,9 @@ init_buffers(struct vl_idct *idct) sizeof(struct vertex2f) * 4 * idct->max_blocks ); + if(idct->vertex_bufs.individual.quad.buffer == NULL) + return false; + idct->vertex_bufs.individual.pos.stride = sizeof(struct vertex2f); idct->vertex_bufs.individual.pos.max_index = 4 * idct->max_blocks - 1; idct->vertex_bufs.individual.pos.buffer_offset = 0; @@ -422,6 +427,9 @@ init_buffers(struct vl_idct *idct) sizeof(struct vertex2f) * 4 * idct->max_blocks ); + if(idct->vertex_bufs.individual.pos.buffer == NULL) + return false; + /* Rect element */ vertex_elems[0].src_offset = 0; vertex_elems[0].instance_divisor = 0; @@ -443,6 +451,9 @@ init_buffers(struct vl_idct *idct) sizeof(struct vertex_shader_consts) ); + if(idct->vs_const_buf == NULL) + return false; + return true; } diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c index 15def609348..32728413700 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c @@ -786,7 +786,7 @@ init_buffers(struct vl_mpeg12_mc_renderer *r) return true; } -static bool +static void init_const_buffers(struct vl_mpeg12_mc_renderer *r) { struct pipe_transfer *buf_transfer; @@ -805,8 +805,6 @@ init_const_buffers(struct vl_mpeg12_mc_renderer *r) memcpy(rect + i * 4, &const_quad, sizeof(const_quad)); pipe_buffer_unmap(r->pipe, r->vertex_bufs.individual.rect.buffer, buf_transfer); - - return true; } static void @@ -1308,40 +1306,51 @@ vl_mpeg12_mc_renderer_init(struct vl_mpeg12_mc_renderer *renderer, if (!renderer->texview_map) return false; - if (!init_pipe_state(renderer)) { - util_delete_keymap(renderer->texview_map, renderer->pipe); - return false; - } - if (!init_shaders(renderer)) { - util_delete_keymap(renderer->texview_map, renderer->pipe); - cleanup_pipe_state(renderer); - return false; - } - if (!init_buffers(renderer)) { - util_delete_keymap(renderer->texview_map, renderer->pipe); - cleanup_shaders(renderer); - cleanup_pipe_state(renderer); - return false; - } + if (!init_pipe_state(renderer)) + goto error_pipe_state; - if (!init_const_buffers(renderer)) { - util_delete_keymap(renderer->texview_map, renderer->pipe); - cleanup_pipe_state(renderer); - cleanup_shaders(renderer); - cleanup_buffers(renderer); - return false; - } + if (!init_shaders(renderer)) + goto error_shaders; + + if (!init_buffers(renderer)) + goto error_buffers; + + init_const_buffers(renderer); renderer->surface = NULL; renderer->past = NULL; renderer->future = NULL; renderer->num_macroblocks = 0; - vl_idct_init(&renderer->idct_y, pipe, renderer->textures.individual.y); - vl_idct_init(&renderer->idct_cr, pipe, renderer->textures.individual.cr); - vl_idct_init(&renderer->idct_cb, pipe, renderer->textures.individual.cb); + if(!vl_idct_init(&renderer->idct_y, pipe, renderer->textures.individual.y)) + goto error_idct_y; + + if(!vl_idct_init(&renderer->idct_cr, pipe, renderer->textures.individual.cr)) + goto error_idct_cr; + + if(!vl_idct_init(&renderer->idct_cb, pipe, renderer->textures.individual.cb)) + goto error_idct_cb; return true; + +error_idct_cb: + vl_idct_cleanup(&renderer->idct_cr); + +error_idct_cr: + vl_idct_cleanup(&renderer->idct_y); + +error_idct_y: + cleanup_buffers(renderer); + +error_buffers: + cleanup_shaders(renderer); + +error_shaders: + cleanup_pipe_state(renderer); + +error_pipe_state: + util_delete_keymap(renderer->texview_map, renderer->pipe); + return false; } void |