unsigned num_vs_inputs = draw->vs.vertex_shader->info.num_inputs;
const struct vertex_info *vinfo;
unsigned i;
- boolean need_psize = 0;
if (!draw->render->set_primitive( draw->render,
for (i = 0; i < vinfo->num_attribs; i++) {
unsigned emit_sz = 0;
- unsigned output_format = PIPE_FORMAT_NONE;
- unsigned vs_output = vinfo->src_index[i];
switch (vinfo->emit[i]) {
case EMIT_4F:
- output_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
emit_sz = 4 * sizeof(float);
break;
case EMIT_3F:
- output_format = PIPE_FORMAT_R32G32B32_FLOAT;
emit_sz = 3 * sizeof(float);
break;
case EMIT_2F:
- output_format = PIPE_FORMAT_R32G32_FLOAT;
emit_sz = 2 * sizeof(float);
break;
case EMIT_1F:
- output_format = PIPE_FORMAT_R32_FLOAT;
emit_sz = 1 * sizeof(float);
break;
case EMIT_1F_PSIZE:
- need_psize = 1;
- output_format = PIPE_FORMAT_R32_FLOAT;
emit_sz = 1 * sizeof(float);
- vs_output = vinfo->num_attribs + 1;
break;
case EMIT_4UB:
- output_format = PIPE_FORMAT_B8G8R8A8_UNORM;
emit_sz = 4 * sizeof(ubyte);
break;
default:
* numbers, not to positions in the hw vertex description --
* that's handled by the output_offset field.
*/
- fse->key.element[vs_output].out.format = output_format;
- fse->key.element[vs_output].out.vs_output = vs_output;
- fse->key.element[vs_output].out.offset = dst_offset;
+ fse->key.element[i].out.format = vinfo->emit[i];
+ fse->key.element[i].out.vs_output = vinfo->src_index[i];
+ fse->key.element[i].out.offset = dst_offset;
dst_offset += emit_sz;
assert(fse->key.output_stride >= dst_offset);
}
}
- /* To make psize work, really need to tell the vertex shader to
- * copy that value from input->output. For 'translate' this was
- * implicit for all elements.
- */
-#if 0
- if (need_psize) {
- unsigned input = num_vs_inputs + 1;
- const struct pipe_vertex_element *src = &draw->pt.vertex_element[i];
- fse->key.element[i].input_format = PIPE_FORMAT_R32_FLOAT;
- fse->key.element[i].input_buffer = 0; //nr_buffers + 1;
- fse->key.element[i].input_offset = 0;
-
- fse->key.nr_inputs += 1;
- fse->key.nr_elements = MAX2(fse->key.nr_inputs,
- fse->key.nr_outputs);
-
- }
-#endif
/* Would normally look up a vertex shader and peruse its list of
* varients somehow. We omitted that step and put all the
void draw_dump_emitted_vertex(const struct vertex_info *vinfo,
const uint8_t *data);
+
+static INLINE unsigned draw_translate_vinfo_format(unsigned format )
+{
+ switch (format) {
+ case EMIT_1F:
+ case EMIT_1F_PSIZE:
+ return PIPE_FORMAT_R32_FLOAT;
+ case EMIT_2F:
+ return PIPE_FORMAT_R32G32_FLOAT;
+ case EMIT_3F:
+ return PIPE_FORMAT_R32G32B32_FLOAT;
+ case EMIT_4F:
+ return PIPE_FORMAT_R32G32B32A32_FLOAT;
+ case EMIT_4UB:
+ return PIPE_FORMAT_R8G8B8A8_UNORM;
+ default:
+ return PIPE_FORMAT_NONE;
+ }
+}
+
+
#endif /* DRAW_VERTEX_H */
{
struct draw_vs_varient_aos_sse *vaos = (struct draw_vs_varient_aos_sse *)varient;
+ vaos->machine->internal[IMM_PSIZE][0] = vaos->draw->rasterizer->point_size;
vaos->gen_run_elts( varient,
elts,
count,
{
struct draw_vs_varient_aos_sse *vaos = (struct draw_vs_varient_aos_sse *)varient;
+ vaos->machine->internal[IMM_PSIZE][0] = vaos->draw->rasterizer->point_size;
vaos->gen_run_linear( varient,
start,
count,
vaos->base.run_linear = vaos_run_linear;
vaos->base.run_elts = vaos_run_elts;
+ vaos->draw = vs->draw;
vaos->machine = align_malloc( sizeof(struct aos_machine), 16 );
if (!vaos->machine)
goto fail;
#define IMM_255 4 /* 255, 255, 255, 255 */
#define IMM_NEGS 5 /* -1,-1,-1,-1 */
#define IMM_RSQ 6 /* -.5,1.5,_,_ */
+#define IMM_PSIZE 7 /* not really an immediate - updated each run */
struct x86_reg aos_get_internal( struct aos_compilation *cp,
unsigned imm );
#include "tgsi/exec/tgsi_exec.h"
#include "draw_vs.h"
#include "draw_vs_aos.h"
+#include "draw_vertex.h"
#include "rtasm/rtasm_x86sse.h"
unsigned format )
{
switch (format) {
- case PIPE_FORMAT_R32_FLOAT:
+ case EMIT_1F:
+ case EMIT_1F_PSIZE:
emit_store_R32(cp, ptr, dataXMM);
break;
- case PIPE_FORMAT_R32G32_FLOAT:
+ case EMIT_2F:
emit_store_R32G32(cp, ptr, dataXMM);
break;
- case PIPE_FORMAT_R32G32B32_FLOAT:
+ case EMIT_3F:
emit_store_R32G32B32(cp, ptr, dataXMM);
break;
- case PIPE_FORMAT_R32G32B32A32_FLOAT:
+ case EMIT_4F:
emit_store_R32G32B32A32(cp, ptr, dataXMM);
break;
- case PIPE_FORMAT_B8G8R8A8_UNORM:
- emit_swizzle(cp, dataXMM, dataXMM, SHUF(Z,Y,X,W));
- emit_store_R8G8B8A8_UNORM(cp, ptr, dataXMM);
- break;
- case PIPE_FORMAT_R8G8B8A8_UNORM:
- emit_store_R8G8B8A8_UNORM(cp, ptr, dataXMM);
+ case EMIT_4UB:
+ if (1) {
+ emit_swizzle(cp, dataXMM, dataXMM, SHUF(Z,Y,X,W));
+ emit_store_R8G8B8A8_UNORM(cp, ptr, dataXMM);
+ }
+ else {
+ emit_store_R8G8B8A8_UNORM(cp, ptr, dataXMM);
+ }
break;
default:
ERROR(cp, "unhandled output format");
unsigned offset = cp->vaos->base.key.element[i].out.offset;
unsigned vs_output = cp->vaos->base.key.element[i].out.vs_output;
- struct x86_reg data = aos_get_shader_reg( cp,
- TGSI_FILE_OUTPUT,
- vs_output );
+ struct x86_reg data;
+
+ if (format == EMIT_1F_PSIZE) {
+ data = aos_get_internal_xmm( cp, IMM_PSIZE );
+ }
+ else {
+ data = aos_get_shader_reg( cp,
+ TGSI_FILE_OUTPUT,
+ vs_output );
+ }
if (data.file != file_XMM) {
struct x86_reg tmp = aos_get_xmm_reg( cp );
output_buffer,
vsvg->base.key.output_stride );
+ vsvg->emit->set_buffer( vsvg->emit,
+ 1,
+ &vsvg->draw->rasterizer->point_size,
+ 0);
vsvg->emit->run( vsvg->emit,
0, count,
emit.nr_elements = key->nr_outputs;
emit.output_stride = key->output_stride;
for (i = 0; i < key->nr_outputs; i++) {
- emit.element[i].input_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
- emit.element[i].input_buffer = 0;
- emit.element[i].input_offset = i * 4 * sizeof(float);
- emit.element[i].output_format = key->element[i].out.format;
- emit.element[i].output_offset = key->element[i].out.offset;
+ if (key->element[i].out.format != EMIT_1F_PSIZE)
+ {
+ emit.element[i].input_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+ emit.element[i].input_buffer = 0;
+ emit.element[i].input_offset = key->element[i].out.vs_output * 4 * sizeof(float);
+ emit.element[i].output_format = draw_translate_vinfo_format(key->element[i].out.format);
+ emit.element[i].output_offset = key->element[i].out.offset;
+ }
+ else {
+ emit.element[i].input_format = PIPE_FORMAT_R32_FLOAT;
+ emit.element[i].input_buffer = 1;
+ emit.element[i].input_offset = 0;
+ emit.element[i].output_format = PIPE_FORMAT_R32_FLOAT;
+ emit.element[i].output_offset = key->element[i].out.offset;
+ }
}
vsvg->fetch = draw_vs_get_fetch( vs->draw, &fetch );