17b0f748efa5af84668cc3609a0070163bfa22607Chad Versace/* 27b0f748efa5af84668cc3609a0070163bfa22607Chad Versace * Copyright © 2011 Intel Corporation 37b0f748efa5af84668cc3609a0070163bfa22607Chad Versace * 47b0f748efa5af84668cc3609a0070163bfa22607Chad Versace * Permission is hereby granted, free of charge, to any person obtaining a 57b0f748efa5af84668cc3609a0070163bfa22607Chad Versace * copy of this software and associated documentation files (the "Software"), 67b0f748efa5af84668cc3609a0070163bfa22607Chad Versace * to deal in the Software without restriction, including without limitation 77b0f748efa5af84668cc3609a0070163bfa22607Chad Versace * the rights to use, copy, modify, merge, publish, distribute, sublicense, 87b0f748efa5af84668cc3609a0070163bfa22607Chad Versace * and/or sell copies of the Software, and to permit persons to whom the 97b0f748efa5af84668cc3609a0070163bfa22607Chad Versace * Software is furnished to do so, subject to the following conditions: 107b0f748efa5af84668cc3609a0070163bfa22607Chad Versace * 117b0f748efa5af84668cc3609a0070163bfa22607Chad Versace * The above copyright notice and this permission notice (including the next 127b0f748efa5af84668cc3609a0070163bfa22607Chad Versace * paragraph) shall be included in all copies or substantial portions of the 137b0f748efa5af84668cc3609a0070163bfa22607Chad Versace * Software. 147b0f748efa5af84668cc3609a0070163bfa22607Chad Versace * 157b0f748efa5af84668cc3609a0070163bfa22607Chad Versace * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 167b0f748efa5af84668cc3609a0070163bfa22607Chad Versace * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 177b0f748efa5af84668cc3609a0070163bfa22607Chad Versace * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 187b0f748efa5af84668cc3609a0070163bfa22607Chad Versace * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 197b0f748efa5af84668cc3609a0070163bfa22607Chad Versace * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 207b0f748efa5af84668cc3609a0070163bfa22607Chad Versace * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 217b0f748efa5af84668cc3609a0070163bfa22607Chad Versace * IN THE SOFTWARE. 227b0f748efa5af84668cc3609a0070163bfa22607Chad Versace */ 237b0f748efa5af84668cc3609a0070163bfa22607Chad Versace 24d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace#include <assert.h> 25d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace 267b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace#include "intel_batchbuffer.h" 27d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace#include "intel_fbo.h" 28d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace#include "intel_mipmap_tree.h" 29d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace 30d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace#include "brw_context.h" 31d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace#include "brw_defines.h" 327b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace#include "brw_state.h" 33d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace 342c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry#include "brw_blorp.h" 35c56918246162d9059ce914f36e8df6db0f578909Paul Berry#include "gen6_blorp.h" 36d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace 377b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace/** 382c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry * \name Constants for BLORP VBO 397b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * \{ 407b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace */ 412c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry#define GEN6_BLORP_NUM_VERTICES 3 422c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry#define GEN6_BLORP_NUM_VUE_ELEMS 8 432c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry#define GEN6_BLORP_VBO_SIZE (GEN6_BLORP_NUM_VERTICES \ 442c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry * GEN6_BLORP_NUM_VUE_ELEMS \ 452c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry * sizeof(float)) 467b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace/** \} */ 479462b8447864c754252cd2580c9e1e4d36d5cc63Neil Roberts 48586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 49586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry/** 50586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * Compute masks to determine how much of draw_x and draw_y should be 51586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * performed using the fine adjustment of "depth coordinate offset X/Y" 52586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * (dw5 of 3DSTATE_DEPTH_BUFFER). See the emit_depthbuffer() function for 53586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * details. 54586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry */ 55586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berryvoid 56586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berrygen6_blorp_compute_tile_masks(const brw_blorp_params *params, 57586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry uint32_t *tile_mask_x, uint32_t *tile_mask_y) 58586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry{ 59586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry uint32_t depth_mask_x, depth_mask_y, hiz_mask_x, hiz_mask_y; 60586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry intel_region_get_tile_masks(params->depth.mt->region, 6196fd94ba9421c7c3072988f999ee869534f2bc2aPaul Berry &depth_mask_x, &depth_mask_y, false); 62586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry intel_region_get_tile_masks(params->depth.mt->hiz_mt->region, 6396fd94ba9421c7c3072988f999ee869534f2bc2aPaul Berry &hiz_mask_x, &hiz_mask_y, false); 64586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 65586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry /* Each HiZ row represents 2 rows of pixels */ 66586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry hiz_mask_y = hiz_mask_y << 1 | 1; 67586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 68586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry *tile_mask_x = depth_mask_x | hiz_mask_x; 69586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry *tile_mask_y = depth_mask_y | hiz_mask_y; 70586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry} 71586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 72586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 737b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versacevoid 742c5510b71b6348b686e76ecc2c34195080d566f4Paul Berrygen6_blorp_emit_batch_head(struct brw_context *brw, 752c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry const brw_blorp_params *params) 767b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace{ 777b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace struct gl_context *ctx = &brw->intel.ctx; 787b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace struct intel_context *intel = &brw->intel; 797b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 807b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace /* To ensure that the batch contains only the resolve, flush the batch 817b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * before beginning and after finishing emitting the resolve packets. 82d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace * 837b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * Ideally, we would not need to flush for the resolve op. But, I suspect 847b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * that it's unsafe for CMD_PIPELINE_SELECT to occur multiple times in 857b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * a single batch, and there is no safe way to ensure that other than by 867b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * fencing the resolve with flushes. Ideally, we would just detect if 877b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * a batch is in progress and do the right thing, but that would require 887b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * the ability to *safely* access brw_context::state::dirty::brw 897b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * outside of the brw_upload_state() codepath. 90d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace */ 917b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace intel_flush(ctx); 927b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 937b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace /* CMD_PIPELINE_SELECT 947b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * 957b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * Select the 3D pipeline, as opposed to the media pipeline. 967b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace */ 977b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace { 987b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace BEGIN_BATCH(1); 997b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace OUT_BATCH(brw->CMD_PIPELINE_SELECT << 16); 1007b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace ADVANCE_BATCH(); 1017b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace } 102f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry} 1037b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 1047b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 105f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry/** 106f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry * CMD_STATE_BASE_ADDRESS 107f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry * 108f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry * From the Sandy Bridge PRM, Volume 1, Part 1, Table STATE_BASE_ADDRESS: 109f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry * The following commands must be reissued following any change to the 110f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry * base addresses: 111f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry * 3DSTATE_CC_POINTERS 112f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry * 3DSTATE_BINDING_TABLE_POINTERS 113f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry * 3DSTATE_SAMPLER_STATE_POINTERS 114f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry * 3DSTATE_VIEWPORT_STATE_POINTERS 115f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry * MEDIA_STATE_POINTERS 116f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry */ 117f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berryvoid 118f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berrygen6_blorp_emit_state_base_address(struct brw_context *brw, 119f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry const brw_blorp_params *params) 120f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry{ 121f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry struct intel_context *intel = &brw->intel; 122f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry 123f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry BEGIN_BATCH(10); 124f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry OUT_BATCH(CMD_STATE_BASE_ADDRESS << 16 | (10 - 2)); 125f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry OUT_BATCH(1); /* GeneralStateBaseAddressModifyEnable */ 126f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry /* SurfaceStateBaseAddress */ 127f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry OUT_RELOC(intel->batch.bo, I915_GEM_DOMAIN_SAMPLER, 0, 1); 128f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry /* DynamicStateBaseAddress */ 129f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry OUT_RELOC(intel->batch.bo, (I915_GEM_DOMAIN_RENDER | 130f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry I915_GEM_DOMAIN_INSTRUCTION), 0, 1); 131f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry OUT_BATCH(1); /* IndirectObjectBaseAddress */ 132f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry if (params->use_wm_prog) { 133f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry OUT_RELOC(brw->cache.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 134f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry 1); /* Instruction base address: shader kernels */ 135f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry } else { 136f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry OUT_BATCH(1); /* InstructionBaseAddress */ 1377b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace } 138f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry OUT_BATCH(1); /* GeneralStateUpperBound */ 139de9752a4e59e869e905cb898c4a0dbe539c43c8dPaul Berry /* Dynamic state upper bound. Although the documentation says that 140de9752a4e59e869e905cb898c4a0dbe539c43c8dPaul Berry * programming it to zero will cause it to be ignored, that is a lie. 141de9752a4e59e869e905cb898c4a0dbe539c43c8dPaul Berry * If this isn't programmed to a real bound, the sampler border color 142de9752a4e59e869e905cb898c4a0dbe539c43c8dPaul Berry * pointer is rejected, causing border color to mysteriously fail. 143de9752a4e59e869e905cb898c4a0dbe539c43c8dPaul Berry */ 144de9752a4e59e869e905cb898c4a0dbe539c43c8dPaul Berry OUT_BATCH(0xfffff001); 145f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry OUT_BATCH(1); /* IndirectObjectUpperBound*/ 146f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry OUT_BATCH(1); /* InstructionAccessUpperBound */ 147f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry ADVANCE_BATCH(); 148d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace} 149d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace 150f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry 1517b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versacevoid 1522c5510b71b6348b686e76ecc2c34195080d566f4Paul Berrygen6_blorp_emit_vertices(struct brw_context *brw, 1532c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry const brw_blorp_params *params) 154d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace{ 1557b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace struct intel_context *intel = &brw->intel; 1560da508644339cdc59f122f503f86ff2eb4949d97Eric Anholt uint32_t vertex_offset; 157d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace 1587b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace /* Setup VBO for the rectangle primitive.. 1597b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * 1607b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * A rectangle primitive (3DPRIM_RECTLIST) consists of only three 1617b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * vertices. The vertices reside in screen space with DirectX coordinates 1627b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * (that is, (0, 0) is the upper left corner). 1637b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * 1647b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * v2 ------ implied 1657b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * | | 1667b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * | | 1677b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * v0 ----- v1 1687b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * 1697b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * Since the VS is disabled, the clipper loads each VUE directly from 1707b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * the URB. This is controlled by the 3DSTATE_VERTEX_BUFFERS and 1717b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * 3DSTATE_VERTEX_ELEMENTS packets below. The VUE contents are as follows: 1727b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * dw0: Reserved, MBZ. 1737b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * dw1: Render Target Array Index. The HiZ op does not use indexed 1747b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * vertices, so set the dword to 0. 1757b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * dw2: Viewport Index. The HiZ op disables viewport mapping and 1767b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * scissoring, so set the dword to 0. 1777b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * dw3: Point Width: The HiZ op does not emit the POINTLIST primitive, so 1787b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * set the dword to 0. 1797b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * dw4: Vertex Position X. 1807b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * dw5: Vertex Position Y. 1817b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * dw6: Vertex Position Z. 1827b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * dw7: Vertex Position W. 1837b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * 1847b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * For details, see the Sandybridge PRM, Volume 2, Part 1, Section 1.5.1 1857b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * "Vertex URB Entry (VUE) Formats". 1867b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace */ 1877b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace { 1880da508644339cdc59f122f503f86ff2eb4949d97Eric Anholt float *vertex_data; 189d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace 1902c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry const float vertices[GEN6_BLORP_VBO_SIZE] = { 1912c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry /* v0 */ 0, 0, 0, 0, params->x0, params->y1, 0, 1, 1922c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry /* v1 */ 0, 0, 0, 0, params->x1, params->y1, 0, 1, 1932c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry /* v2 */ 0, 0, 0, 0, params->x0, params->y0, 0, 1, 1947b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace }; 195d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace 196ea8e854b2cefc3f3590b6c19e6108a471be951baPaul Berry vertex_data = (float *) brw_state_batch(brw, AUB_TRACE_VERTEX_BUFFER, 1972c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry GEN6_BLORP_VBO_SIZE, 32, 19820b153b9ca5e57aa0e20e992347ece56388e71e4Paul Berry &vertex_offset); 1992c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry memcpy(vertex_data, vertices, GEN6_BLORP_VBO_SIZE); 2007b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace } 2017b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 2027b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace /* 3DSTATE_VERTEX_BUFFERS */ 2037b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace { 2047b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace const int num_buffers = 1; 2057b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace const int batch_length = 1 + 4 * num_buffers; 2067b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 2077b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace uint32_t dw0 = GEN6_VB0_ACCESS_VERTEXDATA | 2082c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry (GEN6_BLORP_NUM_VUE_ELEMS * sizeof(float)) << BRW_VB0_PITCH_SHIFT; 2097b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 2107b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace if (intel->gen >= 7) 2117b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace dw0 |= GEN7_VB0_ADDRESS_MODIFYENABLE; 2127b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 2137b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace BEGIN_BATCH(batch_length); 2147b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace OUT_BATCH((_3DSTATE_VERTEX_BUFFERS << 16) | (batch_length - 2)); 2157b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace OUT_BATCH(dw0); 2167b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace /* start address */ 2170da508644339cdc59f122f503f86ff2eb4949d97Eric Anholt OUT_RELOC(intel->batch.bo, I915_GEM_DOMAIN_VERTEX, 0, 2180da508644339cdc59f122f503f86ff2eb4949d97Eric Anholt vertex_offset); 2197b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace /* end address */ 2200da508644339cdc59f122f503f86ff2eb4949d97Eric Anholt OUT_RELOC(intel->batch.bo, I915_GEM_DOMAIN_VERTEX, 0, 2212c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry vertex_offset + GEN6_BLORP_VBO_SIZE - 1); 2227b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace OUT_BATCH(0); 2237b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace ADVANCE_BATCH(); 2247b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace } 2257b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 2267b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace /* 3DSTATE_VERTEX_ELEMENTS 2277b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * 2287b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * Fetch dwords 0 - 7 from each VUE. See the comments above where 2292c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry * the vertex_bo is filled with data. 2307b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace */ 2317b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace { 2327b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace const int num_elements = 2; 2337b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace const int batch_length = 1 + 2 * num_elements; 2347b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 2357b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace BEGIN_BATCH(batch_length); 2367b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace OUT_BATCH((_3DSTATE_VERTEX_ELEMENTS << 16) | (batch_length - 2)); 2377b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace /* Element 0 */ 2387b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace OUT_BATCH(GEN6_VE0_VALID | 2397b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace BRW_SURFACEFORMAT_R32G32B32A32_FLOAT << BRW_VE0_FORMAT_SHIFT | 2407b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 0 << BRW_VE0_SRC_OFFSET_SHIFT); 2417b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace OUT_BATCH(BRW_VE1_COMPONENT_STORE_SRC << BRW_VE1_COMPONENT_0_SHIFT | 2427b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace BRW_VE1_COMPONENT_STORE_SRC << BRW_VE1_COMPONENT_1_SHIFT | 2437b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace BRW_VE1_COMPONENT_STORE_SRC << BRW_VE1_COMPONENT_2_SHIFT | 2447b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace BRW_VE1_COMPONENT_STORE_SRC << BRW_VE1_COMPONENT_3_SHIFT); 2457b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace /* Element 1 */ 2467b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace OUT_BATCH(GEN6_VE0_VALID | 2477b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace BRW_SURFACEFORMAT_R32G32B32A32_FLOAT << BRW_VE0_FORMAT_SHIFT | 2487b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 16 << BRW_VE0_SRC_OFFSET_SHIFT); 2497b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace OUT_BATCH(BRW_VE1_COMPONENT_STORE_SRC << BRW_VE1_COMPONENT_0_SHIFT | 2507b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace BRW_VE1_COMPONENT_STORE_SRC << BRW_VE1_COMPONENT_1_SHIFT | 2517b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace BRW_VE1_COMPONENT_STORE_SRC << BRW_VE1_COMPONENT_2_SHIFT | 2527b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace BRW_VE1_COMPONENT_STORE_SRC << BRW_VE1_COMPONENT_3_SHIFT); 2537b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace ADVANCE_BATCH(); 2547b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace } 255d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace} 256d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace 257586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 258586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry/* 3DSTATE_URB 2597b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * 260586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * Assign the entire URB to the VS. Even though the VS disabled, URB space 261586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * is still needed because the clipper loads the VUE's from the URB. From 262586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * the Sandybridge PRM, Volume 2, Part 1, Section 3DSTATE, 263586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * Dword 1.15:0 "VS Number of URB Entries": 264586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * This field is always used (even if VS Function Enable is DISABLED). 265d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace * 266586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * The warning below appears in the PRM (Section 3DSTATE_URB), but we can 267586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * safely ignore it because this batch contains only one draw call. 268586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * Because of URB corruption caused by allocating a previous GS unit 269586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * URB entry to the VS unit, software is required to send a “GS NULL 270586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * Fence” (Send URB fence with VS URB size == 1 and GS URB size == 0) 271586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * plus a dummy DRAW call before any case where VS will be taking over 272586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * GS URB space. 273d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace */ 274586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berrystatic void 275586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berrygen6_blorp_emit_urb_config(struct brw_context *brw, 276586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry const brw_blorp_params *params) 277d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace{ 278586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry struct intel_context *intel = &brw->intel; 2793ec0e55b63db3c1067f3bbf4563beb3b98a19288Paul Berry 280586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry BEGIN_BATCH(3); 281586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(_3DSTATE_URB << 16 | (3 - 2)); 282586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(brw->urb.max_vs_entries << GEN6_URB_VS_ENTRIES_SHIFT); 283586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(0); 284586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry ADVANCE_BATCH(); 285586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry} 2863ec0e55b63db3c1067f3bbf4563beb3b98a19288Paul Berry 2873ec0e55b63db3c1067f3bbf4563beb3b98a19288Paul Berry 288506d70be21cd3469118de89297cba0c0f709c1aePaul Berry/* BLEND_STATE */ 289506d70be21cd3469118de89297cba0c0f709c1aePaul Berryuint32_t 290506d70be21cd3469118de89297cba0c0f709c1aePaul Berrygen6_blorp_emit_blend_state(struct brw_context *brw, 291506d70be21cd3469118de89297cba0c0f709c1aePaul Berry const brw_blorp_params *params) 292506d70be21cd3469118de89297cba0c0f709c1aePaul Berry{ 293506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t cc_blend_state_offset; 294506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 295506d70be21cd3469118de89297cba0c0f709c1aePaul Berry struct gen6_blend_state *blend = (struct gen6_blend_state *) 296506d70be21cd3469118de89297cba0c0f709c1aePaul Berry brw_state_batch(brw, AUB_TRACE_BLEND_STATE, 297506d70be21cd3469118de89297cba0c0f709c1aePaul Berry sizeof(struct gen6_blend_state), 64, 298506d70be21cd3469118de89297cba0c0f709c1aePaul Berry &cc_blend_state_offset); 299506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 300506d70be21cd3469118de89297cba0c0f709c1aePaul Berry memset(blend, 0, sizeof(*blend)); 301506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 302506d70be21cd3469118de89297cba0c0f709c1aePaul Berry blend->blend1.pre_blend_clamp_enable = 1; 303506d70be21cd3469118de89297cba0c0f709c1aePaul Berry blend->blend1.post_blend_clamp_enable = 1; 304506d70be21cd3469118de89297cba0c0f709c1aePaul Berry blend->blend1.clamp_range = BRW_RENDERTARGET_CLAMPRANGE_FORMAT; 305506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 306506d70be21cd3469118de89297cba0c0f709c1aePaul Berry blend->blend1.write_disable_r = false; 307506d70be21cd3469118de89297cba0c0f709c1aePaul Berry blend->blend1.write_disable_g = false; 308506d70be21cd3469118de89297cba0c0f709c1aePaul Berry blend->blend1.write_disable_b = false; 309506d70be21cd3469118de89297cba0c0f709c1aePaul Berry blend->blend1.write_disable_a = false; 310506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 311506d70be21cd3469118de89297cba0c0f709c1aePaul Berry return cc_blend_state_offset; 312506d70be21cd3469118de89297cba0c0f709c1aePaul Berry} 313506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 314506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 315506d70be21cd3469118de89297cba0c0f709c1aePaul Berry/* CC_STATE */ 316506d70be21cd3469118de89297cba0c0f709c1aePaul Berryuint32_t 317506d70be21cd3469118de89297cba0c0f709c1aePaul Berrygen6_blorp_emit_cc_state(struct brw_context *brw, 318506d70be21cd3469118de89297cba0c0f709c1aePaul Berry const brw_blorp_params *params) 319506d70be21cd3469118de89297cba0c0f709c1aePaul Berry{ 320506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t cc_state_offset; 321506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 322506d70be21cd3469118de89297cba0c0f709c1aePaul Berry struct gen6_color_calc_state *cc = (struct gen6_color_calc_state *) 323506d70be21cd3469118de89297cba0c0f709c1aePaul Berry brw_state_batch(brw, AUB_TRACE_CC_STATE, 324506d70be21cd3469118de89297cba0c0f709c1aePaul Berry sizeof(gen6_color_calc_state), 64, 325506d70be21cd3469118de89297cba0c0f709c1aePaul Berry &cc_state_offset); 326506d70be21cd3469118de89297cba0c0f709c1aePaul Berry memset(cc, 0, sizeof(*cc)); 327506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 328506d70be21cd3469118de89297cba0c0f709c1aePaul Berry return cc_state_offset; 329506d70be21cd3469118de89297cba0c0f709c1aePaul Berry} 330506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 331506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 332586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry/** 333586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * \param out_offset is relative to 334586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * CMD_STATE_BASE_ADDRESS.DynamicStateBaseAddress. 335586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry */ 336586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berryuint32_t 337586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berrygen6_blorp_emit_depth_stencil_state(struct brw_context *brw, 338586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry const brw_blorp_params *params) 339586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry{ 340586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry uint32_t depthstencil_offset; 3413ec0e55b63db3c1067f3bbf4563beb3b98a19288Paul Berry 342586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry struct gen6_depth_stencil_state *state; 343586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry state = (struct gen6_depth_stencil_state *) 344586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry brw_state_batch(brw, AUB_TRACE_DEPTH_STENCIL_STATE, 345586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry sizeof(*state), 64, 346586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry &depthstencil_offset); 347586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry memset(state, 0, sizeof(*state)); 3487b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 349586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry /* See the following sections of the Sandy Bridge PRM, Volume 1, Part2: 350586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * - 7.5.3.1 Depth Buffer Clear 351586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * - 7.5.3.2 Depth Buffer Resolve 352586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * - 7.5.3.3 Hierarchical Depth Buffer Resolve 3537b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace */ 354586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry state->ds2.depth_write_enable = 1; 355586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry if (params->hiz_op == GEN6_HIZ_OP_DEPTH_RESOLVE) { 356586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry state->ds2.depth_test_enable = 1; 357586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry state->ds2.depth_test_func = COMPAREFUNC_NEVER; 358d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace } 359d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace 360586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry return depthstencil_offset; 361586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry} 362d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace 363586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 364586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry/* 3DSTATE_CC_STATE_POINTERS 365586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * 366586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * The pointer offsets are relative to 367586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * CMD_STATE_BASE_ADDRESS.DynamicStateBaseAddress. 368586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * 369586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * The HiZ op doesn't use BLEND_STATE or COLOR_CALC_STATE. 370586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry */ 371586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berrystatic void 372586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berrygen6_blorp_emit_cc_state_pointers(struct brw_context *brw, 373586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry const brw_blorp_params *params, 374506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t cc_blend_state_offset, 375506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t depthstencil_offset, 376506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t cc_state_offset) 377586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry{ 378586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry struct intel_context *intel = &brw->intel; 379586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 380586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry BEGIN_BATCH(4); 381586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(_3DSTATE_CC_STATE_POINTERS << 16 | (4 - 2)); 382506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(cc_blend_state_offset | 1); /* BLEND_STATE offset */ 383586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(depthstencil_offset | 1); /* DEPTH_STENCIL_STATE offset */ 384506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(cc_state_offset | 1); /* COLOR_CALC_STATE offset */ 385506d70be21cd3469118de89297cba0c0f709c1aePaul Berry ADVANCE_BATCH(); 386506d70be21cd3469118de89297cba0c0f709c1aePaul Berry} 387506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 388506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 389506d70be21cd3469118de89297cba0c0f709c1aePaul Berry/* WM push constants */ 390506d70be21cd3469118de89297cba0c0f709c1aePaul Berryuint32_t 391506d70be21cd3469118de89297cba0c0f709c1aePaul Berrygen6_blorp_emit_wm_constants(struct brw_context *brw, 392506d70be21cd3469118de89297cba0c0f709c1aePaul Berry const brw_blorp_params *params) 393506d70be21cd3469118de89297cba0c0f709c1aePaul Berry{ 394506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t wm_push_const_offset; 395506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 396506d70be21cd3469118de89297cba0c0f709c1aePaul Berry void *constants = brw_state_batch(brw, AUB_TRACE_WM_CONSTANTS, 397506d70be21cd3469118de89297cba0c0f709c1aePaul Berry sizeof(params->wm_push_consts), 398506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 32, &wm_push_const_offset); 399506d70be21cd3469118de89297cba0c0f709c1aePaul Berry memcpy(constants, ¶ms->wm_push_consts, 400506d70be21cd3469118de89297cba0c0f709c1aePaul Berry sizeof(params->wm_push_consts)); 401506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 402506d70be21cd3469118de89297cba0c0f709c1aePaul Berry return wm_push_const_offset; 403506d70be21cd3469118de89297cba0c0f709c1aePaul Berry} 404506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 405506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 406506d70be21cd3469118de89297cba0c0f709c1aePaul Berry/* SURFACE_STATE for renderbuffer or texture surface (see 407506d70be21cd3469118de89297cba0c0f709c1aePaul Berry * brw_update_renderbuffer_surface and brw_update_texture_surface) 408506d70be21cd3469118de89297cba0c0f709c1aePaul Berry */ 409506d70be21cd3469118de89297cba0c0f709c1aePaul Berrystatic uint32_t 410506d70be21cd3469118de89297cba0c0f709c1aePaul Berrygen6_blorp_emit_surface_state(struct brw_context *brw, 411506d70be21cd3469118de89297cba0c0f709c1aePaul Berry const brw_blorp_params *params, 412506d70be21cd3469118de89297cba0c0f709c1aePaul Berry const brw_blorp_surface_info *surface, 413506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t read_domains, uint32_t write_domain) 414506d70be21cd3469118de89297cba0c0f709c1aePaul Berry{ 415506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t wm_surf_offset; 416602e9a0f3727b036caf3a7b228fe90d36d832ea7Paul Berry uint32_t width = surface->width; 417602e9a0f3727b036caf3a7b228fe90d36d832ea7Paul Berry uint32_t height = surface->height; 418cb9765ca94b5a73eaafe0468ed40052dce55fdc8Paul Berry if (surface->num_samples > 1) { 419cb9765ca94b5a73eaafe0468ed40052dce55fdc8Paul Berry /* Since gen6 uses INTEL_MSAA_LAYOUT_IMS, width and height are measured 420cb9765ca94b5a73eaafe0468ed40052dce55fdc8Paul Berry * in samples. But SURFACE_STATE wants them in pixels, so we need to 421cb9765ca94b5a73eaafe0468ed40052dce55fdc8Paul Berry * divide them each by 2. 422cb9765ca94b5a73eaafe0468ed40052dce55fdc8Paul Berry */ 42319e9b24626c2b9d7abef054d57bb2a52106c545bPaul Berry width /= 2; 42419e9b24626c2b9d7abef054d57bb2a52106c545bPaul Berry height /= 2; 42519e9b24626c2b9d7abef054d57bb2a52106c545bPaul Berry } 426506d70be21cd3469118de89297cba0c0f709c1aePaul Berry struct intel_region *region = surface->mt->region; 427239e9bef92bd4602bc30e05177fa85a6e5b69fe0Paul Berry uint32_t tile_x, tile_y; 428506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 429506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t *surf = (uint32_t *) 430506d70be21cd3469118de89297cba0c0f709c1aePaul Berry brw_state_batch(brw, AUB_TRACE_SURFACE_STATE, 6 * 4, 32, 431506d70be21cd3469118de89297cba0c0f709c1aePaul Berry &wm_surf_offset); 432506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 433506d70be21cd3469118de89297cba0c0f709c1aePaul Berry surf[0] = (BRW_SURFACE_2D << BRW_SURFACE_TYPE_SHIFT | 434506d70be21cd3469118de89297cba0c0f709c1aePaul Berry BRW_SURFACE_MIPMAPLAYOUT_BELOW << BRW_SURFACE_MIPLAYOUT_SHIFT | 435506d70be21cd3469118de89297cba0c0f709c1aePaul Berry BRW_SURFACE_CUBEFACE_ENABLES | 436040d0157341381708c35c2f27721ebffa2ee1db2Paul Berry surface->brw_surfaceformat << BRW_SURFACE_FORMAT_SHIFT); 437506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 438506d70be21cd3469118de89297cba0c0f709c1aePaul Berry /* reloc */ 439239e9bef92bd4602bc30e05177fa85a6e5b69fe0Paul Berry surf[1] = (surface->compute_tile_offsets(&tile_x, &tile_y) + 440239e9bef92bd4602bc30e05177fa85a6e5b69fe0Paul Berry region->bo->offset); 441506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 442506d70be21cd3469118de89297cba0c0f709c1aePaul Berry surf[2] = (0 << BRW_SURFACE_LOD_SHIFT | 443506d70be21cd3469118de89297cba0c0f709c1aePaul Berry (width - 1) << BRW_SURFACE_WIDTH_SHIFT | 444506d70be21cd3469118de89297cba0c0f709c1aePaul Berry (height - 1) << BRW_SURFACE_HEIGHT_SHIFT); 445506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 446506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t tiling = surface->map_stencil_as_y_tiled 447506d70be21cd3469118de89297cba0c0f709c1aePaul Berry ? BRW_SURFACE_TILED | BRW_SURFACE_TILED_Y 448506d70be21cd3469118de89297cba0c0f709c1aePaul Berry : brw_get_surface_tiling_bits(region->tiling); 449506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t pitch_bytes = region->pitch * region->cpp; 450506d70be21cd3469118de89297cba0c0f709c1aePaul Berry if (surface->map_stencil_as_y_tiled) 451506d70be21cd3469118de89297cba0c0f709c1aePaul Berry pitch_bytes *= 2; 452506d70be21cd3469118de89297cba0c0f709c1aePaul Berry surf[3] = (tiling | 453506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 0 << BRW_SURFACE_DEPTH_SHIFT | 454506d70be21cd3469118de89297cba0c0f709c1aePaul Berry (pitch_bytes - 1) << BRW_SURFACE_PITCH_SHIFT); 455506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 45619e9b24626c2b9d7abef054d57bb2a52106c545bPaul Berry surf[4] = brw_get_surface_num_multisamples(surface->num_samples); 457506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 458239e9bef92bd4602bc30e05177fa85a6e5b69fe0Paul Berry /* Note that the low bits of these fields are missing, so 459239e9bef92bd4602bc30e05177fa85a6e5b69fe0Paul Berry * there's the possibility of getting in trouble. 460239e9bef92bd4602bc30e05177fa85a6e5b69fe0Paul Berry */ 461239e9bef92bd4602bc30e05177fa85a6e5b69fe0Paul Berry assert(tile_x % 4 == 0); 462239e9bef92bd4602bc30e05177fa85a6e5b69fe0Paul Berry assert(tile_y % 2 == 0); 463239e9bef92bd4602bc30e05177fa85a6e5b69fe0Paul Berry surf[5] = ((tile_x / 4) << BRW_SURFACE_X_OFFSET_SHIFT | 464239e9bef92bd4602bc30e05177fa85a6e5b69fe0Paul Berry (tile_y / 2) << BRW_SURFACE_Y_OFFSET_SHIFT | 465506d70be21cd3469118de89297cba0c0f709c1aePaul Berry (surface->mt->align_h == 4 ? 466506d70be21cd3469118de89297cba0c0f709c1aePaul Berry BRW_SURFACE_VERTICAL_ALIGN_ENABLE : 0)); 467506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 468506d70be21cd3469118de89297cba0c0f709c1aePaul Berry /* Emit relocation to surface contents */ 469506d70be21cd3469118de89297cba0c0f709c1aePaul Berry drm_intel_bo_emit_reloc(brw->intel.batch.bo, 470506d70be21cd3469118de89297cba0c0f709c1aePaul Berry wm_surf_offset + 4, 471506d70be21cd3469118de89297cba0c0f709c1aePaul Berry region->bo, 472506d70be21cd3469118de89297cba0c0f709c1aePaul Berry surf[1] - region->bo->offset, 473506d70be21cd3469118de89297cba0c0f709c1aePaul Berry read_domains, write_domain); 474506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 475506d70be21cd3469118de89297cba0c0f709c1aePaul Berry return wm_surf_offset; 476506d70be21cd3469118de89297cba0c0f709c1aePaul Berry} 477506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 478506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 479506d70be21cd3469118de89297cba0c0f709c1aePaul Berry/* BINDING_TABLE. See brw_wm_binding_table(). */ 480506d70be21cd3469118de89297cba0c0f709c1aePaul Berryuint32_t 481506d70be21cd3469118de89297cba0c0f709c1aePaul Berrygen6_blorp_emit_binding_table(struct brw_context *brw, 482506d70be21cd3469118de89297cba0c0f709c1aePaul Berry const brw_blorp_params *params, 483506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t wm_surf_offset_renderbuffer, 484506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t wm_surf_offset_texture) 485506d70be21cd3469118de89297cba0c0f709c1aePaul Berry{ 486506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t wm_bind_bo_offset; 487506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t *bind = (uint32_t *) 488506d70be21cd3469118de89297cba0c0f709c1aePaul Berry brw_state_batch(brw, AUB_TRACE_BINDING_TABLE, 489506d70be21cd3469118de89297cba0c0f709c1aePaul Berry sizeof(uint32_t) * 490506d70be21cd3469118de89297cba0c0f709c1aePaul Berry BRW_BLORP_NUM_BINDING_TABLE_ENTRIES, 491506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 32, /* alignment */ 492506d70be21cd3469118de89297cba0c0f709c1aePaul Berry &wm_bind_bo_offset); 493506d70be21cd3469118de89297cba0c0f709c1aePaul Berry bind[BRW_BLORP_RENDERBUFFER_BINDING_TABLE_INDEX] = 494506d70be21cd3469118de89297cba0c0f709c1aePaul Berry wm_surf_offset_renderbuffer; 495506d70be21cd3469118de89297cba0c0f709c1aePaul Berry bind[BRW_BLORP_TEXTURE_BINDING_TABLE_INDEX] = wm_surf_offset_texture; 496506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 497506d70be21cd3469118de89297cba0c0f709c1aePaul Berry return wm_bind_bo_offset; 498506d70be21cd3469118de89297cba0c0f709c1aePaul Berry} 499506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 500506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 501506d70be21cd3469118de89297cba0c0f709c1aePaul Berry/** 502506d70be21cd3469118de89297cba0c0f709c1aePaul Berry * SAMPLER_STATE. See brw_update_sampler_state(). 503506d70be21cd3469118de89297cba0c0f709c1aePaul Berry */ 504506d70be21cd3469118de89297cba0c0f709c1aePaul Berrystatic uint32_t 505506d70be21cd3469118de89297cba0c0f709c1aePaul Berrygen6_blorp_emit_sampler_state(struct brw_context *brw, 506506d70be21cd3469118de89297cba0c0f709c1aePaul Berry const brw_blorp_params *params) 507506d70be21cd3469118de89297cba0c0f709c1aePaul Berry{ 508506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t sampler_offset; 509506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 510506d70be21cd3469118de89297cba0c0f709c1aePaul Berry struct brw_sampler_state *sampler = (struct brw_sampler_state *) 511506d70be21cd3469118de89297cba0c0f709c1aePaul Berry brw_state_batch(brw, AUB_TRACE_SAMPLER_STATE, 512506d70be21cd3469118de89297cba0c0f709c1aePaul Berry sizeof(struct brw_sampler_state), 513506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 32, &sampler_offset); 514506d70be21cd3469118de89297cba0c0f709c1aePaul Berry memset(sampler, 0, sizeof(*sampler)); 515506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 516506d70be21cd3469118de89297cba0c0f709c1aePaul Berry sampler->ss0.min_filter = BRW_MAPFILTER_LINEAR; 517506d70be21cd3469118de89297cba0c0f709c1aePaul Berry sampler->ss0.mip_filter = BRW_MIPFILTER_NONE; 518506d70be21cd3469118de89297cba0c0f709c1aePaul Berry sampler->ss0.mag_filter = BRW_MAPFILTER_LINEAR; 519506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 520506d70be21cd3469118de89297cba0c0f709c1aePaul Berry sampler->ss1.r_wrap_mode = BRW_TEXCOORDMODE_CLAMP; 521506d70be21cd3469118de89297cba0c0f709c1aePaul Berry sampler->ss1.s_wrap_mode = BRW_TEXCOORDMODE_CLAMP; 522506d70be21cd3469118de89297cba0c0f709c1aePaul Berry sampler->ss1.t_wrap_mode = BRW_TEXCOORDMODE_CLAMP; 523506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 524506d70be21cd3469118de89297cba0c0f709c1aePaul Berry sampler->ss0.min_mag_neq = 1; 525506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 526506d70be21cd3469118de89297cba0c0f709c1aePaul Berry /* Set LOD bias: 527506d70be21cd3469118de89297cba0c0f709c1aePaul Berry */ 528506d70be21cd3469118de89297cba0c0f709c1aePaul Berry sampler->ss0.lod_bias = 0; 529506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 530506d70be21cd3469118de89297cba0c0f709c1aePaul Berry sampler->ss0.lod_preclamp = 1; /* OpenGL mode */ 531506d70be21cd3469118de89297cba0c0f709c1aePaul Berry sampler->ss0.default_color_mode = 0; /* OpenGL/DX10 mode */ 532506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 533506d70be21cd3469118de89297cba0c0f709c1aePaul Berry /* Set BaseMipLevel, MaxLOD, MinLOD: 534506d70be21cd3469118de89297cba0c0f709c1aePaul Berry * 535506d70be21cd3469118de89297cba0c0f709c1aePaul Berry * XXX: I don't think that using firstLevel, lastLevel works, 536506d70be21cd3469118de89297cba0c0f709c1aePaul Berry * because we always setup the surface state as if firstLevel == 537506d70be21cd3469118de89297cba0c0f709c1aePaul Berry * level zero. Probably have to subtract firstLevel from each of 538506d70be21cd3469118de89297cba0c0f709c1aePaul Berry * these: 539506d70be21cd3469118de89297cba0c0f709c1aePaul Berry */ 540506d70be21cd3469118de89297cba0c0f709c1aePaul Berry sampler->ss0.base_level = U_FIXED(0, 1); 541506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 542506d70be21cd3469118de89297cba0c0f709c1aePaul Berry sampler->ss1.max_lod = U_FIXED(0, 6); 543506d70be21cd3469118de89297cba0c0f709c1aePaul Berry sampler->ss1.min_lod = U_FIXED(0, 6); 544506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 545506d70be21cd3469118de89297cba0c0f709c1aePaul Berry sampler->ss3.non_normalized_coord = 1; 546506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 547506d70be21cd3469118de89297cba0c0f709c1aePaul Berry sampler->ss3.address_round |= BRW_ADDRESS_ROUNDING_ENABLE_U_MIN | 548506d70be21cd3469118de89297cba0c0f709c1aePaul Berry BRW_ADDRESS_ROUNDING_ENABLE_V_MIN | 549506d70be21cd3469118de89297cba0c0f709c1aePaul Berry BRW_ADDRESS_ROUNDING_ENABLE_R_MIN; 550506d70be21cd3469118de89297cba0c0f709c1aePaul Berry sampler->ss3.address_round |= BRW_ADDRESS_ROUNDING_ENABLE_U_MAG | 551506d70be21cd3469118de89297cba0c0f709c1aePaul Berry BRW_ADDRESS_ROUNDING_ENABLE_V_MAG | 552506d70be21cd3469118de89297cba0c0f709c1aePaul Berry BRW_ADDRESS_ROUNDING_ENABLE_R_MAG; 553506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 554506d70be21cd3469118de89297cba0c0f709c1aePaul Berry return sampler_offset; 555506d70be21cd3469118de89297cba0c0f709c1aePaul Berry} 556506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 557506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 558506d70be21cd3469118de89297cba0c0f709c1aePaul Berry/** 559506d70be21cd3469118de89297cba0c0f709c1aePaul Berry * 3DSTATE_SAMPLER_STATE_POINTERS. See upload_sampler_state_pointers(). 560506d70be21cd3469118de89297cba0c0f709c1aePaul Berry */ 561506d70be21cd3469118de89297cba0c0f709c1aePaul Berrystatic void 562506d70be21cd3469118de89297cba0c0f709c1aePaul Berrygen6_blorp_emit_sampler_state_pointers(struct brw_context *brw, 563506d70be21cd3469118de89297cba0c0f709c1aePaul Berry const brw_blorp_params *params, 564506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t sampler_offset) 565506d70be21cd3469118de89297cba0c0f709c1aePaul Berry{ 566506d70be21cd3469118de89297cba0c0f709c1aePaul Berry struct intel_context *intel = &brw->intel; 567506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 568506d70be21cd3469118de89297cba0c0f709c1aePaul Berry BEGIN_BATCH(4); 569506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(_3DSTATE_SAMPLER_STATE_POINTERS << 16 | 570506d70be21cd3469118de89297cba0c0f709c1aePaul Berry VS_SAMPLER_STATE_CHANGE | 571506d70be21cd3469118de89297cba0c0f709c1aePaul Berry GS_SAMPLER_STATE_CHANGE | 572506d70be21cd3469118de89297cba0c0f709c1aePaul Berry PS_SAMPLER_STATE_CHANGE | 573506d70be21cd3469118de89297cba0c0f709c1aePaul Berry (4 - 2)); 574506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(0); /* VS */ 575506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(0); /* GS */ 576506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(sampler_offset); 577586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry ADVANCE_BATCH(); 578586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry} 579586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 580586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 581586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry/* 3DSTATE_VS 582586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * 583586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * Disable vertex shader. 584586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry */ 585586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berryvoid 586586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berrygen6_blorp_emit_vs_disable(struct brw_context *brw, 587586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry const brw_blorp_params *params) 588586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry{ 589586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry struct intel_context *intel = &brw->intel; 590586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 591586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry if (intel->gen == 6) { 5927b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace /* From the BSpec, Volume 2a, Part 3 "Vertex Shader", Section 5937b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * 3DSTATE_VS, Dword 5.0 "VS Function Enable": 594586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * 595586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * [DevSNB] A pipeline flush must be programmed prior to a 596586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * 3DSTATE_VS command that causes the VS Function Enable to 597586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * toggle. Pipeline flush can be executed by sending a PIPE_CONTROL 598586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * command with CS stall bit set and a post sync operation. 5997b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace */ 6007b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace intel_emit_post_sync_nonzero_flush(intel); 6017b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace } 602d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace 603586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry BEGIN_BATCH(6); 604586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(_3DSTATE_VS << 16 | (6 - 2)); 605586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(0); 606586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(0); 607586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(0); 608586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(0); 609586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(0); 610586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry ADVANCE_BATCH(); 611586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry} 6127b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 613586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 614586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry/* 3DSTATE_GS 615586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * 616586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * Disable the geometry shader. 617586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry */ 618586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berryvoid 619586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berrygen6_blorp_emit_gs_disable(struct brw_context *brw, 620586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry const brw_blorp_params *params) 621586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry{ 622586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry struct intel_context *intel = &brw->intel; 623586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 624586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry BEGIN_BATCH(7); 625586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(_3DSTATE_GS << 16 | (7 - 2)); 626586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(0); 627586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(0); 628586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(0); 629586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(0); 630586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(0); 631586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(0); 632586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry ADVANCE_BATCH(); 633586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry} 634586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 635586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 636586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry/* 3DSTATE_CLIP 637586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * 638586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * Disable the clipper. 639586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * 640586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * The BLORP op emits a rectangle primitive, which requires clipping to 641586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * be disabled. From page 10 of the Sandy Bridge PRM Volume 2 Part 1 642586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * Section 1.3 "3D Primitives Overview": 643586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * RECTLIST: 644586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * Either the CLIP unit should be DISABLED, or the CLIP unit's Clip 645586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * Mode should be set to a value other than CLIPMODE_NORMAL. 646586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * 647586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * Also disable perspective divide. This doesn't change the clipper's 648586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * output, but does spare a few electrons. 649586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry */ 650586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berryvoid 651586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berrygen6_blorp_emit_clip_disable(struct brw_context *brw, 652586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry const brw_blorp_params *params) 653586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry{ 654586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry struct intel_context *intel = &brw->intel; 655586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 656586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry BEGIN_BATCH(4); 657586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(_3DSTATE_CLIP << 16 | (4 - 2)); 658586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(0); 659586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(GEN6_CLIP_PERSPECTIVE_DIVIDE_DISABLE); 660586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(0); 661586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry ADVANCE_BATCH(); 662586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry} 663586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 664586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 665586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry/* 3DSTATE_SF 666586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * 667586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * Disable ViewportTransformEnable (dw2.1) 668586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * 669586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * From the SandyBridge PRM, Volume 2, Part 1, Section 1.3, "3D 670586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * Primitives Overview": 671586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * RECTLIST: Viewport Mapping must be DISABLED (as is typical with the 672586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * use of screen- space coordinates). 673586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * 674586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * A solid rectangle must be rendered, so set FrontFaceFillMode (dw2.4:3) 675586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * and BackFaceFillMode (dw2.5:6) to SOLID(0). 676586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * 677586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * From the Sandy Bridge PRM, Volume 2, Part 1, Section 678586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * 6.4.1.1 3DSTATE_SF, Field FrontFaceFillMode: 679586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * SOLID: Any triangle or rectangle object found to be front-facing 680586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * is rendered as a solid object. This setting is required when 681586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * (rendering rectangle (RECTLIST) objects. 682586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry */ 683586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berrystatic void 684586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berrygen6_blorp_emit_sf_config(struct brw_context *brw, 685586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry const brw_blorp_params *params) 686586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry{ 687586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry struct intel_context *intel = &brw->intel; 688586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 689586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry BEGIN_BATCH(20); 690586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(_3DSTATE_SF << 16 | (20 - 2)); 691586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH((1 - 1) << GEN6_SF_NUM_OUTPUTS_SHIFT | /* only position */ 692586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 1 << GEN6_SF_URB_ENTRY_READ_LENGTH_SHIFT | 693586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 0 << GEN6_SF_URB_ENTRY_READ_OFFSET_SHIFT); 69419e9b24626c2b9d7abef054d57bb2a52106c545bPaul Berry OUT_BATCH(0); /* dw2 */ 69597fc89c6cbaa3b5ef7f678d2dc2c7d5bbba05315Paul Berry OUT_BATCH(params->num_samples > 1 ? GEN6_SF_MSRAST_ON_PATTERN : 0); 69619e9b24626c2b9d7abef054d57bb2a52106c545bPaul Berry for (int i = 0; i < 16; ++i) 6977b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace OUT_BATCH(0); 698586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry ADVANCE_BATCH(); 699586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry} 7007b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 7017b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 702586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry/** 703506d70be21cd3469118de89297cba0c0f709c1aePaul Berry * Enable or disable thread dispatch and set the HiZ op appropriately. 704586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry */ 705586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berrystatic void 706586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berrygen6_blorp_emit_wm_config(struct brw_context *brw, 707506d70be21cd3469118de89297cba0c0f709c1aePaul Berry const brw_blorp_params *params, 708506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t prog_offset, 709506d70be21cd3469118de89297cba0c0f709c1aePaul Berry brw_blorp_prog_data *prog_data) 710586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry{ 711586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry struct intel_context *intel = &brw->intel; 712506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t dw2, dw4, dw5, dw6; 713586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 714506d70be21cd3469118de89297cba0c0f709c1aePaul Berry /* Even when thread dispatch is disabled, max threads (dw5.25:31) must be 7157b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * nonzero to prevent the GPU from hanging. See the valid ranges in the 7167b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * BSpec, Volume 2a.11 Windower, Section 3DSTATE_WM, Dword 5.25:31 7177b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace * "Maximum Number Of Threads". 718506d70be21cd3469118de89297cba0c0f709c1aePaul Berry * 719506d70be21cd3469118de89297cba0c0f709c1aePaul Berry * To be safe (and to minimize extraneous code) we go ahead and fully 720506d70be21cd3469118de89297cba0c0f709c1aePaul Berry * configure the WM state whether or not there is a WM program. 7217b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace */ 722586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 723506d70be21cd3469118de89297cba0c0f709c1aePaul Berry dw2 = dw4 = dw5 = dw6 = 0; 724586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry switch (params->hiz_op) { 725586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry case GEN6_HIZ_OP_DEPTH_CLEAR: 726586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry dw4 |= GEN6_WM_DEPTH_CLEAR; 727586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry break; 728586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry case GEN6_HIZ_OP_DEPTH_RESOLVE: 729586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry dw4 |= GEN6_WM_DEPTH_RESOLVE; 730586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry break; 731586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry case GEN6_HIZ_OP_HIZ_RESOLVE: 732586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry dw4 |= GEN6_WM_HIERARCHICAL_DEPTH_RESOLVE; 733586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry break; 734506d70be21cd3469118de89297cba0c0f709c1aePaul Berry case GEN6_HIZ_OP_NONE: 735506d70be21cd3469118de89297cba0c0f709c1aePaul Berry break; 736586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry default: 737586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry assert(0); 738586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry break; 7397b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace } 740506d70be21cd3469118de89297cba0c0f709c1aePaul Berry dw4 |= GEN6_WM_STATISTICS_ENABLE; 741506d70be21cd3469118de89297cba0c0f709c1aePaul Berry dw5 |= GEN6_WM_LINE_AA_WIDTH_1_0; 742506d70be21cd3469118de89297cba0c0f709c1aePaul Berry dw5 |= GEN6_WM_LINE_END_CAP_AA_WIDTH_0_5; 743506d70be21cd3469118de89297cba0c0f709c1aePaul Berry dw5 |= (brw->max_wm_threads - 1) << GEN6_WM_MAX_THREADS_SHIFT; 744506d70be21cd3469118de89297cba0c0f709c1aePaul Berry dw6 |= 0 << GEN6_WM_BARYCENTRIC_INTERPOLATION_MODE_SHIFT; /* No interp */ 745506d70be21cd3469118de89297cba0c0f709c1aePaul Berry dw6 |= 0 << GEN6_WM_NUM_SF_OUTPUTS_SHIFT; /* No inputs from SF */ 746506d70be21cd3469118de89297cba0c0f709c1aePaul Berry if (params->use_wm_prog) { 747506d70be21cd3469118de89297cba0c0f709c1aePaul Berry dw2 |= 1 << GEN6_WM_SAMPLER_COUNT_SHIFT; /* Up to 4 samplers */ 748506d70be21cd3469118de89297cba0c0f709c1aePaul Berry dw4 |= prog_data->first_curbe_grf << GEN6_WM_DISPATCH_START_GRF_SHIFT_0; 749506d70be21cd3469118de89297cba0c0f709c1aePaul Berry dw5 |= GEN6_WM_16_DISPATCH_ENABLE; 750506d70be21cd3469118de89297cba0c0f709c1aePaul Berry dw5 |= GEN6_WM_KILL_ENABLE; /* TODO: temporarily smash on */ 751506d70be21cd3469118de89297cba0c0f709c1aePaul Berry dw5 |= GEN6_WM_DISPATCH_ENABLE; /* We are rendering */ 752506d70be21cd3469118de89297cba0c0f709c1aePaul Berry } 7537b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 75497fc89c6cbaa3b5ef7f678d2dc2c7d5bbba05315Paul Berry if (params->num_samples > 1) { 75519e9b24626c2b9d7abef054d57bb2a52106c545bPaul Berry dw6 |= GEN6_WM_MSRAST_ON_PATTERN; 75634a5f12e35dd4a5aff6683a8286d4582ba17df14Paul Berry if (prog_data && prog_data->persample_msaa_dispatch) 75734a5f12e35dd4a5aff6683a8286d4582ba17df14Paul Berry dw6 |= GEN6_WM_MSDISPMODE_PERSAMPLE; 75834a5f12e35dd4a5aff6683a8286d4582ba17df14Paul Berry else 75934a5f12e35dd4a5aff6683a8286d4582ba17df14Paul Berry dw6 |= GEN6_WM_MSDISPMODE_PERPIXEL; 76019e9b24626c2b9d7abef054d57bb2a52106c545bPaul Berry } else { 76119e9b24626c2b9d7abef054d57bb2a52106c545bPaul Berry dw6 |= GEN6_WM_MSRAST_OFF_PIXEL; 76219e9b24626c2b9d7abef054d57bb2a52106c545bPaul Berry dw6 |= GEN6_WM_MSDISPMODE_PERSAMPLE; 76319e9b24626c2b9d7abef054d57bb2a52106c545bPaul Berry } 76419e9b24626c2b9d7abef054d57bb2a52106c545bPaul Berry 765586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry BEGIN_BATCH(9); 766586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(_3DSTATE_WM << 16 | (9 - 2)); 767506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(params->use_wm_prog ? prog_offset : 0); 768506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(dw2); 769506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(0); /* No scratch needed */ 770586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(dw4); 771506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(dw5); 77219e9b24626c2b9d7abef054d57bb2a52106c545bPaul Berry OUT_BATCH(dw6); 773506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(0); /* No other programs */ 774506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(0); /* No other programs */ 775506d70be21cd3469118de89297cba0c0f709c1aePaul Berry ADVANCE_BATCH(); 776506d70be21cd3469118de89297cba0c0f709c1aePaul Berry} 777506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 778506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 779506d70be21cd3469118de89297cba0c0f709c1aePaul Berrystatic void 780506d70be21cd3469118de89297cba0c0f709c1aePaul Berrygen6_blorp_emit_constant_ps(struct brw_context *brw, 781506d70be21cd3469118de89297cba0c0f709c1aePaul Berry const brw_blorp_params *params, 782506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t wm_push_const_offset) 783506d70be21cd3469118de89297cba0c0f709c1aePaul Berry{ 784506d70be21cd3469118de89297cba0c0f709c1aePaul Berry struct intel_context *intel = &brw->intel; 785506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 786506d70be21cd3469118de89297cba0c0f709c1aePaul Berry /* Make sure the push constants fill an exact integer number of 787506d70be21cd3469118de89297cba0c0f709c1aePaul Berry * registers. 788506d70be21cd3469118de89297cba0c0f709c1aePaul Berry */ 789506d70be21cd3469118de89297cba0c0f709c1aePaul Berry assert(sizeof(brw_blorp_wm_push_constants) % 32 == 0); 790506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 791506d70be21cd3469118de89297cba0c0f709c1aePaul Berry /* There must be at least one register worth of push constant data. */ 792506d70be21cd3469118de89297cba0c0f709c1aePaul Berry assert(BRW_BLORP_NUM_PUSH_CONST_REGS > 0); 793506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 794506d70be21cd3469118de89297cba0c0f709c1aePaul Berry /* Enable push constant buffer 0. */ 795506d70be21cd3469118de89297cba0c0f709c1aePaul Berry BEGIN_BATCH(5); 796506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(_3DSTATE_CONSTANT_PS << 16 | 797506d70be21cd3469118de89297cba0c0f709c1aePaul Berry GEN6_CONSTANT_BUFFER_0_ENABLE | 798506d70be21cd3469118de89297cba0c0f709c1aePaul Berry (5 - 2)); 799506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(wm_push_const_offset + (BRW_BLORP_NUM_PUSH_CONST_REGS - 1)); 800506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(0); 801586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(0); 802586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(0); 803586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry ADVANCE_BATCH(); 804586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry} 805586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 806586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 807506d70be21cd3469118de89297cba0c0f709c1aePaul Berry/** 808506d70be21cd3469118de89297cba0c0f709c1aePaul Berry * 3DSTATE_BINDING_TABLE_POINTERS 809506d70be21cd3469118de89297cba0c0f709c1aePaul Berry */ 810506d70be21cd3469118de89297cba0c0f709c1aePaul Berrystatic void 811506d70be21cd3469118de89297cba0c0f709c1aePaul Berrygen6_blorp_emit_binding_table_pointers(struct brw_context *brw, 812506d70be21cd3469118de89297cba0c0f709c1aePaul Berry const brw_blorp_params *params, 813506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t wm_bind_bo_offset) 814506d70be21cd3469118de89297cba0c0f709c1aePaul Berry{ 815506d70be21cd3469118de89297cba0c0f709c1aePaul Berry struct intel_context *intel = &brw->intel; 816506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 817506d70be21cd3469118de89297cba0c0f709c1aePaul Berry BEGIN_BATCH(4); 818506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(_3DSTATE_BINDING_TABLE_POINTERS << 16 | 819506d70be21cd3469118de89297cba0c0f709c1aePaul Berry GEN6_BINDING_TABLE_MODIFY_PS | 820506d70be21cd3469118de89297cba0c0f709c1aePaul Berry (4 - 2)); 821506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(0); /* vs -- ignored */ 822506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(0); /* gs -- ignored */ 823506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(wm_bind_bo_offset); /* wm/ps */ 824506d70be21cd3469118de89297cba0c0f709c1aePaul Berry ADVANCE_BATCH(); 825506d70be21cd3469118de89297cba0c0f709c1aePaul Berry} 826506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 827506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 828586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berrystatic void 829586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berrygen6_blorp_emit_depth_stencil_config(struct brw_context *brw, 830586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry const brw_blorp_params *params) 831586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry{ 832586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry struct intel_context *intel = &brw->intel; 833127dc6d136db64fcf9448d66cb4c86db3bb11226Paul Berry uint32_t draw_x = params->depth.x_offset; 834127dc6d136db64fcf9448d66cb4c86db3bb11226Paul Berry uint32_t draw_y = params->depth.y_offset; 835586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry uint32_t tile_mask_x, tile_mask_y; 836586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 837586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry gen6_blorp_compute_tile_masks(params, &tile_mask_x, &tile_mask_y); 838586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 8397b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace /* 3DSTATE_DEPTH_BUFFER */ 8407b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace { 8413ec0e55b63db3c1067f3bbf4563beb3b98a19288Paul Berry uint32_t tile_x = draw_x & tile_mask_x; 8423ec0e55b63db3c1067f3bbf4563beb3b98a19288Paul Berry uint32_t tile_y = draw_y & tile_mask_y; 8432c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry uint32_t offset = 8442c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry intel_region_get_aligned_offset(params->depth.mt->region, 8452c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry draw_x & ~tile_mask_x, 84668da5dfc2c2e9c0aca47431076be0cd43406d4aaPaul Berry draw_y & ~tile_mask_y, false); 8477b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 848a683012a80a3408b3b71f22b2a97d9eaaac11a46Paul Berry /* According to the Sandy Bridge PRM, volume 2 part 1, pp326-327 849a683012a80a3408b3b71f22b2a97d9eaaac11a46Paul Berry * (3DSTATE_DEPTH_BUFFER dw5), in the documentation for "Depth 850a683012a80a3408b3b71f22b2a97d9eaaac11a46Paul Berry * Coordinate Offset X/Y": 851a683012a80a3408b3b71f22b2a97d9eaaac11a46Paul Berry * 852a683012a80a3408b3b71f22b2a97d9eaaac11a46Paul Berry * "The 3 LSBs of both offsets must be zero to ensure correct 853a683012a80a3408b3b71f22b2a97d9eaaac11a46Paul Berry * alignment" 854a683012a80a3408b3b71f22b2a97d9eaaac11a46Paul Berry * 855a683012a80a3408b3b71f22b2a97d9eaaac11a46Paul Berry * We have no guarantee that tile_x and tile_y are correctly aligned, 856a683012a80a3408b3b71f22b2a97d9eaaac11a46Paul Berry * since they are determined by the mipmap layout, which is only aligned 857a683012a80a3408b3b71f22b2a97d9eaaac11a46Paul Berry * to multiples of 4. 858a683012a80a3408b3b71f22b2a97d9eaaac11a46Paul Berry * 859a683012a80a3408b3b71f22b2a97d9eaaac11a46Paul Berry * So, to avoid hanging the GPU, just smash the low order 3 bits of 860a683012a80a3408b3b71f22b2a97d9eaaac11a46Paul Berry * tile_x and tile_y to 0. This is a temporary workaround until we come 861a683012a80a3408b3b71f22b2a97d9eaaac11a46Paul Berry * up with a better solution. 862a683012a80a3408b3b71f22b2a97d9eaaac11a46Paul Berry */ 863a683012a80a3408b3b71f22b2a97d9eaaac11a46Paul Berry tile_x &= ~7; 864a683012a80a3408b3b71f22b2a97d9eaaac11a46Paul Berry tile_y &= ~7; 865a683012a80a3408b3b71f22b2a97d9eaaac11a46Paul Berry 8667b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace intel_emit_post_sync_nonzero_flush(intel); 8677b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace intel_emit_depth_stall_flushes(intel); 8687b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 8697b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace BEGIN_BATCH(7); 8707b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace OUT_BATCH(_3DSTATE_DEPTH_BUFFER << 16 | (7 - 2)); 8712c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry uint32_t pitch_bytes = 8722c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry params->depth.mt->region->pitch * params->depth.mt->region->cpp; 8732c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry OUT_BATCH((pitch_bytes - 1) | 8742c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry params->depth_format << 18 | 8757b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 1 << 21 | /* separate stencil enable */ 8767b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 1 << 22 | /* hiz enable */ 8777b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace BRW_TILEWALK_YMAJOR << 26 | 8787b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 1 << 27 | /* y-tiled */ 8797b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace BRW_SURFACE_2D << 29); 8802c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry OUT_RELOC(params->depth.mt->region->bo, 8817b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 8827b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace offset); 8837b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace OUT_BATCH(BRW_SURFACE_MIPMAPLAYOUT_BELOW << 1 | 884602e9a0f3727b036caf3a7b228fe90d36d832ea7Paul Berry (params->depth.width + tile_x - 1) << 6 | 885602e9a0f3727b036caf3a7b228fe90d36d832ea7Paul Berry (params->depth.height + tile_y - 1) << 19); 8867b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace OUT_BATCH(0); 8877b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace OUT_BATCH(tile_x | 8887b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace tile_y << 16); 8897b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace OUT_BATCH(0); 8907b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace ADVANCE_BATCH(); 8917b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace } 8927b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 8937b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace /* 3DSTATE_HIER_DEPTH_BUFFER */ 8947b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace { 8952c5510b71b6348b686e76ecc2c34195080d566f4Paul Berry struct intel_region *hiz_region = params->depth.mt->hiz_mt->region; 8963ec0e55b63db3c1067f3bbf4563beb3b98a19288Paul Berry uint32_t hiz_offset = 8973ec0e55b63db3c1067f3bbf4563beb3b98a19288Paul Berry intel_region_get_aligned_offset(hiz_region, 8983ec0e55b63db3c1067f3bbf4563beb3b98a19288Paul Berry draw_x & ~tile_mask_x, 89968da5dfc2c2e9c0aca47431076be0cd43406d4aaPaul Berry (draw_y & ~tile_mask_y) / 2, false); 9007b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 9017b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace BEGIN_BATCH(3); 9027b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace OUT_BATCH((_3DSTATE_HIER_DEPTH_BUFFER << 16) | (3 - 2)); 9037b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace OUT_BATCH(hiz_region->pitch * hiz_region->cpp - 1); 9047b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace OUT_RELOC(hiz_region->bo, 9057b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 9063ec0e55b63db3c1067f3bbf4563beb3b98a19288Paul Berry hiz_offset); 9077b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace ADVANCE_BATCH(); 9087b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace } 9097b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 9107b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace /* 3DSTATE_STENCIL_BUFFER */ 9117b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace { 9127b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace BEGIN_BATCH(3); 9137b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace OUT_BATCH((_3DSTATE_STENCIL_BUFFER << 16) | (3 - 2)); 9147b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace OUT_BATCH(0); 9157b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace OUT_BATCH(0); 9167b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace ADVANCE_BATCH(); 9177b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace } 918586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry} 9197b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 9207b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 921506d70be21cd3469118de89297cba0c0f709c1aePaul Berrystatic void 922506d70be21cd3469118de89297cba0c0f709c1aePaul Berrygen6_blorp_emit_depth_disable(struct brw_context *brw, 923506d70be21cd3469118de89297cba0c0f709c1aePaul Berry const brw_blorp_params *params) 924506d70be21cd3469118de89297cba0c0f709c1aePaul Berry{ 925506d70be21cd3469118de89297cba0c0f709c1aePaul Berry struct intel_context *intel = &brw->intel; 926506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 927506d70be21cd3469118de89297cba0c0f709c1aePaul Berry BEGIN_BATCH(7); 928506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(_3DSTATE_DEPTH_BUFFER << 16 | (7 - 2)); 929506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH((BRW_DEPTHFORMAT_D32_FLOAT << 18) | 930506d70be21cd3469118de89297cba0c0f709c1aePaul Berry (BRW_SURFACE_NULL << 29)); 931506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(0); 932506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(0); 933506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(0); 934506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(0); 935506d70be21cd3469118de89297cba0c0f709c1aePaul Berry OUT_BATCH(0); 936506d70be21cd3469118de89297cba0c0f709c1aePaul Berry ADVANCE_BATCH(); 937506d70be21cd3469118de89297cba0c0f709c1aePaul Berry} 938506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 939506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 940586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry/* 3DSTATE_CLEAR_PARAMS 941586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * 942586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * From the Sandybridge PRM, Volume 2, Part 1, Section 3DSTATE_CLEAR_PARAMS: 943586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * [DevSNB] 3DSTATE_CLEAR_PARAMS packet must follow the DEPTH_BUFFER_STATE 944586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * packet when HiZ is enabled and the DEPTH_BUFFER_STATE changes. 945586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry */ 946586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berrystatic void 947586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berrygen6_blorp_emit_clear_params(struct brw_context *brw, 948586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry const brw_blorp_params *params) 949586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry{ 950586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry struct intel_context *intel = &brw->intel; 9517b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 952586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry BEGIN_BATCH(2); 95368216f35814ab8d292f37b8c0fa0a5f181b7f20dEric Anholt OUT_BATCH(_3DSTATE_CLEAR_PARAMS << 16 | 95468216f35814ab8d292f37b8c0fa0a5f181b7f20dEric Anholt GEN5_DEPTH_CLEAR_VALID | 95568216f35814ab8d292f37b8c0fa0a5f181b7f20dEric Anholt (2 - 2)); 95668216f35814ab8d292f37b8c0fa0a5f181b7f20dEric Anholt OUT_BATCH(params->depth.mt ? params->depth.mt->depth_clear_value : 0); 957586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry ADVANCE_BATCH(); 958586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry} 9597b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 9607b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 961586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry/* 3DSTATE_DRAWING_RECTANGLE */ 962586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berryvoid 963586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berrygen6_blorp_emit_drawing_rectangle(struct brw_context *brw, 964586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry const brw_blorp_params *params) 965586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry{ 966586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry struct intel_context *intel = &brw->intel; 967586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 968586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry BEGIN_BATCH(4); 969586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(_3DSTATE_DRAWING_RECTANGLE << 16 | (4 - 2)); 970586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(0); 971586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(((params->x1 - 1) & 0xffff) | 972586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry ((params->y1 - 1) << 16)); 973586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(0); 974586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry ADVANCE_BATCH(); 975586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry} 976586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 9775b248e598293e7c21257d35904294da4c8f2da58Eric Anholt/* 3DSTATE_VIEWPORT_STATE_POINTERS */ 9785b248e598293e7c21257d35904294da4c8f2da58Eric Anholtvoid 9795b248e598293e7c21257d35904294da4c8f2da58Eric Anholtgen6_blorp_emit_viewport_state(struct brw_context *brw, 9805b248e598293e7c21257d35904294da4c8f2da58Eric Anholt const brw_blorp_params *params) 9815b248e598293e7c21257d35904294da4c8f2da58Eric Anholt{ 9825b248e598293e7c21257d35904294da4c8f2da58Eric Anholt struct intel_context *intel = &brw->intel; 9835b248e598293e7c21257d35904294da4c8f2da58Eric Anholt struct brw_cc_viewport *ccv; 9845b248e598293e7c21257d35904294da4c8f2da58Eric Anholt uint32_t cc_vp_offset; 9855b248e598293e7c21257d35904294da4c8f2da58Eric Anholt 9865b248e598293e7c21257d35904294da4c8f2da58Eric Anholt ccv = (struct brw_cc_viewport *)brw_state_batch(brw, AUB_TRACE_CC_VP_STATE, 9875b248e598293e7c21257d35904294da4c8f2da58Eric Anholt sizeof(*ccv), 32, 9885b248e598293e7c21257d35904294da4c8f2da58Eric Anholt &cc_vp_offset); 9895b248e598293e7c21257d35904294da4c8f2da58Eric Anholt 9905b248e598293e7c21257d35904294da4c8f2da58Eric Anholt ccv->min_depth = 0.0; 9915b248e598293e7c21257d35904294da4c8f2da58Eric Anholt ccv->max_depth = 1.0; 9925b248e598293e7c21257d35904294da4c8f2da58Eric Anholt 9935b248e598293e7c21257d35904294da4c8f2da58Eric Anholt BEGIN_BATCH(4); 9945b248e598293e7c21257d35904294da4c8f2da58Eric Anholt OUT_BATCH(_3DSTATE_VIEWPORT_STATE_POINTERS << 16 | (4 - 2) | 9955b248e598293e7c21257d35904294da4c8f2da58Eric Anholt GEN6_CC_VIEWPORT_MODIFY); 9965b248e598293e7c21257d35904294da4c8f2da58Eric Anholt OUT_BATCH(0); /* clip VP */ 9975b248e598293e7c21257d35904294da4c8f2da58Eric Anholt OUT_BATCH(0); /* SF VP */ 9985b248e598293e7c21257d35904294da4c8f2da58Eric Anholt OUT_BATCH(cc_vp_offset); 9995b248e598293e7c21257d35904294da4c8f2da58Eric Anholt ADVANCE_BATCH(); 10005b248e598293e7c21257d35904294da4c8f2da58Eric Anholt} 10015b248e598293e7c21257d35904294da4c8f2da58Eric Anholt 1002586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 1003586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry/* 3DPRIMITIVE */ 1004586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berrystatic void 1005586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berrygen6_blorp_emit_primitive(struct brw_context *brw, 1006586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry const brw_blorp_params *params) 1007586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry{ 1008586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry struct intel_context *intel = &brw->intel; 1009586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 1010586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry BEGIN_BATCH(6); 1011586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(CMD_3D_PRIM << 16 | (6 - 2) | 1012586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry _3DPRIM_RECTLIST << GEN4_3DPRIM_TOPOLOGY_TYPE_SHIFT | 1013586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry GEN4_3DPRIM_VERTEXBUFFER_ACCESS_SEQUENTIAL); 1014586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(3); /* vertex count per instance */ 1015586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(0); 1016586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(1); /* instance count */ 1017586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(0); 1018586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry OUT_BATCH(0); 1019586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry ADVANCE_BATCH(); 1020d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace} 1021d1f1d348d8ff6ce9249cd9971e79e5bce0e60756Chad Versace 1022586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 10237b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace/** 1024586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * \brief Execute a blit or render pass operation. 1025586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * 1026586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * To execute the operation, this function manually constructs and emits a 1027586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * batch to draw a rectangle primitive. The batchbuffer is flushed before 1028586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * constructing and after emitting the batch. 1029586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * 1030586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * This function alters no GL state. 10317b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace */ 10327b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versacevoid 1033586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berrygen6_blorp_exec(struct intel_context *intel, 1034586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry const brw_blorp_params *params) 10357b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace{ 1036586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry struct gl_context *ctx = &intel->ctx; 1037586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry struct brw_context *brw = brw_context(ctx); 1038506d70be21cd3469118de89297cba0c0f709c1aePaul Berry brw_blorp_prog_data *prog_data = NULL; 1039506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t cc_blend_state_offset = 0; 1040506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t cc_state_offset = 0; 1041586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry uint32_t depthstencil_offset; 1042506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t wm_push_const_offset = 0; 1043506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t wm_bind_bo_offset = 0; 10447b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 1045506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t prog_offset = params->get_wm_prog(brw, &prog_data); 1046586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry gen6_blorp_emit_batch_head(brw, params); 1047f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry gen6_emit_3dstate_multisample(brw, params->num_samples); 10489ea60ce58f8494e0b79771f93227f4b8181731dePaul Berry gen6_emit_3dstate_sample_mask(brw, params->num_samples, 1.0, false); 1049f77959b2c9053b1673418edfe5d74c9b139b2555Paul Berry gen6_blorp_emit_state_base_address(brw, params); 1050586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry gen6_blorp_emit_vertices(brw, params); 1051586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry gen6_blorp_emit_urb_config(brw, params); 1052506d70be21cd3469118de89297cba0c0f709c1aePaul Berry if (params->use_wm_prog) { 1053506d70be21cd3469118de89297cba0c0f709c1aePaul Berry cc_blend_state_offset = gen6_blorp_emit_blend_state(brw, params); 1054506d70be21cd3469118de89297cba0c0f709c1aePaul Berry cc_state_offset = gen6_blorp_emit_cc_state(brw, params); 1055506d70be21cd3469118de89297cba0c0f709c1aePaul Berry } 1056586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry depthstencil_offset = gen6_blorp_emit_depth_stencil_state(brw, params); 1057506d70be21cd3469118de89297cba0c0f709c1aePaul Berry gen6_blorp_emit_cc_state_pointers(brw, params, cc_blend_state_offset, 1058506d70be21cd3469118de89297cba0c0f709c1aePaul Berry depthstencil_offset, cc_state_offset); 1059506d70be21cd3469118de89297cba0c0f709c1aePaul Berry if (params->use_wm_prog) { 1060506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t wm_surf_offset_renderbuffer; 1061506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t wm_surf_offset_texture; 1062506d70be21cd3469118de89297cba0c0f709c1aePaul Berry uint32_t sampler_offset; 1063506d70be21cd3469118de89297cba0c0f709c1aePaul Berry wm_push_const_offset = gen6_blorp_emit_wm_constants(brw, params); 1064506d70be21cd3469118de89297cba0c0f709c1aePaul Berry wm_surf_offset_renderbuffer = 1065506d70be21cd3469118de89297cba0c0f709c1aePaul Berry gen6_blorp_emit_surface_state(brw, params, ¶ms->dst, 1066506d70be21cd3469118de89297cba0c0f709c1aePaul Berry I915_GEM_DOMAIN_RENDER, 1067506d70be21cd3469118de89297cba0c0f709c1aePaul Berry I915_GEM_DOMAIN_RENDER); 1068506d70be21cd3469118de89297cba0c0f709c1aePaul Berry wm_surf_offset_texture = 1069506d70be21cd3469118de89297cba0c0f709c1aePaul Berry gen6_blorp_emit_surface_state(brw, params, ¶ms->src, 1070506d70be21cd3469118de89297cba0c0f709c1aePaul Berry I915_GEM_DOMAIN_SAMPLER, 0); 1071506d70be21cd3469118de89297cba0c0f709c1aePaul Berry wm_bind_bo_offset = 1072506d70be21cd3469118de89297cba0c0f709c1aePaul Berry gen6_blorp_emit_binding_table(brw, params, 1073506d70be21cd3469118de89297cba0c0f709c1aePaul Berry wm_surf_offset_renderbuffer, 1074506d70be21cd3469118de89297cba0c0f709c1aePaul Berry wm_surf_offset_texture); 1075506d70be21cd3469118de89297cba0c0f709c1aePaul Berry sampler_offset = gen6_blorp_emit_sampler_state(brw, params); 1076506d70be21cd3469118de89297cba0c0f709c1aePaul Berry gen6_blorp_emit_sampler_state_pointers(brw, params, sampler_offset); 1077506d70be21cd3469118de89297cba0c0f709c1aePaul Berry } 1078586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry gen6_blorp_emit_vs_disable(brw, params); 1079586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry gen6_blorp_emit_gs_disable(brw, params); 1080586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry gen6_blorp_emit_clip_disable(brw, params); 1081586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry gen6_blorp_emit_sf_config(brw, params); 1082506d70be21cd3469118de89297cba0c0f709c1aePaul Berry if (params->use_wm_prog) 1083506d70be21cd3469118de89297cba0c0f709c1aePaul Berry gen6_blorp_emit_constant_ps(brw, params, wm_push_const_offset); 1084506d70be21cd3469118de89297cba0c0f709c1aePaul Berry gen6_blorp_emit_wm_config(brw, params, prog_offset, prog_data); 1085506d70be21cd3469118de89297cba0c0f709c1aePaul Berry if (params->use_wm_prog) 1086506d70be21cd3469118de89297cba0c0f709c1aePaul Berry gen6_blorp_emit_binding_table_pointers(brw, params, wm_bind_bo_offset); 10875b248e598293e7c21257d35904294da4c8f2da58Eric Anholt gen6_blorp_emit_viewport_state(brw, params); 1088506d70be21cd3469118de89297cba0c0f709c1aePaul Berry 1089506d70be21cd3469118de89297cba0c0f709c1aePaul Berry if (params->depth.mt) 1090506d70be21cd3469118de89297cba0c0f709c1aePaul Berry gen6_blorp_emit_depth_stencil_config(brw, params); 1091506d70be21cd3469118de89297cba0c0f709c1aePaul Berry else 1092506d70be21cd3469118de89297cba0c0f709c1aePaul Berry gen6_blorp_emit_depth_disable(brw, params); 1093586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry gen6_blorp_emit_clear_params(brw, params); 1094586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry gen6_blorp_emit_drawing_rectangle(brw, params); 1095586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry gen6_blorp_emit_primitive(brw, params); 1096586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 1097586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry /* See comments above at first invocation of intel_flush() in 1098586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry * gen6_blorp_emit_batch_head(). 10997b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace */ 1100586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry intel_flush(ctx); 1101586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry 1102586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry /* Be safe. */ 1103586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry brw->state.dirty.brw = ~0; 1104586b3894744819071bb1ad56383e3c0d9e5b7e1fPaul Berry brw->state.dirty.cache = ~0; 11057b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace} 11067b36c68ba6899c7f30fd56b7ef07a78b027771acChad Versace 1107