summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/draw
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary/draw')
-rw-r--r--src/gallium/auxiliary/draw/SConscript1
-rw-r--r--src/gallium/auxiliary/draw/draw_aaline.c57
-rw-r--r--src/gallium/auxiliary/draw/draw_aapoint.c3
-rw-r--r--src/gallium/auxiliary/draw/draw_context.c15
-rw-r--r--src/gallium/auxiliary/draw/draw_context.h5
-rw-r--r--src/gallium/auxiliary/draw/draw_passthrough.c222
-rw-r--r--src/gallium/auxiliary/draw/draw_private.h29
-rw-r--r--src/gallium/auxiliary/draw/draw_pstipple.c73
-rw-r--r--src/gallium/auxiliary/draw/draw_unfilled.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_vbuf.h6
-rw-r--r--src/gallium/auxiliary/draw/draw_vertex_cache.c6
-rw-r--r--src/gallium/auxiliary/draw/draw_vertex_fetch.c44
-rw-r--r--src/gallium/auxiliary/draw/draw_vertex_shader.c17
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_exec.c42
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_llvm.c48
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_sse.c42
16 files changed, 481 insertions, 131 deletions
diff --git a/src/gallium/auxiliary/draw/SConscript b/src/gallium/auxiliary/draw/SConscript
index c18dcb2927..5cb7664c85 100644
--- a/src/gallium/auxiliary/draw/SConscript
+++ b/src/gallium/auxiliary/draw/SConscript
@@ -16,6 +16,7 @@ draw = env.ConvenienceLibrary(
'draw_offset.c',
'draw_prim.c',
'draw_pstipple.c',
+ 'draw_passthrough.c',
'draw_stipple.c',
'draw_twoside.c',
'draw_unfilled.c',
diff --git a/src/gallium/auxiliary/draw/draw_aaline.c b/src/gallium/auxiliary/draw/draw_aaline.c
index 7660e56fe6..6b1e640ae9 100644
--- a/src/gallium/auxiliary/draw/draw_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_aaline.c
@@ -78,7 +78,8 @@ struct aaline_stage
void *sampler_cso;
struct pipe_texture *texture;
- uint sampler_unit;
+ uint num_samplers;
+ uint num_textures;
/*
@@ -98,11 +99,10 @@ struct aaline_stage
void (*driver_bind_fs_state)(struct pipe_context *, void *);
void (*driver_delete_fs_state)(struct pipe_context *, void *);
- void (*driver_bind_sampler_state)(struct pipe_context *, unsigned, void *);
-
- void (*driver_set_sampler_texture)(struct pipe_context *,
- unsigned sampler,
- struct pipe_texture *);
+ void (*driver_bind_sampler_states)(struct pipe_context *, unsigned,
+ void **);
+ void (*driver_set_sampler_textures)(struct pipe_context *, unsigned,
+ struct pipe_texture **);
struct pipe_context *pipe;
};
@@ -607,6 +607,7 @@ aaline_first_line(struct draw_stage *stage, struct prim_header *header)
auto struct aaline_stage *aaline = aaline_stage(stage);
struct draw_context *draw = stage->draw;
struct pipe_context *pipe = aaline->pipe;
+ uint num = MAX2(aaline->num_textures, aaline->num_samplers);
assert(draw->rasterizer->line_smooth);
@@ -624,8 +625,11 @@ aaline_first_line(struct draw_stage *stage, struct prim_header *header)
*/
bind_aaline_fragment_shader(aaline);
- aaline->driver_bind_sampler_state(pipe, aaline->sampler_unit, aaline->sampler_cso);
- aaline->driver_set_sampler_texture(pipe, aaline->sampler_unit, aaline->texture);
+ aaline->state.sampler[num] = aaline->sampler_cso;
+ aaline->state.texture[num] = aaline->texture;
+
+ aaline->driver_bind_sampler_states(pipe, num + 1, aaline->state.sampler);
+ aaline->driver_set_sampler_textures(pipe, num + 1, aaline->state.texture);
/* now really draw first line */
stage->line = aaline_line;
@@ -647,10 +651,10 @@ aaline_flush(struct draw_stage *stage, unsigned flags)
aaline->driver_bind_fs_state(pipe, aaline->fs->driver_fs);
/* XXX restore original texture, sampler state */
- aaline->driver_bind_sampler_state(pipe, aaline->sampler_unit,
- aaline->state.sampler[aaline->sampler_unit]);
- aaline->driver_set_sampler_texture(pipe, aaline->sampler_unit,
- aaline->state.texture[aaline->sampler_unit]);
+ aaline->driver_bind_sampler_states(pipe, aaline->num_samplers,
+ aaline->state.sampler);
+ aaline->driver_set_sampler_textures(pipe, aaline->num_textures,
+ aaline->state.texture);
draw->extra_vp_outputs.slot = 0;
}
@@ -729,7 +733,8 @@ aaline_bind_fs_state(struct pipe_context *pipe, void *fs)
/* save current */
aaline->fs = aafs;
/* pass-through */
- aaline->driver_bind_fs_state(aaline->pipe, aafs->driver_fs);
+ aaline->driver_bind_fs_state(aaline->pipe,
+ (aafs ? aafs->driver_fs : NULL));
}
@@ -745,26 +750,28 @@ aaline_delete_fs_state(struct pipe_context *pipe, void *fs)
static void
-aaline_bind_sampler_state(struct pipe_context *pipe,
- unsigned unit, void *sampler)
+aaline_bind_sampler_states(struct pipe_context *pipe,
+ unsigned num, void **sampler)
{
struct aaline_stage *aaline = aaline_stage_from_pipe(pipe);
/* save current */
- aaline->state.sampler[unit] = sampler;
+ memcpy(aaline->state.sampler, sampler, num * sizeof(void *));
+ aaline->num_samplers = num;
/* pass-through */
- aaline->driver_bind_sampler_state(aaline->pipe, unit, sampler);
+ aaline->driver_bind_sampler_states(aaline->pipe, num, sampler);
}
static void
-aaline_set_sampler_texture(struct pipe_context *pipe,
- unsigned sampler, struct pipe_texture *texture)
+aaline_set_sampler_textures(struct pipe_context *pipe,
+ unsigned num, struct pipe_texture **texture)
{
struct aaline_stage *aaline = aaline_stage_from_pipe(pipe);
/* save current */
- aaline->state.texture[sampler] = texture;
+ memcpy(aaline->state.texture, texture, num * sizeof(struct pipe_texture *));
+ aaline->num_textures = num;
/* pass-through */
- aaline->driver_set_sampler_texture(aaline->pipe, sampler, texture);
+ aaline->driver_set_sampler_textures(aaline->pipe, num, texture);
}
@@ -798,14 +805,14 @@ draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe)
aaline->driver_bind_fs_state = pipe->bind_fs_state;
aaline->driver_delete_fs_state = pipe->delete_fs_state;
- aaline->driver_bind_sampler_state = pipe->bind_sampler_state;
- aaline->driver_set_sampler_texture = pipe->set_sampler_texture;
+ aaline->driver_bind_sampler_states = pipe->bind_sampler_states;
+ aaline->driver_set_sampler_textures = pipe->set_sampler_textures;
/* override the driver's functions */
pipe->create_fs_state = aaline_create_fs_state;
pipe->bind_fs_state = aaline_bind_fs_state;
pipe->delete_fs_state = aaline_delete_fs_state;
- pipe->bind_sampler_state = aaline_bind_sampler_state;
- pipe->set_sampler_texture = aaline_set_sampler_texture;
+ pipe->bind_sampler_states = aaline_bind_sampler_states;
+ pipe->set_sampler_textures = aaline_set_sampler_textures;
}
diff --git a/src/gallium/auxiliary/draw/draw_aapoint.c b/src/gallium/auxiliary/draw/draw_aapoint.c
index 70f696475f..99e9e9fe34 100644
--- a/src/gallium/auxiliary/draw/draw_aapoint.c
+++ b/src/gallium/auxiliary/draw/draw_aapoint.c
@@ -800,7 +800,8 @@ aapoint_bind_fs_state(struct pipe_context *pipe, void *fs)
/* save current */
aapoint->fs = aafs;
/* pass-through */
- aapoint->driver_bind_fs_state(aapoint->pipe, aafs->driver_fs);
+ aapoint->driver_bind_fs_state(aapoint->pipe,
+ (aafs ? aafs->driver_fs : NULL));
}
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index 428b6209e0..fed2b6e759 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -34,6 +34,7 @@
#include "pipe/p_util.h"
#include "draw_context.h"
#include "draw_private.h"
+#include "draw_vbuf.h"
@@ -114,6 +115,13 @@ void draw_destroy( struct draw_context *draw )
draw->pipeline.rasterize->destroy( draw->pipeline.rasterize );
tgsi_exec_machine_free_data(&draw->machine);
align_free( draw->vs.queue[0].vertex ); /* Frees all the vertices. */
+
+ /* Not so fast -- we're just borrowing this at the moment.
+ *
+ if (draw->render)
+ draw->render->destroy( draw->render );
+ */
+
FREE( draw );
}
@@ -349,3 +357,10 @@ void draw_reset_vertex_ids(struct draw_context *draw)
draw_vertex_cache_reset_vertex_ids(draw);
}
+
+
+void draw_set_render( struct draw_context *draw,
+ struct vbuf_render *render )
+{
+ draw->render = render;
+}
diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h
index ab87b4127c..df63e91a22 100644
--- a/src/gallium/auxiliary/draw/draw_context.h
+++ b/src/gallium/auxiliary/draw/draw_context.h
@@ -168,4 +168,9 @@ unsigned draw_trim_prim( unsigned mode, unsigned count );
+
+struct vbuf_render;
+void draw_set_render( struct draw_context *draw,
+ struct vbuf_render *render );
+
#endif /* DRAW_CONTEXT_H */
diff --git a/src/gallium/auxiliary/draw/draw_passthrough.c b/src/gallium/auxiliary/draw/draw_passthrough.c
new file mode 100644
index 0000000000..a51fa0ab23
--- /dev/null
+++ b/src/gallium/auxiliary/draw/draw_passthrough.c
@@ -0,0 +1,222 @@
+/**************************************************************************
+ *
+ * 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.
+ *
+ **************************************************************************/
+
+ /*
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+
+/* This code is a prototype of what a passhthrough vertex shader might
+ * look like.
+ *
+ * Probably the best approach for us is to do:
+ * - vertex fetch
+ * - vertex shader
+ * - cliptest / viewport transform
+ *
+ * in one step, then examine the clipOrMask & choose between two paths:
+ *
+ * Either:
+ * - build primitive headers
+ * - clip and the primitive path
+ * - build clipped vertex buffers,
+ * - vertex-emit to vbuf buffers
+ *
+ * Or, if no clipping:
+ * - vertex-emit directly to vbuf buffers
+ *
+ * But when bypass clipping is enabled, we just take the latter
+ * choice. If (some new) passthrough-vertex-shader flag is also set,
+ * the pipeline degenerates to:
+ *
+ * - vertex fetch
+ * - vertex emit to vbuf buffers
+ *
+ * Which is what is prototyped here.
+ */
+#include "pipe/p_util.h"
+#include "draw/draw_context.h"
+#include "draw/draw_private.h"
+#include "draw/draw_vbuf.h"
+#include "draw/draw_vertex.h"
+
+
+
+/* Example of a fetch/emit passthrough shader which could be
+ * generated when bypass_clipping is enabled on a passthrough vertex
+ * shader.
+ */
+static void fetch_xyz_rgb_st( struct draw_context *draw,
+ float *out,
+ unsigned start,
+ unsigned count )
+{
+ const unsigned *pitch = draw->vertex_fetch.pitch;
+ const ubyte **src = draw->vertex_fetch.src_ptr;
+ unsigned i;
+
+ const ubyte *xyzw = src[0] + start * pitch[0];
+ const ubyte *rgba = src[1] + start * pitch[1];
+ const ubyte *st = src[2] + start * pitch[2];
+
+ /* loop over vertex attributes (vertex shader inputs)
+ */
+ for (i = 0; i < count; i++) {
+ {
+ const float *in = (const float *)xyzw; xyzw += pitch[0];
+ /* decode input, encode output. Assume both are float[4] */
+ out[0] = in[0];
+ out[1] = in[1];
+ out[2] = in[2];
+ out[3] = in[3];
+ }
+
+ {
+ const float *in = (const float *)rgba; rgba += pitch[1];
+ /* decode input, encode output. Assume both are float[4] */
+ out[4] = in[0];
+ out[5] = in[1];
+ out[6] = in[2];
+ out[7] = in[3];
+ }
+
+ {
+ const float *in = (const float *)st; st += pitch[2];
+ /* decode input, encode output. Assume both are float[2] */
+ out[8] = in[0];
+ out[9] = in[1];
+ }
+
+ out += 10;
+ }
+}
+
+
+static boolean update_shader( struct draw_context *draw )
+{
+ const struct vertex_info *vinfo = draw->render->get_vertex_info(draw->render);
+
+ unsigned nr_attrs = vinfo->num_attribs;
+ unsigned i;
+
+ for (i = 0; i < nr_attrs; i++) {
+ unsigned buf = draw->vertex_element[i].vertex_buffer_index;
+
+ draw->vertex_fetch.src_ptr[i] = (const ubyte *) draw->user.vbuffer[buf] +
+ draw->vertex_buffer[buf].buffer_offset +
+ draw->vertex_element[i].src_offset;
+
+ draw->vertex_fetch.pitch[i] = draw->vertex_buffer[buf].pitch;
+ draw->vertex_fetch.fetch[i] = NULL;
+ }
+
+ draw->vertex_fetch.nr_attrs = nr_attrs;
+ draw->vertex_fetch.fetch_func = NULL;
+ draw->vertex_fetch.pt_fetch = NULL;
+
+ draw->pt.hw_vertex_size = vinfo->size * 4;
+
+ /* Just trying to figure out how this would work:
+ */
+ if (nr_attrs == 3 &&
+ 0 /* some other tests */)
+ {
+ draw->vertex_fetch.pt_fetch = fetch_xyz_rgb_st;
+ assert(vinfo->size == 10);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+
+static boolean set_prim( struct draw_context *draw,
+ unsigned prim )
+{
+ assert(!draw->user.elts);
+
+ draw->pt.prim = prim;
+
+ switch (prim) {
+ case PIPE_PRIM_LINE_LOOP:
+ case PIPE_PRIM_QUADS:
+ case PIPE_PRIM_QUAD_STRIP:
+ return FALSE;
+ default:
+ draw->render->set_primitive( draw->render, prim );
+ return TRUE;
+ }
+}
+
+
+
+boolean
+draw_passthrough_arrays(struct draw_context *draw,
+ unsigned prim,
+ unsigned start,
+ unsigned count)
+{
+ float *hw_verts;
+
+ if (!set_prim(draw, prim))
+ return FALSE;
+
+ if (!update_shader( draw ))
+ return FALSE;
+
+ hw_verts = draw->render->allocate_vertices( draw->render,
+ draw->pt.hw_vertex_size,
+ count );
+
+ if (!hw_verts)
+ return FALSE;
+
+ /* Single routine to fetch vertices, run shader and emit HW verts.
+ * Clipping and viewport transformation are done on hardware.
+ */
+ draw->vertex_fetch.pt_fetch( draw,
+ hw_verts,
+ start, count );
+
+ /* Draw arrays path to avoid re-emitting index list again and
+ * again.
+ */
+ draw->render->draw_arrays( draw->render,
+ start,
+ count );
+
+
+ draw->render->release_vertices( draw->render,
+ hw_verts,
+ draw->pt.hw_vertex_size,
+ count );
+
+ return TRUE;
+}
+
diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h
index c732d723a7..4147472d45 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -133,7 +133,7 @@ struct draw_vertex_shader {
/* This member will disappear shortly:
*/
- const struct pipe_shader_state *state;
+ struct pipe_shader_state state;
struct tgsi_shader_info info;
@@ -162,8 +162,14 @@ typedef void (*full_fetch_func)( struct draw_context *draw,
const unsigned *elts,
unsigned count );
+typedef void (*pt_fetch_func)( struct draw_context *draw,
+ float *out,
+ unsigned start,
+ unsigned count );
+struct vbuf_render;
+
/**
* Private context for the drawing module.
*/
@@ -191,6 +197,17 @@ struct draw_context
struct draw_stage *rasterize;
} pipeline;
+
+ struct vbuf_render *render;
+
+ /* Support prototype passthrough path:
+ */
+ struct {
+ unsigned prim;
+ unsigned hw_vertex_size;
+ } pt;
+
+
/* pipe state that we need: */
const struct pipe_rasterizer_state *rasterizer;
struct pipe_viewport_state viewport;
@@ -244,6 +261,7 @@ struct draw_context
fetch_func fetch[PIPE_ATTRIB_MAX];
unsigned nr_attrs;
full_fetch_func fetch_func;
+ pt_fetch_func pt_fetch;
} vertex_fetch;
/* Post-tnl vertex cache:
@@ -331,6 +349,15 @@ struct tgsi_exec_machine;
extern void draw_update_vertex_fetch( struct draw_context *draw );
+/* Prototype/hack
+ */
+boolean
+draw_passthrough_arrays(struct draw_context *draw,
+ unsigned prim,
+ unsigned start,
+ unsigned count);
+
+
#define DRAW_FLUSH_SHADER_QUEUE 0x1 /* sized not to overflow, never raised */
#define DRAW_FLUSH_PRIM_QUEUE 0x2
#define DRAW_FLUSH_VERTEX_CACHE 0x4
diff --git a/src/gallium/auxiliary/draw/draw_pstipple.c b/src/gallium/auxiliary/draw/draw_pstipple.c
index 2cfeb813b3..8b3e84a9a0 100644
--- a/src/gallium/auxiliary/draw/draw_pstipple.c
+++ b/src/gallium/auxiliary/draw/draw_pstipple.c
@@ -67,16 +67,18 @@ struct pstip_stage
struct draw_stage stage;
void *sampler_cso;
- struct pipe_texture *texture;
uint sampler_unit;
+ struct pipe_texture *texture;
+ uint num_samplers;
+ uint num_textures;
/*
* Currently bound state
*/
struct pstip_fragment_shader *fs;
struct {
- void *sampler[PIPE_MAX_SAMPLERS];
- struct pipe_texture *texture[PIPE_MAX_SAMPLERS];
+ void *samplers[PIPE_MAX_SAMPLERS];
+ struct pipe_texture *textures[PIPE_MAX_SAMPLERS];
const struct pipe_poly_stipple *stipple;
} state;
@@ -88,11 +90,10 @@ struct pstip_stage
void (*driver_bind_fs_state)(struct pipe_context *, void *);
void (*driver_delete_fs_state)(struct pipe_context *, void *);
- void (*driver_bind_sampler_state)(struct pipe_context *, unsigned, void *);
+ void (*driver_bind_sampler_states)(struct pipe_context *, unsigned, void **);
- void (*driver_set_sampler_texture)(struct pipe_context *,
- unsigned sampler,
- struct pipe_texture *);
+ void (*driver_set_sampler_textures)(struct pipe_context *, unsigned,
+ struct pipe_texture **);
void (*driver_set_polygon_stipple)(struct pipe_context *,
const struct pipe_poly_stipple *);
@@ -484,18 +485,25 @@ static void
pstip_first_tri(struct draw_stage *stage, struct prim_header *header)
{
struct pstip_stage *pstip = pstip_stage(stage);
- struct draw_context *draw = stage->draw;
struct pipe_context *pipe = pstip->pipe;
+ uint num_samplers;
- assert(draw->rasterizer->poly_stipple_enable);
+ /* how many samplers? */
+ /* we'll use sampler/texture[pstip->sampler_unit] for the stipple */
+ num_samplers = MAX2(pstip->num_textures, pstip->num_samplers);
+ num_samplers = MAX2(num_samplers, pstip->sampler_unit + 1);
- /*
- * Bind our fragprog, sampler and texture
- */
+ assert(stage->draw->rasterizer->poly_stipple_enable);
+
+ /* bind our fragprog */
bind_pstip_fragment_shader(pstip);
- pstip->driver_bind_sampler_state(pipe, pstip->sampler_unit, pstip->sampler_cso);
- pstip->driver_set_sampler_texture(pipe, pstip->sampler_unit, pstip->texture);
+ /* plug in our sampler, texture */
+ pstip->state.samplers[pstip->sampler_unit] = pstip->sampler_cso;
+ pstip->state.textures[pstip->sampler_unit] = pstip->texture;
+
+ pstip->driver_bind_sampler_states(pipe, num_samplers, pstip->state.samplers);
+ pstip->driver_set_sampler_textures(pipe, num_samplers, pstip->state.textures);
/* now really draw first line */
stage->tri = passthrough_tri;
@@ -517,10 +525,10 @@ pstip_flush(struct draw_stage *stage, unsigned flags)
pstip->driver_bind_fs_state(pipe, pstip->fs->driver_fs);
/* XXX restore original texture, sampler state */
- pstip->driver_bind_sampler_state(pipe, pstip->sampler_unit,
- pstip->state.sampler[pstip->sampler_unit]);
- pstip->driver_set_sampler_texture(pipe, pstip->sampler_unit,
- pstip->state.texture[pstip->sampler_unit]);
+ pstip->driver_bind_sampler_states(pipe, pstip->num_samplers,
+ pstip->state.samplers);
+ pstip->driver_set_sampler_textures(pipe, pstip->num_textures,
+ pstip->state.textures);
}
@@ -597,7 +605,8 @@ pstip_bind_fs_state(struct pipe_context *pipe, void *fs)
/* save current */
pstip->fs = aafs;
/* pass-through */
- pstip->driver_bind_fs_state(pstip->pipe, aafs->driver_fs);
+ pstip->driver_bind_fs_state(pstip->pipe,
+ (aafs ? aafs->driver_fs : NULL));
}
@@ -613,26 +622,28 @@ pstip_delete_fs_state(struct pipe_context *pipe, void *fs)
static void
-pstip_bind_sampler_state(struct pipe_context *pipe,
- unsigned unit, void *sampler)
+pstip_bind_sampler_states(struct pipe_context *pipe,
+ unsigned num, void **sampler)
{
struct pstip_stage *pstip = pstip_stage_from_pipe(pipe);
/* save current */
- pstip->state.sampler[unit] = sampler;
+ memcpy(pstip->state.samplers, sampler, num * sizeof(void *));
+ pstip->num_samplers = num;
/* pass-through */
- pstip->driver_bind_sampler_state(pstip->pipe, unit, sampler);
+ pstip->driver_bind_sampler_states(pstip->pipe, num, sampler);
}
static void
-pstip_set_sampler_texture(struct pipe_context *pipe,
- unsigned sampler, struct pipe_texture *texture)
+pstip_set_sampler_textures(struct pipe_context *pipe,
+ unsigned num, struct pipe_texture **texture)
{
struct pstip_stage *pstip = pstip_stage_from_pipe(pipe);
/* save current */
- pstip->state.texture[sampler] = texture;
+ memcpy(pstip->state.textures, texture, num * sizeof(struct pipe_texture *));
+ pstip->num_textures = num;
/* pass-through */
- pstip->driver_set_sampler_texture(pstip->pipe, sampler, texture);
+ pstip->driver_set_sampler_textures(pstip->pipe, num, texture);
}
@@ -682,8 +693,8 @@ draw_install_pstipple_stage(struct draw_context *draw,
pstip->driver_bind_fs_state = pipe->bind_fs_state;
pstip->driver_delete_fs_state = pipe->delete_fs_state;
- pstip->driver_bind_sampler_state = pipe->bind_sampler_state;
- pstip->driver_set_sampler_texture = pipe->set_sampler_texture;
+ pstip->driver_bind_sampler_states = pipe->bind_sampler_states;
+ pstip->driver_set_sampler_textures = pipe->set_sampler_textures;
pstip->driver_set_polygon_stipple = pipe->set_polygon_stipple;
/* override the driver's functions */
@@ -691,7 +702,7 @@ draw_install_pstipple_stage(struct draw_context *draw,
pipe->bind_fs_state = pstip_bind_fs_state;
pipe->delete_fs_state = pstip_delete_fs_state;
- pipe->bind_sampler_state = pstip_bind_sampler_state;
- pipe->set_sampler_texture = pstip_set_sampler_texture;
+ pipe->bind_sampler_states = pstip_bind_sampler_states;
+ pipe->set_sampler_textures = pstip_set_sampler_textures;
pipe->set_polygon_stipple = pstip_set_polygon_stipple;
}
diff --git a/src/gallium/auxiliary/draw/draw_unfilled.c b/src/gallium/auxiliary/draw/draw_unfilled.c
index 4d718d514c..b07860cd9e 100644
--- a/src/gallium/auxiliary/draw/draw_unfilled.c
+++ b/src/gallium/auxiliary/draw/draw_unfilled.c
@@ -129,7 +129,7 @@ static void unfilled_tri( struct draw_stage *stage,
points( stage, header );
break;
default:
- abort();
+ assert(0);
}
}
diff --git a/src/gallium/auxiliary/draw/draw_vbuf.h b/src/gallium/auxiliary/draw/draw_vbuf.h
index cfd2b9820c..5e7de905c1 100644
--- a/src/gallium/auxiliary/draw/draw_vbuf.h
+++ b/src/gallium/auxiliary/draw/draw_vbuf.h
@@ -85,6 +85,12 @@ struct vbuf_render {
const ushort *indices,
uint nr_indices );
+ /* Draw Arrays path too.
+ */
+ void (*draw_arrays)( struct vbuf_render *,
+ unsigned start,
+ uint nr );
+
/**
* Called when vbuf is done with this set of vertices:
*/
diff --git a/src/gallium/auxiliary/draw/draw_vertex_cache.c b/src/gallium/auxiliary/draw/draw_vertex_cache.c
index 53f8bbec44..161b247d4e 100644
--- a/src/gallium/auxiliary/draw/draw_vertex_cache.c
+++ b/src/gallium/auxiliary/draw/draw_vertex_cache.c
@@ -41,7 +41,11 @@ void draw_vertex_cache_invalidate( struct draw_context *draw )
assert(draw->vs.queue_nr == 0);
assert(draw->vcache.referenced == 0);
-// memset(draw->vcache.idx, ~0, sizeof(draw->vcache.idx));
+ /* There's an error somewhere in the vcache code that requires this
+ * memset. The bug is exposed in q3demo demo001, but probably
+ * elsewhere as well. Will track it down later.
+ */
+ memset(draw->vcache.idx, ~0, sizeof(draw->vcache.idx));
}
diff --git a/src/gallium/auxiliary/draw/draw_vertex_fetch.c b/src/gallium/auxiliary/draw/draw_vertex_fetch.c
index cb8cdd04a3..b56d85396d 100644
--- a/src/gallium/auxiliary/draw/draw_vertex_fetch.c
+++ b/src/gallium/auxiliary/draw/draw_vertex_fetch.c
@@ -54,7 +54,7 @@ fetch_##NAME(const void *ptr, float *attrib) \
int i; \
\
for (i = 0; i < SZ; i++) { \
- attrib[i] = CVT; \
+ attrib[i] = CVT(i); \
} \
\
for (; i < 4; i++) { \
@@ -62,24 +62,24 @@ fetch_##NAME(const void *ptr, float *attrib) \
} \
}
-#define CVT_64_FLOAT (float) ((double *) ptr)[i]
-#define CVT_32_FLOAT ((float *) ptr)[i]
+#define CVT_64_FLOAT(i) (float) ((double *) ptr)[i]
+#define CVT_32_FLOAT(i) ((float *) ptr)[i]
-#define CVT_8_USCALED (float) ((unsigned char *) ptr)[i]
-#define CVT_16_USCALED (float) ((unsigned short *) ptr)[i]
-#define CVT_32_USCALED (float) ((unsigned int *) ptr)[i]
+#define CVT_8_USCALED(i) (float) ((unsigned char *) ptr)[i]
+#define CVT_16_USCALED(i) (float) ((unsigned short *) ptr)[i]
+#define CVT_32_USCALED(i) (float) ((unsigned int *) ptr)[i]
-#define CVT_8_SSCALED (float) ((char *) ptr)[i]
-#define CVT_16_SSCALED (float) ((short *) ptr)[i]
-#define CVT_32_SSCALED (float) ((int *) ptr)[i]
+#define CVT_8_SSCALED(i) (float) ((char *) ptr)[i]
+#define CVT_16_SSCALED(i) (float) ((short *) ptr)[i]
+#define CVT_32_SSCALED(i) (float) ((int *) ptr)[i]
-#define CVT_8_UNORM (float) ((unsigned char *) ptr)[i] / 255.0f
-#define CVT_16_UNORM (float) ((unsigned short *) ptr)[i] / 65535.0f
-#define CVT_32_UNORM (float) ((unsigned int *) ptr)[i] / 4294967295.0f
+#define CVT_8_UNORM(i) (float) ((unsigned char *) ptr)[i] / 255.0f
+#define CVT_16_UNORM(i) (float) ((unsigned short *) ptr)[i] / 65535.0f
+#define CVT_32_UNORM(i) (float) ((unsigned int *) ptr)[i] / 4294967295.0f
-#define CVT_8_SNORM (float) ((char *) ptr)[i] / 127.0f
-#define CVT_16_SNORM (float) ((short *) ptr)[i] / 32767.0f
-#define CVT_32_SNORM (float) ((int *) ptr)[i] / 2147483647.0f
+#define CVT_8_SNORM(i) (float) ((char *) ptr)[i] / 127.0f
+#define CVT_16_SNORM(i) (float) ((short *) ptr)[i] / 32767.0f
+#define CVT_32_SNORM(i) (float) ((int *) ptr)[i] / 2147483647.0f
FETCH_ATTRIB( R64G64B64A64_FLOAT, 4, CVT_64_FLOAT )
FETCH_ATTRIB( R64G64B64_FLOAT, 3, CVT_64_FLOAT )
@@ -156,6 +156,16 @@ FETCH_ATTRIB( A8R8G8B8_UNORM, 4, CVT_8_UNORM )
+static void
+fetch_B8G8R8A8_UNORM(const void *ptr, float *attrib)
+{
+ attrib[2] = CVT_8_UNORM(0);
+ attrib[1] = CVT_8_UNORM(1);
+ attrib[0] = CVT_8_UNORM(2);
+ attrib[3] = CVT_8_UNORM(3);
+}
+
+
static fetch_func get_fetch_func( enum pipe_format format )
{
#if 0
@@ -296,6 +306,10 @@ static fetch_func get_fetch_func( enum pipe_format format )
case PIPE_FORMAT_A8R8G8B8_UNORM:
return fetch_A8R8G8B8_UNORM;
+
+ case PIPE_FORMAT_B8G8R8A8_UNORM:
+ return fetch_B8G8R8A8_UNORM;
+
case 0:
return NULL; /* not sure why this is needed */
diff --git a/src/gallium/auxiliary/draw/draw_vertex_shader.c b/src/gallium/auxiliary/draw/draw_vertex_shader.c
index 1e95355555..133418baca 100644
--- a/src/gallium/auxiliary/draw/draw_vertex_shader.c
+++ b/src/gallium/auxiliary/draw/draw_vertex_shader.c
@@ -110,13 +110,20 @@ draw_bind_vertex_shader(struct draw_context *draw,
struct draw_vertex_shader *dvs)
{
draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
+
+ if (dvs)
+ {
+ draw->vertex_shader = dvs;
+ draw->num_vs_outputs = dvs->info.num_outputs;
- draw->vertex_shader = dvs;
- draw->num_vs_outputs = dvs->info.num_outputs;
+ tgsi_exec_machine_init(&draw->machine);
- tgsi_exec_machine_init(&draw->machine);
-
- dvs->prepare( dvs, draw );
+ dvs->prepare( dvs, draw );
+ }
+ else {
+ draw->vertex_shader = NULL;
+ draw->num_vs_outputs = 0;
+ }
}
diff --git a/src/gallium/auxiliary/draw/draw_vs_exec.c b/src/gallium/auxiliary/draw/draw_vs_exec.c
index 583812aadd..55bec14116 100644
--- a/src/gallium/auxiliary/draw/draw_vs_exec.c
+++ b/src/gallium/auxiliary/draw/draw_vs_exec.c
@@ -71,7 +71,7 @@ vs_exec_prepare( struct draw_vertex_shader *shader,
{
/* specify the vertex program to interpret/execute */
tgsi_exec_machine_bind_shader(&draw->machine,
- shader->state->tokens,
+ shader->state.tokens,
PIPE_MAX_SAMPLERS,
NULL /*samplers*/ );
@@ -132,20 +132,30 @@ vs_exec_run( struct draw_vertex_shader *shader,
z = vOut[j]->clip[2] = machine->Outputs[0].xyzw[2].f[j];
w = vOut[j]->clip[3] = machine->Outputs[0].xyzw[3].f[j];
- vOut[j]->clipmask = compute_clipmask(vOut[j]->clip, draw->plane, draw->nr_planes);
- vOut[j]->edgeflag = 1;
-
- /* divide by w */
- w = 1.0f / w;
- x *= w;
- y *= w;
- z *= w;
-
- /* Viewport mapping */
- vOut[j]->data[0][0] = x * scale[0] + trans[0];
- vOut[j]->data[0][1] = y * scale[1] + trans[1];
- vOut[j]->data[0][2] = z * scale[2] + trans[2];
- vOut[j]->data[0][3] = w;
+ if (!draw->rasterizer->bypass_clipping) {
+ vOut[j]->clipmask = compute_clipmask(vOut[j]->clip, draw->plane, draw->nr_planes);
+ vOut[j]->edgeflag = 1;
+
+ /* divide by w */
+ w = 1.0f / w;
+ x *= w;
+ y *= w;
+ z *= w;
+
+ /* Viewport mapping */
+ vOut[j]->data[0][0] = x * scale[0] + trans[0];
+ vOut[j]->data[0][1] = y * scale[1] + trans[1];
+ vOut[j]->data[0][2] = z * scale[2] + trans[2];
+ vOut[j]->data[0][3] = w;
+ }
+ else {
+ vOut[j]->clipmask = 0;
+ vOut[j]->edgeflag = 1;
+ vOut[j]->data[0][0] = x;
+ vOut[j]->data[0][1] = y;
+ vOut[j]->data[0][2] = z;
+ vOut[j]->data[0][3] = w;
+ }
/* Remaining attributes are packed into sequential post-transform
* vertex attrib slots.
@@ -177,7 +187,7 @@ draw_create_vs_exec(struct draw_context *draw,
if (vs == NULL)
return NULL;
- vs->state = state;
+ vs->state = *state;
vs->prepare = vs_exec_prepare;
vs->run = vs_exec_run;
vs->delete = vs_exec_delete;
diff --git a/src/gallium/auxiliary/draw/draw_vs_llvm.c b/src/gallium/auxiliary/draw/draw_vs_llvm.c
index 0fd557d667..53c260be53 100644
--- a/src/gallium/auxiliary/draw/draw_vs_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_vs_llvm.c
@@ -135,25 +135,35 @@ vs_llvm_run( struct draw_vertex_shader *base,
unsigned slot;
float x, y, z, w;
- x = vOut[j]->clip[0] = machine->Outputs[0].xyzw[0].f[j];
- y = vOut[j]->clip[1] = machine->Outputs[0].xyzw[1].f[j];
- z = vOut[j]->clip[2] = machine->Outputs[0].xyzw[2].f[j];
- w = vOut[j]->clip[3] = machine->Outputs[0].xyzw[3].f[j];
-
- vOut[j]->clipmask = compute_clipmask(vOut[j]->clip, draw->plane, draw->nr_planes);
- vOut[j]->edgeflag = 1;
-
- /* divide by w */
- w = 1.0f / w;
- x *= w;
- y *= w;
- z *= w;
-
- /* Viewport mapping */
- vOut[j]->data[0][0] = x * scale[0] + trans[0];
- vOut[j]->data[0][1] = y * scale[1] + trans[1];
- vOut[j]->data[0][2] = z * scale[2] + trans[2];
- vOut[j]->data[0][3] = w;
+ if (!draw->rasterizer->bypass_clipping) {
+ x = vOut[j]->clip[0] = machine->Outputs[0].xyzw[0].f[j];
+ y = vOut[j]->clip[1] = machine->Outputs[0].xyzw[1].f[j];
+ z = vOut[j]->clip[2] = machine->Outputs[0].xyzw[2].f[j];
+ w = vOut[j]->clip[3] = machine->Outputs[0].xyzw[3].f[j];
+
+ vOut[j]->clipmask = compute_clipmask(vOut[j]->clip, draw->plane, draw->nr_planes);
+ vOut[j]->edgeflag = 1;
+
+ /* divide by w */
+ w = 1.0f / w;
+ x *= w;
+ y *= w;
+ z *= w;
+
+ /* Viewport mapping */
+ vOut[j]->data[0][0] = x * scale[0] + trans[0];
+ vOut[j]->data[0][1] = y * scale[1] + trans[1];
+ vOut[j]->data[0][2] = z * scale[2] + trans[2];
+ vOut[j]->data[0][3] = w;
+ }
+ else {
+ vOut[j]->clipmask = 0;
+ vOut[j]->edgeflag = 1;
+ vOut[j]->data[0][0] = x;
+ vOut[j]->data[0][1] = y;
+ vOut[j]->data[0][2] = z;
+ vOut[j]->data[0][3] = w;
+ }
/* Remaining attributes are packed into sequential post-transform
* vertex attrib slots.
diff --git a/src/gallium/auxiliary/draw/draw_vs_sse.c b/src/gallium/auxiliary/draw/draw_vs_sse.c
index 0b8bc2bf14..5ee2adb344 100644
--- a/src/gallium/auxiliary/draw/draw_vs_sse.c
+++ b/src/gallium/auxiliary/draw/draw_vs_sse.c
@@ -158,20 +158,30 @@ vs_sse_run( struct draw_vertex_shader *base,
z = vOut[j]->clip[2] = machine->Outputs[0].xyzw[2].f[j];
w = vOut[j]->clip[3] = machine->Outputs[0].xyzw[3].f[j];
- vOut[j]->clipmask = compute_clipmask(vOut[j]->clip, draw->plane, draw->nr_planes);
- vOut[j]->edgeflag = 1;
-
- /* divide by w */
- w = 1.0f / w;
- x *= w;
- y *= w;
- z *= w;
-
- /* Viewport mapping */
- vOut[j]->data[0][0] = x * scale[0] + trans[0];
- vOut[j]->data[0][1] = y * scale[1] + trans[1];
- vOut[j]->data[0][2] = z * scale[2] + trans[2];
- vOut[j]->data[0][3] = w;
+ if (!draw->rasterizer->bypass_clipping) {
+ vOut[j]->clipmask = compute_clipmask(vOut[j]->clip, draw->plane, draw->nr_planes);
+ vOut[j]->edgeflag = 1;
+
+ /* divide by w */
+ w = 1.0f / w;
+ x *= w;
+ y *= w;
+ z *= w;
+
+ /* Viewport mapping */
+ vOut[j]->data[0][0] = x * scale[0] + trans[0];
+ vOut[j]->data[0][1] = y * scale[1] + trans[1];
+ vOut[j]->data[0][2] = z * scale[2] + trans[2];
+ vOut[j]->data[0][3] = w;
+ }
+ else {
+ vOut[j]->clipmask = 0;
+ vOut[j]->edgeflag = 1;
+ vOut[j]->data[0][0] = x;
+ vOut[j]->data[0][1] = y;
+ vOut[j]->data[0][2] = z;
+ vOut[j]->data[0][3] = w;
+ }
/* Remaining attributes are packed into sequential post-transform
* vertex attrib slots.
@@ -211,14 +221,14 @@ draw_create_vs_sse(struct draw_context *draw,
if (vs == NULL)
return NULL;
- vs->base.state = templ;
+ vs->base.state = *templ;
vs->base.prepare = vs_sse_prepare;
vs->base.run = vs_sse_run;
vs->base.delete = vs_sse_delete;
x86_init_func( &vs->sse2_program );
- if (!tgsi_emit_sse2( (struct tgsi_token *) vs->base.state->tokens,
+ if (!tgsi_emit_sse2( (struct tgsi_token *) vs->base.state.tokens,
&vs->sse2_program ))
goto fail;