* Keith Whitwell <keith@tungstengraphics.com>
*/
+#include <spu_mfcio.h>
#include "pipe/p_util.h"
#include "pipe/p_state.h"
#include "pipe/p_shader_tokens.h"
#include "spu_exec.h"
#include "spu_vertex_shader.h"
+#include "spu_main.h"
#define DRAW_DBG 0
/**
* Fetch vertex attributes for 'count' vertices.
*/
-static void generic_vertex_fetch( struct spu_vs_context *draw,
- struct spu_exec_machine *machine,
- const unsigned *elts,
- unsigned count )
+static void generic_vertex_fetch(struct spu_vs_context *draw,
+ struct spu_exec_machine *machine,
+ const unsigned *elts,
+ unsigned count)
{
unsigned nr_attrs = draw->vertex_fetch.nr_attrs;
unsigned attr;
assert(count <= 4);
+ wait_on_mask(1 << TAG_VERTEX_BUFFER);
+
// _mesa_printf("%s %d\n", __FUNCTION__, count);
/* loop over vertex attributes (vertex shader inputs)
* a prototype for an sse implementation, which would have
* difficulties doing that.
*/
- for (i = 0; i < count; i++)
- fetch( src + elts[i] * pitch, p[i] );
+ for (i = 0; i < count; i++) {
+ uint8_t buffer[32 + (sizeof(float) * 4)] ALIGN16_ATTRIB;
+ const unsigned long addr = src + elts[i] * pitch;
+ const unsigned size = (sizeof(float) * 4) + (addr & 0x0f);
+
+ mfc_get(buffer, addr & ~0x0f, size, TAG_VERTEX_BUFFER, 0, 0);
+ wait_on_mask(1 << TAG_VERTEX_BUFFER);
+
+ memcpy(& buffer, buffer + (addr & 0x0f), sizeof(float) * 4);
+
+ fetch(buffer, p[i]);
+ }
/* Be nice and zero out any missing vertices:
*/
for (/* empty */; i < 4; i++)
- p[i][0] = p[i][1] = p[i][2] = p[i][3] = 0;
+ p[i][0] = p[i][1] = p[i][2] = p[i][3] = 0;
/* Transpose/swizzle into sse-friendly format. Currently
* assuming that all vertex shader inputs are float[4], but this
draw->vertex_fetch.fetch_func = generic_vertex_fetch;
+ /* Disable the fast path because they don't use mfc_get yet.
+ */
+#if 0
switch (draw->vertex_fetch.nr_attrs) {
case 2:
if (draw->vertex_fetch.format[0] == PIPE_FORMAT_R32G32B32_FLOAT &&
default:
break;
}
+#endif
}
* Ian Romanick <idr@us.ibm.com>
*/
+#include <spu_mfcio.h>
+
#include "pipe/p_util.h"
#include "pipe/p_state.h"
#include "pipe/p_shader_tokens.h"
#include "pipe/draw/draw_private.h"
#include "pipe/draw/draw_context.h"
#include "pipe/cell/common.h"
-
-#define DBG_VS 0
-
+#include "spu_main.h"
static INLINE unsigned
compute_clipmask(const float *clip, /*const*/ float plane[][4], unsigned nr)
for (j = 0; j < count; j++) {
unsigned slot;
float x, y, z, w;
+ unsigned char buffer[sizeof(struct vertex_header)
+ + MAX_VERTEX_SIZE] ALIGN16_ATTRIB;
+ struct vertex_header *const tmpOut =
+ (struct vertex_header *) buffer;
+ const unsigned vert_size = sizeof(struct vertex_header)
+ + (sizeof(float) * 4 * draw->num_vs_outputs);
/* Handle attr[0] (position) specially:
*
* program as a set of DP4 instructions appended to the
* user-provided code.
*/
- 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];
+ x = tmpOut->clip[0] = machine->Outputs[0].xyzw[0].f[j];
+ y = tmpOut->clip[1] = machine->Outputs[0].xyzw[1].f[j];
+ z = tmpOut->clip[2] = machine->Outputs[0].xyzw[2].f[j];
+ w = tmpOut->clip[3] = machine->Outputs[0].xyzw[3].f[j];
- vOut[j]->clipmask = compute_clipmask(vOut[j]->clip, draw->plane,
+ tmpOut->clipmask = compute_clipmask(tmpOut->clip, draw->plane,
draw->nr_planes);
- vOut[j]->edgeflag = 1;
+ tmpOut->edgeflag = 1;
/* divide by w */
w = 1.0f / 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 DBG_VS
- printf("output[%d]win: %f %f %f %f\n", j,
- vOut[j]->data[0][0],
- vOut[j]->data[0][1],
- vOut[j]->data[0][2],
- vOut[j]->data[0][3]);
-#endif
+ tmpOut->data[0][0] = x * scale[0] + trans[0];
+ tmpOut->data[0][1] = y * scale[1] + trans[1];
+ tmpOut->data[0][2] = z * scale[2] + trans[2];
+ tmpOut->data[0][3] = w;
+
/* Remaining attributes are packed into sequential post-transform
* vertex attrib slots.
*/
for (slot = 1; slot < draw->num_vs_outputs; slot++) {
- vOut[j]->data[slot][0] = machine->Outputs[slot].xyzw[0].f[j];
- vOut[j]->data[slot][1] = machine->Outputs[slot].xyzw[1].f[j];
- vOut[j]->data[slot][2] = machine->Outputs[slot].xyzw[2].f[j];
- vOut[j]->data[slot][3] = machine->Outputs[slot].xyzw[3].f[j];
-#if DBG_VS
- printf("output[%d][%d]: %f %f %f %f\n", j, slot,
- vOut[j]->data[slot][0],
- vOut[j]->data[slot][1],
- vOut[j]->data[slot][2],
- vOut[j]->data[slot][3]);
-#endif
+ tmpOut->data[slot][0] = machine->Outputs[slot].xyzw[0].f[j];
+ tmpOut->data[slot][1] = machine->Outputs[slot].xyzw[1].f[j];
+ tmpOut->data[slot][2] = machine->Outputs[slot].xyzw[2].f[j];
+ tmpOut->data[slot][3] = machine->Outputs[slot].xyzw[3].f[j];
}
+
+ wait_on_mask(1 << TAG_VERTEX_BUFFER);
+ mfc_put(tmpOut, vOut[j], vert_size, TAG_VERTEX_BUFFER, 0, 0);
+
} /* loop over vertices */
+
+ wait_on_mask(1 << TAG_VERTEX_BUFFER);
}