diff options
author | Marek Olšák <[email protected]> | 2017-02-15 15:07:03 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-02-18 01:22:08 +0100 |
commit | f246ae1ee9b543ccd878a60a9cdb6f25d66a8d4e (patch) | |
tree | 11dd4cdbf96e7f2911cbc7d44803f21f54879094 /src/gallium | |
parent | c8d84801b76aa0bfb04f5adcfb83335ee54b01e6 (diff) |
vl: fix a buffer leak in the bicubic filter by using an uploader
there's no error checking, because the previous code didn't do it either.
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/auxiliary/vl/vl_bicubic_filter.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/src/gallium/auxiliary/vl/vl_bicubic_filter.c b/src/gallium/auxiliary/vl/vl_bicubic_filter.c index 774702c600e..570f1538583 100644 --- a/src/gallium/auxiliary/vl/vl_bicubic_filter.c +++ b/src/gallium/auxiliary/vl/vl_bicubic_filter.c @@ -35,6 +35,7 @@ #include "util/u_memory.h" #include "util/u_math.h" #include "util/u_rect.h" +#include "util/u_upload_mgr.h" #include "vl_types.h" #include "vl_vertex_buffers.h" @@ -384,8 +385,7 @@ vl_bicubic_filter_render(struct vl_bicubic_filter *filter, struct pipe_framebuffer_state fb_state; struct pipe_scissor_state scissor; union pipe_color_union clear_color; - struct pipe_transfer *buf_transfer; - struct pipe_resource *surface_size; + assert(filter && src && dst); if (dst_clip) { @@ -402,14 +402,6 @@ vl_bicubic_filter_render(struct vl_bicubic_filter *filter, clear_color.f[0] = clear_color.f[1] = 0.0f; clear_color.f[2] = clear_color.f[3] = 0.0f; - surface_size = pipe_buffer_create - ( - filter->pipe->screen, - PIPE_BIND_CONSTANT_BUFFER, - PIPE_USAGE_DEFAULT, - 2*sizeof(float) - ); - memset(&viewport, 0, sizeof(viewport)); if(dst_area){ @@ -423,14 +415,16 @@ vl_bicubic_filter_render(struct vl_bicubic_filter *filter, } viewport.scale[2] = 1; - float *ptr = pipe_buffer_map(filter->pipe, surface_size, - PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE, - &buf_transfer); + struct pipe_constant_buffer cb = {}; + float *ptr; + + u_upload_alloc(filter->pipe->const_uploader, 0, 2 * sizeof(float), 256, + &cb.buffer_offset, &cb.buffer, (void**)&ptr); + cb.buffer_size = 2 * sizeof(float); ptr[0] = 0.5f/viewport.scale[0]; ptr[1] = 0.5f/viewport.scale[1]; - - pipe_buffer_unmap(filter->pipe, buf_transfer); + u_upload_unmap(filter->pipe->const_uploader); memset(&fb_state, 0, sizeof(fb_state)); fb_state.width = dst->width; @@ -441,7 +435,8 @@ vl_bicubic_filter_render(struct vl_bicubic_filter *filter, filter->pipe->set_scissor_states(filter->pipe, 0, 1, &scissor); filter->pipe->clear_render_target(filter->pipe, dst, &clear_color, 0, 0, dst->width, dst->height, false); - pipe_set_constant_buffer(filter->pipe, PIPE_SHADER_FRAGMENT, 0, surface_size); + filter->pipe->set_constant_buffer(filter->pipe, PIPE_SHADER_FRAGMENT, + 0, &cb); filter->pipe->bind_rasterizer_state(filter->pipe, filter->rs_state); filter->pipe->bind_blend_state(filter->pipe, filter->blend); filter->pipe->bind_sampler_states(filter->pipe, PIPE_SHADER_FRAGMENT, |