19f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt/* 29f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt Copyright (C) Intel Corp. 2006. All Rights Reserved. 3877128505431adaf817dc8069172ebe4a1cdf5d8José Fonseca Intel funded Tungsten Graphics to 49f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt develop this 3D driver. 5a7bdd4cba8ddcab8dff59ecaaa7efbd436c6c307Kenneth Graunke 69f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt Permission is hereby granted, free of charge, to any person obtaining 79f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt a copy of this software and associated documentation files (the 89f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt "Software"), to deal in the Software without restriction, including 99f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt without limitation the rights to use, copy, modify, merge, publish, 109f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt distribute, sublicense, and/or sell copies of the Software, and to 119f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt permit persons to whom the Software is furnished to do so, subject to 129f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt the following conditions: 13a7bdd4cba8ddcab8dff59ecaaa7efbd436c6c307Kenneth Graunke 149f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt The above copyright notice and this permission notice (including the 159f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt next paragraph) shall be included in all copies or substantial 169f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt portions of the Software. 17a7bdd4cba8ddcab8dff59ecaaa7efbd436c6c307Kenneth Graunke 189f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 199f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 209f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 219f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE 229f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 239f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 249f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25a7bdd4cba8ddcab8dff59ecaaa7efbd436c6c307Kenneth Graunke 269f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt **********************************************************************/ 279f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt /* 289f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt * Authors: 29877128505431adaf817dc8069172ebe4a1cdf5d8José Fonseca * Keith Whitwell <keithw@vmware.com> 309f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */ 319f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 32ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/macros.h" 33ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/enums.h" 349f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 359f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#include "intel_batchbuffer.h" 369f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 379f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#include "brw_defines.h" 389f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#include "brw_context.h" 399f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#include "brw_eu.h" 409f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#include "brw_util.h" 419f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#include "brw_state.h" 429f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#include "brw_clip.h" 439f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 441e0da6233be6e5fb0143615d5e3d3642ddb7964fKenneth Graunke#include "util/ralloc.h" 45774fb90db3e83d5e7326b7a72e05ce805c306b24Kenneth Graunke 469f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#define FRONT_UNFILLED_BIT 0x1 479f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#define BACK_UNFILLED_BIT 0x2 489f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 499f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 509f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtstatic void compile_clip_prog( struct brw_context *brw, 519f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt struct brw_clip_prog_key *key ) 529f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{ 539f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt struct brw_clip_compile c; 549f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt const GLuint *program; 55774fb90db3e83d5e7326b7a72e05ce805c306b24Kenneth Graunke void *mem_ctx; 569f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt GLuint program_size; 579f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 589f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt memset(&c, 0, sizeof(c)); 59774fb90db3e83d5e7326b7a72e05ce805c306b24Kenneth Graunke 60774fb90db3e83d5e7326b7a72e05ce805c306b24Kenneth Graunke mem_ctx = ralloc_context(NULL); 61a7bdd4cba8ddcab8dff59ecaaa7efbd436c6c307Kenneth Graunke 629f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt /* Begin the compilation: 639f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */ 64bc24590f0c579a2528fd94eb8d40dd4ce12eba29Lionel Landwerlin brw_init_codegen(&brw->screen->devinfo, &c.func, mem_ctx); 659f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 661b9f78195f62959601d440475a6cbba5e8046813Eric Anholt c.func.single_program_flow = 1; 671b9f78195f62959601d440475a6cbba5e8046813Eric Anholt 689f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt c.key = *key; 69bf9bfe838eba116cb63dac9a8998da475e1bd98bPaul Berry c.vue_map = brw->vue_map_geom_out; 709f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 7171cb82f63ab156599613f7555a62ad52d2e3dbd7Paul Berry /* nr_regs is the number of registers filled by reading data from the VUE. 7271cb82f63ab156599613f7555a62ad52d2e3dbd7Paul Berry * This program accesses the entire VUE, so nr_regs needs to be the size of 7371cb82f63ab156599613f7555a62ad52d2e3dbd7Paul Berry * the VUE (measured in pairs, since two slots are stored in each 7471cb82f63ab156599613f7555a62ad52d2e3dbd7Paul Berry * register). 75e29cff62734b6aaf0b05dba0b3ed98fe78842a42Eric Anholt */ 7671cb82f63ab156599613f7555a62ad52d2e3dbd7Paul Berry c.nr_regs = (c.vue_map.num_slots + 1)/2; 772995bf0d68f1b28ba68b81e9dc79e3ab52bc2795Xiang, Haihao 789f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt c.prog_data.clip_mode = c.key.clip_mode; /* XXX */ 799f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 809f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt /* For some reason the thread is spawned with only 4 channels 81a7bdd4cba8ddcab8dff59ecaaa7efbd436c6c307Kenneth Graunke * unmasked. 829f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */ 83e374809819d82f2e3e946fe809c4d46061ddc5b5Kenneth Graunke brw_set_default_mask_control(&c.func, BRW_MASK_DISABLE); 849f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 859f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 869f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt /* Would ideally have the option of producing a program which could 879f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt * do all three: 889f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */ 899f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt switch (key->primitive) { 90a7bdd4cba8ddcab8dff59ecaaa7efbd436c6c307Kenneth Graunke case GL_TRIANGLES: 919f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt if (key->do_unfilled) 929f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt brw_emit_unfilled_clip( &c ); 939f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt else 949f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt brw_emit_tri_clip( &c ); 959f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt break; 969f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt case GL_LINES: 979f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt brw_emit_line_clip( &c ); 989f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt break; 999f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt case GL_POINTS: 1009f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt brw_emit_point_clip( &c ); 1019f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt break; 1029f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt default: 1033d826729dabab53896cdbb1f453c76fab1c7e696Matt Turner unreachable("not reached"); 1049f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt } 1059f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 106a35b9cb625495e51a42b56cd1d8d2cb019abe243Matt Turner brw_compact_instructions(&c.func, 0, 0, NULL); 1079f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 1089f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt /* get the program 1099f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */ 1109f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt program = brw_get_program(&c.func, &program_size); 1119f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 112bb1540835056cdea5db6f55b19c0c87358f14cd1Eric Anholt if (unlikely(INTEL_DEBUG & DEBUG_CLIP)) { 113a76e5dce4fc8d50f8699c108833f24e80167d706Eric Anholt fprintf(stderr, "clip:\n"); 114bc24590f0c579a2528fd94eb8d40dd4ce12eba29Lionel Landwerlin brw_disassemble(&brw->screen->devinfo, c.func.store, 115639314d40e78b5b56c3fc840b2f416e7fc519a4dJason Ekstrand 0, program_size, stderr); 116a76e5dce4fc8d50f8699c108833f24e80167d706Eric Anholt fprintf(stderr, "\n"); 117bb1540835056cdea5db6f55b19c0c87358f14cd1Eric Anholt } 118562e2d114ec0cba879463980522d1d54af9444e6Eric Anholt 119c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt brw_upload_cache(&brw->cache, 12067c498086d0858a94d53ebb6921cfda847250368Kenneth Graunke BRW_CACHE_CLIP_PROG, 121c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt &c.key, sizeof(c.key), 122c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt program, program_size, 123c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt &c.prog_data, sizeof(c.prog_data), 124c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt &brw->clip.prog_offset, &brw->clip.prog_data); 125774fb90db3e83d5e7326b7a72e05ce805c306b24Kenneth Graunke ralloc_free(mem_ctx); 1269f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt} 1279f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 1289f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt/* Calculate interpolants for triangle and line rasterization. 1299f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */ 1307b70a12e1c6dffc63fbcec6a89af3e02ba9a1a1dKenneth Graunkevoid 131dc9a753f6687133d2d057597e5af86abcdc56781Eric Anholtbrw_upload_clip_prog(struct brw_context *brw) 1329f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{ 1338c9a54e7bcfc80295ad77097910d35958dfd3644Kenneth Graunke struct gl_context *ctx = &brw->ctx; 1349f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt struct brw_clip_prog_key key; 1359f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 1367b70a12e1c6dffc63fbcec6a89af3e02ba9a1a1dKenneth Graunke if (!brw_state_dirty(brw, 1377b70a12e1c6dffc63fbcec6a89af3e02ba9a1a1dKenneth Graunke _NEW_BUFFERS | 1387b70a12e1c6dffc63fbcec6a89af3e02ba9a1a1dKenneth Graunke _NEW_LIGHT | 1397b70a12e1c6dffc63fbcec6a89af3e02ba9a1a1dKenneth Graunke _NEW_POLYGON | 1407b70a12e1c6dffc63fbcec6a89af3e02ba9a1a1dKenneth Graunke _NEW_TRANSFORM, 1417b70a12e1c6dffc63fbcec6a89af3e02ba9a1a1dKenneth Graunke BRW_NEW_BLORP | 1420d5071db5e50629a63490639a3c86dfc65bf27abKenneth Graunke BRW_NEW_FS_PROG_DATA | 1437b70a12e1c6dffc63fbcec6a89af3e02ba9a1a1dKenneth Graunke BRW_NEW_REDUCED_PRIMITIVE | 1447b70a12e1c6dffc63fbcec6a89af3e02ba9a1a1dKenneth Graunke BRW_NEW_VUE_MAP_GEOM_OUT)) 1457b70a12e1c6dffc63fbcec6a89af3e02ba9a1a1dKenneth Graunke return; 1467b70a12e1c6dffc63fbcec6a89af3e02ba9a1a1dKenneth Graunke 1479f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt memset(&key, 0, sizeof(key)); 1489f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 1499f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt /* Populate the key: 1509f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */ 1519f51499d28f80cbbafa4c1489637e1a6a68d9345Chris Forbes 1520d5071db5e50629a63490639a3c86dfc65bf27abKenneth Graunke /* BRW_NEW_FS_PROG_DATA */ 1530d5071db5e50629a63490639a3c86dfc65bf27abKenneth Graunke const struct brw_wm_prog_data *wm_prog_data = 1540d5071db5e50629a63490639a3c86dfc65bf27abKenneth Graunke brw_wm_prog_data(brw->wm.base.prog_data); 1550d5071db5e50629a63490639a3c86dfc65bf27abKenneth Graunke if (wm_prog_data) { 1560d5071db5e50629a63490639a3c86dfc65bf27abKenneth Graunke key.contains_flat_varying = wm_prog_data->contains_flat_varying; 1570d5071db5e50629a63490639a3c86dfc65bf27abKenneth Graunke key.contains_noperspective_varying = 1580d5071db5e50629a63490639a3c86dfc65bf27abKenneth Graunke wm_prog_data->contains_noperspective_varying; 1590d5071db5e50629a63490639a3c86dfc65bf27abKenneth Graunke key.interp_mode = wm_prog_data->interp_mode; 16091d61fbf7cb61a44adcaae51ee08ad0dd6b2a03bTimothy Arceri } 1619f51499d28f80cbbafa4c1489637e1a6a68d9345Chris Forbes 1629f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt /* BRW_NEW_REDUCED_PRIMITIVE */ 163fe0a8cb30dd53bed0d024b01e2c2b60911a3c526Kenneth Graunke key.primitive = brw->reduced_primitive; 164bf9bfe838eba116cb63dac9a8998da475e1bd98bPaul Berry /* BRW_NEW_VUE_MAP_GEOM_OUT */ 165bf9bfe838eba116cb63dac9a8998da475e1bd98bPaul Berry key.attrs = brw->vue_map_geom_out.slots_valid; 166f0feb32eaf8d4b35e5c3a47ef90aa876b231ada6Chris Forbes 1679f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt /* _NEW_LIGHT */ 168ab12e764ba3f57ad9f0d7252262cfc6e07839928Roland Scheidegger key.pv_first = (ctx->Light.ProvokingVertex == GL_FIRST_VERTEX_CONVENTION); 1699f3d3216cf25d8ffed4d72fbce6feacbc2990e4bEric Anholt /* _NEW_TRANSFORM (also part of VUE map)*/ 170ee0b8e0f063597c4f9dacaa3638ebd8875de151cChris Forbes if (ctx->Transform.ClipPlanesEnabled) 171ee0b8e0f063597c4f9dacaa3638ebd8875de151cChris Forbes key.nr_userclip = _mesa_logbase2(ctx->Transform.ClipPlanesEnabled) + 1; 1722995bf0d68f1b28ba68b81e9dc79e3ab52bc2795Xiang, Haihao 17353631be4ebaa4fb13a7f129727c1cdd32fcc6f3dKenneth Graunke if (brw->gen == 5) 1742995bf0d68f1b28ba68b81e9dc79e3ab52bc2795Xiang, Haihao key.clip_mode = BRW_CLIPMODE_KERNEL_CLIP; 1752995bf0d68f1b28ba68b81e9dc79e3ab52bc2795Xiang, Haihao else 1762995bf0d68f1b28ba68b81e9dc79e3ab52bc2795Xiang, Haihao key.clip_mode = BRW_CLIPMODE_NORMAL; 1779f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 1789f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt /* _NEW_POLYGON */ 1799f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt if (key.primitive == GL_TRIANGLES) { 18081d555068408d4343d7627c8bedda5675f09bd21Eric Anholt if (ctx->Polygon.CullFlag && 18181d555068408d4343d7627c8bedda5675f09bd21Eric Anholt ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) 1829f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt key.clip_mode = BRW_CLIPMODE_REJECT_ALL; 1839f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt else { 1849f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt GLuint fill_front = CLIP_CULL; 1859f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt GLuint fill_back = CLIP_CULL; 1869f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt GLuint offset_front = 0; 1879f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt GLuint offset_back = 0; 1889f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 189052c1d66a1ab1f2665870dc77dab28d20416cdf1Eric Anholt if (!ctx->Polygon.CullFlag || 190052c1d66a1ab1f2665870dc77dab28d20416cdf1Eric Anholt ctx->Polygon.CullFaceMode != GL_FRONT) { 191052c1d66a1ab1f2665870dc77dab28d20416cdf1Eric Anholt switch (ctx->Polygon.FrontMode) { 192a7bdd4cba8ddcab8dff59ecaaa7efbd436c6c307Kenneth Graunke case GL_FILL: 193a7bdd4cba8ddcab8dff59ecaaa7efbd436c6c307Kenneth Graunke fill_front = CLIP_FILL; 1949f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt offset_front = 0; 1959f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt break; 1969f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt case GL_LINE: 1979f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt fill_front = CLIP_LINE; 198052c1d66a1ab1f2665870dc77dab28d20416cdf1Eric Anholt offset_front = ctx->Polygon.OffsetLine; 1999f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt break; 2009f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt case GL_POINT: 2019f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt fill_front = CLIP_POINT; 202052c1d66a1ab1f2665870dc77dab28d20416cdf1Eric Anholt offset_front = ctx->Polygon.OffsetPoint; 2039f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt break; 2049f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt } 2059f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt } 2069f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 207052c1d66a1ab1f2665870dc77dab28d20416cdf1Eric Anholt if (!ctx->Polygon.CullFlag || 208052c1d66a1ab1f2665870dc77dab28d20416cdf1Eric Anholt ctx->Polygon.CullFaceMode != GL_BACK) { 209052c1d66a1ab1f2665870dc77dab28d20416cdf1Eric Anholt switch (ctx->Polygon.BackMode) { 210a7bdd4cba8ddcab8dff59ecaaa7efbd436c6c307Kenneth Graunke case GL_FILL: 211a7bdd4cba8ddcab8dff59ecaaa7efbd436c6c307Kenneth Graunke fill_back = CLIP_FILL; 2129f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt offset_back = 0; 2139f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt break; 2149f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt case GL_LINE: 2159f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt fill_back = CLIP_LINE; 216052c1d66a1ab1f2665870dc77dab28d20416cdf1Eric Anholt offset_back = ctx->Polygon.OffsetLine; 2179f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt break; 2189f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt case GL_POINT: 2199f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt fill_back = CLIP_POINT; 220052c1d66a1ab1f2665870dc77dab28d20416cdf1Eric Anholt offset_back = ctx->Polygon.OffsetPoint; 2219f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt break; 2229f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt } 2239f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt } 2249f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 225052c1d66a1ab1f2665870dc77dab28d20416cdf1Eric Anholt if (ctx->Polygon.BackMode != GL_FILL || 226052c1d66a1ab1f2665870dc77dab28d20416cdf1Eric Anholt ctx->Polygon.FrontMode != GL_FILL) { 2275cc56cbad89d8d1b15d0dc67d41732a8883ae7bcEric Anholt key.do_unfilled = 1; 2283ee6a77e97f7d2996f8fffdbb4787a9589189b39Xiang, Haihao 2295cc56cbad89d8d1b15d0dc67d41732a8883ae7bcEric Anholt /* Most cases the fixed function units will handle. Cases where 2305cc56cbad89d8d1b15d0dc67d41732a8883ae7bcEric Anholt * one or more polygon faces are unfilled will require help: 2315cc56cbad89d8d1b15d0dc67d41732a8883ae7bcEric Anholt */ 2329f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt key.clip_mode = BRW_CLIPMODE_CLIP_NON_REJECTED; 2339f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 2349f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt if (offset_back || offset_front) { 2359f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt /* _NEW_POLYGON, _NEW_BUFFERS */ 236c20f973c4f8fa2c275e445b5da8deefcba874d2eEric Anholt key.offset_units = ctx->Polygon.OffsetUnits * ctx->DrawBuffer->_MRD * 2; 237052c1d66a1ab1f2665870dc77dab28d20416cdf1Eric Anholt key.offset_factor = ctx->Polygon.OffsetFactor * ctx->DrawBuffer->_MRD; 238dbae576f7f25fef72ca0b9f6f4822e0fddf7d607Ilia Mirkin key.offset_clamp = ctx->Polygon.OffsetClamp * ctx->DrawBuffer->_MRD; 2399f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt } 2409f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 241fdd90fcb15c109f3dcbf5e46fa8a1f8284b9c266Mathias Fröhlich if (!ctx->Polygon._FrontBit) { 2429f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt key.fill_ccw = fill_front; 2439f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt key.fill_cw = fill_back; 2449f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt key.offset_ccw = offset_front; 2459f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt key.offset_cw = offset_back; 246052c1d66a1ab1f2665870dc77dab28d20416cdf1Eric Anholt if (ctx->Light.Model.TwoSide && 247a7bdd4cba8ddcab8dff59ecaaa7efbd436c6c307Kenneth Graunke key.fill_cw != CLIP_CULL) 2489f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt key.copy_bfc_cw = 1; 249fdd90fcb15c109f3dcbf5e46fa8a1f8284b9c266Mathias Fröhlich } else { 2509f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt key.fill_cw = fill_front; 2519f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt key.fill_ccw = fill_back; 2529f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt key.offset_cw = offset_front; 2539f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt key.offset_ccw = offset_back; 254052c1d66a1ab1f2665870dc77dab28d20416cdf1Eric Anholt if (ctx->Light.Model.TwoSide && 255a7bdd4cba8ddcab8dff59ecaaa7efbd436c6c307Kenneth Graunke key.fill_ccw != CLIP_CULL) 2569f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt key.copy_bfc_ccw = 1; 2579f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt } 2589f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt } 2599f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt } 2609f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt } 2619f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 26267c498086d0858a94d53ebb6921cfda847250368Kenneth Graunke if (!brw_search_cache(&brw->cache, BRW_CACHE_CLIP_PROG, 263c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt &key, sizeof(key), 264c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt &brw->clip.prog_offset, &brw->clip.prog_data)) { 265125bd4cae51c6deaacd2e90f14931c2052f146abEric Anholt compile_clip_prog( brw, &key ); 266c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt } 2679f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt} 268