diff options
Diffstat (limited to 'src/gallium/state_trackers/python/p_context.i')
-rw-r--r-- | src/gallium/state_trackers/python/p_context.i | 78 |
1 files changed, 55 insertions, 23 deletions
diff --git a/src/gallium/state_trackers/python/p_context.i b/src/gallium/state_trackers/python/p_context.i index 1fdbdf98b2..a40aa1e518 100644 --- a/src/gallium/state_trackers/python/p_context.i +++ b/src/gallium/state_trackers/python/p_context.i @@ -116,15 +116,17 @@ struct st_context { } void set_constant_buffer(unsigned shader, unsigned index, - struct st_buffer *buffer ) + struct pipe_buffer *buffer ) { struct pipe_constant_buffer state; memset(&state, 0, sizeof(state)); - state.buffer = buffer ? buffer->buffer : NULL; + state.buffer = buffer; $self->pipe->set_constant_buffer($self->pipe, shader, index, &state); } - void set_framebuffer(const struct pipe_framebuffer_state *state ) { + void set_framebuffer(const struct pipe_framebuffer_state *state ) + { + memcpy(&$self->framebuffer, state, sizeof *state); cso_set_framebuffer($self->cso, state); } @@ -151,19 +153,19 @@ struct st_context { } void set_vertex_buffer(unsigned index, - unsigned pitch, + unsigned stride, unsigned max_index, unsigned buffer_offset, - struct st_buffer *buffer) + struct pipe_buffer *buffer) { unsigned i; struct pipe_vertex_buffer state; memset(&state, 0, sizeof(state)); - state.stride = pitch; + state.stride = stride; state.max_index = max_index; state.buffer_offset = buffer_offset; - state.buffer = buffer ? buffer->buffer : NULL; + state.buffer = buffer; memcpy(&$self->vertex_buffers[index], &state, sizeof(state)); @@ -198,22 +200,22 @@ struct st_context { $self->pipe->draw_arrays($self->pipe, mode, start, count); } - void draw_elements( struct st_buffer *indexBuffer, + void draw_elements( struct pipe_buffer *indexBuffer, unsigned indexSize, unsigned mode, unsigned start, unsigned count) { $self->pipe->draw_elements($self->pipe, - indexBuffer->buffer, + indexBuffer, indexSize, mode, start, count); } - void draw_range_elements( struct st_buffer *indexBuffer, + void draw_range_elements( struct pipe_buffer *indexBuffer, unsigned indexSize, unsigned minIndex, unsigned maxIndex, unsigned mode, unsigned start, unsigned count) { $self->pipe->draw_range_elements($self->pipe, - indexBuffer->buffer, + indexBuffer, indexSize, minIndex, maxIndex, mode, start, count); } @@ -256,32 +258,62 @@ error1: flush(unsigned flags = 0) { struct pipe_fence_handle *fence = NULL; $self->pipe->flush($self->pipe, flags | PIPE_FLUSH_RENDER_CACHE, &fence); - /* TODO: allow asynchronous operation */ - $self->pipe->winsys->fence_finish( $self->pipe->winsys, fence, 0 ); - $self->pipe->winsys->fence_reference( $self->pipe->winsys, &fence, NULL ); + if(fence) { + /* TODO: allow asynchronous operation */ + $self->pipe->screen->fence_finish( $self->pipe->screen, fence, 0 ); + $self->pipe->screen->fence_reference( $self->pipe->screen, &fence, NULL ); + } } /* * Surface functions */ - void surface_copy(struct pipe_surface *dest, + void surface_copy(struct st_surface *dst, unsigned destx, unsigned desty, - struct pipe_surface *src, + struct st_surface *src, unsigned srcx, unsigned srcy, - unsigned width, unsigned height) { - $self->pipe->surface_copy($self->pipe, dest, destx, desty, src, srcx, srcy, width, height); + unsigned width, unsigned height) + { + struct pipe_surface *_dst = NULL; + struct pipe_surface *_src = NULL; + + _dst = st_pipe_surface(dst, PIPE_BUFFER_USAGE_GPU_WRITE); + if(!_dst) + SWIG_exception(SWIG_ValueError, "couldn't acquire destination surface for writing"); + + _src = st_pipe_surface(src, PIPE_BUFFER_USAGE_GPU_READ); + if(!_src) + SWIG_exception(SWIG_ValueError, "couldn't acquire source surface for reading"); + + $self->pipe->surface_copy($self->pipe, _dst, destx, desty, _src, srcx, srcy, width, height); + + fail: + pipe_surface_reference(&_src, NULL); + pipe_surface_reference(&_dst, NULL); } - void surface_fill(struct pipe_surface *dst, + void surface_fill(struct st_surface *dst, unsigned x, unsigned y, unsigned width, unsigned height, - unsigned value) { - $self->pipe->surface_fill($self->pipe, dst, x, y, width, height, value); + unsigned value) + { + struct pipe_surface *_dst = NULL; + + _dst = st_pipe_surface(dst, PIPE_BUFFER_USAGE_GPU_WRITE); + if(!_dst) + SWIG_exception(SWIG_ValueError, "couldn't acquire destination surface for writing"); + + $self->pipe->surface_fill($self->pipe, _dst, x, y, width, height, value); + + fail: + pipe_surface_reference(&_dst, NULL); } - void surface_clear(struct pipe_surface *surface, unsigned value = 0) { - $self->pipe->clear($self->pipe, surface, value); + void clear(unsigned buffers, const float *rgba, double depth = 0.0f, + unsigned stencil = 0) + { + $self->pipe->clear($self->pipe, buffers, rgba, depth, stencil); } }; |