Path: blob/21.2-virgl/src/intel/compiler/brw_compile_ff_gs.c
4550 views
/*1Copyright (C) Intel Corp. 2006. All Rights Reserved.2Intel funded Tungsten Graphics to3develop this 3D driver.45Permission is hereby granted, free of charge, to any person obtaining6a copy of this software and associated documentation files (the7"Software"), to deal in the Software without restriction, including8without limitation the rights to use, copy, modify, merge, publish,9distribute, sublicense, and/or sell copies of the Software, and to10permit persons to whom the Software is furnished to do so, subject to11the following conditions:1213The above copyright notice and this permission notice (including the14next paragraph) shall be included in all copies or substantial15portions of the Software.1617THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,18EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.20IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE21LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION22OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION23WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.2425**********************************************************************/26/*27* Authors:28* Keith Whitwell <[email protected]>29*/3031#include "brw_compiler.h"32#include "brw_eu.h"3334#include "dev/intel_debug.h"3536#define MAX_GS_VERTS (4)3738struct brw_ff_gs_compile {39struct brw_codegen func;40struct brw_ff_gs_prog_key key;41struct brw_ff_gs_prog_data *prog_data;4243struct {44struct brw_reg R0;4546/**47* Register holding streamed vertex buffer pointers -- see the Sandy48* Bridge PRM, volume 2 part 1, section 4.4.2 (GS Thread Payload49* [DevSNB]). These pointers are delivered in GRF 1.50*/51struct brw_reg SVBI;5253struct brw_reg vertex[MAX_GS_VERTS];54struct brw_reg header;55struct brw_reg temp;5657/**58* Register holding destination indices for streamed buffer writes.59* Only used for SOL programs.60*/61struct brw_reg destination_indices;62} reg;6364/* Number of registers used to store vertex data */65GLuint nr_regs;6667struct brw_vue_map vue_map;68};6970/**71* Allocate registers for GS.72*73* If sol_program is true, then:74*75* - The thread will be spawned with the "SVBI Payload Enable" bit set, so GRF76* 1 needs to be set aside to hold the streamed vertex buffer indices.77*78* - The thread will need to use the destination_indices register.79*/80static void brw_ff_gs_alloc_regs(struct brw_ff_gs_compile *c,81GLuint nr_verts,82bool sol_program)83{84GLuint i = 0,j;8586/* Register usage is static, precompute here:87*/88c->reg.R0 = retype(brw_vec8_grf(i, 0), BRW_REGISTER_TYPE_UD); i++;8990/* Streamed vertex buffer indices */91if (sol_program)92c->reg.SVBI = retype(brw_vec8_grf(i++, 0), BRW_REGISTER_TYPE_UD);9394/* Payload vertices plus space for more generated vertices:95*/96for (j = 0; j < nr_verts; j++) {97c->reg.vertex[j] = brw_vec4_grf(i, 0);98i += c->nr_regs;99}100101c->reg.header = retype(brw_vec8_grf(i++, 0), BRW_REGISTER_TYPE_UD);102c->reg.temp = retype(brw_vec8_grf(i++, 0), BRW_REGISTER_TYPE_UD);103104if (sol_program) {105c->reg.destination_indices =106retype(brw_vec4_grf(i++, 0), BRW_REGISTER_TYPE_UD);107}108109c->prog_data->urb_read_length = c->nr_regs;110c->prog_data->total_grf = i;111}112113114/**115* Set up the initial value of c->reg.header register based on c->reg.R0.116*117* The following information is passed to the GS thread in R0, and needs to be118* included in the first URB_WRITE or FF_SYNC message sent by the GS:119*120* - DWORD 0 [31:0] handle info (Gen4 only)121* - DWORD 5 [7:0] FFTID122* - DWORD 6 [31:0] Debug info123* - DWORD 7 [31:0] Debug info124*125* This function sets up the above data by copying by copying the contents of126* R0 to the header register.127*/128static void brw_ff_gs_initialize_header(struct brw_ff_gs_compile *c)129{130struct brw_codegen *p = &c->func;131brw_MOV(p, c->reg.header, c->reg.R0);132}133134/**135* Overwrite DWORD 2 of c->reg.header with the given immediate unsigned value.136*137* In URB_WRITE messages, DWORD 2 contains the fields PrimType, PrimStart,138* PrimEnd, Increment CL_INVOCATIONS, and SONumPrimsWritten, many of which we139* need to be able to update on a per-vertex basis.140*/141static void brw_ff_gs_overwrite_header_dw2(struct brw_ff_gs_compile *c,142unsigned dw2)143{144struct brw_codegen *p = &c->func;145brw_MOV(p, get_element_ud(c->reg.header, 2), brw_imm_ud(dw2));146}147148/**149* Overwrite DWORD 2 of c->reg.header with the primitive type from c->reg.R0.150*151* When the thread is spawned, GRF 0 contains the primitive type in bits 4:0152* of DWORD 2. URB_WRITE messages need the primitive type in bits 6:2 of153* DWORD 2. So this function extracts the primitive type field, bitshifts it154* appropriately, and stores it in c->reg.header.155*/156static void brw_ff_gs_overwrite_header_dw2_from_r0(struct brw_ff_gs_compile *c)157{158struct brw_codegen *p = &c->func;159brw_AND(p, get_element_ud(c->reg.header, 2), get_element_ud(c->reg.R0, 2),160brw_imm_ud(0x1f));161brw_SHL(p, get_element_ud(c->reg.header, 2),162get_element_ud(c->reg.header, 2), brw_imm_ud(2));163}164165/**166* Apply an additive offset to DWORD 2 of c->reg.header.167*168* This is used to set/unset the "PrimStart" and "PrimEnd" flags appropriately169* for each vertex.170*/171static void brw_ff_gs_offset_header_dw2(struct brw_ff_gs_compile *c,172int offset)173{174struct brw_codegen *p = &c->func;175brw_ADD(p, get_element_d(c->reg.header, 2), get_element_d(c->reg.header, 2),176brw_imm_d(offset));177}178179180/**181* Emit a vertex using the URB_WRITE message. Use the contents of182* c->reg.header for the message header, and the registers starting at \c vert183* for the vertex data.184*185* If \c last is true, then this is the last vertex, so no further URB space186* should be allocated, and this message should end the thread.187*188* If \c last is false, then a new URB entry will be allocated, and its handle189* will be stored in DWORD 0 of c->reg.header for use in the next URB_WRITE190* message.191*/192static void brw_ff_gs_emit_vue(struct brw_ff_gs_compile *c,193struct brw_reg vert,194bool last)195{196struct brw_codegen *p = &c->func;197int write_offset = 0;198bool complete = false;199200do {201/* We can't write more than 14 registers at a time to the URB */202int write_len = MIN2(c->nr_regs - write_offset, 14);203if (write_len == c->nr_regs - write_offset)204complete = true;205206/* Copy the vertex from vertn into m1..mN+1:207*/208brw_copy8(p, brw_message_reg(1), offset(vert, write_offset), write_len);209210/* Send the vertex data to the URB. If this is the last write for this211* vertex, then we mark it as complete, and either end the thread or212* allocate another vertex URB entry (depending whether this is the last213* vertex).214*/215enum brw_urb_write_flags flags;216if (!complete)217flags = BRW_URB_WRITE_NO_FLAGS;218else if (last)219flags = BRW_URB_WRITE_EOT_COMPLETE;220else221flags = BRW_URB_WRITE_ALLOCATE_COMPLETE;222brw_urb_WRITE(p,223(flags & BRW_URB_WRITE_ALLOCATE) ? c->reg.temp224: retype(brw_null_reg(), BRW_REGISTER_TYPE_UD),2250,226c->reg.header,227flags,228write_len + 1, /* msg length */229(flags & BRW_URB_WRITE_ALLOCATE) ? 1230: 0, /* response length */231write_offset, /* urb offset */232BRW_URB_SWIZZLE_NONE);233write_offset += write_len;234} while (!complete);235236if (!last) {237brw_MOV(p, get_element_ud(c->reg.header, 0),238get_element_ud(c->reg.temp, 0));239}240}241242/**243* Send an FF_SYNC message to ensure that all previously spawned GS threads244* have finished sending primitives down the pipeline, and to allocate a URB245* entry for the first output vertex. Only needed on Ironlake+.246*247* This function modifies c->reg.header: in DWORD 1, it stores num_prim (which248* is needed by the FF_SYNC message), and in DWORD 0, it stores the handle to249* the allocated URB entry (which will be needed by the URB_WRITE meesage that250* follows).251*/252static void brw_ff_gs_ff_sync(struct brw_ff_gs_compile *c, int num_prim)253{254struct brw_codegen *p = &c->func;255256brw_MOV(p, get_element_ud(c->reg.header, 1), brw_imm_ud(num_prim));257brw_ff_sync(p,258c->reg.temp,2590,260c->reg.header,2611, /* allocate */2621, /* response length */2630 /* eot */);264brw_MOV(p, get_element_ud(c->reg.header, 0),265get_element_ud(c->reg.temp, 0));266}267268269static void270brw_ff_gs_quads(struct brw_ff_gs_compile *c,271const struct brw_ff_gs_prog_key *key)272{273brw_ff_gs_alloc_regs(c, 4, false);274brw_ff_gs_initialize_header(c);275/* Use polygons for correct edgeflag behaviour. Note that vertex 3276* is the PV for quads, but vertex 0 for polygons:277*/278if (c->func.devinfo->ver == 5)279brw_ff_gs_ff_sync(c, 1);280brw_ff_gs_overwrite_header_dw2(281c, ((_3DPRIM_POLYGON << URB_WRITE_PRIM_TYPE_SHIFT)282| URB_WRITE_PRIM_START));283if (key->pv_first) {284brw_ff_gs_emit_vue(c, c->reg.vertex[0], 0);285brw_ff_gs_overwrite_header_dw2(286c, _3DPRIM_POLYGON << URB_WRITE_PRIM_TYPE_SHIFT);287brw_ff_gs_emit_vue(c, c->reg.vertex[1], 0);288brw_ff_gs_emit_vue(c, c->reg.vertex[2], 0);289brw_ff_gs_overwrite_header_dw2(290c, ((_3DPRIM_POLYGON << URB_WRITE_PRIM_TYPE_SHIFT)291| URB_WRITE_PRIM_END));292brw_ff_gs_emit_vue(c, c->reg.vertex[3], 1);293}294else {295brw_ff_gs_emit_vue(c, c->reg.vertex[3], 0);296brw_ff_gs_overwrite_header_dw2(297c, _3DPRIM_POLYGON << URB_WRITE_PRIM_TYPE_SHIFT);298brw_ff_gs_emit_vue(c, c->reg.vertex[0], 0);299brw_ff_gs_emit_vue(c, c->reg.vertex[1], 0);300brw_ff_gs_overwrite_header_dw2(301c, ((_3DPRIM_POLYGON << URB_WRITE_PRIM_TYPE_SHIFT)302| URB_WRITE_PRIM_END));303brw_ff_gs_emit_vue(c, c->reg.vertex[2], 1);304}305}306307static void308brw_ff_gs_quad_strip(struct brw_ff_gs_compile *c,309const struct brw_ff_gs_prog_key *key)310{311brw_ff_gs_alloc_regs(c, 4, false);312brw_ff_gs_initialize_header(c);313314if (c->func.devinfo->ver == 5)315brw_ff_gs_ff_sync(c, 1);316brw_ff_gs_overwrite_header_dw2(317c, ((_3DPRIM_POLYGON << URB_WRITE_PRIM_TYPE_SHIFT)318| URB_WRITE_PRIM_START));319if (key->pv_first) {320brw_ff_gs_emit_vue(c, c->reg.vertex[0], 0);321brw_ff_gs_overwrite_header_dw2(322c, _3DPRIM_POLYGON << URB_WRITE_PRIM_TYPE_SHIFT);323brw_ff_gs_emit_vue(c, c->reg.vertex[1], 0);324brw_ff_gs_emit_vue(c, c->reg.vertex[2], 0);325brw_ff_gs_overwrite_header_dw2(326c, ((_3DPRIM_POLYGON << URB_WRITE_PRIM_TYPE_SHIFT)327| URB_WRITE_PRIM_END));328brw_ff_gs_emit_vue(c, c->reg.vertex[3], 1);329}330else {331brw_ff_gs_emit_vue(c, c->reg.vertex[2], 0);332brw_ff_gs_overwrite_header_dw2(333c, _3DPRIM_POLYGON << URB_WRITE_PRIM_TYPE_SHIFT);334brw_ff_gs_emit_vue(c, c->reg.vertex[3], 0);335brw_ff_gs_emit_vue(c, c->reg.vertex[0], 0);336brw_ff_gs_overwrite_header_dw2(337c, ((_3DPRIM_POLYGON << URB_WRITE_PRIM_TYPE_SHIFT)338| URB_WRITE_PRIM_END));339brw_ff_gs_emit_vue(c, c->reg.vertex[1], 1);340}341}342343static void brw_ff_gs_lines(struct brw_ff_gs_compile *c)344{345brw_ff_gs_alloc_regs(c, 2, false);346brw_ff_gs_initialize_header(c);347348if (c->func.devinfo->ver == 5)349brw_ff_gs_ff_sync(c, 1);350brw_ff_gs_overwrite_header_dw2(351c, ((_3DPRIM_LINESTRIP << URB_WRITE_PRIM_TYPE_SHIFT)352| URB_WRITE_PRIM_START));353brw_ff_gs_emit_vue(c, c->reg.vertex[0], 0);354brw_ff_gs_overwrite_header_dw2(355c, ((_3DPRIM_LINESTRIP << URB_WRITE_PRIM_TYPE_SHIFT)356| URB_WRITE_PRIM_END));357brw_ff_gs_emit_vue(c, c->reg.vertex[1], 1);358}359360/**361* Generate the geometry shader program used on Gen6 to perform stream output362* (transform feedback).363*/364static void365gfx6_sol_program(struct brw_ff_gs_compile *c, const struct brw_ff_gs_prog_key *key,366unsigned num_verts, bool check_edge_flags)367{368struct brw_codegen *p = &c->func;369brw_inst *inst;370c->prog_data->svbi_postincrement_value = num_verts;371372brw_ff_gs_alloc_regs(c, num_verts, true);373brw_ff_gs_initialize_header(c);374375if (key->num_transform_feedback_bindings > 0) {376unsigned vertex, binding;377struct brw_reg destination_indices_uw =378vec8(retype(c->reg.destination_indices, BRW_REGISTER_TYPE_UW));379380/* Note: since we use the binding table to keep track of buffer offsets381* and stride, the GS doesn't need to keep track of a separate pointer382* into each buffer; it uses a single pointer which increments by 1 for383* each vertex. So we use SVBI0 for this pointer, regardless of whether384* transform feedback is in interleaved or separate attribs mode.385*386* Make sure that the buffers have enough room for all the vertices.387*/388brw_ADD(p, get_element_ud(c->reg.temp, 0),389get_element_ud(c->reg.SVBI, 0), brw_imm_ud(num_verts));390brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_LE,391get_element_ud(c->reg.temp, 0),392get_element_ud(c->reg.SVBI, 4));393brw_IF(p, BRW_EXECUTE_1);394395/* Compute the destination indices to write to. Usually we use SVBI[0]396* + (0, 1, 2). However, for odd-numbered triangles in tristrips, the397* vertices come down the pipeline in reversed winding order, so we need398* to flip the order when writing to the transform feedback buffer. To399* ensure that flatshading accuracy is preserved, we need to write them400* in order SVBI[0] + (0, 2, 1) if we're using the first provoking401* vertex convention, and in order SVBI[0] + (1, 0, 2) if we're using402* the last provoking vertex convention.403*404* Note: since brw_imm_v can only be used in instructions in405* packed-word execution mode, and SVBI is a double-word, we need to406* first move the appropriate immediate constant ((0, 1, 2), (0, 2, 1),407* or (1, 0, 2)) to the destination_indices register, and then add SVBI408* using a separate instruction. Also, since the immediate constant is409* expressed as packed words, and we need to load double-words into410* destination_indices, we need to intersperse zeros to fill the upper411* halves of each double-word.412*/413brw_MOV(p, destination_indices_uw,414brw_imm_v(0x00020100)); /* (0, 1, 2) */415if (num_verts == 3) {416/* Get primitive type into temp register. */417brw_AND(p, get_element_ud(c->reg.temp, 0),418get_element_ud(c->reg.R0, 2), brw_imm_ud(0x1f));419420/* Test if primitive type is TRISTRIP_REVERSE. We need to do this as421* an 8-wide comparison so that the conditional MOV that follows422* moves all 8 words correctly.423*/424brw_CMP(p, vec8(brw_null_reg()), BRW_CONDITIONAL_EQ,425get_element_ud(c->reg.temp, 0),426brw_imm_ud(_3DPRIM_TRISTRIP_REVERSE));427428/* If so, then overwrite destination_indices_uw with the appropriate429* reordering.430*/431inst = brw_MOV(p, destination_indices_uw,432brw_imm_v(key->pv_first ? 0x00010200 /* (0, 2, 1) */433: 0x00020001)); /* (1, 0, 2) */434brw_inst_set_pred_control(p->devinfo, inst, BRW_PREDICATE_NORMAL);435}436437assert(c->reg.destination_indices.width == BRW_EXECUTE_4);438brw_push_insn_state(p);439brw_set_default_exec_size(p, BRW_EXECUTE_4);440brw_ADD(p, c->reg.destination_indices,441c->reg.destination_indices, get_element_ud(c->reg.SVBI, 0));442brw_pop_insn_state(p);443/* For each vertex, generate code to output each varying using the444* appropriate binding table entry.445*/446for (vertex = 0; vertex < num_verts; ++vertex) {447/* Set up the correct destination index for this vertex */448brw_MOV(p, get_element_ud(c->reg.header, 5),449get_element_ud(c->reg.destination_indices, vertex));450451for (binding = 0; binding < key->num_transform_feedback_bindings;452++binding) {453unsigned char varying =454key->transform_feedback_bindings[binding];455unsigned char slot = c->vue_map.varying_to_slot[varying];456/* From the Sandybridge PRM, Volume 2, Part 1, Section 4.5.1:457*458* "Prior to End of Thread with a URB_WRITE, the kernel must459* ensure that all writes are complete by sending the final460* write as a committed write."461*/462bool final_write =463binding == key->num_transform_feedback_bindings - 1 &&464vertex == num_verts - 1;465struct brw_reg vertex_slot = c->reg.vertex[vertex];466vertex_slot.nr += slot / 2;467vertex_slot.subnr = (slot % 2) * 16;468/* gl_PointSize is stored in VARYING_SLOT_PSIZ.w. */469vertex_slot.swizzle = varying == VARYING_SLOT_PSIZ470? BRW_SWIZZLE_WWWW : key->transform_feedback_swizzles[binding];471brw_set_default_access_mode(p, BRW_ALIGN_16);472brw_push_insn_state(p);473brw_set_default_exec_size(p, BRW_EXECUTE_4);474475brw_MOV(p, stride(c->reg.header, 4, 4, 1),476retype(vertex_slot, BRW_REGISTER_TYPE_UD));477brw_pop_insn_state(p);478479brw_set_default_access_mode(p, BRW_ALIGN_1);480brw_svb_write(p,481final_write ? c->reg.temp : brw_null_reg(), /* dest */4821, /* msg_reg_nr */483c->reg.header, /* src0 */484BRW_GFX6_SOL_BINDING_START + binding, /* binding_table_index */485final_write); /* send_commit_msg */486}487}488brw_ENDIF(p);489490/* Now, reinitialize the header register from R0 to restore the parts of491* the register that we overwrote while streaming out transform feedback492* data.493*/494brw_ff_gs_initialize_header(c);495496/* Finally, wait for the write commit to occur so that we can proceed to497* other things safely.498*499* From the Sandybridge PRM, Volume 4, Part 1, Section 3.3:500*501* The write commit does not modify the destination register, but502* merely clears the dependency associated with the destination503* register. Thus, a simple “mov” instruction using the register as a504* source is sufficient to wait for the write commit to occur.505*/506brw_MOV(p, c->reg.temp, c->reg.temp);507}508509brw_ff_gs_ff_sync(c, 1);510511brw_ff_gs_overwrite_header_dw2_from_r0(c);512switch (num_verts) {513case 1:514brw_ff_gs_offset_header_dw2(c,515URB_WRITE_PRIM_START | URB_WRITE_PRIM_END);516brw_ff_gs_emit_vue(c, c->reg.vertex[0], true);517break;518case 2:519brw_ff_gs_offset_header_dw2(c, URB_WRITE_PRIM_START);520brw_ff_gs_emit_vue(c, c->reg.vertex[0], false);521brw_ff_gs_offset_header_dw2(c,522URB_WRITE_PRIM_END - URB_WRITE_PRIM_START);523brw_ff_gs_emit_vue(c, c->reg.vertex[1], true);524break;525case 3:526if (check_edge_flags) {527/* Only emit vertices 0 and 1 if this is the first triangle of the528* polygon. Otherwise they are redundant.529*/530brw_AND(p, retype(brw_null_reg(), BRW_REGISTER_TYPE_UD),531get_element_ud(c->reg.R0, 2),532brw_imm_ud(BRW_GS_EDGE_INDICATOR_0));533brw_inst_set_cond_modifier(p->devinfo, brw_last_inst, BRW_CONDITIONAL_NZ);534brw_IF(p, BRW_EXECUTE_1);535}536brw_ff_gs_offset_header_dw2(c, URB_WRITE_PRIM_START);537brw_ff_gs_emit_vue(c, c->reg.vertex[0], false);538brw_ff_gs_offset_header_dw2(c, -URB_WRITE_PRIM_START);539brw_ff_gs_emit_vue(c, c->reg.vertex[1], false);540if (check_edge_flags) {541brw_ENDIF(p);542/* Only emit vertex 2 in PRIM_END mode if this is the last triangle543* of the polygon. Otherwise leave the primitive incomplete because544* there are more polygon vertices coming.545*/546brw_AND(p, retype(brw_null_reg(), BRW_REGISTER_TYPE_UD),547get_element_ud(c->reg.R0, 2),548brw_imm_ud(BRW_GS_EDGE_INDICATOR_1));549brw_inst_set_cond_modifier(p->devinfo, brw_last_inst, BRW_CONDITIONAL_NZ);550brw_set_default_predicate_control(p, BRW_PREDICATE_NORMAL);551}552brw_ff_gs_offset_header_dw2(c, URB_WRITE_PRIM_END);553brw_set_default_predicate_control(p, BRW_PREDICATE_NONE);554brw_ff_gs_emit_vue(c, c->reg.vertex[2], true);555break;556}557}558559const unsigned *560brw_compile_ff_gs_prog(struct brw_compiler *compiler,561void *mem_ctx,562const struct brw_ff_gs_prog_key *key,563struct brw_ff_gs_prog_data *prog_data,564struct brw_vue_map *vue_map,565unsigned *final_assembly_size)566{567struct brw_ff_gs_compile c;568const GLuint *program;569570memset(&c, 0, sizeof(c));571572c.key = *key;573c.vue_map = *vue_map;574c.nr_regs = (c.vue_map.num_slots + 1)/2;575c.prog_data = prog_data;576577mem_ctx = ralloc_context(NULL);578579/* Begin the compilation:580*/581brw_init_codegen(compiler->devinfo, &c.func, mem_ctx);582583c.func.single_program_flow = 1;584585/* For some reason the thread is spawned with only 4 channels586* unmasked.587*/588brw_set_default_mask_control(&c.func, BRW_MASK_DISABLE);589590if (compiler->devinfo->ver >= 6) {591unsigned num_verts;592bool check_edge_flag;593/* On Sandybridge, we use the GS for implementing transform feedback594* (called "Stream Out" in the PRM).595*/596switch (key->primitive) {597case _3DPRIM_POINTLIST:598num_verts = 1;599check_edge_flag = false;600break;601case _3DPRIM_LINELIST:602case _3DPRIM_LINESTRIP:603case _3DPRIM_LINELOOP:604num_verts = 2;605check_edge_flag = false;606break;607case _3DPRIM_TRILIST:608case _3DPRIM_TRIFAN:609case _3DPRIM_TRISTRIP:610case _3DPRIM_RECTLIST:611num_verts = 3;612check_edge_flag = false;613break;614case _3DPRIM_QUADLIST:615case _3DPRIM_QUADSTRIP:616case _3DPRIM_POLYGON:617num_verts = 3;618check_edge_flag = true;619break;620default:621unreachable("Unexpected primitive type in Gen6 SOL program.");622}623gfx6_sol_program(&c, key, num_verts, check_edge_flag);624} else {625/* On Gen4-5, we use the GS to decompose certain types of primitives.626* Note that primitives which don't require a GS program have already627* been weeded out by now.628*/629switch (key->primitive) {630case _3DPRIM_QUADLIST:631brw_ff_gs_quads( &c, key );632break;633case _3DPRIM_QUADSTRIP:634brw_ff_gs_quad_strip( &c, key );635break;636case _3DPRIM_LINELOOP:637brw_ff_gs_lines( &c );638break;639default:640return NULL;641}642}643644brw_compact_instructions(&c.func, 0, NULL);645646/* get the program647*/648program = brw_get_program(&c.func, final_assembly_size);649650if (INTEL_DEBUG & DEBUG_GS) {651fprintf(stderr, "gs:\n");652brw_disassemble_with_labels(compiler->devinfo, c.func.store,6530, *final_assembly_size, stderr);654fprintf(stderr, "\n");655}656657return program;658}659660661662