101e04c3fSmrg/* 201e04c3fSmrg Copyright (C) Intel Corp. 2006. All Rights Reserved. 301e04c3fSmrg Intel funded Tungsten Graphics to 401e04c3fSmrg develop this 3D driver. 501e04c3fSmrg 601e04c3fSmrg Permission is hereby granted, free of charge, to any person obtaining 701e04c3fSmrg a copy of this software and associated documentation files (the 801e04c3fSmrg "Software"), to deal in the Software without restriction, including 901e04c3fSmrg without limitation the rights to use, copy, modify, merge, publish, 1001e04c3fSmrg distribute, sublicense, and/or sell copies of the Software, and to 1101e04c3fSmrg permit persons to whom the Software is furnished to do so, subject to 1201e04c3fSmrg the following conditions: 1301e04c3fSmrg 1401e04c3fSmrg The above copyright notice and this permission notice (including the 1501e04c3fSmrg next paragraph) shall be included in all copies or substantial 1601e04c3fSmrg portions of the Software. 1701e04c3fSmrg 1801e04c3fSmrg THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 1901e04c3fSmrg EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2001e04c3fSmrg MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 2101e04c3fSmrg IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE 2201e04c3fSmrg LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 2301e04c3fSmrg OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 2401e04c3fSmrg WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2501e04c3fSmrg 2601e04c3fSmrg **********************************************************************/ 2701e04c3fSmrg /* 2801e04c3fSmrg * Authors: 2901e04c3fSmrg * Keith Whitwell <keithw@vmware.com> 3001e04c3fSmrg */ 3101e04c3fSmrg 3201e04c3fSmrg 3301e04c3fSmrg#include "brw_fs.h" 3401e04c3fSmrg 3501e04c3fSmrg 3601e04c3fSmrg#undef P /* prompted depth */ 3701e04c3fSmrg#undef C /* computed */ 3801e04c3fSmrg#undef N /* non-promoted? */ 3901e04c3fSmrg 4001e04c3fSmrg#define P 0 4101e04c3fSmrg#define C 1 4201e04c3fSmrg#define N 2 4301e04c3fSmrg 4401e04c3fSmrgstatic const struct { 4501e04c3fSmrg GLuint mode:2; 4601e04c3fSmrg GLuint sd_present:1; 4701e04c3fSmrg GLuint sd_to_rt:1; 4801e04c3fSmrg GLuint dd_present:1; 4901e04c3fSmrg GLuint ds_present:1; 5001e04c3fSmrg} wm_iz_table[BRW_WM_IZ_BIT_MAX] = 5101e04c3fSmrg{ 5201e04c3fSmrg { P, 0, 0, 0, 0 }, 5301e04c3fSmrg { P, 0, 0, 0, 0 }, 5401e04c3fSmrg { P, 0, 0, 0, 0 }, 5501e04c3fSmrg { P, 0, 0, 0, 0 }, 5601e04c3fSmrg { P, 0, 0, 0, 0 }, 5701e04c3fSmrg { N, 1, 1, 0, 0 }, 5801e04c3fSmrg { N, 0, 1, 0, 0 }, 5901e04c3fSmrg { N, 0, 1, 0, 0 }, 6001e04c3fSmrg { P, 0, 0, 0, 0 }, 6101e04c3fSmrg { P, 0, 0, 0, 0 }, 6201e04c3fSmrg { C, 0, 1, 1, 0 }, 6301e04c3fSmrg { C, 0, 1, 1, 0 }, 6401e04c3fSmrg { P, 0, 0, 0, 0 }, 6501e04c3fSmrg { N, 1, 1, 0, 0 }, 6601e04c3fSmrg { C, 0, 1, 1, 0 }, 6701e04c3fSmrg { C, 0, 1, 1, 0 }, 6801e04c3fSmrg { P, 0, 0, 0, 0 }, 6901e04c3fSmrg { P, 0, 0, 0, 0 }, 7001e04c3fSmrg { P, 0, 0, 0, 0 }, 7101e04c3fSmrg { P, 0, 0, 0, 0 }, 7201e04c3fSmrg { P, 0, 0, 0, 0 }, 7301e04c3fSmrg { N, 1, 1, 0, 0 }, 7401e04c3fSmrg { N, 0, 1, 0, 0 }, 7501e04c3fSmrg { N, 0, 1, 0, 0 }, 7601e04c3fSmrg { P, 0, 0, 0, 0 }, 7701e04c3fSmrg { P, 0, 0, 0, 0 }, 7801e04c3fSmrg { C, 0, 1, 1, 0 }, 7901e04c3fSmrg { C, 0, 1, 1, 0 }, 8001e04c3fSmrg { P, 0, 0, 0, 0 }, 8101e04c3fSmrg { N, 1, 1, 0, 0 }, 8201e04c3fSmrg { C, 0, 1, 1, 0 }, 8301e04c3fSmrg { C, 0, 1, 1, 0 }, 8401e04c3fSmrg { P, 0, 0, 0, 0 }, 8501e04c3fSmrg { P, 0, 0, 0, 0 }, 8601e04c3fSmrg { P, 0, 0, 0, 0 }, 8701e04c3fSmrg { P, 0, 0, 0, 0 }, 8801e04c3fSmrg { P, 0, 0, 0, 0 }, 8901e04c3fSmrg { N, 1, 1, 0, 1 }, 9001e04c3fSmrg { N, 0, 1, 0, 1 }, 9101e04c3fSmrg { N, 0, 1, 0, 1 }, 9201e04c3fSmrg { P, 0, 0, 0, 0 }, 9301e04c3fSmrg { P, 0, 0, 0, 0 }, 9401e04c3fSmrg { C, 0, 1, 1, 1 }, 9501e04c3fSmrg { C, 0, 1, 1, 1 }, 9601e04c3fSmrg { P, 0, 0, 0, 0 }, 9701e04c3fSmrg { N, 1, 1, 0, 1 }, 9801e04c3fSmrg { C, 0, 1, 1, 1 }, 9901e04c3fSmrg { C, 0, 1, 1, 1 }, 10001e04c3fSmrg { P, 0, 0, 0, 0 }, 10101e04c3fSmrg { C, 0, 0, 0, 1 }, 10201e04c3fSmrg { P, 0, 0, 0, 0 }, 10301e04c3fSmrg { C, 0, 1, 0, 1 }, 10401e04c3fSmrg { P, 0, 0, 0, 0 }, 10501e04c3fSmrg { C, 1, 1, 0, 1 }, 10601e04c3fSmrg { C, 0, 1, 0, 1 }, 10701e04c3fSmrg { C, 0, 1, 0, 1 }, 10801e04c3fSmrg { P, 0, 0, 0, 0 }, 10901e04c3fSmrg { C, 1, 1, 1, 1 }, 11001e04c3fSmrg { C, 0, 1, 1, 1 }, 11101e04c3fSmrg { C, 0, 1, 1, 1 }, 11201e04c3fSmrg { P, 0, 0, 0, 0 }, 11301e04c3fSmrg { C, 1, 1, 1, 1 }, 11401e04c3fSmrg { C, 0, 1, 1, 1 }, 11501e04c3fSmrg { C, 0, 1, 1, 1 } 11601e04c3fSmrg}; 11701e04c3fSmrg 11801e04c3fSmrg/** 11901e04c3fSmrg * \param line_aa BRW_WM_AA_NEVER, BRW_WM_AA_ALWAYS or BRW_WM_AA_SOMETIMES 12001e04c3fSmrg * \param lookup bitmask of BRW_WM_IZ_* flags 12101e04c3fSmrg */ 1227ec681f3Smrgvoid fs_visitor::setup_fs_payload_gfx4() 12301e04c3fSmrg{ 12401e04c3fSmrg assert(stage == MESA_SHADER_FRAGMENT); 12501e04c3fSmrg assert(dispatch_width <= 16); 12601e04c3fSmrg struct brw_wm_prog_data *prog_data = brw_wm_prog_data(this->prog_data); 12701e04c3fSmrg brw_wm_prog_key *key = (brw_wm_prog_key*) this->key; 12801e04c3fSmrg GLuint reg = 1; 12901e04c3fSmrg bool kill_stats_promoted_workaround = false; 13001e04c3fSmrg int lookup = key->iz_lookup; 13101e04c3fSmrg 13201e04c3fSmrg assert(lookup < BRW_WM_IZ_BIT_MAX); 13301e04c3fSmrg 13401e04c3fSmrg /* Crazy workaround in the windowizer, which we need to track in 13501e04c3fSmrg * our register allocation and render target writes. See the "If 13601e04c3fSmrg * statistics are enabled..." paragraph of 11.5.3.2: Early Depth 13701e04c3fSmrg * Test Cases [Pre-DevGT] of the 3D Pipeline - Windower B-Spec. 13801e04c3fSmrg */ 13901e04c3fSmrg if (key->stats_wm && 14001e04c3fSmrg (lookup & BRW_WM_IZ_PS_KILL_ALPHATEST_BIT) && 14101e04c3fSmrg wm_iz_table[lookup].mode == P) { 14201e04c3fSmrg kill_stats_promoted_workaround = true; 14301e04c3fSmrg } 14401e04c3fSmrg 14501e04c3fSmrg payload.subspan_coord_reg[0] = reg++; 14601e04c3fSmrg 14701e04c3fSmrg if (wm_iz_table[lookup].sd_present || prog_data->uses_src_depth || 14801e04c3fSmrg kill_stats_promoted_workaround) { 14901e04c3fSmrg payload.source_depth_reg[0] = reg; 15001e04c3fSmrg reg += 2; 15101e04c3fSmrg } 15201e04c3fSmrg 15301e04c3fSmrg if (wm_iz_table[lookup].sd_to_rt || kill_stats_promoted_workaround) 15401e04c3fSmrg source_depth_to_render_target = true; 15501e04c3fSmrg 15601e04c3fSmrg if (wm_iz_table[lookup].ds_present || key->line_aa != BRW_WM_AA_NEVER) { 15701e04c3fSmrg payload.aa_dest_stencil_reg[0] = reg; 15801e04c3fSmrg runtime_check_aads_emit = 15901e04c3fSmrg !wm_iz_table[lookup].ds_present && key->line_aa == BRW_WM_AA_SOMETIMES; 16001e04c3fSmrg reg++; 16101e04c3fSmrg } 16201e04c3fSmrg 16301e04c3fSmrg if (wm_iz_table[lookup].dd_present) { 16401e04c3fSmrg payload.dest_depth_reg[0] = reg; 16501e04c3fSmrg reg+=2; 16601e04c3fSmrg } 16701e04c3fSmrg 16801e04c3fSmrg payload.num_regs = reg; 16901e04c3fSmrg} 170