From c8bf63e992f902f1bef0c20e5b50f397c4d219a7 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 15 Oct 2007 11:28:25 -0600 Subject: [PATCH] feedback/rasterpos fix-ups --- src/mesa/pipe/i915simple/i915_context.c | 23 +++++++++++++++++++ src/mesa/pipe/i915simple/i915_context.h | 4 ++++ src/mesa/pipe/i915simple/i915_state.c | 30 +++++++++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c index 5d97eed247e..8150fcfbf5e 100644 --- a/src/mesa/pipe/i915simple/i915_context.c +++ b/src/mesa/pipe/i915simple/i915_context.c @@ -212,6 +212,19 @@ static boolean i915_draw_elements( struct pipe_context *pipe, draw_set_mapped_element_buffer(draw, 0, NULL); } + /* Map feedback buffers if enabled */ + if (i915->feedback.enabled) { + const uint n = i915->feedback.interleaved ? 1 : i915->feedback.num_attribs; + for (i = 0; i < n; i++) { + void *ptr = pipe->winsys->buffer_map(pipe->winsys, + i915->feedback_buffer[i].buffer, + PIPE_BUFFER_FLAG_WRITE); + draw_set_mapped_feedback_buffer(draw, i, ptr, + i915->feedback_buffer[i].size); + } + } + + draw_set_mapped_constant_buffer(draw, i915->current.constants[PIPE_SHADER_VERTEX]); @@ -232,6 +245,16 @@ static boolean i915_draw_elements( struct pipe_context *pipe, draw_set_mapped_element_buffer(draw, 0, NULL); } + /* Unmap feedback buffers if enabled */ + if (i915->feedback.enabled) { + const uint n = i915->feedback.interleaved ? 1 : i915->feedback.num_attribs; + for (i = 0; i < n; i++) { + pipe->winsys->buffer_unmap(pipe->winsys, + i915->feedback_buffer[i].buffer); + draw_set_mapped_feedback_buffer(draw, i, NULL, 0); + } + } + return TRUE; } diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h index dc19b6efeb9..a3dd392e755 100644 --- a/src/mesa/pipe/i915simple/i915_context.h +++ b/src/mesa/pipe/i915simple/i915_context.h @@ -169,6 +169,7 @@ struct i915_context struct pipe_clear_color_state clear_color; struct pipe_clip_state clip; struct pipe_constant_buffer constants[PIPE_SHADER_TYPES]; + struct pipe_feedback_state feedback; struct pipe_framebuffer_state framebuffer; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; @@ -176,6 +177,9 @@ struct i915_context struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; + /** Feedback buffers */ + struct pipe_feedback_buffer feedback_buffer[PIPE_MAX_FEEDBACK_ATTRIBS]; + unsigned dirty; unsigned *batch_start; diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c index 19ca5e575fb..4a31747fe85 100644 --- a/src/mesa/pipe/i915simple/i915_state.c +++ b/src/mesa/pipe/i915simple/i915_state.c @@ -550,6 +550,33 @@ static void i915_set_framebuffer_state(struct pipe_context *pipe, } +static void +i915_set_feedback_state(struct pipe_context *pipe, + const struct pipe_feedback_state *feedback) +{ + struct i915_context *i915 = i915_context(pipe); + i915->feedback = *feedback; + draw_set_feedback_state(i915->draw, feedback); +} + + +static void +i915_set_feedback_buffer(struct pipe_context *pipe, + unsigned index, + const struct pipe_feedback_buffer *feedback) +{ + struct i915_context *i915 = i915_context(pipe); + + assert(index < PIPE_MAX_FEEDBACK_ATTRIBS); + + /* Need to be careful with referencing */ + pipe->winsys->buffer_reference(pipe->winsys, + &i915->feedback_buffer[index].buffer, + feedback->buffer); + i915->feedback_buffer[index].size = feedback->size; + i915->feedback_buffer[index].start_offset = feedback->start_offset; +} + static void i915_set_clear_color_state(struct pipe_context *pipe, @@ -731,6 +758,9 @@ i915_init_state_functions( struct i915_context *i915 ) i915->pipe.set_clear_color_state = i915_set_clear_color_state; i915->pipe.set_constant_buffer = i915_set_constant_buffer; i915->pipe.set_framebuffer_state = i915_set_framebuffer_state; + i915->pipe.set_feedback_state = i915_set_feedback_state; + i915->pipe.set_feedback_buffer = i915_set_feedback_buffer; + i915->pipe.set_polygon_stipple = i915_set_polygon_stipple; i915->pipe.set_scissor_state = i915_set_scissor_state; i915->pipe.set_texture_state = i915_set_texture_state; -- 2.30.2