19f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt/* 29f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt Copyright (C) Intel Corp. 2006. All Rights Reserved. 39f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to 49f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt develop this 3D driver. 59f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 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: 139f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 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. 179f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 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. 259f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 269f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt **********************************************************************/ 279f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt /* 289f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt * Authors: 299f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt * Keith Whitwell <keith@tungstengraphics.com> 309f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */ 319f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 329f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 339f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 34a98dd64af750fb6dae54b2dc02e0c5a3711156afEric Anholt#include "intel_fbo.h" 359f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#include "brw_context.h" 369f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#include "brw_state.h" 379f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#include "brw_defines.h" 38d19d0596daf004b56d80f78fa1a329b43c2ebf94Zou Nan hai#include "brw_wm.h" 399f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 409f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt/*********************************************************************** 419f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt * WM unit - fragment programs and rasterization 429f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */ 439f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 44f30de6964018619658439216cd8bf9371ee6256dEric Anholtbool 45f30de6964018619658439216cd8bf9371ee6256dEric Anholtbrw_color_buffer_write_enabled(struct brw_context *brw) 46f30de6964018619658439216cd8bf9371ee6256dEric Anholt{ 47f30de6964018619658439216cd8bf9371ee6256dEric Anholt struct gl_context *ctx = &brw->intel.ctx; 48f30de6964018619658439216cd8bf9371ee6256dEric Anholt const struct gl_fragment_program *fp = brw->fragment_program; 49f30de6964018619658439216cd8bf9371ee6256dEric Anholt int i; 50f30de6964018619658439216cd8bf9371ee6256dEric Anholt 51f30de6964018619658439216cd8bf9371ee6256dEric Anholt /* _NEW_BUFFERS */ 52f30de6964018619658439216cd8bf9371ee6256dEric Anholt for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) { 53f30de6964018619658439216cd8bf9371ee6256dEric Anholt struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[i]; 54f30de6964018619658439216cd8bf9371ee6256dEric Anholt 55f30de6964018619658439216cd8bf9371ee6256dEric Anholt /* _NEW_COLOR */ 56f30de6964018619658439216cd8bf9371ee6256dEric Anholt if (rb && 57f30de6964018619658439216cd8bf9371ee6256dEric Anholt (fp->Base.OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_COLOR) || 58f30de6964018619658439216cd8bf9371ee6256dEric Anholt fp->Base.OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_DATA0 + i)) && 59f30de6964018619658439216cd8bf9371ee6256dEric Anholt (ctx->Color.ColorMask[i][0] || 60f30de6964018619658439216cd8bf9371ee6256dEric Anholt ctx->Color.ColorMask[i][1] || 61f30de6964018619658439216cd8bf9371ee6256dEric Anholt ctx->Color.ColorMask[i][2] || 62f30de6964018619658439216cd8bf9371ee6256dEric Anholt ctx->Color.ColorMask[i][3])) { 63f30de6964018619658439216cd8bf9371ee6256dEric Anholt return true; 64f30de6964018619658439216cd8bf9371ee6256dEric Anholt } 65f30de6964018619658439216cd8bf9371ee6256dEric Anholt } 66f30de6964018619658439216cd8bf9371ee6256dEric Anholt 67f30de6964018619658439216cd8bf9371ee6256dEric Anholt return false; 68f30de6964018619658439216cd8bf9371ee6256dEric Anholt} 69f30de6964018619658439216cd8bf9371ee6256dEric Anholt 701a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt/** 711a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt * Setup wm hardware state. See page 225 of Volume 2 721a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt */ 739e9f6f105c81436cecfe55a8a80d2efe45bc0d72Eric Anholtstatic void 74c4aaf85285fc9484e95e9cda89db9cc6923259f4Eric Anholtbrw_upload_wm_unit(struct brw_context *brw) 759f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{ 769f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt struct intel_context *intel = &brw->intel; 771a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt struct gl_context *ctx = &intel->ctx; 781a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt const struct gl_fragment_program *fp = brw->fragment_program; 791a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt struct brw_wm_unit_state *wm; 809f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 81d375df220fae47f38944c4832bcbd5f5d568884cEric Anholt wm = brw_state_batch(brw, AUB_TRACE_WM_STATE, 82d375df220fae47f38944c4832bcbd5f5d568884cEric Anholt sizeof(*wm), 32, &brw->wm.state_offset); 831a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt memset(wm, 0, sizeof(*wm)); 840ff3eb637bac9e100aab0a109a46e81bea9203a3Eric Anholt 851a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt if (brw->wm.prog_data->prog_offset_16) { 8642ad2f0b9b6a18f1613f6d915a46b4a4a89c5aa2Eric Anholt /* These two fields should be the same pre-gen6, which is why we 8742ad2f0b9b6a18f1613f6d915a46b4a4a89c5aa2Eric Anholt * only have one hardware field to program for both dispatch 8842ad2f0b9b6a18f1613f6d915a46b4a4a89c5aa2Eric Anholt * widths. 8942ad2f0b9b6a18f1613f6d915a46b4a4a89c5aa2Eric Anholt */ 9042ad2f0b9b6a18f1613f6d915a46b4a4a89c5aa2Eric Anholt assert(brw->wm.prog_data->first_curbe_grf == 9142ad2f0b9b6a18f1613f6d915a46b4a4a89c5aa2Eric Anholt brw->wm.prog_data->first_curbe_grf_16); 9242ad2f0b9b6a18f1613f6d915a46b4a4a89c5aa2Eric Anholt } 939f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 94c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt /* BRW_NEW_PROGRAM_CACHE | CACHE_NEW_WM_PROG */ 951791857d7d950d3d2834bbb09b495f51f43ef7c1Eric Anholt wm->thread0.grf_reg_count = brw->wm.prog_data->reg_blocks; 961791857d7d950d3d2834bbb09b495f51f43ef7c1Eric Anholt wm->wm9.grf_reg_count_2 = brw->wm.prog_data->reg_blocks_16; 97c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt 98c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt wm->thread0.kernel_start_pointer = 99c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt brw_program_reloc(brw, 100c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt brw->wm.state_offset + 101c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt offsetof(struct brw_wm_unit_state, thread0), 102c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt brw->wm.prog_offset + 103c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt (wm->thread0.grf_reg_count << 1)) >> 6; 104c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt 105c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt wm->wm9.kernel_start_pointer_2 = 106c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt brw_program_reloc(brw, 107c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt brw->wm.state_offset + 108c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt offsetof(struct brw_wm_unit_state, wm9), 109c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt brw->wm.prog_offset + 110c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt brw->wm.prog_data->prog_offset_16 + 111c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt (wm->wm9.grf_reg_count_2 << 1)) >> 6; 112c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt 1131a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->thread1.depth_coef_urb_read_offset = 1; 1141a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754; 1150ff3eb637bac9e100aab0a109a46e81bea9203a3Eric Anholt 1166ba9090ea05e817bd38c1fcc63c53168b16593c7Kenneth Graunke wm->thread1.binding_table_entry_count = 0; 1179f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 1181a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt if (brw->wm.prog_data->total_scratch != 0) { 1191a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->thread2.scratch_space_base_pointer = 1201a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt brw->wm.scratch_bo->offset >> 10; /* reloc */ 1211a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->thread2.per_thread_scratch_space = 1221a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt ffs(brw->wm.prog_data->total_scratch) - 11; 1231a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt } else { 1241a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->thread2.scratch_space_base_pointer = 0; 1251a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->thread2.per_thread_scratch_space = 0; 1261a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt } 1279f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 1281a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->thread3.dispatch_grf_start_reg = brw->wm.prog_data->first_curbe_grf; 1291a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->thread3.urb_entry_read_length = brw->wm.prog_data->urb_read_length; 1301a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->thread3.urb_entry_read_offset = 0; 1311a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->thread3.const_urb_entry_read_length = 1321a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt brw->wm.prog_data->curb_read_length; 1331a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt /* BRW_NEW_CURBE_OFFSETS */ 1341a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->thread3.const_urb_entry_read_offset = brw->curbe.wm_start * 2; 135e3a6e60040b7f6ea7965e52f8f9881ed31e0347cEric Anholt 1361a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt if (intel->gen == 5) 1371a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->wm4.sampler_count = 0; /* hardware requirement */ 1381a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt else { 1391a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt /* CACHE_NEW_SAMPLER */ 14032dfa6e5ef3d1fb703ec34942c55408be22e7ec3Kenneth Graunke wm->wm4.sampler_count = (brw->sampler.count + 1) / 4; 1411a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt } 1429f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 14332dfa6e5ef3d1fb703ec34942c55408be22e7ec3Kenneth Graunke if (brw->sampler.count) { 1441a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt /* reloc */ 1455c742ea1ee0cea031cb99651155d0c7521f42b4eEric Anholt wm->wm4.sampler_state_pointer = (intel->batch.bo->offset + 14632dfa6e5ef3d1fb703ec34942c55408be22e7ec3Kenneth Graunke brw->sampler.offset) >> 5; 1471a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt } else { 1481a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->wm4.sampler_state_pointer = 0; 1491a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt } 1501a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt 1511a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt /* BRW_NEW_FRAGMENT_PROGRAM */ 1521a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->wm5.program_uses_depth = (fp->Base.InputsRead & 1531a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt (1 << FRAG_ATTRIB_WPOS)) != 0; 1541a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->wm5.program_computes_depth = (fp->Base.OutputsWritten & 1551a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt BITFIELD64_BIT(FRAG_RESULT_DEPTH)) != 0; 156a98dd64af750fb6dae54b2dc02e0c5a3711156afEric Anholt /* _NEW_BUFFERS 1573e4539a471da48066a83eda8e14301dbc4dbf6dbEric Anholt * Override for NULL depthbuffer case, required by the Pixel Shader Computed 1583e4539a471da48066a83eda8e14301dbc4dbf6dbEric Anholt * Depth field. 1593e4539a471da48066a83eda8e14301dbc4dbf6dbEric Anholt */ 160a98dd64af750fb6dae54b2dc02e0c5a3711156afEric Anholt if (!intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_DEPTH)) 1611a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->wm5.program_computes_depth = 0; 162f30de6964018619658439216cd8bf9371ee6256dEric Anholt 1639e9f6f105c81436cecfe55a8a80d2efe45bc0d72Eric Anholt /* _NEW_COLOR */ 1641a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->wm5.program_uses_killpixel = fp->UsesKill || ctx->Color.AlphaEnabled; 1651a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt 1665cbd1170da0a902fdc9c460584bc503b0c4085a6Brian Paul 1671a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt /* BRW_NEW_FRAGMENT_PROGRAM 1681a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt * 1691a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt * If using the fragment shader backend, the program is always 1701a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt * 8-wide. If not, it's always 16. 1719763d0a82a1ee605a8794f199d432824fb972b6aEric Anholt */ 172b527dd65c830a2b008816cf390d5be906e29bb23Ian Romanick if (ctx->Shader._CurrentFragmentProgram) { 1733322fbaf3b5e305ce00c1d08c26965bb98e0cef0Ian Romanick struct brw_shader *shader = (struct brw_shader *) 174b527dd65c830a2b008816cf390d5be906e29bb23Ian Romanick ctx->Shader._CurrentFragmentProgram->_LinkedShaders[MESA_SHADER_FRAGMENT]; 1759763d0a82a1ee605a8794f199d432824fb972b6aEric Anholt 1763322fbaf3b5e305ce00c1d08c26965bb98e0cef0Ian Romanick if (shader != NULL && shader->ir != NULL) { 1771a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->wm5.enable_8_pix = 1; 1781a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt if (brw->wm.prog_data->prog_offset_16) 1791a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->wm5.enable_16_pix = 1; 1809763d0a82a1ee605a8794f199d432824fb972b6aEric Anholt } 1819763d0a82a1ee605a8794f199d432824fb972b6aEric Anholt } 1821a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt if (!wm->wm5.enable_8_pix) 1831a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->wm5.enable_16_pix = 1; 1849f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 185db6dd6d88fdc4361193dd063e4f150f01a104faaKenneth Graunke wm->wm5.max_threads = brw->max_wm_threads - 1; 1869e9f6f105c81436cecfe55a8a80d2efe45bc0d72Eric Anholt 1871a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt /* _NEW_BUFFERS | _NEW_COLOR */ 1881a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt if (brw_color_buffer_write_enabled(brw) || 1891a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->wm5.program_uses_killpixel || 1901a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->wm5.program_computes_depth) { 1911a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->wm5.thread_dispatch_enable = 1; 192f30de6964018619658439216cd8bf9371ee6256dEric Anholt } 193f30de6964018619658439216cd8bf9371ee6256dEric Anholt 1941a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->wm5.legacy_line_rast = 0; 1951a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->wm5.legacy_global_depth_bias = 0; 1961a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->wm5.early_depth_test = 1; /* never need to disable */ 1971a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->wm5.line_aa_region_width = 0; 1981a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->wm5.line_endcap_aa_region_width = 1; 1999f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 2001a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt /* _NEW_POLYGONSTIPPLE */ 2011a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->wm5.polygon_stipple = ctx->Polygon.StippleFlag; 2029f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 2031a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt /* _NEW_POLYGON */ 2041a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt if (ctx->Polygon.OffsetFill) { 2051a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->wm5.depth_offset = 1; 2069f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt /* Something wierd going on with legacy_global_depth_bias, 2079f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt * offset_constant, scaling and MRD. This value passes glean 2089f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt * but gives some odd results elsewere (eg. the 2099f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt * quad-offset-units test). 2109f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */ 2111a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->global_depth_offset_constant = ctx->Polygon.OffsetUnits * 2; 2129f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 2139f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt /* This is the only value that passes glean: 2149f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */ 2151a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->global_depth_offset_scale = ctx->Polygon.OffsetFactor; 2169f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt } 2179f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 2181a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt /* _NEW_LINE */ 2191a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->wm5.line_stipple = ctx->Line.StippleFlag; 2209f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 2211a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt /* _NEW_DEPTH */ 2221a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt if (unlikely(INTEL_DEBUG & DEBUG_STATS) || intel->stats_wm) 2231a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->wm4.stats_enable = 1; 22438bad7677e57d629eeffd4ef39a7fc254db12735Eric Anholt 2258abffada70fcd62e3c2dcbcdc6d00d258805326bEric Anholt /* Emit scratch space relocation */ 2261a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt if (brw->wm.prog_data->total_scratch != 0) { 2271a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt drm_intel_bo_emit_reloc(intel->batch.bo, 2281a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt brw->wm.state_offset + 2291a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt offsetof(struct brw_wm_unit_state, thread2), 230df3c1a563f3d76b07ab82c7b230b0030452f36ffEric Anholt brw->wm.scratch_bo, 2311a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt wm->thread2.per_thread_scratch_space, 232ff81a1dd92f1bffcbfbd2c5268ea0d821b8e9dd4Eric Anholt I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER); 2338abffada70fcd62e3c2dcbcdc6d00d258805326bEric Anholt } 2348abffada70fcd62e3c2dcbcdc6d00d258805326bEric Anholt 2358abffada70fcd62e3c2dcbcdc6d00d258805326bEric Anholt /* Emit sampler state relocation */ 23632dfa6e5ef3d1fb703ec34942c55408be22e7ec3Kenneth Graunke if (brw->sampler.count != 0) { 2371a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt drm_intel_bo_emit_reloc(intel->batch.bo, 2381a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt brw->wm.state_offset + 2391a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt offsetof(struct brw_wm_unit_state, wm4), 24032dfa6e5ef3d1fb703ec34942c55408be22e7ec3Kenneth Graunke intel->batch.bo, (brw->sampler.offset | 2415c742ea1ee0cea031cb99651155d0c7521f42b4eEric Anholt wm->wm4.stats_enable | 2425c742ea1ee0cea031cb99651155d0c7521f42b4eEric Anholt (wm->wm4.sampler_count << 2)), 243df3c1a563f3d76b07ab82c7b230b0030452f36ffEric Anholt I915_GEM_DOMAIN_INSTRUCTION, 0); 2448abffada70fcd62e3c2dcbcdc6d00d258805326bEric Anholt } 2458abffada70fcd62e3c2dcbcdc6d00d258805326bEric Anholt 2461a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt brw->state.dirty.cache |= CACHE_NEW_WM_UNIT; 24738bad7677e57d629eeffd4ef39a7fc254db12735Eric Anholt} 24838bad7677e57d629eeffd4ef39a7fc254db12735Eric Anholt 2499f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtconst struct brw_tracked_state brw_wm_unit = { 2509f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt .dirty = { 2519f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt .mesa = (_NEW_POLYGON | 2529f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt _NEW_POLYGONSTIPPLE | 2539f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt _NEW_LINE | 254c0d6e07909733af054cc592e2cfc6212155b0a9eEric Anholt _NEW_COLOR | 255f30de6964018619658439216cd8bf9371ee6256dEric Anholt _NEW_DEPTH | 256f30de6964018619658439216cd8bf9371ee6256dEric Anholt _NEW_BUFFERS), 2579f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 2581a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt .brw = (BRW_NEW_BATCH | 259c173541d9769d41a85cc899bc49699a3587df4bfEric Anholt BRW_NEW_PROGRAM_CACHE | 2601a447749ed421db8eb6ba20012630785aef9bb12Eric Anholt BRW_NEW_FRAGMENT_PROGRAM | 2616ba9090ea05e817bd38c1fcc63c53168b16593c7Kenneth Graunke BRW_NEW_CURBE_OFFSETS), 2629f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 263e476acb1051ae1a7e5e2be35a89488a8e5b07ff4Eric Anholt .cache = (CACHE_NEW_WM_PROG | 2649f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt CACHE_NEW_SAMPLER) 2659f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt }, 266c4aaf85285fc9484e95e9cda89db9cc6923259f4Eric Anholt .emit = brw_upload_wm_unit, 2679f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}; 2689f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 269