aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/sources.mak1
-rw-r--r--src/mesa/state_tracker/st_cb_accum.c3
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.c60
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.h6
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c31
-rw-r--r--src/mesa/state_tracker/st_cb_clear.h3
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c2
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c2
-rw-r--r--src/mesa/state_tracker/st_cb_flush.c11
-rw-r--r--src/mesa/state_tracker/st_cb_readpixels.c4
-rw-r--r--src/mesa/state_tracker/st_context.h2
-rw-r--r--src/mesa/state_tracker/st_draw.c242
-rw-r--r--src/mesa/state_tracker/st_draw.h5
-rw-r--r--src/mesa/state_tracker/st_draw_feedback.c262
-rw-r--r--src/mesa/state_tracker/st_mesa_to_tgsi.c12
15 files changed, 393 insertions, 253 deletions
diff --git a/src/mesa/sources.mak b/src/mesa/sources.mak
index 14fd8597a8f..9ebac8e1cd1 100644
--- a/src/mesa/sources.mak
+++ b/src/mesa/sources.mak
@@ -201,6 +201,7 @@ STATETRACKER_SOURCES = \
state_tracker/st_context.c \
state_tracker/st_debug.c \
state_tracker/st_draw.c \
+ state_tracker/st_draw_feedback.c \
state_tracker/st_extensions.c \
state_tracker/st_format.c \
state_tracker/st_framebuffer.c \
diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c
index cf3a99e7e9d..a4e72b48ed4 100644
--- a/src/mesa/state_tracker/st_cb_accum.c
+++ b/src/mesa/state_tracker/st_cb_accum.c
@@ -38,6 +38,7 @@
#include "st_cb_accum.h"
#include "st_cb_fbo.h"
#include "st_draw.h"
+#include "st_public.h"
#include "st_format.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
@@ -324,7 +325,7 @@ st_Accum(GLcontext *ctx, GLenum op, GLfloat value)
const GLint height = ctx->DrawBuffer->_Ymax - ypos;
/* make sure color bufs aren't cached */
- pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
+ st_flush( st, PIPE_FLUSH_RENDER_CACHE, NULL );
switch (op) {
case GL_ADD:
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index aa68aa9e3c1..f14e562400b 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -349,8 +349,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
return pt;
}
-
-static void
+static GLuint
setup_bitmap_vertex_data(struct st_context *st,
int x, int y, int width, int height,
float z, const float color[4])
@@ -369,12 +368,18 @@ setup_bitmap_vertex_data(struct st_context *st,
const GLfloat clip_y0 = (GLfloat)(y0 / fb_height * 2.0 - 1.0);
const GLfloat clip_x1 = (GLfloat)(x1 / fb_width * 2.0 - 1.0);
const GLfloat clip_y1 = (GLfloat)(y1 / fb_height * 2.0 - 1.0);
+ const GLuint max_slots = 4096 / sizeof(st->bitmap.vertices);
GLuint i;
- void *buf;
+
+ if (st->bitmap.vbuf_slot >= max_slots) {
+ pipe_buffer_reference(pipe->screen, &st->bitmap.vbuf, NULL);
+ st->bitmap.vbuf_slot = 0;
+ }
if (!st->bitmap.vbuf) {
- st->bitmap.vbuf = pipe_buffer_create(pipe->screen, 32, PIPE_BUFFER_USAGE_VERTEX,
- sizeof(st->bitmap.vertices));
+ st->bitmap.vbuf = pipe_buffer_create(pipe->screen, 32,
+ PIPE_BUFFER_USAGE_VERTEX,
+ max_slots * sizeof(st->bitmap.vertices));
}
/* Positions are in clip coords since we need to do clipping in case
@@ -413,9 +418,19 @@ setup_bitmap_vertex_data(struct st_context *st,
}
/* put vertex data into vbuf */
- buf = pipe_buffer_map(pipe->screen, st->bitmap.vbuf, PIPE_BUFFER_USAGE_CPU_WRITE);
- memcpy(buf, st->bitmap.vertices, sizeof(st->bitmap.vertices));
- pipe_buffer_unmap(pipe->screen, st->bitmap.vbuf);
+ {
+ char *buf = pipe_buffer_map(pipe->screen,
+ st->bitmap.vbuf,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
+
+ memcpy(buf + st->bitmap.vbuf_slot * sizeof st->bitmap.vertices,
+ st->bitmap.vertices,
+ sizeof st->bitmap.vertices);
+
+ pipe_buffer_unmap(pipe->screen, st->bitmap.vbuf);
+ }
+
+ return st->bitmap.vbuf_slot++ * sizeof st->bitmap.vertices;
}
@@ -434,6 +449,7 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
struct cso_context *cso = ctx->st->cso_context;
struct st_fragment_program *stfp;
GLuint maxSize;
+ GLuint offset;
stfp = combined_bitmap_fragment_program(ctx);
@@ -518,11 +534,11 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
}
/* draw textured quad */
- setup_bitmap_vertex_data(st, x, y, width, height,
- ctx->Current.RasterPos[2],
- color);
+ offset = setup_bitmap_vertex_data(st, x, y, width, height,
+ ctx->Current.RasterPos[2],
+ color);
- util_draw_vertex_buffer(pipe, st->bitmap.vbuf,
+ util_draw_vertex_buffer(pipe, st->bitmap.vbuf, offset,
PIPE_PRIM_TRIANGLE_FAN,
4, /* verts */
3); /* attribs/vert */
@@ -592,12 +608,12 @@ st_flush_bitmap_cache(struct st_context *st)
struct pipe_screen *screen = pipe->screen;
assert(cache->xmin <= cache->xmax);
- /*
- printf("flush size %d x %d at %d, %d\n",
+
+/* printf("flush size %d x %d at %d, %d\n",
cache->xmax - cache->xmin,
cache->ymax - cache->ymin,
cache->xpos, cache->ypos);
- */
+*/
/* The texture surface has been mapped until now.
* So unmap and release the texture surface before drawing.
@@ -623,6 +639,20 @@ st_flush_bitmap_cache(struct st_context *st)
}
}
+/* Flush bitmap cache and release vertex buffer.
+ */
+void
+st_flush_bitmap( struct st_context *st )
+{
+ st_flush_bitmap_cache(st);
+
+ /* Release vertex buffer to avoid synchronous rendering if we were
+ * to map it in the next frame.
+ */
+ pipe_buffer_reference(st->pipe->screen, &st->bitmap.vbuf, NULL);
+ st->bitmap.vbuf_slot = 0;
+}
+
/**
* Try to accumulate this glBitmap call in the bitmap cache.
diff --git a/src/mesa/state_tracker/st_cb_bitmap.h b/src/mesa/state_tracker/st_cb_bitmap.h
index aae11d34c92..81cf61981dc 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.h
+++ b/src/mesa/state_tracker/st_cb_bitmap.h
@@ -42,5 +42,11 @@ st_destroy_bitmap(struct st_context *st);
extern void
st_flush_bitmap_cache(struct st_context *st);
+/* Flush bitmap cache and release vertex buffer. Needed at end of
+ * frame to avoid synchronous rendering.
+ */
+extern void
+st_flush_bitmap(struct st_context *st);
+
#endif /* ST_CB_BITMAP_H */
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 1412a3761f1..fca1107d72e 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -148,12 +148,18 @@ draw_quad(GLcontext *ctx,
{
struct st_context *st = ctx->st;
struct pipe_context *pipe = st->pipe;
+ const GLuint max_slots = 1024 / sizeof(st->clear.vertices);
GLuint i;
void *buf;
+ if (st->clear.vbuf_slot >= max_slots) {
+ pipe_buffer_reference(pipe->screen, &st->clear.vbuf, NULL);
+ st->clear.vbuf_slot = 0;
+ }
+
if (!st->clear.vbuf) {
st->clear.vbuf = pipe_buffer_create(pipe->screen, 32, PIPE_BUFFER_USAGE_VERTEX,
- sizeof(st->clear.vertices));
+ max_slots * sizeof(st->clear.vertices));
}
/* positions */
@@ -181,14 +187,23 @@ draw_quad(GLcontext *ctx,
/* put vertex data into vbuf */
buf = pipe_buffer_map(pipe->screen, st->clear.vbuf, PIPE_BUFFER_USAGE_CPU_WRITE);
- memcpy(buf, st->clear.vertices, sizeof(st->clear.vertices));
+
+ memcpy((char *)buf + st->clear.vbuf_slot * sizeof(st->clear.vertices),
+ st->clear.vertices,
+ sizeof(st->clear.vertices));
+
pipe_buffer_unmap(pipe->screen, st->clear.vbuf);
/* draw */
- util_draw_vertex_buffer(pipe, st->clear.vbuf,
+ util_draw_vertex_buffer(pipe,
+ st->clear.vbuf,
+ st->clear.vbuf_slot * sizeof(st->clear.vertices),
PIPE_PRIM_TRIANGLE_FAN,
4, /* verts */
2); /* attribs/vert */
+
+ /* Increment slot */
+ st->clear.vbuf_slot++;
}
@@ -508,6 +523,16 @@ clear_depth_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
}
+void st_flush_clear( struct st_context *st )
+{
+ /* Release vertex buffer to avoid synchronous rendering if we were
+ * to map it in the next frame.
+ */
+ pipe_buffer_reference(st->pipe->screen, &st->clear.vbuf, NULL);
+ st->clear.vbuf_slot = 0;
+}
+
+
/**
* Called via ctx->Driver.Clear()
diff --git a/src/mesa/state_tracker/st_cb_clear.h b/src/mesa/state_tracker/st_cb_clear.h
index f49387747d6..bc035ac25ca 100644
--- a/src/mesa/state_tracker/st_cb_clear.h
+++ b/src/mesa/state_tracker/st_cb_clear.h
@@ -37,6 +37,9 @@ st_init_clear(struct st_context *st);
extern void
st_destroy_clear(struct st_context *st);
+extern void
+st_flush_clear(struct st_context *st);
+
extern void
st_init_clear_functions(struct dd_function_table *functions);
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 5b24b9f0687..32bf21411da 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -494,7 +494,7 @@ draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z,
memcpy(map, verts, sizeof(verts));
pipe_buffer_unmap(pipe->screen, buf);
- util_draw_vertex_buffer(pipe, buf,
+ util_draw_vertex_buffer(pipe, buf, 0,
PIPE_PRIM_QUADS,
4, /* verts */
3); /* attribs/vert */
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index 00076f61e0f..eece7dee112 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -426,7 +426,7 @@ st_finish_render_texture(GLcontext *ctx,
if (!strb)
return;
- ctx->st->pipe->flush(ctx->st->pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
+ st_flush( ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL );
if (strb->surface)
screen->tex_surface_release( screen, &strb->surface );
diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c
index cc404679416..072f2e92ad7 100644
--- a/src/mesa/state_tracker/st_cb_flush.c
+++ b/src/mesa/state_tracker/st_cb_flush.c
@@ -37,11 +37,14 @@
#include "st_context.h"
#include "st_cb_bitmap.h"
#include "st_cb_flush.h"
+#include "st_cb_clear.h"
#include "st_cb_fbo.h"
#include "st_public.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_winsys.h"
+#include "util/u_gen_mipmap.h"
+#include "util/u_blit.h"
static INLINE GLboolean
@@ -78,7 +81,13 @@ void st_flush( struct st_context *st, uint pipeFlushFlags,
{
FLUSH_VERTICES(st->ctx, 0);
- st_flush_bitmap_cache(st);
+ /* Release any vertex buffers that might potentially be accessed in
+ * successive frames:
+ */
+ st_flush_bitmap(st);
+ st_flush_clear(st);
+ util_blit_flush(st->blit);
+ util_gen_mipmap_flush(st->gen_mipmap);
st->pipe->flush( st->pipe, pipeFlushFlags, fence );
}
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index c8015327885..646eaff1903 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -317,10 +317,8 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
if (!dest)
return;
- st_flush_bitmap_cache(ctx->st);
-
/* make sure rendering has completed */
- pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
+ st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
if (format == GL_STENCIL_INDEX) {
st_read_stencil_pixels(ctx, x, y, width, height, type, pack, dest);
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 5bcb87ce208..695ac4a96f4 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -154,6 +154,7 @@ struct st_context
void *vs;
float vertices[4][3][4]; /**< vertex pos + color + texcoord */
struct pipe_buffer *vbuf;
+ unsigned vbuf_slot; /* next free slot in vbuf */
struct bitmap_cache *cache;
} bitmap;
@@ -173,6 +174,7 @@ struct st_context
void *fs;
float vertices[4][2][4]; /**< vertex pos + color */
struct pipe_buffer *vbuf;
+ unsigned vbuf_slot;
} clear;
void *passthrough_fs; /**< simple pass-through frag shader */
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index bac84a4dba9..31383b48874 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -47,9 +47,6 @@
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "draw/draw_private.h"
-#include "draw/draw_context.h"
-
static GLuint double_types[4] = {
PIPE_FORMAT_R64_FLOAT,
@@ -161,8 +158,8 @@ static GLuint fixed_types[4] = {
/**
* Return a PIPE_FORMAT_x for the given GL datatype and size.
*/
-static GLuint
-pipe_vertex_format(GLenum type, GLuint size, GLboolean normalized)
+GLuint
+st_pipe_vertex_format(GLenum type, GLuint size, GLboolean normalized)
{
assert((type >= GL_BYTE && type <= GL_DOUBLE) ||
type == GL_FIXED);
@@ -393,9 +390,9 @@ setup_interleaved_attribs(GLcontext *ctx,
velements[attr].vertex_buffer_index = 0;
velements[attr].nr_components = arrays[mesaAttr]->Size;
velements[attr].src_format =
- pipe_vertex_format(arrays[mesaAttr]->Type,
- arrays[mesaAttr]->Size,
- arrays[mesaAttr]->Normalized);
+ st_pipe_vertex_format(arrays[mesaAttr]->Type,
+ arrays[mesaAttr]->Size,
+ arrays[mesaAttr]->Normalized);
assert(velements[attr].src_format);
}
}
@@ -412,6 +409,7 @@ setup_non_interleaved_attribs(GLcontext *ctx,
const struct st_vertex_program *vp,
const struct gl_client_array **arrays,
GLuint max_index,
+ GLboolean *userSpace,
struct pipe_vertex_buffer vbuffer[],
struct pipe_vertex_element velements[])
{
@@ -423,6 +421,8 @@ setup_non_interleaved_attribs(GLcontext *ctx,
struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj;
GLsizei stride = arrays[mesaAttr]->StrideB;
+ *userSpace = GL_FALSE;
+
if (bufobj && bufobj->Name) {
/* Attribute data is in a VBO.
* Recall that for VBOs, the gl_client_array->Ptr field is
@@ -442,6 +442,8 @@ setup_non_interleaved_attribs(GLcontext *ctx,
uint bytes;
/*printf("user-space array %d stride %d\n", attr, stride);*/
+ *userSpace = GL_TRUE;
+
/* wrap user data */
if (arrays[mesaAttr]->Ptr) {
/* user's vertex array */
@@ -475,9 +477,9 @@ setup_non_interleaved_attribs(GLcontext *ctx,
velements[attr].vertex_buffer_index = attr;
velements[attr].nr_components = arrays[mesaAttr]->Size;
velements[attr].src_format
- = pipe_vertex_format(arrays[mesaAttr]->Type,
- arrays[mesaAttr]->Size,
- arrays[mesaAttr]->Normalized);
+ = st_pipe_vertex_format(arrays[mesaAttr]->Type,
+ arrays[mesaAttr]->Size,
+ arrays[mesaAttr]->Normalized);
assert(velements[attr].src_format);
}
}
@@ -558,7 +560,7 @@ st_draw_vbo(GLcontext *ctx,
else {
/*printf("Draw non-interleaved\n");*/
setup_non_interleaved_attribs(ctx, vp, arrays, max_index,
- vbuffer, velements);
+ &userSpace, vbuffer, velements);
num_vbuffers = vp->num_inputs;
num_velements = vp->num_inputs;
}
@@ -672,223 +674,13 @@ st_draw_vbo(GLcontext *ctx,
pipe_buffer_reference(pipe->screen, &vbuffer[attr].buffer, NULL);
assert(!vbuffer[attr].buffer);
}
- pipe->set_vertex_buffers(pipe, num_vbuffers, vbuffer);
-}
-
-
-#if FEATURE_feedback || FEATURE_drawpix
-
-/**
- * Set the (private) draw module's post-transformed vertex format when in
- * GL_SELECT or GL_FEEDBACK mode or for glRasterPos.
- */
-static void
-set_feedback_vertex_format(GLcontext *ctx)
-{
-#if 0
- struct st_context *st = ctx->st;
- struct vertex_info vinfo;
- GLuint i;
-
- memset(&vinfo, 0, sizeof(vinfo));
-
- if (ctx->RenderMode == GL_SELECT) {
- assert(ctx->RenderMode == GL_SELECT);
- vinfo.num_attribs = 1;
- vinfo.format[0] = FORMAT_4F;
- vinfo.interp_mode[0] = INTERP_LINEAR;
- }
- else {
- /* GL_FEEDBACK, or glRasterPos */
- /* emit all attribs (pos, color, texcoord) as GLfloat[4] */
- vinfo.num_attribs = st->state.vs->cso->state.num_outputs;
- for (i = 0; i < vinfo.num_attribs; i++) {
- vinfo.format[i] = FORMAT_4F;
- vinfo.interp_mode[i] = INTERP_LINEAR;
- }
- }
-
- draw_set_vertex_info(st->draw, &vinfo);
-#endif
-}
-
-
-/**
- * Called by VBO to draw arrays when in selection or feedback mode and
- * to implement glRasterPos.
- * This is very much like the normal draw_vbo() function above.
- * Look at code refactoring some day.
- * Might move this into the failover module some day.
- */
-void
-st_feedback_draw_vbo(GLcontext *ctx,
- const struct gl_client_array **arrays,
- const struct _mesa_prim *prims,
- GLuint nr_prims,
- const struct _mesa_index_buffer *ib,
- GLuint min_index,
- GLuint max_index)
-{
- struct st_context *st = ctx->st;
- struct pipe_context *pipe = st->pipe;
- struct draw_context *draw = st->draw;
- const struct st_vertex_program *vp;
- const struct pipe_shader_state *vs;
- struct pipe_buffer *index_buffer_handle = 0;
- struct pipe_vertex_buffer vbuffers[PIPE_MAX_SHADER_INPUTS];
- struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS];
- GLuint attr, i;
- ubyte *mapped_constants;
-
- assert(draw);
-
- st_validate_state(ctx->st);
-
- /* must get these after state validation! */
- vp = ctx->st->vp;
- vs = &st->vp->state;
-
- if (!st->vp->draw_shader) {
- st->vp->draw_shader = draw_create_vertex_shader(draw, vs);
- }
-
- /*
- * Set up the draw module's state.
- *
- * We'd like to do this less frequently, but the normal state-update
- * code sends state updates to the pipe, not to our private draw module.
- */
- assert(draw);
- draw_set_viewport_state(draw, &st->state.viewport);
- draw_set_clip_state(draw, &st->state.clip);
- draw_set_rasterizer_state(draw, &st->state.rasterizer);
- draw_bind_vertex_shader(draw, st->vp->draw_shader);
- set_feedback_vertex_format(ctx);
-
- /* loop over TGSI shader inputs to determine vertex buffer
- * and attribute info
- */
- for (attr = 0; attr < vp->num_inputs; attr++) {
- const GLuint mesaAttr = vp->index_to_input[attr];
- struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj;
- void *map;
-
- if (bufobj && bufobj->Name) {
- /* Attribute data is in a VBO.
- * Recall that for VBOs, the gl_client_array->Ptr field is
- * really an offset from the start of the VBO, not a pointer.
- */
- struct st_buffer_object *stobj = st_buffer_object(bufobj);
- assert(stobj->buffer);
-
- vbuffers[attr].buffer = NULL;
- pipe_buffer_reference(pipe->screen, &vbuffers[attr].buffer, stobj->buffer);
- vbuffers[attr].buffer_offset = (unsigned) arrays[0]->Ptr;/* in bytes */
- velements[attr].src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr;
- }
- else {
- /* attribute data is in user-space memory, not a VBO */
- uint bytes = (arrays[mesaAttr]->Size
- * _mesa_sizeof_type(arrays[mesaAttr]->Type)
- * (max_index + 1));
-
- /* wrap user data */
- vbuffers[attr].buffer
- = pipe_user_buffer_create(pipe->screen, (void *) arrays[mesaAttr]->Ptr,
- bytes);
- vbuffers[attr].buffer_offset = 0;
- velements[attr].src_offset = 0;
- }
-
- /* common-case setup */
- vbuffers[attr].pitch = arrays[mesaAttr]->StrideB; /* in bytes */
- vbuffers[attr].max_index = max_index;
- velements[attr].vertex_buffer_index = attr;
- velements[attr].nr_components = arrays[mesaAttr]->Size;
- velements[attr].src_format = pipe_vertex_format(arrays[mesaAttr]->Type,
- arrays[mesaAttr]->Size,
- arrays[mesaAttr]->Normalized);
- assert(velements[attr].src_format);
-
- /* tell draw about this attribute */
-#if 0
- draw_set_vertex_buffer(draw, attr, &vbuffer[attr]);
-#endif
-
- /* map the attrib buffer */
- map = pipe_buffer_map(pipe->screen, vbuffers[attr].buffer,
- PIPE_BUFFER_USAGE_CPU_READ);
- draw_set_mapped_vertex_buffer(draw, attr, map);
- }
-
- draw_set_vertex_buffers(draw, vp->num_inputs, vbuffers);
- draw_set_vertex_elements(draw, vp->num_inputs, velements);
-
- if (ib) {
- unsigned indexSize;
- struct gl_buffer_object *bufobj = ib->obj;
- struct st_buffer_object *stobj = st_buffer_object(bufobj);
- void *map;
-
- index_buffer_handle = stobj->buffer;
-
- switch (ib->type) {
- case GL_UNSIGNED_INT:
- indexSize = 4;
- break;
- case GL_UNSIGNED_SHORT:
- indexSize = 2;
- break;
- default:
- assert(0);
- return;
- }
-
- map = pipe_buffer_map(pipe->screen, index_buffer_handle,
- PIPE_BUFFER_USAGE_CPU_READ);
- draw_set_mapped_element_buffer(draw, indexSize, map);
- }
- else {
- /* no index/element buffer */
- draw_set_mapped_element_buffer(draw, 0, NULL);
- }
-
- /* map constant buffers */
- mapped_constants = pipe_buffer_map(pipe->screen,
- st->state.constants[PIPE_SHADER_VERTEX].buffer,
- PIPE_BUFFER_USAGE_CPU_READ);
- draw_set_mapped_constant_buffer(st->draw, mapped_constants,
- st->state.constants[PIPE_SHADER_VERTEX].buffer->size);
-
-
- /* draw here */
- for (i = 0; i < nr_prims; i++) {
- draw_arrays(draw, prims[i].mode, prims[i].start, prims[i].count);
- }
-
-
- /* unmap constant buffers */
- pipe_buffer_unmap(pipe->screen, st->state.constants[PIPE_SHADER_VERTEX].buffer);
-
- /*
- * unmap vertex/index buffers
- */
- for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
- if (draw->pt.vertex_buffer[i].buffer) {
- pipe_buffer_unmap(pipe->screen, draw->pt.vertex_buffer[i].buffer);
- pipe_buffer_reference(pipe->screen, &draw->pt.vertex_buffer[i].buffer, NULL);
- draw_set_mapped_vertex_buffer(draw, i, NULL);
- }
- }
- if (ib) {
- pipe_buffer_unmap(pipe->screen, index_buffer_handle);
- draw_set_mapped_element_buffer(draw, 0, NULL);
+ if (userSpace)
+ {
+ pipe->set_vertex_buffers(pipe, 0, NULL);
}
}
-#endif /* FEATURE_feedback || FEATURE_drawpix */
-
void st_init_draw( struct st_context *st )
{
diff --git a/src/mesa/state_tracker/st_draw.h b/src/mesa/state_tracker/st_draw.h
index c81f2b25dad..659c3ac834f 100644
--- a/src/mesa/state_tracker/st_draw.h
+++ b/src/mesa/state_tracker/st_draw.h
@@ -59,4 +59,9 @@ st_feedback_draw_vbo(GLcontext *ctx,
GLuint min_index,
GLuint max_index);
+/* Internal function:
+ */
+extern GLuint
+st_pipe_vertex_format(GLenum type, GLuint size, GLboolean normalized);
+
#endif
diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c
new file mode 100644
index 00000000000..834c3844c4f
--- /dev/null
+++ b/src/mesa/state_tracker/st_draw_feedback.c
@@ -0,0 +1,262 @@
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "main/imports.h"
+#include "main/image.h"
+#include "main/macros.h"
+#include "shader/prog_uniform.h"
+
+#include "vbo/vbo.h"
+
+#include "st_context.h"
+#include "st_atom.h"
+#include "st_cb_bufferobjects.h"
+#include "st_draw.h"
+#include "st_program.h"
+
+#include "pipe/p_context.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_inlines.h"
+
+#include "draw/draw_private.h"
+#include "draw/draw_context.h"
+
+
+#if FEATURE_feedback || FEATURE_drawpix
+
+/**
+ * Set the (private) draw module's post-transformed vertex format when in
+ * GL_SELECT or GL_FEEDBACK mode or for glRasterPos.
+ */
+static void
+set_feedback_vertex_format(GLcontext *ctx)
+{
+#if 0
+ struct st_context *st = ctx->st;
+ struct vertex_info vinfo;
+ GLuint i;
+
+ memset(&vinfo, 0, sizeof(vinfo));
+
+ if (ctx->RenderMode == GL_SELECT) {
+ assert(ctx->RenderMode == GL_SELECT);
+ vinfo.num_attribs = 1;
+ vinfo.format[0] = FORMAT_4F;
+ vinfo.interp_mode[0] = INTERP_LINEAR;
+ }
+ else {
+ /* GL_FEEDBACK, or glRasterPos */
+ /* emit all attribs (pos, color, texcoord) as GLfloat[4] */
+ vinfo.num_attribs = st->state.vs->cso->state.num_outputs;
+ for (i = 0; i < vinfo.num_attribs; i++) {
+ vinfo.format[i] = FORMAT_4F;
+ vinfo.interp_mode[i] = INTERP_LINEAR;
+ }
+ }
+
+ draw_set_vertex_info(st->draw, &vinfo);
+#endif
+}
+
+
+/**
+ * Called by VBO to draw arrays when in selection or feedback mode and
+ * to implement glRasterPos.
+ * This is very much like the normal draw_vbo() function above.
+ * Look at code refactoring some day.
+ * Might move this into the failover module some day.
+ */
+void
+st_feedback_draw_vbo(GLcontext *ctx,
+ const struct gl_client_array **arrays,
+ const struct _mesa_prim *prims,
+ GLuint nr_prims,
+ const struct _mesa_index_buffer *ib,
+ GLuint min_index,
+ GLuint max_index)
+{
+ struct st_context *st = ctx->st;
+ struct pipe_context *pipe = st->pipe;
+ struct draw_context *draw = st->draw;
+ const struct st_vertex_program *vp;
+ const struct pipe_shader_state *vs;
+ struct pipe_buffer *index_buffer_handle = 0;
+ struct pipe_vertex_buffer vbuffers[PIPE_MAX_SHADER_INPUTS];
+ struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS];
+ GLuint attr, i;
+ ubyte *mapped_constants;
+
+ assert(draw);
+
+ st_validate_state(ctx->st);
+
+ /* must get these after state validation! */
+ vp = ctx->st->vp;
+ vs = &st->vp->state;
+
+ if (!st->vp->draw_shader) {
+ st->vp->draw_shader = draw_create_vertex_shader(draw, vs);
+ }
+
+ /*
+ * Set up the draw module's state.
+ *
+ * We'd like to do this less frequently, but the normal state-update
+ * code sends state updates to the pipe, not to our private draw module.
+ */
+ assert(draw);
+ draw_set_viewport_state(draw, &st->state.viewport);
+ draw_set_clip_state(draw, &st->state.clip);
+ draw_set_rasterizer_state(draw, &st->state.rasterizer);
+ draw_bind_vertex_shader(draw, st->vp->draw_shader);
+ set_feedback_vertex_format(ctx);
+
+ /* loop over TGSI shader inputs to determine vertex buffer
+ * and attribute info
+ */
+ for (attr = 0; attr < vp->num_inputs; attr++) {
+ const GLuint mesaAttr = vp->index_to_input[attr];
+ struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj;
+ void *map;
+
+ if (bufobj && bufobj->Name) {
+ /* Attribute data is in a VBO.
+ * Recall that for VBOs, the gl_client_array->Ptr field is
+ * really an offset from the start of the VBO, not a pointer.
+ */
+ struct st_buffer_object *stobj = st_buffer_object(bufobj);
+ assert(stobj->buffer);
+
+ vbuffers[attr].buffer = NULL;
+ pipe_buffer_reference(pipe->screen, &vbuffers[attr].buffer, stobj->buffer);
+ vbuffers[attr].buffer_offset = (unsigned) arrays[0]->Ptr;/* in bytes */
+ velements[attr].src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr;
+ }
+ else {
+ /* attribute data is in user-space memory, not a VBO */
+ uint bytes = (arrays[mesaAttr]->Size
+ * _mesa_sizeof_type(arrays[mesaAttr]->Type)
+ * (max_index + 1));
+
+ /* wrap user data */
+ vbuffers[attr].buffer
+ = pipe_user_buffer_create(pipe->screen, (void *) arrays[mesaAttr]->Ptr,
+ bytes);
+ vbuffers[attr].buffer_offset = 0;
+ velements[attr].src_offset = 0;
+ }
+
+ /* common-case setup */
+ vbuffers[attr].pitch = arrays[mesaAttr]->StrideB; /* in bytes */
+ vbuffers[attr].max_index = max_index;
+ velements[attr].vertex_buffer_index = attr;
+ velements[attr].nr_components = arrays[mesaAttr]->Size;
+ velements[attr].src_format =
+ st_pipe_vertex_format(arrays[mesaAttr]->Type,
+ arrays[mesaAttr]->Size,
+ arrays[mesaAttr]->Normalized);
+ assert(velements[attr].src_format);
+
+ /* tell draw about this attribute */
+#if 0
+ draw_set_vertex_buffer(draw, attr, &vbuffer[attr]);
+#endif
+
+ /* map the attrib buffer */
+ map = pipe_buffer_map(pipe->screen, vbuffers[attr].buffer,
+ PIPE_BUFFER_USAGE_CPU_READ);
+ draw_set_mapped_vertex_buffer(draw, attr, map);
+ }
+
+ draw_set_vertex_buffers(draw, vp->num_inputs, vbuffers);
+ draw_set_vertex_elements(draw, vp->num_inputs, velements);
+
+ if (ib) {
+ unsigned indexSize;
+ struct gl_buffer_object *bufobj = ib->obj;
+ struct st_buffer_object *stobj = st_buffer_object(bufobj);
+ void *map;
+
+ index_buffer_handle = stobj->buffer;
+
+ switch (ib->type) {
+ case GL_UNSIGNED_INT:
+ indexSize = 4;
+ break;
+ case GL_UNSIGNED_SHORT:
+ indexSize = 2;
+ break;
+ default:
+ assert(0);
+ return;
+ }
+
+ map = pipe_buffer_map(pipe->screen, index_buffer_handle,
+ PIPE_BUFFER_USAGE_CPU_READ);
+ draw_set_mapped_element_buffer(draw, indexSize, map);
+ }
+ else {
+ /* no index/element buffer */
+ draw_set_mapped_element_buffer(draw, 0, NULL);
+ }
+
+
+ /* map constant buffers */
+ mapped_constants = pipe_buffer_map(pipe->screen,
+ st->state.constants[PIPE_SHADER_VERTEX].buffer,
+ PIPE_BUFFER_USAGE_CPU_READ);
+ draw_set_mapped_constant_buffer(st->draw, mapped_constants,
+ st->state.constants[PIPE_SHADER_VERTEX].buffer->size);
+
+
+ /* draw here */
+ for (i = 0; i < nr_prims; i++) {
+ draw_arrays(draw, prims[i].mode, prims[i].start, prims[i].count);
+ }
+
+
+ /* unmap constant buffers */
+ pipe_buffer_unmap(pipe->screen, st->state.constants[PIPE_SHADER_VERTEX].buffer);
+
+ /*
+ * unmap vertex/index buffers
+ */
+ for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
+ if (draw->pt.vertex_buffer[i].buffer) {
+ pipe_buffer_unmap(pipe->screen, draw->pt.vertex_buffer[i].buffer);
+ pipe_buffer_reference(pipe->screen, &draw->pt.vertex_buffer[i].buffer, NULL);
+ draw_set_mapped_vertex_buffer(draw, i, NULL);
+ }
+ }
+ if (ib) {
+ pipe_buffer_unmap(pipe->screen, index_buffer_handle);
+ draw_set_mapped_element_buffer(draw, 0, NULL);
+ }
+}
+
+#endif /* FEATURE_feedback || FEATURE_drawpix */
+
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c
index 401f092cd06..ce8b4411940 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -475,9 +475,15 @@ compile_instruction(
break;
case OPCODE_RSQ:
fullinst->Instruction.Opcode = TGSI_OPCODE_RSQ;
- tgsi_util_set_full_src_register_sign_mode(
- &fullinst->FullSrcRegisters[0],
- TGSI_UTIL_SIGN_CLEAR );
+
+ /* KW: Don't do this here. If particular hardware needs to do
+ * this, can do so in the driver..
+ */
+#if 0
+ tgsi_util_set_full_src_register_sign_mode(
+ &fullinst->FullSrcRegisters[0],
+ TGSI_UTIL_SIGN_CLEAR );
+#endif
break;
case OPCODE_SCS:
fullinst->Instruction.Opcode = TGSI_OPCODE_SCS;