00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "brw_defines.h"
00033 #include "brw_context.h"
00034 #include "brw_eu.h"
00035 #include "brw_util.h"
00036 #include "brw_gs.h"
00037
00038 static void brw_gs_alloc_regs( struct brw_gs_compile *c,
00039 unsigned nr_verts )
00040 {
00041 unsigned i = 0,j;
00042
00043
00044
00045 c->reg.R0 = retype(brw_vec8_grf(i, 0), BRW_REGISTER_TYPE_UD); i++;
00046
00047
00048
00049 for (j = 0; j < nr_verts; j++) {
00050 c->reg.vertex[j] = brw_vec4_grf(i, 0);
00051 i += c->nr_regs;
00052 }
00053
00054 c->prog_data.urb_read_length = c->nr_regs;
00055 c->prog_data.total_grf = i;
00056 }
00057
00058
00059 static void brw_gs_emit_vue(struct brw_gs_compile *c,
00060 struct brw_reg vert,
00061 boolean last,
00062 unsigned header)
00063 {
00064 struct brw_compile *p = &c->func;
00065 boolean allocate = !last;
00066
00067
00068
00069
00070 brw_MOV(p, get_element_ud(c->reg.R0, 2), brw_imm_ud(header));
00071
00072
00073
00074 brw_copy8(p, brw_message_reg(1), vert, c->nr_regs);
00075
00076
00077
00078
00079
00080
00081
00082 brw_urb_WRITE(p,
00083 allocate ? c->reg.R0 : retype(brw_null_reg(), BRW_REGISTER_TYPE_UD),
00084 0,
00085 c->reg.R0,
00086 allocate,
00087 1,
00088 c->nr_regs + 1,
00089 allocate ? 1 : 0,
00090 allocate ? 0 : 1,
00091 1,
00092 0,
00093 BRW_URB_SWIZZLE_NONE);
00094 }
00095
00096
00097
00098 void brw_gs_quads( struct brw_gs_compile *c )
00099 {
00100 brw_gs_alloc_regs(c, 4);
00101
00102
00103
00104
00105 brw_gs_emit_vue(c, c->reg.vertex[3], 0, ((_3DPRIM_POLYGON << 2) | R02_PRIM_START));
00106 brw_gs_emit_vue(c, c->reg.vertex[0], 0, (_3DPRIM_POLYGON << 2));
00107 brw_gs_emit_vue(c, c->reg.vertex[1], 0, (_3DPRIM_POLYGON << 2));
00108 brw_gs_emit_vue(c, c->reg.vertex[2], 1, ((_3DPRIM_POLYGON << 2) | R02_PRIM_END));
00109 }
00110
00111 void brw_gs_quad_strip( struct brw_gs_compile *c )
00112 {
00113 brw_gs_alloc_regs(c, 4);
00114
00115 brw_gs_emit_vue(c, c->reg.vertex[2], 0, ((_3DPRIM_POLYGON << 2) | R02_PRIM_START));
00116 brw_gs_emit_vue(c, c->reg.vertex[3], 0, (_3DPRIM_POLYGON << 2));
00117 brw_gs_emit_vue(c, c->reg.vertex[0], 0, (_3DPRIM_POLYGON << 2));
00118 brw_gs_emit_vue(c, c->reg.vertex[1], 1, ((_3DPRIM_POLYGON << 2) | R02_PRIM_END));
00119 }
00120
00121 void brw_gs_tris( struct brw_gs_compile *c )
00122 {
00123 brw_gs_alloc_regs(c, 3);
00124 brw_gs_emit_vue(c, c->reg.vertex[0], 0, ((_3DPRIM_TRILIST << 2) | R02_PRIM_START));
00125 brw_gs_emit_vue(c, c->reg.vertex[1], 0, (_3DPRIM_TRILIST << 2));
00126 brw_gs_emit_vue(c, c->reg.vertex[2], 1, ((_3DPRIM_TRILIST << 2) | R02_PRIM_END));
00127 }
00128
00129 void brw_gs_lines( struct brw_gs_compile *c )
00130 {
00131 brw_gs_alloc_regs(c, 2);
00132 brw_gs_emit_vue(c, c->reg.vertex[0], 0, ((_3DPRIM_LINESTRIP << 2) | R02_PRIM_START));
00133 brw_gs_emit_vue(c, c->reg.vertex[1], 1, ((_3DPRIM_LINESTRIP << 2) | R02_PRIM_END));
00134 }
00135
00136 void brw_gs_points( struct brw_gs_compile *c )
00137 {
00138 brw_gs_alloc_regs(c, 1);
00139 brw_gs_emit_vue(c, c->reg.vertex[0], 1, ((_3DPRIM_POINTLIST << 2) | R02_PRIM_START | R02_PRIM_END));
00140 }
00141
00142
00143
00144
00145
00146
00147
00148