summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-08-18 16:06:49 +0100
committerBrian <[email protected]>2007-08-18 16:06:49 +0100
commit0453760a0bf139f113792d22e65ce6904f06f28b (patch)
tree2090448245ac2a7898830108b517886a379ee247 /src
parent1f026d98dd77b6d26cc76946d92f69a9e6091b8e (diff)
more work on vertex shaders, now using vertex shaders instead of TnL module by default
Diffstat (limited to 'src')
-rw-r--r--src/mesa/pipe/softpipe/sp_draw_arrays.c64
-rw-r--r--src/mesa/pipe/softpipe/sp_state_derived.c2
2 files changed, 59 insertions, 7 deletions
diff --git a/src/mesa/pipe/softpipe/sp_draw_arrays.c b/src/mesa/pipe/softpipe/sp_draw_arrays.c
index 18ed3c9d5a6..e7dec319216 100644
--- a/src/mesa/pipe/softpipe/sp_draw_arrays.c
+++ b/src/mesa/pipe/softpipe/sp_draw_arrays.c
@@ -87,6 +87,36 @@ compute_clipmask(float cx, float cy, float cz, float cw)
}
+/**
+ * Fetch a float[4] vertex attribute from memory, doing format/type
+ * conversion as needed.
+ * XXX this might be a temporary thing.
+ */
+static void
+fetch_attrib4(const void *ptr, unsigned format, float attrib[4])
+{
+ /* defaults */
+ attrib[1] = 0.0;
+ attrib[2] = 0.0;
+ attrib[3] = 1.0;
+ switch (format) {
+ case PIPE_FORMAT_R32G32B32A32_FLOAT:
+ attrib[3] = ((float *) ptr)[3];
+ /* fall-through */
+ case PIPE_FORMAT_R32G32B32_FLOAT:
+ attrib[2] = ((float *) ptr)[2];
+ /* fall-through */
+ case PIPE_FORMAT_R32G32_FLOAT:
+ attrib[1] = ((float *) ptr)[1];
+ /* fall-through */
+ case PIPE_FORMAT_R32_FLOAT:
+ attrib[0] = ((float *) ptr)[0];
+ break;
+ default:
+ assert(0);
+ }
+}
+
/**
* Transform vertices with the current vertex program/shader
@@ -129,21 +159,39 @@ run_vertex_program(struct draw_context *draw,
machine.Inputs = ALIGN16_ASSIGN(inputs);
machine.Outputs = ALIGN16_ASSIGN(outputs);
+
+ if (0)
+ {
+ unsigned attr;
+ for (attr = 0; attr < 16; attr++) {
+ if (sp->vs.inputs_read & (1 << attr)) {
+ printf("attr %d: buf_off %d src_off %d pitch %d\n",
+ attr,
+ draw->vertex_buffer[attr].buffer_offset,
+ draw->vertex_element[attr].src_offset,
+ draw->vertex_buffer[attr].pitch);
+ }
+ }
+ }
+
/* load machine inputs */
for (j = 0; j < count; j++) {
unsigned attr;
for (attr = 0; attr < 16; attr++) {
if (sp->vs.inputs_read & (1 << attr)) {
- const float *p
- = (const float *) ((const ubyte *) vbuffer
- + draw->vertex_buffer[attr].buffer_offset
- + draw->vertex_element[attr].src_offset
- + elts[j] * draw->vertex_buffer[attr].pitch);
+ const void *src
+ = (const void *) ((const ubyte *) vbuffer
+ + draw->vertex_buffer[attr].buffer_offset
+ + draw->vertex_element[attr].src_offset
+ + elts[j] * draw->vertex_buffer[attr].pitch);
+ float p[4];
+
+ fetch_attrib4(src, draw->vertex_element[attr].src_format, p);
machine.Inputs[attr].xyzw[0].f[j] = p[0]; /*X*/
machine.Inputs[attr].xyzw[1].f[j] = p[1]; /*Y*/
machine.Inputs[attr].xyzw[2].f[j] = p[2]; /*Z*/
- machine.Inputs[attr].xyzw[3].f[j] = 1.0; /*W*/
+ machine.Inputs[attr].xyzw[3].f[j] = p[3]; /*W*/
#if 0
if (attr == 0) {
printf("Input vertex %d: %f %f %f\n",
@@ -371,12 +419,16 @@ softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
struct draw_context *draw = sp->draw;
struct pipe_buffer_handle *buf;
+ if (sp->dirty)
+ softpipe_update_derived( sp );
+
softpipe_map_surfaces(sp);
/*
* Map vertex buffers
*/
buf = sp->vertex_buffer[0].buffer;
+ assert(buf);
draw->mapped_vbuffer
= pipe->winsys->buffer_map(pipe->winsys, buf, PIPE_BUFFER_FLAG_READ);
diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c
index 35f1a971ca3..95b0cfee033 100644
--- a/src/mesa/pipe/softpipe/sp_state_derived.c
+++ b/src/mesa/pipe/softpipe/sp_state_derived.c
@@ -216,7 +216,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
if (attr_mask != softpipe->attr_mask) {
softpipe->attr_mask = attr_mask;
-#define USE_NEW_DRAW 0
+#define USE_NEW_DRAW 01
#if USE_NEW_DRAW
draw_set_vertex_attributes2( softpipe->draw,
slot_to_vf_attr,