103b705cfSriastradh/* 203b705cfSriastradh * Copyright © 2006,2008 Intel Corporation 303b705cfSriastradh * Copyright © 2007 Red Hat, Inc. 403b705cfSriastradh * 503b705cfSriastradh * Permission is hereby granted, free of charge, to any person obtaining a 603b705cfSriastradh * copy of this software and associated documentation files (the "Software"), 703b705cfSriastradh * to deal in the Software without restriction, including without limitation 803b705cfSriastradh * the rights to use, copy, modify, merge, publish, distribute, sublicense, 903b705cfSriastradh * and/or sell copies of the Software, and to permit persons to whom the 1003b705cfSriastradh * Software is furnished to do so, subject to the following conditions: 1103b705cfSriastradh * 1203b705cfSriastradh * The above copyright notice and this permission notice (including the next 1303b705cfSriastradh * paragraph) shall be included in all copies or substantial portions of the 1403b705cfSriastradh * Software. 1503b705cfSriastradh * 1603b705cfSriastradh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1703b705cfSriastradh * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1803b705cfSriastradh * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1903b705cfSriastradh * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 2003b705cfSriastradh * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 2103b705cfSriastradh * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 2203b705cfSriastradh * SOFTWARE. 2303b705cfSriastradh * 2403b705cfSriastradh * Authors: 2503b705cfSriastradh * Wang Zhenyu <zhenyu.z.wang@intel.com> 2603b705cfSriastradh * Eric Anholt <eric@anholt.net> 2703b705cfSriastradh * Carl Worth <cworth@redhat.com> 2803b705cfSriastradh * Keith Packard <keithp@keithp.com> 2903b705cfSriastradh * 3003b705cfSriastradh */ 3103b705cfSriastradh 3203b705cfSriastradh#ifdef HAVE_CONFIG_H 3303b705cfSriastradh#include "config.h" 3403b705cfSriastradh#endif 3503b705cfSriastradh 3603b705cfSriastradh#include <assert.h> 3742542f5fSchristos#include "xorg-server.h" 3803b705cfSriastradh#include "xf86.h" 3903b705cfSriastradh#include "intel.h" 4013496ba1Ssnj#include "intel_uxa.h" 4103b705cfSriastradh#include "i830_reg.h" 4203b705cfSriastradh#include "i965_reg.h" 4303b705cfSriastradh 4403b705cfSriastradh/* bring in brw structs */ 4503b705cfSriastradh#include "brw_defines.h" 4603b705cfSriastradh#include "brw_structs.h" 4703b705cfSriastradh 4803b705cfSriastradh// refer vol2, 3d rasterization 3.8.1 4903b705cfSriastradh 5003b705cfSriastradh/* defined in brw_defines.h */ 5103b705cfSriastradhstatic const struct blendinfo { 5203b705cfSriastradh Bool dst_alpha; 5303b705cfSriastradh Bool src_alpha; 5403b705cfSriastradh uint32_t src_blend; 5503b705cfSriastradh uint32_t dst_blend; 5603b705cfSriastradh} i965_blend_op[] = { 5703b705cfSriastradh /* Clear */ 5803b705cfSriastradh {0, 0, BRW_BLENDFACTOR_ZERO, BRW_BLENDFACTOR_ZERO}, 5903b705cfSriastradh /* Src */ 6003b705cfSriastradh {0, 0, BRW_BLENDFACTOR_ONE, BRW_BLENDFACTOR_ZERO}, 6103b705cfSriastradh /* Dst */ 6203b705cfSriastradh {0, 0, BRW_BLENDFACTOR_ZERO, BRW_BLENDFACTOR_ONE}, 6303b705cfSriastradh /* Over */ 6403b705cfSriastradh {0, 1, BRW_BLENDFACTOR_ONE, BRW_BLENDFACTOR_INV_SRC_ALPHA}, 6503b705cfSriastradh /* OverReverse */ 6603b705cfSriastradh {1, 0, BRW_BLENDFACTOR_INV_DST_ALPHA, BRW_BLENDFACTOR_ONE}, 6703b705cfSriastradh /* In */ 6803b705cfSriastradh {1, 0, BRW_BLENDFACTOR_DST_ALPHA, BRW_BLENDFACTOR_ZERO}, 6903b705cfSriastradh /* InReverse */ 7003b705cfSriastradh {0, 1, BRW_BLENDFACTOR_ZERO, BRW_BLENDFACTOR_SRC_ALPHA}, 7103b705cfSriastradh /* Out */ 7203b705cfSriastradh {1, 0, BRW_BLENDFACTOR_INV_DST_ALPHA, BRW_BLENDFACTOR_ZERO}, 7303b705cfSriastradh /* OutReverse */ 7403b705cfSriastradh {0, 1, BRW_BLENDFACTOR_ZERO, BRW_BLENDFACTOR_INV_SRC_ALPHA}, 7503b705cfSriastradh /* Atop */ 7603b705cfSriastradh {1, 1, BRW_BLENDFACTOR_DST_ALPHA, BRW_BLENDFACTOR_INV_SRC_ALPHA}, 7703b705cfSriastradh /* AtopReverse */ 7803b705cfSriastradh {1, 1, BRW_BLENDFACTOR_INV_DST_ALPHA, BRW_BLENDFACTOR_SRC_ALPHA}, 7903b705cfSriastradh /* Xor */ 8003b705cfSriastradh {1, 1, BRW_BLENDFACTOR_INV_DST_ALPHA, BRW_BLENDFACTOR_INV_SRC_ALPHA}, 8103b705cfSriastradh /* Add */ 8203b705cfSriastradh {0, 0, BRW_BLENDFACTOR_ONE, BRW_BLENDFACTOR_ONE}, 8303b705cfSriastradh}; 8403b705cfSriastradh 8503b705cfSriastradh/** 8603b705cfSriastradh * Highest-valued BLENDFACTOR used in i965_blend_op. 8703b705cfSriastradh * 8803b705cfSriastradh * This leaves out BRW_BLENDFACTOR_INV_DST_COLOR, 8903b705cfSriastradh * BRW_BLENDFACTOR_INV_CONST_{COLOR,ALPHA}, 9003b705cfSriastradh * BRW_BLENDFACTOR_INV_SRC1_{COLOR,ALPHA} 9103b705cfSriastradh */ 9203b705cfSriastradh#define BRW_BLENDFACTOR_COUNT (BRW_BLENDFACTOR_INV_DST_ALPHA + 1) 9303b705cfSriastradh 9403b705cfSriastradh/* FIXME: surface format defined in brw_defines.h, shared Sampling engine 9503b705cfSriastradh * 1.7.2 9603b705cfSriastradh */ 9703b705cfSriastradhstatic const struct formatinfo { 9803b705cfSriastradh int fmt; 9903b705cfSriastradh uint32_t card_fmt; 10003b705cfSriastradh} i965_tex_formats[] = { 10103b705cfSriastradh {PICT_a8, BRW_SURFACEFORMAT_A8_UNORM}, 10203b705cfSriastradh {PICT_a8r8g8b8, BRW_SURFACEFORMAT_B8G8R8A8_UNORM}, 10303b705cfSriastradh {PICT_x8r8g8b8, BRW_SURFACEFORMAT_B8G8R8X8_UNORM}, 10403b705cfSriastradh {PICT_a8b8g8r8, BRW_SURFACEFORMAT_R8G8B8A8_UNORM}, 10503b705cfSriastradh {PICT_x8b8g8r8, BRW_SURFACEFORMAT_R8G8B8X8_UNORM}, 10603b705cfSriastradh {PICT_r8g8b8, BRW_SURFACEFORMAT_R8G8B8_UNORM}, 10703b705cfSriastradh {PICT_r5g6b5, BRW_SURFACEFORMAT_B5G6R5_UNORM}, 10803b705cfSriastradh {PICT_a1r5g5b5, BRW_SURFACEFORMAT_B5G5R5A1_UNORM}, 10903b705cfSriastradh#if XORG_VERSION_CURRENT >= 10699900 11003b705cfSriastradh {PICT_a2r10g10b10, BRW_SURFACEFORMAT_B10G10R10A2_UNORM}, 11103b705cfSriastradh {PICT_x2r10g10b10, BRW_SURFACEFORMAT_B10G10R10X2_UNORM}, 11203b705cfSriastradh {PICT_a2b10g10r10, BRW_SURFACEFORMAT_R10G10B10A2_UNORM}, 11303b705cfSriastradh {PICT_x2r10g10b10, BRW_SURFACEFORMAT_B10G10R10X2_UNORM}, 11403b705cfSriastradh#endif 11503b705cfSriastradh {PICT_a4r4g4b4, BRW_SURFACEFORMAT_B4G4R4A4_UNORM}, 11603b705cfSriastradh}; 11703b705cfSriastradh 11803b705cfSriastradhstatic void i965_get_blend_cntl(int op, PicturePtr mask, uint32_t dst_format, 11903b705cfSriastradh uint32_t * sblend, uint32_t * dblend) 12003b705cfSriastradh{ 12103b705cfSriastradh 12203b705cfSriastradh *sblend = i965_blend_op[op].src_blend; 12303b705cfSriastradh *dblend = i965_blend_op[op].dst_blend; 12403b705cfSriastradh 12503b705cfSriastradh /* If there's no dst alpha channel, adjust the blend op so that we'll treat 12603b705cfSriastradh * it as always 1. 12703b705cfSriastradh */ 12803b705cfSriastradh if (PICT_FORMAT_A(dst_format) == 0 && i965_blend_op[op].dst_alpha) { 12903b705cfSriastradh if (*sblend == BRW_BLENDFACTOR_DST_ALPHA) 13003b705cfSriastradh *sblend = BRW_BLENDFACTOR_ONE; 13103b705cfSriastradh else if (*sblend == BRW_BLENDFACTOR_INV_DST_ALPHA) 13203b705cfSriastradh *sblend = BRW_BLENDFACTOR_ZERO; 13303b705cfSriastradh } 13403b705cfSriastradh 13503b705cfSriastradh /* If the source alpha is being used, then we should only be in a case where 13603b705cfSriastradh * the source blend factor is 0, and the source blend value is the mask 13703b705cfSriastradh * channels multiplied by the source picture's alpha. 13803b705cfSriastradh */ 13903b705cfSriastradh if (mask && mask->componentAlpha && PICT_FORMAT_RGB(mask->format) 14003b705cfSriastradh && i965_blend_op[op].src_alpha) { 14103b705cfSriastradh if (*dblend == BRW_BLENDFACTOR_SRC_ALPHA) { 14203b705cfSriastradh *dblend = BRW_BLENDFACTOR_SRC_COLOR; 14303b705cfSriastradh } else if (*dblend == BRW_BLENDFACTOR_INV_SRC_ALPHA) { 14403b705cfSriastradh *dblend = BRW_BLENDFACTOR_INV_SRC_COLOR; 14503b705cfSriastradh } 14603b705cfSriastradh } 14703b705cfSriastradh 14803b705cfSriastradh} 14903b705cfSriastradh 15003b705cfSriastradhstatic uint32_t i965_get_dest_format(PicturePtr dest_picture) 15103b705cfSriastradh{ 15203b705cfSriastradh switch (dest_picture->format) { 15303b705cfSriastradh case PICT_a8r8g8b8: 15403b705cfSriastradh case PICT_x8r8g8b8: 15503b705cfSriastradh return BRW_SURFACEFORMAT_B8G8R8A8_UNORM; 15603b705cfSriastradh case PICT_a8b8g8r8: 15703b705cfSriastradh case PICT_x8b8g8r8: 15803b705cfSriastradh return BRW_SURFACEFORMAT_R8G8B8A8_UNORM; 15903b705cfSriastradh#if XORG_VERSION_CURRENT >= 10699900 16003b705cfSriastradh case PICT_a2r10g10b10: 16103b705cfSriastradh case PICT_x2r10g10b10: 16203b705cfSriastradh return BRW_SURFACEFORMAT_B10G10R10A2_UNORM; 16303b705cfSriastradh#endif 16403b705cfSriastradh case PICT_r5g6b5: 16503b705cfSriastradh return BRW_SURFACEFORMAT_B5G6R5_UNORM; 16603b705cfSriastradh case PICT_x1r5g5b5: 16703b705cfSriastradh case PICT_a1r5g5b5: 16803b705cfSriastradh return BRW_SURFACEFORMAT_B5G5R5A1_UNORM; 16903b705cfSriastradh case PICT_a8: 17003b705cfSriastradh return BRW_SURFACEFORMAT_A8_UNORM; 17103b705cfSriastradh case PICT_a4r4g4b4: 17203b705cfSriastradh case PICT_x4r4g4b4: 17303b705cfSriastradh return BRW_SURFACEFORMAT_B4G4R4A4_UNORM; 17403b705cfSriastradh default: 17503b705cfSriastradh return -1; 17603b705cfSriastradh } 17703b705cfSriastradh} 17803b705cfSriastradh 17903b705cfSriastradhBool 18003b705cfSriastradhi965_check_composite(int op, 18103b705cfSriastradh PicturePtr source_picture, 18203b705cfSriastradh PicturePtr mask_picture, 18303b705cfSriastradh PicturePtr dest_picture, 18403b705cfSriastradh int width, int height) 18503b705cfSriastradh{ 18603b705cfSriastradh ScrnInfoPtr scrn = xf86ScreenToScrn(dest_picture->pDrawable->pScreen); 18703b705cfSriastradh 18803b705cfSriastradh /* Check for unsupported compositing operations. */ 18903b705cfSriastradh if (op >= sizeof(i965_blend_op) / sizeof(i965_blend_op[0])) { 19013496ba1Ssnj intel_uxa_debug_fallback(scrn, 19103b705cfSriastradh "Unsupported Composite op 0x%x\n", op); 19203b705cfSriastradh return FALSE; 19303b705cfSriastradh } 19403b705cfSriastradh 19503b705cfSriastradh if (mask_picture && mask_picture->componentAlpha && 19603b705cfSriastradh PICT_FORMAT_RGB(mask_picture->format)) { 19703b705cfSriastradh /* Check if it's component alpha that relies on a source alpha and on 19803b705cfSriastradh * the source value. We can only get one of those into the single 19903b705cfSriastradh * source value that we get to blend with. 20003b705cfSriastradh */ 20103b705cfSriastradh if (i965_blend_op[op].src_alpha && 20203b705cfSriastradh (i965_blend_op[op].src_blend != BRW_BLENDFACTOR_ZERO)) { 20313496ba1Ssnj intel_uxa_debug_fallback(scrn, 20403b705cfSriastradh "Component alpha not supported " 20503b705cfSriastradh "with source alpha and source " 20603b705cfSriastradh "value blending.\n"); 20703b705cfSriastradh return FALSE; 20803b705cfSriastradh } 20903b705cfSriastradh } 21003b705cfSriastradh 21103b705cfSriastradh if (i965_get_dest_format(dest_picture) == -1) { 21213496ba1Ssnj intel_uxa_debug_fallback(scrn, "Usupported Color buffer format 0x%x\n", 21303b705cfSriastradh (int)dest_picture->format); 21403b705cfSriastradh return FALSE; 21503b705cfSriastradh } 21603b705cfSriastradh 21703b705cfSriastradh return TRUE; 21803b705cfSriastradh} 21903b705cfSriastradh 22003b705cfSriastradhBool 22103b705cfSriastradhi965_check_composite_texture(ScreenPtr screen, PicturePtr picture) 22203b705cfSriastradh{ 22303b705cfSriastradh if (picture->repeatType > RepeatReflect) { 22403b705cfSriastradh ScrnInfoPtr scrn = xf86ScreenToScrn(screen); 22513496ba1Ssnj intel_uxa_debug_fallback(scrn, 22603b705cfSriastradh "extended repeat (%d) not supported\n", 22703b705cfSriastradh picture->repeatType); 22803b705cfSriastradh return FALSE; 22903b705cfSriastradh } 23003b705cfSriastradh 23103b705cfSriastradh if (picture->filter != PictFilterNearest && 23203b705cfSriastradh picture->filter != PictFilterBilinear) { 23303b705cfSriastradh ScrnInfoPtr scrn = xf86ScreenToScrn(screen); 23413496ba1Ssnj intel_uxa_debug_fallback(scrn, "Unsupported filter 0x%x\n", 23503b705cfSriastradh picture->filter); 23603b705cfSriastradh return FALSE; 23703b705cfSriastradh } 23803b705cfSriastradh 23903b705cfSriastradh if (picture->pDrawable) { 24003b705cfSriastradh int w, h, i; 24103b705cfSriastradh 24203b705cfSriastradh w = picture->pDrawable->width; 24303b705cfSriastradh h = picture->pDrawable->height; 24403b705cfSriastradh if ((w > 8192) || (h > 8192)) { 24503b705cfSriastradh ScrnInfoPtr scrn = xf86ScreenToScrn(screen); 24613496ba1Ssnj intel_uxa_debug_fallback(scrn, 24703b705cfSriastradh "Picture w/h too large (%dx%d)\n", 24803b705cfSriastradh w, h); 24903b705cfSriastradh return FALSE; 25003b705cfSriastradh } 25103b705cfSriastradh 25203b705cfSriastradh for (i = 0; 25303b705cfSriastradh i < sizeof(i965_tex_formats) / sizeof(i965_tex_formats[0]); 25403b705cfSriastradh i++) { 25503b705cfSriastradh if (i965_tex_formats[i].fmt == picture->format) 25603b705cfSriastradh break; 25703b705cfSriastradh } 25803b705cfSriastradh if (i == sizeof(i965_tex_formats) / sizeof(i965_tex_formats[0])) 25903b705cfSriastradh { 26003b705cfSriastradh ScrnInfoPtr scrn = xf86ScreenToScrn(screen); 26113496ba1Ssnj intel_uxa_debug_fallback(scrn, 26203b705cfSriastradh "Unsupported picture format " 26303b705cfSriastradh "0x%x\n", 26403b705cfSriastradh (int)picture->format); 26503b705cfSriastradh return FALSE; 26603b705cfSriastradh } 26703b705cfSriastradh 26803b705cfSriastradh return TRUE; 26903b705cfSriastradh } 27003b705cfSriastradh 27103b705cfSriastradh return FALSE; 27203b705cfSriastradh} 27303b705cfSriastradh 27403b705cfSriastradh 27503b705cfSriastradh#define BRW_GRF_BLOCKS(nreg) ((nreg + 15) / 16 - 1) 27603b705cfSriastradh 27703b705cfSriastradh/* Set up a default static partitioning of the URB, which is supposed to 27803b705cfSriastradh * allow anything we would want to do, at potentially lower performance. 27903b705cfSriastradh */ 28003b705cfSriastradh#define URB_CS_ENTRY_SIZE 0 28103b705cfSriastradh#define URB_CS_ENTRIES 0 28203b705cfSriastradh 28303b705cfSriastradh#define URB_VS_ENTRY_SIZE 1 // each 512-bit row 28403b705cfSriastradh#define URB_VS_ENTRIES 8 // we needs at least 8 entries 28503b705cfSriastradh 28603b705cfSriastradh#define URB_GS_ENTRY_SIZE 0 28703b705cfSriastradh#define URB_GS_ENTRIES 0 28803b705cfSriastradh 28903b705cfSriastradh#define URB_CLIP_ENTRY_SIZE 0 29003b705cfSriastradh#define URB_CLIP_ENTRIES 0 29103b705cfSriastradh 29203b705cfSriastradh#define URB_SF_ENTRY_SIZE 2 29303b705cfSriastradh#define URB_SF_ENTRIES 1 29403b705cfSriastradh 29503b705cfSriastradh/* 29603b705cfSriastradh * this program computes dA/dx and dA/dy for the texture coordinates along 29703b705cfSriastradh * with the base texture coordinate. It was extracted from the Mesa driver 29803b705cfSriastradh */ 29903b705cfSriastradh 30003b705cfSriastradh#define SF_KERNEL_NUM_GRF 16 30103b705cfSriastradh#define SF_MAX_THREADS 2 30203b705cfSriastradh 30303b705cfSriastradhstatic const uint32_t sf_kernel_static[][4] = { 30403b705cfSriastradh#include "exa_sf.g4b" 30503b705cfSriastradh}; 30603b705cfSriastradh 30703b705cfSriastradhstatic const uint32_t sf_kernel_mask_static[][4] = { 30803b705cfSriastradh#include "exa_sf_mask.g4b" 30903b705cfSriastradh}; 31003b705cfSriastradh 31103b705cfSriastradh/* ps kernels */ 31203b705cfSriastradh#define PS_KERNEL_NUM_GRF 32 31303b705cfSriastradh#define PS_MAX_THREADS 48 31403b705cfSriastradh 31503b705cfSriastradhstatic const uint32_t ps_kernel_nomask_affine_static[][4] = { 31603b705cfSriastradh#include "exa_wm_xy.g4b" 31703b705cfSriastradh#include "exa_wm_src_affine.g4b" 31803b705cfSriastradh#include "exa_wm_src_sample_argb.g4b" 31903b705cfSriastradh#include "exa_wm_write.g4b" 32003b705cfSriastradh}; 32103b705cfSriastradh 32203b705cfSriastradhstatic const uint32_t ps_kernel_nomask_projective_static[][4] = { 32303b705cfSriastradh#include "exa_wm_xy.g4b" 32403b705cfSriastradh#include "exa_wm_src_projective.g4b" 32503b705cfSriastradh#include "exa_wm_src_sample_argb.g4b" 32603b705cfSriastradh#include "exa_wm_write.g4b" 32703b705cfSriastradh}; 32803b705cfSriastradh 32903b705cfSriastradhstatic const uint32_t ps_kernel_maskca_affine_static[][4] = { 33003b705cfSriastradh#include "exa_wm_xy.g4b" 33103b705cfSriastradh#include "exa_wm_src_affine.g4b" 33203b705cfSriastradh#include "exa_wm_src_sample_argb.g4b" 33303b705cfSriastradh#include "exa_wm_mask_affine.g4b" 33403b705cfSriastradh#include "exa_wm_mask_sample_argb.g4b" 33503b705cfSriastradh#include "exa_wm_ca.g4b" 33603b705cfSriastradh#include "exa_wm_write.g4b" 33703b705cfSriastradh}; 33803b705cfSriastradh 33903b705cfSriastradhstatic const uint32_t ps_kernel_maskca_projective_static[][4] = { 34003b705cfSriastradh#include "exa_wm_xy.g4b" 34103b705cfSriastradh#include "exa_wm_src_projective.g4b" 34203b705cfSriastradh#include "exa_wm_src_sample_argb.g4b" 34303b705cfSriastradh#include "exa_wm_mask_projective.g4b" 34403b705cfSriastradh#include "exa_wm_mask_sample_argb.g4b" 34503b705cfSriastradh#include "exa_wm_ca.g4b" 34603b705cfSriastradh#include "exa_wm_write.g4b" 34703b705cfSriastradh}; 34803b705cfSriastradh 34903b705cfSriastradhstatic const uint32_t ps_kernel_maskca_srcalpha_affine_static[][4] = { 35003b705cfSriastradh#include "exa_wm_xy.g4b" 35103b705cfSriastradh#include "exa_wm_src_affine.g4b" 35203b705cfSriastradh#include "exa_wm_src_sample_a.g4b" 35303b705cfSriastradh#include "exa_wm_mask_affine.g4b" 35403b705cfSriastradh#include "exa_wm_mask_sample_argb.g4b" 35503b705cfSriastradh#include "exa_wm_ca_srcalpha.g4b" 35603b705cfSriastradh#include "exa_wm_write.g4b" 35703b705cfSriastradh}; 35803b705cfSriastradh 35903b705cfSriastradhstatic const uint32_t ps_kernel_maskca_srcalpha_projective_static[][4] = { 36003b705cfSriastradh#include "exa_wm_xy.g4b" 36103b705cfSriastradh#include "exa_wm_src_projective.g4b" 36203b705cfSriastradh#include "exa_wm_src_sample_a.g4b" 36303b705cfSriastradh#include "exa_wm_mask_projective.g4b" 36403b705cfSriastradh#include "exa_wm_mask_sample_argb.g4b" 36503b705cfSriastradh#include "exa_wm_ca_srcalpha.g4b" 36603b705cfSriastradh#include "exa_wm_write.g4b" 36703b705cfSriastradh}; 36803b705cfSriastradh 36903b705cfSriastradhstatic const uint32_t ps_kernel_masknoca_affine_static[][4] = { 37003b705cfSriastradh#include "exa_wm_xy.g4b" 37103b705cfSriastradh#include "exa_wm_src_affine.g4b" 37203b705cfSriastradh#include "exa_wm_src_sample_argb.g4b" 37303b705cfSriastradh#include "exa_wm_mask_affine.g4b" 37403b705cfSriastradh#include "exa_wm_mask_sample_a.g4b" 37503b705cfSriastradh#include "exa_wm_noca.g4b" 37603b705cfSriastradh#include "exa_wm_write.g4b" 37703b705cfSriastradh}; 37803b705cfSriastradh 37903b705cfSriastradhstatic const uint32_t ps_kernel_masknoca_projective_static[][4] = { 38003b705cfSriastradh#include "exa_wm_xy.g4b" 38103b705cfSriastradh#include "exa_wm_src_projective.g4b" 38203b705cfSriastradh#include "exa_wm_src_sample_argb.g4b" 38303b705cfSriastradh#include "exa_wm_mask_projective.g4b" 38403b705cfSriastradh#include "exa_wm_mask_sample_a.g4b" 38503b705cfSriastradh#include "exa_wm_noca.g4b" 38603b705cfSriastradh#include "exa_wm_write.g4b" 38703b705cfSriastradh}; 38803b705cfSriastradh 38903b705cfSriastradh/* new programs for Ironlake */ 39003b705cfSriastradhstatic const uint32_t sf_kernel_static_gen5[][4] = { 39103b705cfSriastradh#include "exa_sf.g4b.gen5" 39203b705cfSriastradh}; 39303b705cfSriastradh 39403b705cfSriastradhstatic const uint32_t sf_kernel_mask_static_gen5[][4] = { 39503b705cfSriastradh#include "exa_sf_mask.g4b.gen5" 39603b705cfSriastradh}; 39703b705cfSriastradh 39803b705cfSriastradhstatic const uint32_t ps_kernel_nomask_affine_static_gen5[][4] = { 39903b705cfSriastradh#include "exa_wm_xy.g4b.gen5" 40003b705cfSriastradh#include "exa_wm_src_affine.g4b.gen5" 40103b705cfSriastradh#include "exa_wm_src_sample_argb.g4b.gen5" 40203b705cfSriastradh#include "exa_wm_write.g4b.gen5" 40303b705cfSriastradh}; 40403b705cfSriastradh 40503b705cfSriastradhstatic const uint32_t ps_kernel_nomask_projective_static_gen5[][4] = { 40603b705cfSriastradh#include "exa_wm_xy.g4b.gen5" 40703b705cfSriastradh#include "exa_wm_src_projective.g4b.gen5" 40803b705cfSriastradh#include "exa_wm_src_sample_argb.g4b.gen5" 40903b705cfSriastradh#include "exa_wm_write.g4b.gen5" 41003b705cfSriastradh}; 41103b705cfSriastradh 41203b705cfSriastradhstatic const uint32_t ps_kernel_maskca_affine_static_gen5[][4] = { 41303b705cfSriastradh#include "exa_wm_xy.g4b.gen5" 41403b705cfSriastradh#include "exa_wm_src_affine.g4b.gen5" 41503b705cfSriastradh#include "exa_wm_src_sample_argb.g4b.gen5" 41603b705cfSriastradh#include "exa_wm_mask_affine.g4b.gen5" 41703b705cfSriastradh#include "exa_wm_mask_sample_argb.g4b.gen5" 41803b705cfSriastradh#include "exa_wm_ca.g4b.gen5" 41903b705cfSriastradh#include "exa_wm_write.g4b.gen5" 42003b705cfSriastradh}; 42103b705cfSriastradh 42203b705cfSriastradhstatic const uint32_t ps_kernel_maskca_projective_static_gen5[][4] = { 42303b705cfSriastradh#include "exa_wm_xy.g4b.gen5" 42403b705cfSriastradh#include "exa_wm_src_projective.g4b.gen5" 42503b705cfSriastradh#include "exa_wm_src_sample_argb.g4b.gen5" 42603b705cfSriastradh#include "exa_wm_mask_projective.g4b.gen5" 42703b705cfSriastradh#include "exa_wm_mask_sample_argb.g4b.gen5" 42803b705cfSriastradh#include "exa_wm_ca.g4b.gen5" 42903b705cfSriastradh#include "exa_wm_write.g4b.gen5" 43003b705cfSriastradh}; 43103b705cfSriastradh 43203b705cfSriastradhstatic const uint32_t ps_kernel_maskca_srcalpha_affine_static_gen5[][4] = { 43303b705cfSriastradh#include "exa_wm_xy.g4b.gen5" 43403b705cfSriastradh#include "exa_wm_src_affine.g4b.gen5" 43503b705cfSriastradh#include "exa_wm_src_sample_a.g4b.gen5" 43603b705cfSriastradh#include "exa_wm_mask_affine.g4b.gen5" 43703b705cfSriastradh#include "exa_wm_mask_sample_argb.g4b.gen5" 43803b705cfSriastradh#include "exa_wm_ca_srcalpha.g4b.gen5" 43903b705cfSriastradh#include "exa_wm_write.g4b.gen5" 44003b705cfSriastradh}; 44103b705cfSriastradh 44203b705cfSriastradhstatic const uint32_t ps_kernel_maskca_srcalpha_projective_static_gen5[][4] = { 44303b705cfSriastradh#include "exa_wm_xy.g4b.gen5" 44403b705cfSriastradh#include "exa_wm_src_projective.g4b.gen5" 44503b705cfSriastradh#include "exa_wm_src_sample_a.g4b.gen5" 44603b705cfSriastradh#include "exa_wm_mask_projective.g4b.gen5" 44703b705cfSriastradh#include "exa_wm_mask_sample_argb.g4b.gen5" 44803b705cfSriastradh#include "exa_wm_ca_srcalpha.g4b.gen5" 44903b705cfSriastradh#include "exa_wm_write.g4b.gen5" 45003b705cfSriastradh}; 45103b705cfSriastradh 45203b705cfSriastradhstatic const uint32_t ps_kernel_masknoca_affine_static_gen5[][4] = { 45303b705cfSriastradh#include "exa_wm_xy.g4b.gen5" 45403b705cfSriastradh#include "exa_wm_src_affine.g4b.gen5" 45503b705cfSriastradh#include "exa_wm_src_sample_argb.g4b.gen5" 45603b705cfSriastradh#include "exa_wm_mask_affine.g4b.gen5" 45703b705cfSriastradh#include "exa_wm_mask_sample_a.g4b.gen5" 45803b705cfSriastradh#include "exa_wm_noca.g4b.gen5" 45903b705cfSriastradh#include "exa_wm_write.g4b.gen5" 46003b705cfSriastradh}; 46103b705cfSriastradh 46203b705cfSriastradhstatic const uint32_t ps_kernel_masknoca_projective_static_gen5[][4] = { 46303b705cfSriastradh#include "exa_wm_xy.g4b.gen5" 46403b705cfSriastradh#include "exa_wm_src_projective.g4b.gen5" 46503b705cfSriastradh#include "exa_wm_src_sample_argb.g4b.gen5" 46603b705cfSriastradh#include "exa_wm_mask_projective.g4b.gen5" 46703b705cfSriastradh#include "exa_wm_mask_sample_a.g4b.gen5" 46803b705cfSriastradh#include "exa_wm_noca.g4b.gen5" 46903b705cfSriastradh#include "exa_wm_write.g4b.gen5" 47003b705cfSriastradh}; 47103b705cfSriastradh 47203b705cfSriastradh/* programs for GEN6 */ 47303b705cfSriastradhstatic const uint32_t ps_kernel_nomask_affine_static_gen6[][4] = { 47403b705cfSriastradh#include "exa_wm_src_affine.g6b" 47503b705cfSriastradh#include "exa_wm_src_sample_argb.g6b" 47603b705cfSriastradh#include "exa_wm_write.g6b" 47703b705cfSriastradh}; 47803b705cfSriastradh 47903b705cfSriastradhstatic const uint32_t ps_kernel_nomask_projective_static_gen6[][4] = { 48003b705cfSriastradh#include "exa_wm_src_projective.g6b" 48103b705cfSriastradh#include "exa_wm_src_sample_argb.g6b" 48203b705cfSriastradh#include "exa_wm_write.g6b" 48303b705cfSriastradh}; 48403b705cfSriastradh 48503b705cfSriastradhstatic const uint32_t ps_kernel_maskca_affine_static_gen6[][4] = { 48603b705cfSriastradh#include "exa_wm_src_affine.g6b" 48703b705cfSriastradh#include "exa_wm_src_sample_argb.g6b" 48803b705cfSriastradh#include "exa_wm_mask_affine.g6b" 48903b705cfSriastradh#include "exa_wm_mask_sample_argb.g6b" 49003b705cfSriastradh#include "exa_wm_ca.g6b" 49103b705cfSriastradh#include "exa_wm_write.g6b" 49203b705cfSriastradh}; 49303b705cfSriastradh 49403b705cfSriastradhstatic const uint32_t ps_kernel_maskca_projective_static_gen6[][4] = { 49503b705cfSriastradh#include "exa_wm_src_projective.g6b" 49603b705cfSriastradh#include "exa_wm_src_sample_argb.g6b" 49703b705cfSriastradh#include "exa_wm_mask_projective.g6b" 49803b705cfSriastradh#include "exa_wm_mask_sample_argb.g6b" 49903b705cfSriastradh#include "exa_wm_ca.g4b.gen5" 50003b705cfSriastradh#include "exa_wm_write.g6b" 50103b705cfSriastradh}; 50203b705cfSriastradh 50303b705cfSriastradhstatic const uint32_t ps_kernel_maskca_srcalpha_affine_static_gen6[][4] = { 50403b705cfSriastradh#include "exa_wm_src_affine.g6b" 50503b705cfSriastradh#include "exa_wm_src_sample_a.g6b" 50603b705cfSriastradh#include "exa_wm_mask_affine.g6b" 50703b705cfSriastradh#include "exa_wm_mask_sample_argb.g6b" 50803b705cfSriastradh#include "exa_wm_ca_srcalpha.g6b" 50903b705cfSriastradh#include "exa_wm_write.g6b" 51003b705cfSriastradh}; 51103b705cfSriastradh 51203b705cfSriastradhstatic const uint32_t ps_kernel_maskca_srcalpha_projective_static_gen6[][4] = { 51303b705cfSriastradh#include "exa_wm_src_projective.g6b" 51403b705cfSriastradh#include "exa_wm_src_sample_a.g6b" 51503b705cfSriastradh#include "exa_wm_mask_projective.g6b" 51603b705cfSriastradh#include "exa_wm_mask_sample_argb.g6b" 51703b705cfSriastradh#include "exa_wm_ca_srcalpha.g6b" 51803b705cfSriastradh#include "exa_wm_write.g6b" 51903b705cfSriastradh}; 52003b705cfSriastradh 52103b705cfSriastradhstatic const uint32_t ps_kernel_masknoca_affine_static_gen6[][4] = { 52203b705cfSriastradh#include "exa_wm_src_affine.g6b" 52303b705cfSriastradh#include "exa_wm_src_sample_argb.g6b" 52403b705cfSriastradh#include "exa_wm_mask_affine.g6b" 52503b705cfSriastradh#include "exa_wm_mask_sample_a.g6b" 52603b705cfSriastradh#include "exa_wm_noca.g6b" 52703b705cfSriastradh#include "exa_wm_write.g6b" 52803b705cfSriastradh}; 52903b705cfSriastradh 53003b705cfSriastradhstatic const uint32_t ps_kernel_masknoca_projective_static_gen6[][4] = { 53103b705cfSriastradh#include "exa_wm_src_projective.g6b" 53203b705cfSriastradh#include "exa_wm_src_sample_argb.g6b" 53303b705cfSriastradh#include "exa_wm_mask_projective.g6b" 53403b705cfSriastradh#include "exa_wm_mask_sample_a.g6b" 53503b705cfSriastradh#include "exa_wm_noca.g6b" 53603b705cfSriastradh#include "exa_wm_write.g6b" 53703b705cfSriastradh}; 53803b705cfSriastradh 53903b705cfSriastradh/* programs for GEN7 */ 54003b705cfSriastradhstatic const uint32_t ps_kernel_nomask_affine_static_gen7[][4] = { 54103b705cfSriastradh#include "exa_wm_src_affine.g7b" 54203b705cfSriastradh#include "exa_wm_src_sample_argb.g7b" 54303b705cfSriastradh#include "exa_wm_write.g7b" 54403b705cfSriastradh}; 54503b705cfSriastradh 54603b705cfSriastradhstatic const uint32_t ps_kernel_nomask_projective_static_gen7[][4] = { 54703b705cfSriastradh#include "exa_wm_src_projective.g7b" 54803b705cfSriastradh#include "exa_wm_src_sample_argb.g7b" 54903b705cfSriastradh#include "exa_wm_write.g7b" 55003b705cfSriastradh}; 55103b705cfSriastradh 55203b705cfSriastradhstatic const uint32_t ps_kernel_maskca_affine_static_gen7[][4] = { 55303b705cfSriastradh#include "exa_wm_src_affine.g7b" 55403b705cfSriastradh#include "exa_wm_src_sample_argb.g7b" 55503b705cfSriastradh#include "exa_wm_mask_affine.g7b" 55603b705cfSriastradh#include "exa_wm_mask_sample_argb.g7b" 55703b705cfSriastradh#include "exa_wm_ca.g6b" 55803b705cfSriastradh#include "exa_wm_write.g7b" 55903b705cfSriastradh}; 56003b705cfSriastradh 56103b705cfSriastradhstatic const uint32_t ps_kernel_maskca_projective_static_gen7[][4] = { 56203b705cfSriastradh#include "exa_wm_src_projective.g7b" 56303b705cfSriastradh#include "exa_wm_src_sample_argb.g7b" 56403b705cfSriastradh#include "exa_wm_mask_projective.g7b" 56503b705cfSriastradh#include "exa_wm_mask_sample_argb.g7b" 56603b705cfSriastradh#include "exa_wm_ca.g4b.gen5" 56703b705cfSriastradh#include "exa_wm_write.g7b" 56803b705cfSriastradh}; 56903b705cfSriastradh 57003b705cfSriastradhstatic const uint32_t ps_kernel_maskca_srcalpha_affine_static_gen7[][4] = { 57103b705cfSriastradh#include "exa_wm_src_affine.g7b" 57203b705cfSriastradh#include "exa_wm_src_sample_a.g7b" 57303b705cfSriastradh#include "exa_wm_mask_affine.g7b" 57403b705cfSriastradh#include "exa_wm_mask_sample_argb.g7b" 57503b705cfSriastradh#include "exa_wm_ca_srcalpha.g6b" 57603b705cfSriastradh#include "exa_wm_write.g7b" 57703b705cfSriastradh}; 57803b705cfSriastradh 57903b705cfSriastradhstatic const uint32_t ps_kernel_maskca_srcalpha_projective_static_gen7[][4] = { 58003b705cfSriastradh#include "exa_wm_src_projective.g7b" 58103b705cfSriastradh#include "exa_wm_src_sample_a.g7b" 58203b705cfSriastradh#include "exa_wm_mask_projective.g7b" 58303b705cfSriastradh#include "exa_wm_mask_sample_argb.g7b" 58403b705cfSriastradh#include "exa_wm_ca_srcalpha.g6b" 58503b705cfSriastradh#include "exa_wm_write.g7b" 58603b705cfSriastradh}; 58703b705cfSriastradh 58803b705cfSriastradhstatic const uint32_t ps_kernel_masknoca_affine_static_gen7[][4] = { 58903b705cfSriastradh#include "exa_wm_src_affine.g7b" 59003b705cfSriastradh#include "exa_wm_src_sample_argb.g7b" 59103b705cfSriastradh#include "exa_wm_mask_affine.g7b" 59203b705cfSriastradh#include "exa_wm_mask_sample_a.g7b" 59303b705cfSriastradh#include "exa_wm_noca.g6b" 59403b705cfSriastradh#include "exa_wm_write.g7b" 59503b705cfSriastradh}; 59603b705cfSriastradh 59703b705cfSriastradhstatic const uint32_t ps_kernel_masknoca_projective_static_gen7[][4] = { 59803b705cfSriastradh#include "exa_wm_src_projective.g7b" 59903b705cfSriastradh#include "exa_wm_src_sample_argb.g7b" 60003b705cfSriastradh#include "exa_wm_mask_projective.g7b" 60103b705cfSriastradh#include "exa_wm_mask_sample_a.g7b" 60203b705cfSriastradh#include "exa_wm_noca.g6b" 60303b705cfSriastradh#include "exa_wm_write.g7b" 60403b705cfSriastradh}; 60503b705cfSriastradh 60603b705cfSriastradh 60703b705cfSriastradhtypedef enum { 60803b705cfSriastradh SS_INVALID_FILTER = -1, 60903b705cfSriastradh SS_FILTER_NEAREST, 61003b705cfSriastradh SS_FILTER_BILINEAR, 61103b705cfSriastradh FILTER_COUNT, 61203b705cfSriastradh} sampler_state_filter_t; 61303b705cfSriastradh 61403b705cfSriastradhtypedef enum { 61503b705cfSriastradh SS_INVALID_EXTEND = -1, 61603b705cfSriastradh SS_EXTEND_NONE, 61703b705cfSriastradh SS_EXTEND_REPEAT, 61803b705cfSriastradh SS_EXTEND_PAD, 61903b705cfSriastradh SS_EXTEND_REFLECT, 62003b705cfSriastradh EXTEND_COUNT, 62103b705cfSriastradh} sampler_state_extend_t; 62203b705cfSriastradh 62303b705cfSriastradhtypedef enum { 62403b705cfSriastradh WM_KERNEL_NOMASK_AFFINE, 62503b705cfSriastradh WM_KERNEL_NOMASK_PROJECTIVE, 62603b705cfSriastradh WM_KERNEL_MASKCA_AFFINE, 62703b705cfSriastradh WM_KERNEL_MASKCA_PROJECTIVE, 62803b705cfSriastradh WM_KERNEL_MASKCA_SRCALPHA_AFFINE, 62903b705cfSriastradh WM_KERNEL_MASKCA_SRCALPHA_PROJECTIVE, 63003b705cfSriastradh WM_KERNEL_MASKNOCA_AFFINE, 63103b705cfSriastradh WM_KERNEL_MASKNOCA_PROJECTIVE, 63203b705cfSriastradh KERNEL_COUNT 63303b705cfSriastradh} wm_kernel_t; 63403b705cfSriastradh 63503b705cfSriastradh#define KERNEL(kernel_enum, kernel, masked) \ 63603b705cfSriastradh [kernel_enum] = {&kernel, sizeof(kernel), masked} 63703b705cfSriastradhstruct wm_kernel_info { 63803b705cfSriastradh const void *data; 63903b705cfSriastradh unsigned int size; 64003b705cfSriastradh Bool has_mask; 64103b705cfSriastradh}; 64203b705cfSriastradh 64303b705cfSriastradhstatic const struct wm_kernel_info wm_kernels_gen4[] = { 64403b705cfSriastradh KERNEL(WM_KERNEL_NOMASK_AFFINE, 64503b705cfSriastradh ps_kernel_nomask_affine_static, FALSE), 64603b705cfSriastradh KERNEL(WM_KERNEL_NOMASK_PROJECTIVE, 64703b705cfSriastradh ps_kernel_nomask_projective_static, FALSE), 64803b705cfSriastradh KERNEL(WM_KERNEL_MASKCA_AFFINE, 64903b705cfSriastradh ps_kernel_maskca_affine_static, TRUE), 65003b705cfSriastradh KERNEL(WM_KERNEL_MASKCA_PROJECTIVE, 65103b705cfSriastradh ps_kernel_maskca_projective_static, TRUE), 65203b705cfSriastradh KERNEL(WM_KERNEL_MASKCA_SRCALPHA_AFFINE, 65303b705cfSriastradh ps_kernel_maskca_srcalpha_affine_static, TRUE), 65403b705cfSriastradh KERNEL(WM_KERNEL_MASKCA_SRCALPHA_PROJECTIVE, 65503b705cfSriastradh ps_kernel_maskca_srcalpha_projective_static, TRUE), 65603b705cfSriastradh KERNEL(WM_KERNEL_MASKNOCA_AFFINE, 65703b705cfSriastradh ps_kernel_masknoca_affine_static, TRUE), 65803b705cfSriastradh KERNEL(WM_KERNEL_MASKNOCA_PROJECTIVE, 65903b705cfSriastradh ps_kernel_masknoca_projective_static, TRUE), 66003b705cfSriastradh}; 66103b705cfSriastradh 66203b705cfSriastradhstatic const struct wm_kernel_info wm_kernels_gen5[] = { 66303b705cfSriastradh KERNEL(WM_KERNEL_NOMASK_AFFINE, 66403b705cfSriastradh ps_kernel_nomask_affine_static_gen5, FALSE), 66503b705cfSriastradh KERNEL(WM_KERNEL_NOMASK_PROJECTIVE, 66603b705cfSriastradh ps_kernel_nomask_projective_static_gen5, FALSE), 66703b705cfSriastradh KERNEL(WM_KERNEL_MASKCA_AFFINE, 66803b705cfSriastradh ps_kernel_maskca_affine_static_gen5, TRUE), 66903b705cfSriastradh KERNEL(WM_KERNEL_MASKCA_PROJECTIVE, 67003b705cfSriastradh ps_kernel_maskca_projective_static_gen5, TRUE), 67103b705cfSriastradh KERNEL(WM_KERNEL_MASKCA_SRCALPHA_AFFINE, 67203b705cfSriastradh ps_kernel_maskca_srcalpha_affine_static_gen5, TRUE), 67303b705cfSriastradh KERNEL(WM_KERNEL_MASKCA_SRCALPHA_PROJECTIVE, 67403b705cfSriastradh ps_kernel_maskca_srcalpha_projective_static_gen5, TRUE), 67503b705cfSriastradh KERNEL(WM_KERNEL_MASKNOCA_AFFINE, 67603b705cfSriastradh ps_kernel_masknoca_affine_static_gen5, TRUE), 67703b705cfSriastradh KERNEL(WM_KERNEL_MASKNOCA_PROJECTIVE, 67803b705cfSriastradh ps_kernel_masknoca_projective_static_gen5, TRUE), 67903b705cfSriastradh}; 68003b705cfSriastradh 68103b705cfSriastradhstatic const struct wm_kernel_info wm_kernels_gen6[] = { 68203b705cfSriastradh KERNEL(WM_KERNEL_NOMASK_AFFINE, 68303b705cfSriastradh ps_kernel_nomask_affine_static_gen6, FALSE), 68403b705cfSriastradh KERNEL(WM_KERNEL_NOMASK_PROJECTIVE, 68503b705cfSriastradh ps_kernel_nomask_projective_static_gen6, FALSE), 68603b705cfSriastradh KERNEL(WM_KERNEL_MASKCA_AFFINE, 68703b705cfSriastradh ps_kernel_maskca_affine_static_gen6, TRUE), 68803b705cfSriastradh KERNEL(WM_KERNEL_MASKCA_PROJECTIVE, 68903b705cfSriastradh ps_kernel_maskca_projective_static_gen6, TRUE), 69003b705cfSriastradh KERNEL(WM_KERNEL_MASKCA_SRCALPHA_AFFINE, 69103b705cfSriastradh ps_kernel_maskca_srcalpha_affine_static_gen6, TRUE), 69203b705cfSriastradh KERNEL(WM_KERNEL_MASKCA_SRCALPHA_PROJECTIVE, 69303b705cfSriastradh ps_kernel_maskca_srcalpha_projective_static_gen6, TRUE), 69403b705cfSriastradh KERNEL(WM_KERNEL_MASKNOCA_AFFINE, 69503b705cfSriastradh ps_kernel_masknoca_affine_static_gen6, TRUE), 69603b705cfSriastradh KERNEL(WM_KERNEL_MASKNOCA_PROJECTIVE, 69703b705cfSriastradh ps_kernel_masknoca_projective_static_gen6, TRUE), 69803b705cfSriastradh}; 69903b705cfSriastradh 70003b705cfSriastradhstatic const struct wm_kernel_info wm_kernels_gen7[] = { 70103b705cfSriastradh KERNEL(WM_KERNEL_NOMASK_AFFINE, 70203b705cfSriastradh ps_kernel_nomask_affine_static_gen7, FALSE), 70303b705cfSriastradh KERNEL(WM_KERNEL_NOMASK_PROJECTIVE, 70403b705cfSriastradh ps_kernel_nomask_projective_static_gen7, FALSE), 70503b705cfSriastradh KERNEL(WM_KERNEL_MASKCA_AFFINE, 70603b705cfSriastradh ps_kernel_maskca_affine_static_gen7, TRUE), 70703b705cfSriastradh KERNEL(WM_KERNEL_MASKCA_PROJECTIVE, 70803b705cfSriastradh ps_kernel_maskca_projective_static_gen7, TRUE), 70903b705cfSriastradh KERNEL(WM_KERNEL_MASKCA_SRCALPHA_AFFINE, 71003b705cfSriastradh ps_kernel_maskca_srcalpha_affine_static_gen7, TRUE), 71103b705cfSriastradh KERNEL(WM_KERNEL_MASKCA_SRCALPHA_PROJECTIVE, 71203b705cfSriastradh ps_kernel_maskca_srcalpha_projective_static_gen7, TRUE), 71303b705cfSriastradh KERNEL(WM_KERNEL_MASKNOCA_AFFINE, 71403b705cfSriastradh ps_kernel_masknoca_affine_static_gen7, TRUE), 71503b705cfSriastradh KERNEL(WM_KERNEL_MASKNOCA_PROJECTIVE, 71603b705cfSriastradh ps_kernel_masknoca_projective_static_gen7, TRUE), 71703b705cfSriastradh}; 71803b705cfSriastradh 71903b705cfSriastradh#undef KERNEL 72003b705cfSriastradh 72103b705cfSriastradhtypedef struct _brw_cc_unit_state_padded { 72203b705cfSriastradh struct brw_cc_unit_state state; 72303b705cfSriastradh char pad[64 - sizeof(struct brw_cc_unit_state)]; 72403b705cfSriastradh} brw_cc_unit_state_padded; 72503b705cfSriastradh 72603b705cfSriastradh#ifndef MAX 72703b705cfSriastradh#define MAX(a, b) ((a) > (b) ? (a) : (b)) 72803b705cfSriastradh#endif 72903b705cfSriastradh#define SURFACE_STATE_PADDED_SIZE ALIGN(MAX(sizeof(struct brw_surface_state), sizeof(struct gen7_surface_state)), 32) 73003b705cfSriastradh 73103b705cfSriastradhstruct gen4_cc_unit_state { 73203b705cfSriastradh /* Index by [src_blend][dst_blend] */ 73303b705cfSriastradh brw_cc_unit_state_padded cc_state[BRW_BLENDFACTOR_COUNT][BRW_BLENDFACTOR_COUNT]; 73403b705cfSriastradh}; 73503b705cfSriastradh 73603b705cfSriastradhtypedef struct gen4_composite_op { 73703b705cfSriastradh int op; 73803b705cfSriastradh sampler_state_filter_t src_filter; 73903b705cfSriastradh sampler_state_filter_t mask_filter; 74003b705cfSriastradh sampler_state_extend_t src_extend; 74103b705cfSriastradh sampler_state_extend_t mask_extend; 74203b705cfSriastradh Bool is_affine; 74303b705cfSriastradh wm_kernel_t wm_kernel; 74403b705cfSriastradh int vertex_id; 74503b705cfSriastradh} gen4_composite_op; 74603b705cfSriastradh 74703b705cfSriastradh/** Private data for gen4 render accel implementation. */ 74803b705cfSriastradhstruct gen4_render_state { 74903b705cfSriastradh drm_intel_bo *vs_state_bo; 75003b705cfSriastradh drm_intel_bo *sf_state_bo; 75103b705cfSriastradh drm_intel_bo *sf_mask_state_bo; 75203b705cfSriastradh drm_intel_bo *cc_state_bo; 75303b705cfSriastradh drm_intel_bo *wm_state_bo[KERNEL_COUNT] 75403b705cfSriastradh [FILTER_COUNT] [EXTEND_COUNT] 75503b705cfSriastradh [FILTER_COUNT] [EXTEND_COUNT]; 75603b705cfSriastradh drm_intel_bo *wm_kernel_bo[KERNEL_COUNT]; 75703b705cfSriastradh 75803b705cfSriastradh drm_intel_bo *cc_vp_bo; 75903b705cfSriastradh drm_intel_bo *gen6_blend_bo; 76003b705cfSriastradh drm_intel_bo *gen6_depth_stencil_bo; 76103b705cfSriastradh drm_intel_bo *ps_sampler_state_bo[FILTER_COUNT] 76203b705cfSriastradh [EXTEND_COUNT] 76303b705cfSriastradh [FILTER_COUNT] 76403b705cfSriastradh [EXTEND_COUNT]; 76503b705cfSriastradh gen4_composite_op composite_op; 76603b705cfSriastradh}; 76703b705cfSriastradh 76803b705cfSriastradhstatic void gen6_emit_composite_state(struct intel_screen_private *intel); 76903b705cfSriastradhstatic void gen6_render_state_init(ScrnInfoPtr scrn); 77003b705cfSriastradh 77103b705cfSriastradh/** 77203b705cfSriastradh * Sets up the SF state pointing at an SF kernel. 77303b705cfSriastradh * 77403b705cfSriastradh * The SF kernel does coord interp: for each attribute, 77503b705cfSriastradh * calculate dA/dx and dA/dy. Hand these interpolation coefficients 77603b705cfSriastradh * back to SF which then hands pixels off to WM. 77703b705cfSriastradh */ 77803b705cfSriastradhstatic drm_intel_bo *gen4_create_sf_state(intel_screen_private *intel, 77903b705cfSriastradh drm_intel_bo * kernel_bo) 78003b705cfSriastradh{ 78103b705cfSriastradh struct brw_sf_unit_state *sf_state; 78203b705cfSriastradh drm_intel_bo *sf_state_bo; 78303b705cfSriastradh int ret; 78403b705cfSriastradh 78503b705cfSriastradh sf_state_bo = drm_intel_bo_alloc(intel->bufmgr, "gen4 SF state", 78603b705cfSriastradh sizeof(*sf_state), 4096); 78703b705cfSriastradh assert(sf_state_bo); 78803b705cfSriastradh 78903b705cfSriastradh ret = drm_intel_bo_map(sf_state_bo, TRUE); 79003b705cfSriastradh assert(ret == 0); 79103b705cfSriastradh 79203b705cfSriastradh sf_state = memset(sf_state_bo->virtual, 0, sizeof(*sf_state)); 79303b705cfSriastradh sf_state->thread0.grf_reg_count = BRW_GRF_BLOCKS(SF_KERNEL_NUM_GRF); 79403b705cfSriastradh sf_state->thread0.kernel_start_pointer = 79513496ba1Ssnj intel_uxa_emit_reloc(sf_state_bo, 79603b705cfSriastradh offsetof(struct brw_sf_unit_state, thread0), 79703b705cfSriastradh kernel_bo, sf_state->thread0.grf_reg_count << 1, 79803b705cfSriastradh I915_GEM_DOMAIN_INSTRUCTION, 0) >> 6; 79903b705cfSriastradh sf_state->sf1.single_program_flow = 1; 80003b705cfSriastradh sf_state->sf1.binding_table_entry_count = 0; 80103b705cfSriastradh sf_state->sf1.thread_priority = 0; 80203b705cfSriastradh sf_state->sf1.floating_point_mode = 0; /* Mesa does this */ 80303b705cfSriastradh sf_state->sf1.illegal_op_exception_enable = 1; 80403b705cfSriastradh sf_state->sf1.mask_stack_exception_enable = 1; 80503b705cfSriastradh sf_state->sf1.sw_exception_enable = 1; 80603b705cfSriastradh sf_state->thread2.per_thread_scratch_space = 0; 80703b705cfSriastradh /* scratch space is not used in our kernel */ 80803b705cfSriastradh sf_state->thread2.scratch_space_base_pointer = 0; 80903b705cfSriastradh sf_state->thread3.const_urb_entry_read_length = 0; /* no const URBs */ 81003b705cfSriastradh sf_state->thread3.const_urb_entry_read_offset = 0; /* no const URBs */ 81103b705cfSriastradh sf_state->thread3.urb_entry_read_length = 1; /* 1 URB per vertex */ 81203b705cfSriastradh /* don't smash vertex header, read start from dw8 */ 81303b705cfSriastradh sf_state->thread3.urb_entry_read_offset = 1; 81403b705cfSriastradh sf_state->thread3.dispatch_grf_start_reg = 3; 81503b705cfSriastradh sf_state->thread4.max_threads = SF_MAX_THREADS - 1; 81603b705cfSriastradh sf_state->thread4.urb_entry_allocation_size = URB_SF_ENTRY_SIZE - 1; 81703b705cfSriastradh sf_state->thread4.nr_urb_entries = URB_SF_ENTRIES; 81803b705cfSriastradh sf_state->sf5.viewport_transform = FALSE; /* skip viewport */ 81903b705cfSriastradh sf_state->sf6.cull_mode = BRW_CULLMODE_NONE; 82003b705cfSriastradh sf_state->sf6.scissor = 0; 82103b705cfSriastradh sf_state->sf7.trifan_pv = 2; 82203b705cfSriastradh sf_state->sf6.dest_org_vbias = 0x8; 82303b705cfSriastradh sf_state->sf6.dest_org_hbias = 0x8; 82403b705cfSriastradh 82503b705cfSriastradh drm_intel_bo_unmap(sf_state_bo); 82603b705cfSriastradh 82703b705cfSriastradh return sf_state_bo; 82803b705cfSriastradh (void)ret; 82903b705cfSriastradh} 83003b705cfSriastradh 83103b705cfSriastradhstatic drm_intel_bo *sampler_border_color_create(intel_screen_private *intel) 83203b705cfSriastradh{ 83303b705cfSriastradh struct brw_sampler_legacy_border_color sampler_border_color; 83403b705cfSriastradh 83503b705cfSriastradh /* Set up the sampler border color (always transparent black) */ 83603b705cfSriastradh memset(&sampler_border_color, 0, sizeof(sampler_border_color)); 83703b705cfSriastradh sampler_border_color.color[0] = 0; /* R */ 83803b705cfSriastradh sampler_border_color.color[1] = 0; /* G */ 83903b705cfSriastradh sampler_border_color.color[2] = 0; /* B */ 84003b705cfSriastradh sampler_border_color.color[3] = 0; /* A */ 84103b705cfSriastradh 84213496ba1Ssnj return intel_uxa_bo_alloc_for_data(intel, 84303b705cfSriastradh &sampler_border_color, 84403b705cfSriastradh sizeof(sampler_border_color), 84503b705cfSriastradh "gen4 render sampler border color"); 84603b705cfSriastradh} 84703b705cfSriastradh 84803b705cfSriastradhstatic void 84903b705cfSriastradhgen4_sampler_state_init(drm_intel_bo * sampler_state_bo, 85003b705cfSriastradh struct brw_sampler_state *sampler_state, 85103b705cfSriastradh sampler_state_filter_t filter, 85203b705cfSriastradh sampler_state_extend_t extend, 85303b705cfSriastradh drm_intel_bo * border_color_bo) 85403b705cfSriastradh{ 85503b705cfSriastradh uint32_t sampler_state_offset; 85603b705cfSriastradh 85703b705cfSriastradh sampler_state_offset = (char *)sampler_state - 85803b705cfSriastradh (char *)sampler_state_bo->virtual; 85903b705cfSriastradh 86003b705cfSriastradh /* PS kernel use this sampler */ 86103b705cfSriastradh memset(sampler_state, 0, sizeof(*sampler_state)); 86203b705cfSriastradh 86303b705cfSriastradh sampler_state->ss0.lod_preclamp = 1; /* GL mode */ 86403b705cfSriastradh 86503b705cfSriastradh /* We use the legacy mode to get the semantics specified by 86603b705cfSriastradh * the Render extension. */ 86703b705cfSriastradh sampler_state->ss0.border_color_mode = BRW_BORDER_COLOR_MODE_LEGACY; 86803b705cfSriastradh 86903b705cfSriastradh switch (filter) { 87003b705cfSriastradh default: 87103b705cfSriastradh case SS_FILTER_NEAREST: 87203b705cfSriastradh sampler_state->ss0.min_filter = BRW_MAPFILTER_NEAREST; 87303b705cfSriastradh sampler_state->ss0.mag_filter = BRW_MAPFILTER_NEAREST; 87403b705cfSriastradh break; 87503b705cfSriastradh case SS_FILTER_BILINEAR: 87603b705cfSriastradh sampler_state->ss0.min_filter = BRW_MAPFILTER_LINEAR; 87703b705cfSriastradh sampler_state->ss0.mag_filter = BRW_MAPFILTER_LINEAR; 87803b705cfSriastradh break; 87903b705cfSriastradh } 88003b705cfSriastradh 88103b705cfSriastradh switch (extend) { 88203b705cfSriastradh default: 88303b705cfSriastradh case SS_EXTEND_NONE: 88403b705cfSriastradh sampler_state->ss1.r_wrap_mode = BRW_TEXCOORDMODE_CLAMP_BORDER; 88503b705cfSriastradh sampler_state->ss1.s_wrap_mode = BRW_TEXCOORDMODE_CLAMP_BORDER; 88603b705cfSriastradh sampler_state->ss1.t_wrap_mode = BRW_TEXCOORDMODE_CLAMP_BORDER; 88703b705cfSriastradh break; 88803b705cfSriastradh case SS_EXTEND_REPEAT: 88903b705cfSriastradh sampler_state->ss1.r_wrap_mode = BRW_TEXCOORDMODE_WRAP; 89003b705cfSriastradh sampler_state->ss1.s_wrap_mode = BRW_TEXCOORDMODE_WRAP; 89103b705cfSriastradh sampler_state->ss1.t_wrap_mode = BRW_TEXCOORDMODE_WRAP; 89203b705cfSriastradh break; 89303b705cfSriastradh case SS_EXTEND_PAD: 89403b705cfSriastradh sampler_state->ss1.r_wrap_mode = BRW_TEXCOORDMODE_CLAMP; 89503b705cfSriastradh sampler_state->ss1.s_wrap_mode = BRW_TEXCOORDMODE_CLAMP; 89603b705cfSriastradh sampler_state->ss1.t_wrap_mode = BRW_TEXCOORDMODE_CLAMP; 89703b705cfSriastradh break; 89803b705cfSriastradh case SS_EXTEND_REFLECT: 89903b705cfSriastradh sampler_state->ss1.r_wrap_mode = BRW_TEXCOORDMODE_MIRROR; 90003b705cfSriastradh sampler_state->ss1.s_wrap_mode = BRW_TEXCOORDMODE_MIRROR; 90103b705cfSriastradh sampler_state->ss1.t_wrap_mode = BRW_TEXCOORDMODE_MIRROR; 90203b705cfSriastradh break; 90303b705cfSriastradh } 90403b705cfSriastradh 90503b705cfSriastradh sampler_state->ss2.border_color_pointer = 90613496ba1Ssnj intel_uxa_emit_reloc(sampler_state_bo, sampler_state_offset + 90703b705cfSriastradh offsetof(struct brw_sampler_state, ss2), 90803b705cfSriastradh border_color_bo, 0, 90903b705cfSriastradh I915_GEM_DOMAIN_SAMPLER, 0) >> 5; 91003b705cfSriastradh 91103b705cfSriastradh sampler_state->ss3.chroma_key_enable = 0; /* disable chromakey */ 91203b705cfSriastradh} 91303b705cfSriastradh 91403b705cfSriastradhstatic void 91503b705cfSriastradhgen7_sampler_state_init(drm_intel_bo * sampler_state_bo, 91603b705cfSriastradh struct gen7_sampler_state *sampler_state, 91703b705cfSriastradh sampler_state_filter_t filter, 91803b705cfSriastradh sampler_state_extend_t extend, 91903b705cfSriastradh drm_intel_bo * border_color_bo) 92003b705cfSriastradh{ 92103b705cfSriastradh uint32_t sampler_state_offset; 92203b705cfSriastradh 92303b705cfSriastradh sampler_state_offset = (char *)sampler_state - 92403b705cfSriastradh (char *)sampler_state_bo->virtual; 92503b705cfSriastradh 92603b705cfSriastradh /* PS kernel use this sampler */ 92703b705cfSriastradh memset(sampler_state, 0, sizeof(*sampler_state)); 92803b705cfSriastradh 92903b705cfSriastradh sampler_state->ss0.lod_preclamp = 1; /* GL mode */ 93003b705cfSriastradh 93103b705cfSriastradh /* We use the legacy mode to get the semantics specified by 93203b705cfSriastradh * the Render extension. */ 93303b705cfSriastradh sampler_state->ss0.default_color_mode = BRW_BORDER_COLOR_MODE_LEGACY; 93403b705cfSriastradh 93503b705cfSriastradh switch (filter) { 93603b705cfSriastradh default: 93703b705cfSriastradh case SS_FILTER_NEAREST: 93803b705cfSriastradh sampler_state->ss0.min_filter = BRW_MAPFILTER_NEAREST; 93903b705cfSriastradh sampler_state->ss0.mag_filter = BRW_MAPFILTER_NEAREST; 94003b705cfSriastradh break; 94103b705cfSriastradh case SS_FILTER_BILINEAR: 94203b705cfSriastradh sampler_state->ss0.min_filter = BRW_MAPFILTER_LINEAR; 94303b705cfSriastradh sampler_state->ss0.mag_filter = BRW_MAPFILTER_LINEAR; 94403b705cfSriastradh break; 94503b705cfSriastradh } 94603b705cfSriastradh 94703b705cfSriastradh switch (extend) { 94803b705cfSriastradh default: 94903b705cfSriastradh case SS_EXTEND_NONE: 95003b705cfSriastradh sampler_state->ss3.r_wrap_mode = BRW_TEXCOORDMODE_CLAMP_BORDER; 95103b705cfSriastradh sampler_state->ss3.s_wrap_mode = BRW_TEXCOORDMODE_CLAMP_BORDER; 95203b705cfSriastradh sampler_state->ss3.t_wrap_mode = BRW_TEXCOORDMODE_CLAMP_BORDER; 95303b705cfSriastradh break; 95403b705cfSriastradh case SS_EXTEND_REPEAT: 95503b705cfSriastradh sampler_state->ss3.r_wrap_mode = BRW_TEXCOORDMODE_WRAP; 95603b705cfSriastradh sampler_state->ss3.s_wrap_mode = BRW_TEXCOORDMODE_WRAP; 95703b705cfSriastradh sampler_state->ss3.t_wrap_mode = BRW_TEXCOORDMODE_WRAP; 95803b705cfSriastradh break; 95903b705cfSriastradh case SS_EXTEND_PAD: 96003b705cfSriastradh sampler_state->ss3.r_wrap_mode = BRW_TEXCOORDMODE_CLAMP; 96103b705cfSriastradh sampler_state->ss3.s_wrap_mode = BRW_TEXCOORDMODE_CLAMP; 96203b705cfSriastradh sampler_state->ss3.t_wrap_mode = BRW_TEXCOORDMODE_CLAMP; 96303b705cfSriastradh break; 96403b705cfSriastradh case SS_EXTEND_REFLECT: 96503b705cfSriastradh sampler_state->ss3.r_wrap_mode = BRW_TEXCOORDMODE_MIRROR; 96603b705cfSriastradh sampler_state->ss3.s_wrap_mode = BRW_TEXCOORDMODE_MIRROR; 96703b705cfSriastradh sampler_state->ss3.t_wrap_mode = BRW_TEXCOORDMODE_MIRROR; 96803b705cfSriastradh break; 96903b705cfSriastradh } 97003b705cfSriastradh 97103b705cfSriastradh sampler_state->ss2.default_color_pointer = 97213496ba1Ssnj intel_uxa_emit_reloc(sampler_state_bo, sampler_state_offset + 97303b705cfSriastradh offsetof(struct gen7_sampler_state, ss2), 97403b705cfSriastradh border_color_bo, 0, 97503b705cfSriastradh I915_GEM_DOMAIN_SAMPLER, 0) >> 5; 97603b705cfSriastradh 97703b705cfSriastradh sampler_state->ss3.chroma_key_enable = 0; /* disable chromakey */ 97803b705cfSriastradh} 97903b705cfSriastradh 98003b705cfSriastradh 98103b705cfSriastradh 98203b705cfSriastradhstatic drm_intel_bo *gen4_create_sampler_state(intel_screen_private *intel, 98303b705cfSriastradh sampler_state_filter_t src_filter, 98403b705cfSriastradh sampler_state_extend_t src_extend, 98503b705cfSriastradh sampler_state_filter_t mask_filter, 98603b705cfSriastradh sampler_state_extend_t mask_extend, 98703b705cfSriastradh drm_intel_bo * border_color_bo) 98803b705cfSriastradh{ 98903b705cfSriastradh drm_intel_bo *sampler_state_bo; 99003b705cfSriastradh struct brw_sampler_state *sampler_state; 99103b705cfSriastradh int ret; 99203b705cfSriastradh 99303b705cfSriastradh sampler_state_bo = 99403b705cfSriastradh drm_intel_bo_alloc(intel->bufmgr, "gen4 sampler state", 99503b705cfSriastradh sizeof(struct brw_sampler_state) * 2, 4096); 99603b705cfSriastradh assert(sampler_state_bo); 99703b705cfSriastradh 99803b705cfSriastradh ret = drm_intel_bo_map(sampler_state_bo, TRUE); 99903b705cfSriastradh assert(ret == 0); 100003b705cfSriastradh 100103b705cfSriastradh sampler_state = sampler_state_bo->virtual; 100203b705cfSriastradh 100303b705cfSriastradh gen4_sampler_state_init(sampler_state_bo, 100403b705cfSriastradh &sampler_state[0], 100503b705cfSriastradh src_filter, src_extend, border_color_bo); 100603b705cfSriastradh gen4_sampler_state_init(sampler_state_bo, 100703b705cfSriastradh &sampler_state[1], 100803b705cfSriastradh mask_filter, mask_extend, border_color_bo); 100903b705cfSriastradh 101003b705cfSriastradh drm_intel_bo_unmap(sampler_state_bo); 101103b705cfSriastradh 101203b705cfSriastradh return sampler_state_bo; 101303b705cfSriastradh (void)ret; 101403b705cfSriastradh} 101503b705cfSriastradh 101603b705cfSriastradhstatic drm_intel_bo * 101703b705cfSriastradhgen7_create_sampler_state(intel_screen_private *intel, 101803b705cfSriastradh sampler_state_filter_t src_filter, 101903b705cfSriastradh sampler_state_extend_t src_extend, 102003b705cfSriastradh sampler_state_filter_t mask_filter, 102103b705cfSriastradh sampler_state_extend_t mask_extend, 102203b705cfSriastradh drm_intel_bo * border_color_bo) 102303b705cfSriastradh{ 102403b705cfSriastradh drm_intel_bo *sampler_state_bo; 102503b705cfSriastradh struct gen7_sampler_state *sampler_state; 102603b705cfSriastradh int ret; 102703b705cfSriastradh 102803b705cfSriastradh sampler_state_bo = 102903b705cfSriastradh drm_intel_bo_alloc(intel->bufmgr, "gen7 sampler state", 103003b705cfSriastradh sizeof(struct gen7_sampler_state) * 2, 4096); 103103b705cfSriastradh assert(sampler_state_bo); 103203b705cfSriastradh 103303b705cfSriastradh ret = drm_intel_bo_map(sampler_state_bo, TRUE); 103403b705cfSriastradh assert(ret == 0); 103503b705cfSriastradh 103603b705cfSriastradh sampler_state = sampler_state_bo->virtual; 103703b705cfSriastradh 103803b705cfSriastradh gen7_sampler_state_init(sampler_state_bo, 103903b705cfSriastradh &sampler_state[0], 104003b705cfSriastradh src_filter, src_extend, border_color_bo); 104103b705cfSriastradh gen7_sampler_state_init(sampler_state_bo, 104203b705cfSriastradh &sampler_state[1], 104303b705cfSriastradh mask_filter, mask_extend, border_color_bo); 104403b705cfSriastradh 104503b705cfSriastradh drm_intel_bo_unmap(sampler_state_bo); 104603b705cfSriastradh 104703b705cfSriastradh return sampler_state_bo; 104803b705cfSriastradh (void)ret; 104903b705cfSriastradh} 105003b705cfSriastradh 105103b705cfSriastradhstatic inline drm_intel_bo * 105203b705cfSriastradhi965_create_sampler_state(intel_screen_private *intel, 105303b705cfSriastradh sampler_state_filter_t src_filter, 105403b705cfSriastradh sampler_state_extend_t src_extend, 105503b705cfSriastradh sampler_state_filter_t mask_filter, 105603b705cfSriastradh sampler_state_extend_t mask_extend, 105703b705cfSriastradh drm_intel_bo * border_color_bo) 105803b705cfSriastradh{ 105903b705cfSriastradh if (INTEL_INFO(intel)->gen < 070) 106003b705cfSriastradh return gen4_create_sampler_state(intel, src_filter, src_extend, 106103b705cfSriastradh mask_filter, mask_extend, 106203b705cfSriastradh border_color_bo); 106303b705cfSriastradh return gen7_create_sampler_state(intel, src_filter, src_extend, 106403b705cfSriastradh mask_filter, mask_extend, 106503b705cfSriastradh border_color_bo); 106603b705cfSriastradh} 106703b705cfSriastradh 106803b705cfSriastradh 106903b705cfSriastradhstatic void 107003b705cfSriastradhcc_state_init(drm_intel_bo * cc_state_bo, 107103b705cfSriastradh uint32_t cc_state_offset, 107203b705cfSriastradh int src_blend, int dst_blend, drm_intel_bo * cc_vp_bo) 107303b705cfSriastradh{ 107403b705cfSriastradh struct brw_cc_unit_state *cc_state; 107503b705cfSriastradh 107603b705cfSriastradh cc_state = (struct brw_cc_unit_state *)((char *)cc_state_bo->virtual + 107703b705cfSriastradh cc_state_offset); 107803b705cfSriastradh 107903b705cfSriastradh memset(cc_state, 0, sizeof(*cc_state)); 108003b705cfSriastradh cc_state->cc0.stencil_enable = 0; /* disable stencil */ 108103b705cfSriastradh cc_state->cc2.depth_test = 0; /* disable depth test */ 108203b705cfSriastradh cc_state->cc2.logicop_enable = 0; /* disable logic op */ 108303b705cfSriastradh cc_state->cc3.ia_blend_enable = 0; /* blend alpha same as colors */ 108403b705cfSriastradh cc_state->cc3.blend_enable = 1; /* enable color blend */ 108503b705cfSriastradh cc_state->cc3.alpha_test = 0; /* disable alpha test */ 108603b705cfSriastradh 108703b705cfSriastradh cc_state->cc4.cc_viewport_state_offset = 108813496ba1Ssnj intel_uxa_emit_reloc(cc_state_bo, cc_state_offset + 108903b705cfSriastradh offsetof(struct brw_cc_unit_state, cc4), 109003b705cfSriastradh cc_vp_bo, 0, I915_GEM_DOMAIN_INSTRUCTION, 0) >> 5; 109103b705cfSriastradh 109203b705cfSriastradh cc_state->cc5.dither_enable = 0; /* disable dither */ 109303b705cfSriastradh cc_state->cc5.logicop_func = 0xc; /* COPY */ 109403b705cfSriastradh cc_state->cc5.statistics_enable = 1; 109503b705cfSriastradh cc_state->cc5.ia_blend_function = BRW_BLENDFUNCTION_ADD; 109603b705cfSriastradh 109703b705cfSriastradh /* Fill in alpha blend factors same as color, for the future. */ 109803b705cfSriastradh cc_state->cc5.ia_src_blend_factor = src_blend; 109903b705cfSriastradh cc_state->cc5.ia_dest_blend_factor = dst_blend; 110003b705cfSriastradh 110103b705cfSriastradh cc_state->cc6.blend_function = BRW_BLENDFUNCTION_ADD; 110203b705cfSriastradh cc_state->cc6.clamp_post_alpha_blend = 1; 110303b705cfSriastradh cc_state->cc6.clamp_pre_alpha_blend = 1; 110403b705cfSriastradh cc_state->cc6.clamp_range = 0; /* clamp range [0,1] */ 110503b705cfSriastradh 110603b705cfSriastradh cc_state->cc6.src_blend_factor = src_blend; 110703b705cfSriastradh cc_state->cc6.dest_blend_factor = dst_blend; 110803b705cfSriastradh} 110903b705cfSriastradh 111003b705cfSriastradhstatic drm_intel_bo *gen4_create_wm_state(intel_screen_private *intel, 111103b705cfSriastradh Bool has_mask, 111203b705cfSriastradh drm_intel_bo * kernel_bo, 111303b705cfSriastradh drm_intel_bo * sampler_bo) 111403b705cfSriastradh{ 111503b705cfSriastradh struct brw_wm_unit_state *state; 111603b705cfSriastradh drm_intel_bo *wm_state_bo; 111703b705cfSriastradh int ret; 111803b705cfSriastradh 111903b705cfSriastradh wm_state_bo = drm_intel_bo_alloc(intel->bufmgr, "gen4 WM state", 112003b705cfSriastradh sizeof(*state), 4096); 112103b705cfSriastradh assert(wm_state_bo); 112203b705cfSriastradh 112303b705cfSriastradh ret = drm_intel_bo_map(wm_state_bo, TRUE); 112403b705cfSriastradh assert(ret == 0); 112503b705cfSriastradh 112603b705cfSriastradh state = memset(wm_state_bo->virtual, 0, sizeof(*state)); 112703b705cfSriastradh state->thread0.grf_reg_count = BRW_GRF_BLOCKS(PS_KERNEL_NUM_GRF); 112803b705cfSriastradh state->thread0.kernel_start_pointer = 112913496ba1Ssnj intel_uxa_emit_reloc(wm_state_bo, 113003b705cfSriastradh offsetof(struct brw_wm_unit_state, thread0), 113103b705cfSriastradh kernel_bo, state->thread0.grf_reg_count << 1, 113203b705cfSriastradh I915_GEM_DOMAIN_INSTRUCTION, 0) >> 6; 113303b705cfSriastradh 113403b705cfSriastradh state->thread1.single_program_flow = 0; 113503b705cfSriastradh 113603b705cfSriastradh /* scratch space is not used in our kernel */ 113703b705cfSriastradh state->thread2.scratch_space_base_pointer = 0; 113803b705cfSriastradh state->thread2.per_thread_scratch_space = 0; 113903b705cfSriastradh 114003b705cfSriastradh state->thread3.const_urb_entry_read_length = 0; 114103b705cfSriastradh state->thread3.const_urb_entry_read_offset = 0; 114203b705cfSriastradh 114303b705cfSriastradh state->thread3.urb_entry_read_offset = 0; 114403b705cfSriastradh /* wm kernel use urb from 3, see wm_program in compiler module */ 114503b705cfSriastradh state->thread3.dispatch_grf_start_reg = 3; /* must match kernel */ 114603b705cfSriastradh 114703b705cfSriastradh if (IS_GEN5(intel)) 114803b705cfSriastradh state->wm4.sampler_count = 0; /* hardware requirement */ 114903b705cfSriastradh else 115003b705cfSriastradh state->wm4.sampler_count = 1; /* 1-4 samplers used */ 115103b705cfSriastradh 115203b705cfSriastradh state->wm4.sampler_state_pointer = 115313496ba1Ssnj intel_uxa_emit_reloc(wm_state_bo, 115403b705cfSriastradh offsetof(struct brw_wm_unit_state, wm4), 115503b705cfSriastradh sampler_bo, 115603b705cfSriastradh state->wm4.sampler_count << 2, 115703b705cfSriastradh I915_GEM_DOMAIN_INSTRUCTION, 0) >> 5; 115803b705cfSriastradh state->wm5.max_threads = PS_MAX_THREADS - 1; 115903b705cfSriastradh state->wm5.transposed_urb_read = 0; 116003b705cfSriastradh state->wm5.thread_dispatch_enable = 1; 116103b705cfSriastradh /* just use 16-pixel dispatch (4 subspans), don't need to change kernel 116203b705cfSriastradh * start point 116303b705cfSriastradh */ 116403b705cfSriastradh state->wm5.enable_16_pix = 1; 116503b705cfSriastradh state->wm5.enable_8_pix = 0; 116603b705cfSriastradh state->wm5.early_depth_test = 1; 116703b705cfSriastradh 116803b705cfSriastradh /* Each pair of attributes (src/mask coords) is two URB entries */ 116903b705cfSriastradh if (has_mask) { 117003b705cfSriastradh state->thread1.binding_table_entry_count = 3; /* 2 tex and fb */ 117103b705cfSriastradh state->thread3.urb_entry_read_length = 4; 117203b705cfSriastradh } else { 117303b705cfSriastradh state->thread1.binding_table_entry_count = 2; /* 1 tex and fb */ 117403b705cfSriastradh state->thread3.urb_entry_read_length = 2; 117503b705cfSriastradh } 117603b705cfSriastradh 117703b705cfSriastradh /* binding table entry count is only used for prefetching, and it has to 117803b705cfSriastradh * be set 0 for Ironlake 117903b705cfSriastradh */ 118003b705cfSriastradh if (IS_GEN5(intel)) 118103b705cfSriastradh state->thread1.binding_table_entry_count = 0; 118203b705cfSriastradh 118303b705cfSriastradh drm_intel_bo_unmap(wm_state_bo); 118403b705cfSriastradh 118503b705cfSriastradh return wm_state_bo; 118603b705cfSriastradh (void)ret; 118703b705cfSriastradh} 118803b705cfSriastradh 118903b705cfSriastradhstatic drm_intel_bo *gen4_create_cc_viewport(intel_screen_private *intel) 119003b705cfSriastradh{ 119103b705cfSriastradh drm_intel_bo *bo; 119203b705cfSriastradh struct brw_cc_viewport vp; 119303b705cfSriastradh int ret; 119403b705cfSriastradh 119503b705cfSriastradh vp.min_depth = -1.e35; 119603b705cfSriastradh vp.max_depth = 1.e35; 119703b705cfSriastradh 119803b705cfSriastradh bo = drm_intel_bo_alloc(intel->bufmgr, "gen4 render unit state", 119903b705cfSriastradh sizeof(vp), 4096); 120003b705cfSriastradh assert(bo); 120103b705cfSriastradh 120203b705cfSriastradh ret = drm_intel_bo_subdata(bo, 0, sizeof(vp), &vp); 120303b705cfSriastradh assert(ret == 0); 120403b705cfSriastradh 120503b705cfSriastradh return bo; 120603b705cfSriastradh (void)ret; 120703b705cfSriastradh} 120803b705cfSriastradh 120903b705cfSriastradhstatic drm_intel_bo *gen4_create_vs_unit_state(intel_screen_private *intel) 121003b705cfSriastradh{ 121103b705cfSriastradh struct brw_vs_unit_state vs_state; 121203b705cfSriastradh memset(&vs_state, 0, sizeof(vs_state)); 121303b705cfSriastradh 121403b705cfSriastradh /* Set up the vertex shader to be disabled (passthrough) */ 121503b705cfSriastradh if (IS_GEN5(intel)) 121603b705cfSriastradh vs_state.thread4.nr_urb_entries = URB_VS_ENTRIES >> 2; /* hardware requirement */ 121703b705cfSriastradh else 121803b705cfSriastradh vs_state.thread4.nr_urb_entries = URB_VS_ENTRIES; 121903b705cfSriastradh vs_state.thread4.urb_entry_allocation_size = URB_VS_ENTRY_SIZE - 1; 122003b705cfSriastradh vs_state.vs6.vs_enable = 0; 122103b705cfSriastradh vs_state.vs6.vert_cache_disable = 1; 122203b705cfSriastradh 122313496ba1Ssnj return intel_uxa_bo_alloc_for_data(intel, &vs_state, sizeof(vs_state), 122403b705cfSriastradh "gen4 render VS state"); 122503b705cfSriastradh} 122603b705cfSriastradh 122703b705cfSriastradh/** 122803b705cfSriastradh * Set up all combinations of cc state: each blendfactor for source and 122903b705cfSriastradh * dest. 123003b705cfSriastradh */ 123103b705cfSriastradhstatic drm_intel_bo *gen4_create_cc_unit_state(intel_screen_private *intel) 123203b705cfSriastradh{ 123303b705cfSriastradh drm_intel_bo *cc_state_bo, *cc_vp_bo; 123403b705cfSriastradh int i, j, ret; 123503b705cfSriastradh 123603b705cfSriastradh cc_vp_bo = gen4_create_cc_viewport(intel); 123703b705cfSriastradh 123803b705cfSriastradh cc_state_bo = drm_intel_bo_alloc(intel->bufmgr, "gen4 CC state", 123903b705cfSriastradh sizeof(struct gen4_cc_unit_state), 124003b705cfSriastradh 4096); 124103b705cfSriastradh assert(cc_state_bo); 124203b705cfSriastradh 124303b705cfSriastradh ret = drm_intel_bo_map(cc_state_bo, TRUE); 124403b705cfSriastradh assert(ret == 0); 124503b705cfSriastradh 124603b705cfSriastradh for (i = 0; i < BRW_BLENDFACTOR_COUNT; i++) { 124703b705cfSriastradh for (j = 0; j < BRW_BLENDFACTOR_COUNT; j++) { 124803b705cfSriastradh cc_state_init(cc_state_bo, 124903b705cfSriastradh offsetof(struct gen4_cc_unit_state, 125003b705cfSriastradh cc_state[i][j].state), 125103b705cfSriastradh i, j, cc_vp_bo); 125203b705cfSriastradh } 125303b705cfSriastradh } 125403b705cfSriastradh drm_intel_bo_unmap(cc_state_bo); 125503b705cfSriastradh 125603b705cfSriastradh drm_intel_bo_unreference(cc_vp_bo); 125703b705cfSriastradh 125803b705cfSriastradh return cc_state_bo; 125903b705cfSriastradh (void)ret; 126003b705cfSriastradh} 126103b705cfSriastradh 126203b705cfSriastradhstatic uint32_t i965_get_card_format(PicturePtr picture) 126303b705cfSriastradh{ 126442542f5fSchristos unsigned i; 126503b705cfSriastradh 126603b705cfSriastradh for (i = 0; i < sizeof(i965_tex_formats) / sizeof(i965_tex_formats[0]); 126742542f5fSchristos i++) 126803b705cfSriastradh if (i965_tex_formats[i].fmt == picture->format) 126942542f5fSchristos return i965_tex_formats[i].card_fmt; 127042542f5fSchristos 127103b705cfSriastradh assert(i != sizeof(i965_tex_formats) / sizeof(i965_tex_formats[0])); 127203b705cfSriastradh 127342542f5fSchristos return 0; 127403b705cfSriastradh} 127503b705cfSriastradh 127603b705cfSriastradhstatic sampler_state_filter_t sampler_state_filter_from_picture(int filter) 127703b705cfSriastradh{ 127803b705cfSriastradh switch (filter) { 127903b705cfSriastradh case PictFilterNearest: 128003b705cfSriastradh return SS_FILTER_NEAREST; 128103b705cfSriastradh case PictFilterBilinear: 128203b705cfSriastradh return SS_FILTER_BILINEAR; 128303b705cfSriastradh default: 128403b705cfSriastradh return SS_INVALID_FILTER; 128503b705cfSriastradh } 128603b705cfSriastradh} 128703b705cfSriastradh 128803b705cfSriastradhstatic sampler_state_extend_t sampler_state_extend_from_picture(int repeat_type) 128903b705cfSriastradh{ 129003b705cfSriastradh switch (repeat_type) { 129103b705cfSriastradh case RepeatNone: 129203b705cfSriastradh return SS_EXTEND_NONE; 129303b705cfSriastradh case RepeatNormal: 129403b705cfSriastradh return SS_EXTEND_REPEAT; 129503b705cfSriastradh case RepeatPad: 129603b705cfSriastradh return SS_EXTEND_PAD; 129703b705cfSriastradh case RepeatReflect: 129803b705cfSriastradh return SS_EXTEND_REFLECT; 129903b705cfSriastradh default: 130003b705cfSriastradh return SS_INVALID_EXTEND; 130103b705cfSriastradh } 130203b705cfSriastradh} 130303b705cfSriastradh 130403b705cfSriastradh/** 130503b705cfSriastradh * Sets up the common fields for a surface state buffer for the given 130603b705cfSriastradh * picture in the given surface state buffer. 130703b705cfSriastradh */ 130803b705cfSriastradhstatic int 130903b705cfSriastradhgen4_set_picture_surface_state(intel_screen_private *intel, 131003b705cfSriastradh PicturePtr picture, PixmapPtr pixmap, 131103b705cfSriastradh Bool is_dst) 131203b705cfSriastradh{ 131313496ba1Ssnj struct intel_uxa_pixmap *priv = intel_uxa_get_pixmap_private(pixmap); 131403b705cfSriastradh struct brw_surface_state *ss; 131503b705cfSriastradh uint32_t write_domain, read_domains; 131603b705cfSriastradh int offset; 131703b705cfSriastradh 131803b705cfSriastradh if (is_dst) { 131903b705cfSriastradh write_domain = I915_GEM_DOMAIN_RENDER; 132003b705cfSriastradh read_domains = I915_GEM_DOMAIN_RENDER; 132103b705cfSriastradh } else { 132203b705cfSriastradh write_domain = 0; 132303b705cfSriastradh read_domains = I915_GEM_DOMAIN_SAMPLER; 132403b705cfSriastradh } 132503b705cfSriastradh intel_batch_mark_pixmap_domains(intel, priv, 132603b705cfSriastradh read_domains, write_domain); 132703b705cfSriastradh ss = (struct brw_surface_state *) 132803b705cfSriastradh (intel->surface_data + intel->surface_used); 132903b705cfSriastradh 133003b705cfSriastradh memset(ss, 0, sizeof(*ss)); 133103b705cfSriastradh ss->ss0.surface_type = BRW_SURFACE_2D; 133203b705cfSriastradh if (is_dst) 133303b705cfSriastradh ss->ss0.surface_format = i965_get_dest_format(picture); 133403b705cfSriastradh else 133503b705cfSriastradh ss->ss0.surface_format = i965_get_card_format(picture); 133603b705cfSriastradh 133703b705cfSriastradh ss->ss0.data_return_format = BRW_SURFACERETURNFORMAT_FLOAT32; 133803b705cfSriastradh ss->ss0.color_blend = 1; 133903b705cfSriastradh ss->ss1.base_addr = priv->bo->offset; 134003b705cfSriastradh 134103b705cfSriastradh ss->ss2.height = pixmap->drawable.height - 1; 134203b705cfSriastradh ss->ss2.width = pixmap->drawable.width - 1; 134303b705cfSriastradh ss->ss3.pitch = intel_pixmap_pitch(pixmap) - 1; 134403b705cfSriastradh ss->ss3.tile_walk = 0; /* Tiled X */ 134513496ba1Ssnj ss->ss3.tiled_surface = intel_uxa_pixmap_tiled(pixmap) ? 1 : 0; 134603b705cfSriastradh 134703b705cfSriastradh dri_bo_emit_reloc(intel->surface_bo, 134803b705cfSriastradh read_domains, write_domain, 134903b705cfSriastradh 0, 135003b705cfSriastradh intel->surface_used + 135103b705cfSriastradh offsetof(struct brw_surface_state, ss1), 135203b705cfSriastradh priv->bo); 135303b705cfSriastradh 135403b705cfSriastradh offset = intel->surface_used; 135503b705cfSriastradh intel->surface_used += SURFACE_STATE_PADDED_SIZE; 135603b705cfSriastradh 135703b705cfSriastradh return offset; 135803b705cfSriastradh} 135903b705cfSriastradh 136003b705cfSriastradhstatic int 136103b705cfSriastradhgen7_set_picture_surface_state(intel_screen_private *intel, 136203b705cfSriastradh PicturePtr picture, PixmapPtr pixmap, 136303b705cfSriastradh Bool is_dst) 136403b705cfSriastradh{ 136513496ba1Ssnj struct intel_uxa_pixmap *priv = intel_uxa_get_pixmap_private(pixmap); 136603b705cfSriastradh struct gen7_surface_state *ss; 136703b705cfSriastradh uint32_t write_domain, read_domains; 136803b705cfSriastradh int offset; 136903b705cfSriastradh 137003b705cfSriastradh if (is_dst) { 137103b705cfSriastradh write_domain = I915_GEM_DOMAIN_RENDER; 137203b705cfSriastradh read_domains = I915_GEM_DOMAIN_RENDER; 137303b705cfSriastradh } else { 137403b705cfSriastradh write_domain = 0; 137503b705cfSriastradh read_domains = I915_GEM_DOMAIN_SAMPLER; 137603b705cfSriastradh } 137703b705cfSriastradh intel_batch_mark_pixmap_domains(intel, priv, 137803b705cfSriastradh read_domains, write_domain); 137903b705cfSriastradh ss = (struct gen7_surface_state *) 138003b705cfSriastradh (intel->surface_data + intel->surface_used); 138103b705cfSriastradh 138203b705cfSriastradh memset(ss, 0, sizeof(*ss)); 138303b705cfSriastradh ss->ss0.surface_type = BRW_SURFACE_2D; 138403b705cfSriastradh if (is_dst) 138503b705cfSriastradh ss->ss0.surface_format = i965_get_dest_format(picture); 138603b705cfSriastradh else 138703b705cfSriastradh ss->ss0.surface_format = i965_get_card_format(picture); 138803b705cfSriastradh 138903b705cfSriastradh ss->ss0.tile_walk = 0; /* Tiled X */ 139013496ba1Ssnj ss->ss0.tiled_surface = intel_uxa_pixmap_tiled(pixmap) ? 1 : 0; 139103b705cfSriastradh ss->ss1.base_addr = priv->bo->offset; 139203b705cfSriastradh 139303b705cfSriastradh ss->ss2.height = pixmap->drawable.height - 1; 139403b705cfSriastradh ss->ss2.width = pixmap->drawable.width - 1; 139503b705cfSriastradh ss->ss3.pitch = intel_pixmap_pitch(pixmap) - 1; 139603b705cfSriastradh 139703b705cfSriastradh if (IS_HSW(intel)) { 139803b705cfSriastradh ss->ss7.shader_chanel_select_r = HSW_SCS_RED; 139903b705cfSriastradh ss->ss7.shader_chanel_select_g = HSW_SCS_GREEN; 140003b705cfSriastradh ss->ss7.shader_chanel_select_b = HSW_SCS_BLUE; 140103b705cfSriastradh ss->ss7.shader_chanel_select_a = HSW_SCS_ALPHA; 140203b705cfSriastradh } 140303b705cfSriastradh 140403b705cfSriastradh dri_bo_emit_reloc(intel->surface_bo, 140503b705cfSriastradh read_domains, write_domain, 140603b705cfSriastradh 0, 140703b705cfSriastradh intel->surface_used + 140803b705cfSriastradh offsetof(struct gen7_surface_state, ss1), 140903b705cfSriastradh priv->bo); 141003b705cfSriastradh 141103b705cfSriastradh offset = intel->surface_used; 141203b705cfSriastradh intel->surface_used += SURFACE_STATE_PADDED_SIZE; 141303b705cfSriastradh 141403b705cfSriastradh return offset; 141503b705cfSriastradh} 141603b705cfSriastradh 141703b705cfSriastradhstatic inline int 141803b705cfSriastradhi965_set_picture_surface_state(intel_screen_private *intel, 141903b705cfSriastradh PicturePtr picture, PixmapPtr pixmap, 142003b705cfSriastradh Bool is_dst) 142103b705cfSriastradh{ 142203b705cfSriastradh if (INTEL_INFO(intel)->gen < 070) 142303b705cfSriastradh return gen4_set_picture_surface_state(intel, picture, pixmap, is_dst); 142403b705cfSriastradh return gen7_set_picture_surface_state(intel, picture, pixmap, is_dst); 142503b705cfSriastradh} 142603b705cfSriastradh 142703b705cfSriastradhstatic void gen4_composite_vertex_elements(struct intel_screen_private *intel) 142803b705cfSriastradh{ 142903b705cfSriastradh struct gen4_render_state *render_state = intel->gen4_render_state; 143003b705cfSriastradh gen4_composite_op *composite_op = &render_state->composite_op; 143103b705cfSriastradh Bool has_mask = intel->render_mask != NULL; 143203b705cfSriastradh Bool is_affine = composite_op->is_affine; 143303b705cfSriastradh /* 143403b705cfSriastradh * number of extra parameters per vertex 143503b705cfSriastradh */ 143603b705cfSriastradh int nelem = has_mask ? 2 : 1; 143703b705cfSriastradh /* 143803b705cfSriastradh * size of extra parameters: 143903b705cfSriastradh * 3 for homogenous (xyzw) 144003b705cfSriastradh * 2 for cartesian (xy) 144103b705cfSriastradh */ 144203b705cfSriastradh int selem = is_affine ? 2 : 3; 144303b705cfSriastradh uint32_t w_component; 144403b705cfSriastradh uint32_t src_format; 144503b705cfSriastradh int id; 144603b705cfSriastradh 144703b705cfSriastradh id = has_mask << 1 | is_affine; 144803b705cfSriastradh 144903b705cfSriastradh if (composite_op->vertex_id == id) 145003b705cfSriastradh return; 145103b705cfSriastradh 145203b705cfSriastradh composite_op->vertex_id = id; 145303b705cfSriastradh 145403b705cfSriastradh if (is_affine) { 145503b705cfSriastradh src_format = BRW_SURFACEFORMAT_R32G32_FLOAT; 145603b705cfSriastradh w_component = BRW_VFCOMPONENT_STORE_1_FLT; 145703b705cfSriastradh } else { 145803b705cfSriastradh src_format = BRW_SURFACEFORMAT_R32G32B32_FLOAT; 145903b705cfSriastradh w_component = BRW_VFCOMPONENT_STORE_SRC; 146003b705cfSriastradh } 146103b705cfSriastradh 146203b705cfSriastradh if (IS_GEN5(intel)) { 146303b705cfSriastradh /* 146403b705cfSriastradh * The reason to add this extra vertex element in the header is that 146503b705cfSriastradh * Ironlake has different vertex header definition and origin method to 146603b705cfSriastradh * set destination element offset doesn't exist anymore, which means 146703b705cfSriastradh * hardware requires a predefined vertex element layout. 146803b705cfSriastradh * 146903b705cfSriastradh * haihao proposed this approach to fill the first vertex element, so 147003b705cfSriastradh * origin layout for Gen4 doesn't need to change, and origin shader 147103b705cfSriastradh * programs behavior is also kept. 147203b705cfSriastradh * 147303b705cfSriastradh * I think this is not bad. - zhenyu 147403b705cfSriastradh */ 147503b705cfSriastradh 147603b705cfSriastradh OUT_BATCH(BRW_3DSTATE_VERTEX_ELEMENTS | 147703b705cfSriastradh ((2 * (2 + nelem)) - 1)); 147803b705cfSriastradh OUT_BATCH((id << VE0_VERTEX_BUFFER_INDEX_SHIFT) | VE0_VALID | 147903b705cfSriastradh (BRW_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) | 148003b705cfSriastradh (0 << VE0_OFFSET_SHIFT)); 148103b705cfSriastradh 148203b705cfSriastradh OUT_BATCH((BRW_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_0_SHIFT) | 148303b705cfSriastradh (BRW_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_1_SHIFT) | 148403b705cfSriastradh (BRW_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_2_SHIFT) | 148503b705cfSriastradh (BRW_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_3_SHIFT)); 148603b705cfSriastradh } else { 148703b705cfSriastradh /* Set up our vertex elements, sourced from the single vertex buffer. 148803b705cfSriastradh * that will be set up later. 148903b705cfSriastradh */ 149003b705cfSriastradh OUT_BATCH(BRW_3DSTATE_VERTEX_ELEMENTS | 149103b705cfSriastradh ((2 * (1 + nelem)) - 1)); 149203b705cfSriastradh } 149303b705cfSriastradh 149403b705cfSriastradh /* x,y */ 149503b705cfSriastradh OUT_BATCH((id << VE0_VERTEX_BUFFER_INDEX_SHIFT) | VE0_VALID | 149603b705cfSriastradh (BRW_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) | 149703b705cfSriastradh (0 << VE0_OFFSET_SHIFT)); 149803b705cfSriastradh 149903b705cfSriastradh if (IS_GEN5(intel)) 150003b705cfSriastradh OUT_BATCH((BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) | 150103b705cfSriastradh (BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) | 150203b705cfSriastradh (BRW_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT) | 150303b705cfSriastradh (BRW_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT)); 150403b705cfSriastradh else 150503b705cfSriastradh OUT_BATCH((BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) | 150603b705cfSriastradh (BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) | 150703b705cfSriastradh (BRW_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT) | 150803b705cfSriastradh (BRW_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT) | 150903b705cfSriastradh (4 << VE1_DESTINATION_ELEMENT_OFFSET_SHIFT)); 151003b705cfSriastradh /* u0, v0, w0 */ 151103b705cfSriastradh OUT_BATCH((id << VE0_VERTEX_BUFFER_INDEX_SHIFT) | VE0_VALID | 151203b705cfSriastradh (src_format << VE0_FORMAT_SHIFT) | 151303b705cfSriastradh ((2 * 4) << VE0_OFFSET_SHIFT)); /* offset vb in bytes */ 151403b705cfSriastradh 151503b705cfSriastradh if (IS_GEN5(intel)) 151603b705cfSriastradh OUT_BATCH((BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) | 151703b705cfSriastradh (BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) | 151803b705cfSriastradh (w_component << VE1_VFCOMPONENT_2_SHIFT) | 151903b705cfSriastradh (BRW_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT)); 152003b705cfSriastradh else 152103b705cfSriastradh OUT_BATCH((BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) | 152203b705cfSriastradh (BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) | 152303b705cfSriastradh (w_component << VE1_VFCOMPONENT_2_SHIFT) | 152403b705cfSriastradh (BRW_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT) | 152503b705cfSriastradh ((4 + 4) << VE1_DESTINATION_ELEMENT_OFFSET_SHIFT)); /* VUE offset in dwords */ 152603b705cfSriastradh /* u1, v1, w1 */ 152703b705cfSriastradh if (has_mask) { 152803b705cfSriastradh OUT_BATCH((id << VE0_VERTEX_BUFFER_INDEX_SHIFT) | VE0_VALID | 152903b705cfSriastradh (src_format << VE0_FORMAT_SHIFT) | 153003b705cfSriastradh (((2 + selem) * 4) << VE0_OFFSET_SHIFT)); /* vb offset in bytes */ 153103b705cfSriastradh 153203b705cfSriastradh if (IS_GEN5(intel)) 153303b705cfSriastradh OUT_BATCH((BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) | 153403b705cfSriastradh (BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) | 153503b705cfSriastradh (w_component << VE1_VFCOMPONENT_2_SHIFT) | 153603b705cfSriastradh (BRW_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT)); 153703b705cfSriastradh else 153803b705cfSriastradh OUT_BATCH((BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) | 153903b705cfSriastradh (BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) | 154003b705cfSriastradh (w_component << VE1_VFCOMPONENT_2_SHIFT) | 154103b705cfSriastradh (BRW_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT) | 154203b705cfSriastradh ((4 + 4 + 4) << VE1_DESTINATION_ELEMENT_OFFSET_SHIFT)); /* VUE offset in dwords */ 154303b705cfSriastradh } 154403b705cfSriastradh} 154503b705cfSriastradh 154603b705cfSriastradhstatic void i965_emit_composite_state(struct intel_screen_private *intel) 154703b705cfSriastradh{ 154803b705cfSriastradh struct gen4_render_state *render_state = intel->gen4_render_state; 154903b705cfSriastradh gen4_composite_op *composite_op = &render_state->composite_op; 155003b705cfSriastradh int op = composite_op->op; 155103b705cfSriastradh PicturePtr mask_picture = intel->render_mask_picture; 155203b705cfSriastradh PicturePtr dest_picture = intel->render_dest_picture; 155303b705cfSriastradh PixmapPtr mask = intel->render_mask; 155403b705cfSriastradh PixmapPtr dest = intel->render_dest; 155503b705cfSriastradh sampler_state_filter_t src_filter = composite_op->src_filter; 155603b705cfSriastradh sampler_state_filter_t mask_filter = composite_op->mask_filter; 155703b705cfSriastradh sampler_state_extend_t src_extend = composite_op->src_extend; 155803b705cfSriastradh sampler_state_extend_t mask_extend = composite_op->mask_extend; 155903b705cfSriastradh uint32_t src_blend, dst_blend; 156003b705cfSriastradh 156103b705cfSriastradh intel->needs_render_state_emit = FALSE; 156203b705cfSriastradh 156303b705cfSriastradh /* Begin the long sequence of commands needed to set up the 3D 156403b705cfSriastradh * rendering pipe 156503b705cfSriastradh */ 156603b705cfSriastradh 156703b705cfSriastradh if (intel->needs_3d_invariant) { 156803b705cfSriastradh if (IS_GEN5(intel)) { 156903b705cfSriastradh /* Ironlake errata workaround: Before disabling the clipper, 157003b705cfSriastradh * you have to MI_FLUSH to get the pipeline idle. 157103b705cfSriastradh */ 157203b705cfSriastradh OUT_BATCH(MI_FLUSH | MI_INHIBIT_RENDER_CACHE_FLUSH); 157303b705cfSriastradh } 157403b705cfSriastradh 157503b705cfSriastradh /* Match Mesa driver setup */ 157603b705cfSriastradh if (INTEL_INFO(intel)->gen >= 045) 157703b705cfSriastradh OUT_BATCH(NEW_PIPELINE_SELECT | PIPELINE_SELECT_3D); 157803b705cfSriastradh else 157903b705cfSriastradh OUT_BATCH(BRW_PIPELINE_SELECT | PIPELINE_SELECT_3D); 158003b705cfSriastradh 158103b705cfSriastradh /* Set system instruction pointer */ 158203b705cfSriastradh OUT_BATCH(BRW_STATE_SIP | 0); 158303b705cfSriastradh OUT_BATCH(0); 158403b705cfSriastradh 158503b705cfSriastradh intel->needs_3d_invariant = FALSE; 158603b705cfSriastradh } 158703b705cfSriastradh 158803b705cfSriastradh if (intel->surface_reloc == 0) { 158903b705cfSriastradh /* Zero out the two base address registers so all offsets are 159003b705cfSriastradh * absolute. 159103b705cfSriastradh */ 159203b705cfSriastradh if (IS_GEN5(intel)) { 159303b705cfSriastradh OUT_BATCH(BRW_STATE_BASE_ADDRESS | 6); 159403b705cfSriastradh OUT_BATCH(0 | BASE_ADDRESS_MODIFY); /* Generate state base address */ 159503b705cfSriastradh intel->surface_reloc = intel->batch_used; 159603b705cfSriastradh intel_batch_emit_dword(intel, 159703b705cfSriastradh intel->surface_bo->offset | BASE_ADDRESS_MODIFY); 159803b705cfSriastradh OUT_BATCH(0 | BASE_ADDRESS_MODIFY); /* media base addr, don't care */ 159903b705cfSriastradh OUT_BATCH(0 | BASE_ADDRESS_MODIFY); /* Instruction base address */ 160003b705cfSriastradh /* general state max addr, disabled */ 160103b705cfSriastradh OUT_BATCH(0 | BASE_ADDRESS_MODIFY); 160203b705cfSriastradh /* media object state max addr, disabled */ 160303b705cfSriastradh OUT_BATCH(0 | BASE_ADDRESS_MODIFY); 160403b705cfSriastradh /* Instruction max addr, disabled */ 160503b705cfSriastradh OUT_BATCH(0 | BASE_ADDRESS_MODIFY); 160603b705cfSriastradh } else { 160703b705cfSriastradh OUT_BATCH(BRW_STATE_BASE_ADDRESS | 4); 160803b705cfSriastradh OUT_BATCH(0 | BASE_ADDRESS_MODIFY); /* Generate state base address */ 160903b705cfSriastradh intel->surface_reloc = intel->batch_used; 161003b705cfSriastradh intel_batch_emit_dword(intel, 161103b705cfSriastradh intel->surface_bo->offset | BASE_ADDRESS_MODIFY); 161203b705cfSriastradh OUT_BATCH(0 | BASE_ADDRESS_MODIFY); /* media base addr, don't care */ 161303b705cfSriastradh /* general state max addr, disabled */ 161403b705cfSriastradh OUT_BATCH(0 | BASE_ADDRESS_MODIFY); 161503b705cfSriastradh /* media object state max addr, disabled */ 161603b705cfSriastradh OUT_BATCH(0 | BASE_ADDRESS_MODIFY); 161703b705cfSriastradh } 161803b705cfSriastradh } 161903b705cfSriastradh 162003b705cfSriastradh i965_get_blend_cntl(op, mask_picture, dest_picture->format, 162103b705cfSriastradh &src_blend, &dst_blend); 162203b705cfSriastradh 162303b705cfSriastradh /* Binding table pointers */ 162403b705cfSriastradh OUT_BATCH(BRW_3DSTATE_BINDING_TABLE_POINTERS | 4); 162503b705cfSriastradh OUT_BATCH(0); /* vs */ 162603b705cfSriastradh OUT_BATCH(0); /* gs */ 162703b705cfSriastradh OUT_BATCH(0); /* clip */ 162803b705cfSriastradh OUT_BATCH(0); /* sf */ 162903b705cfSriastradh /* Only the PS uses the binding table */ 163003b705cfSriastradh OUT_BATCH(intel->surface_table); 163103b705cfSriastradh 163203b705cfSriastradh /* The drawing rectangle clipping is always on. Set it to values that 163303b705cfSriastradh * shouldn't do any clipping. 163403b705cfSriastradh */ 163503b705cfSriastradh OUT_BATCH(BRW_3DSTATE_DRAWING_RECTANGLE | 2); 163603b705cfSriastradh OUT_BATCH(0x00000000); /* ymin, xmin */ 163703b705cfSriastradh OUT_BATCH(DRAW_YMAX(dest->drawable.height - 1) | 163803b705cfSriastradh DRAW_XMAX(dest->drawable.width - 1)); /* ymax, xmax */ 163903b705cfSriastradh OUT_BATCH(0x00000000); /* yorigin, xorigin */ 164003b705cfSriastradh 164103b705cfSriastradh /* skip the depth buffer */ 164203b705cfSriastradh /* skip the polygon stipple */ 164303b705cfSriastradh /* skip the polygon stipple offset */ 164403b705cfSriastradh /* skip the line stipple */ 164503b705cfSriastradh 164603b705cfSriastradh /* Set the pointers to the 3d pipeline state */ 164703b705cfSriastradh OUT_BATCH(BRW_3DSTATE_PIPELINED_POINTERS | 5); 164803b705cfSriastradh OUT_RELOC(render_state->vs_state_bo, 164903b705cfSriastradh I915_GEM_DOMAIN_INSTRUCTION, 0, 0); 165003b705cfSriastradh OUT_BATCH(BRW_GS_DISABLE); /* disable GS, resulting in passthrough */ 165103b705cfSriastradh OUT_BATCH(BRW_CLIP_DISABLE); /* disable CLIP, resulting in passthrough */ 165203b705cfSriastradh if (mask) { 165303b705cfSriastradh OUT_RELOC(render_state->sf_mask_state_bo, 165403b705cfSriastradh I915_GEM_DOMAIN_INSTRUCTION, 0, 0); 165503b705cfSriastradh } else { 165603b705cfSriastradh OUT_RELOC(render_state->sf_state_bo, 165703b705cfSriastradh I915_GEM_DOMAIN_INSTRUCTION, 0, 0); 165803b705cfSriastradh } 165903b705cfSriastradh 166003b705cfSriastradh OUT_RELOC(render_state->wm_state_bo[composite_op->wm_kernel] 166103b705cfSriastradh [src_filter][src_extend] 166203b705cfSriastradh [mask_filter][mask_extend], 166303b705cfSriastradh I915_GEM_DOMAIN_INSTRUCTION, 0, 0); 166403b705cfSriastradh 166503b705cfSriastradh OUT_RELOC(render_state->cc_state_bo, 166603b705cfSriastradh I915_GEM_DOMAIN_INSTRUCTION, 0, 166703b705cfSriastradh offsetof(struct gen4_cc_unit_state, 166803b705cfSriastradh cc_state[src_blend][dst_blend])); 166903b705cfSriastradh 167003b705cfSriastradh { 167103b705cfSriastradh int urb_vs_start, urb_vs_size; 167203b705cfSriastradh int urb_gs_start, urb_gs_size; 167303b705cfSriastradh int urb_clip_start, urb_clip_size; 167403b705cfSriastradh int urb_sf_start, urb_sf_size; 167503b705cfSriastradh int urb_cs_start, urb_cs_size; 167603b705cfSriastradh 167703b705cfSriastradh urb_vs_start = 0; 167803b705cfSriastradh urb_vs_size = URB_VS_ENTRIES * URB_VS_ENTRY_SIZE; 167903b705cfSriastradh urb_gs_start = urb_vs_start + urb_vs_size; 168003b705cfSriastradh urb_gs_size = URB_GS_ENTRIES * URB_GS_ENTRY_SIZE; 168103b705cfSriastradh urb_clip_start = urb_gs_start + urb_gs_size; 168203b705cfSriastradh urb_clip_size = URB_CLIP_ENTRIES * URB_CLIP_ENTRY_SIZE; 168303b705cfSriastradh urb_sf_start = urb_clip_start + urb_clip_size; 168403b705cfSriastradh urb_sf_size = URB_SF_ENTRIES * URB_SF_ENTRY_SIZE; 168503b705cfSriastradh urb_cs_start = urb_sf_start + urb_sf_size; 168603b705cfSriastradh urb_cs_size = URB_CS_ENTRIES * URB_CS_ENTRY_SIZE; 168703b705cfSriastradh 168803b705cfSriastradh /* Erratum (Vol 1a, p32): 168903b705cfSriastradh * URB_FENCE must not cross a cache-line (64 bytes). 169003b705cfSriastradh */ 169103b705cfSriastradh if ((intel->batch_used & 15) > (16 - 3)) { 169203b705cfSriastradh int cnt = 16 - (intel->batch_used & 15); 169303b705cfSriastradh while (cnt--) 169403b705cfSriastradh OUT_BATCH(MI_NOOP); 169503b705cfSriastradh } 169603b705cfSriastradh 169703b705cfSriastradh OUT_BATCH(BRW_URB_FENCE | 169803b705cfSriastradh UF0_CS_REALLOC | 169903b705cfSriastradh UF0_SF_REALLOC | 170003b705cfSriastradh UF0_CLIP_REALLOC | 170103b705cfSriastradh UF0_GS_REALLOC | 170203b705cfSriastradh UF0_VS_REALLOC | 170303b705cfSriastradh 1); 170403b705cfSriastradh OUT_BATCH(((urb_clip_start + urb_clip_size) << UF1_CLIP_FENCE_SHIFT) | 170503b705cfSriastradh ((urb_gs_start + urb_gs_size) << UF1_GS_FENCE_SHIFT) | 170603b705cfSriastradh ((urb_vs_start + urb_vs_size) << UF1_VS_FENCE_SHIFT)); 170703b705cfSriastradh OUT_BATCH(((urb_cs_start + urb_cs_size) << UF2_CS_FENCE_SHIFT) | 170803b705cfSriastradh ((urb_sf_start + urb_sf_size) << UF2_SF_FENCE_SHIFT)); 170903b705cfSriastradh 171003b705cfSriastradh /* Constant buffer state */ 171103b705cfSriastradh OUT_BATCH(BRW_CS_URB_STATE | 0); 171203b705cfSriastradh OUT_BATCH(((URB_CS_ENTRY_SIZE - 1) << 4) | 171303b705cfSriastradh (URB_CS_ENTRIES << 0)); 171403b705cfSriastradh } 171503b705cfSriastradh 171603b705cfSriastradh gen4_composite_vertex_elements(intel); 171703b705cfSriastradh} 171803b705cfSriastradh 171903b705cfSriastradh/** 172003b705cfSriastradh * Returns whether the current set of composite state plus vertex buffer is 172103b705cfSriastradh * expected to fit in the aperture. 172203b705cfSriastradh */ 172303b705cfSriastradhstatic Bool i965_composite_check_aperture(intel_screen_private *intel) 172403b705cfSriastradh{ 172503b705cfSriastradh struct gen4_render_state *render_state = intel->gen4_render_state; 172603b705cfSriastradh gen4_composite_op *composite_op = &render_state->composite_op; 172703b705cfSriastradh drm_intel_bo *bo_table[] = { 172803b705cfSriastradh intel->batch_bo, 172903b705cfSriastradh intel->vertex_bo, 173003b705cfSriastradh intel->surface_bo, 173103b705cfSriastradh render_state->vs_state_bo, 173203b705cfSriastradh render_state->sf_state_bo, 173303b705cfSriastradh render_state->sf_mask_state_bo, 173403b705cfSriastradh render_state->wm_state_bo[composite_op->wm_kernel] 173503b705cfSriastradh [composite_op->src_filter] 173603b705cfSriastradh [composite_op->src_extend] 173703b705cfSriastradh [composite_op->mask_filter] 173803b705cfSriastradh [composite_op->mask_extend], 173903b705cfSriastradh render_state->cc_state_bo, 174003b705cfSriastradh }; 174103b705cfSriastradh drm_intel_bo *gen6_bo_table[] = { 174203b705cfSriastradh intel->batch_bo, 174303b705cfSriastradh intel->vertex_bo, 174403b705cfSriastradh intel->surface_bo, 174503b705cfSriastradh render_state->wm_kernel_bo[composite_op->wm_kernel], 174603b705cfSriastradh render_state->ps_sampler_state_bo[composite_op->src_filter] 174703b705cfSriastradh [composite_op->src_extend] 174803b705cfSriastradh [composite_op->mask_filter] 174903b705cfSriastradh [composite_op->mask_extend], 175003b705cfSriastradh render_state->cc_vp_bo, 175103b705cfSriastradh render_state->cc_state_bo, 175203b705cfSriastradh render_state->gen6_blend_bo, 175303b705cfSriastradh render_state->gen6_depth_stencil_bo, 175403b705cfSriastradh }; 175503b705cfSriastradh 175603b705cfSriastradh if (INTEL_INFO(intel)->gen >= 060) 175703b705cfSriastradh return drm_intel_bufmgr_check_aperture_space(gen6_bo_table, 175803b705cfSriastradh ARRAY_SIZE(gen6_bo_table)) == 0; 175903b705cfSriastradh else 176003b705cfSriastradh return drm_intel_bufmgr_check_aperture_space(bo_table, 176103b705cfSriastradh ARRAY_SIZE(bo_table)) == 0; 176203b705cfSriastradh} 176303b705cfSriastradh 176403b705cfSriastradhstatic void i965_surface_flush(struct intel_screen_private *intel) 176503b705cfSriastradh{ 176603b705cfSriastradh int ret; 176703b705cfSriastradh 176803b705cfSriastradh ret = drm_intel_bo_subdata(intel->surface_bo, 176903b705cfSriastradh 0, intel->surface_used, 177003b705cfSriastradh intel->surface_data); 177103b705cfSriastradh assert(ret == 0); 177203b705cfSriastradh intel->surface_used = 0; 177303b705cfSriastradh 177403b705cfSriastradh assert (intel->surface_reloc != 0); 177503b705cfSriastradh drm_intel_bo_emit_reloc(intel->batch_bo, 177603b705cfSriastradh intel->surface_reloc * 4, 177703b705cfSriastradh intel->surface_bo, BASE_ADDRESS_MODIFY, 177803b705cfSriastradh I915_GEM_DOMAIN_INSTRUCTION, 0); 177903b705cfSriastradh intel->surface_reloc = 0; 178003b705cfSriastradh 178103b705cfSriastradh drm_intel_bo_unreference(intel->surface_bo); 178203b705cfSriastradh intel->surface_bo = 178303b705cfSriastradh drm_intel_bo_alloc(intel->bufmgr, "surface data", 178403b705cfSriastradh sizeof(intel->surface_data), 4096); 178503b705cfSriastradh assert(intel->surface_bo); 178603b705cfSriastradh 178703b705cfSriastradh return; 178803b705cfSriastradh (void)ret; 178903b705cfSriastradh} 179003b705cfSriastradh 179103b705cfSriastradhstatic void 179203b705cfSriastradhi965_emit_composite_primitive_identity_source(intel_screen_private *intel, 179303b705cfSriastradh int srcX, int srcY, 179403b705cfSriastradh int maskX, int maskY, 179503b705cfSriastradh int dstX, int dstY, 179603b705cfSriastradh int w, int h) 179703b705cfSriastradh{ 179803b705cfSriastradh OUT_VERTEX(dstX + w); 179903b705cfSriastradh OUT_VERTEX(dstY + h); 180003b705cfSriastradh OUT_VERTEX((srcX + w) * intel->scale_units[0][0]); 180103b705cfSriastradh OUT_VERTEX((srcY + h) * intel->scale_units[0][1]); 180203b705cfSriastradh 180303b705cfSriastradh OUT_VERTEX(dstX); 180403b705cfSriastradh OUT_VERTEX(dstY + h); 180503b705cfSriastradh OUT_VERTEX(srcX * intel->scale_units[0][0]); 180603b705cfSriastradh OUT_VERTEX((srcY + h) * intel->scale_units[0][1]); 180703b705cfSriastradh 180803b705cfSriastradh OUT_VERTEX(dstX); 180903b705cfSriastradh OUT_VERTEX(dstY); 181003b705cfSriastradh OUT_VERTEX(srcX * intel->scale_units[0][0]); 181103b705cfSriastradh OUT_VERTEX(srcY * intel->scale_units[0][1]); 181203b705cfSriastradh} 181303b705cfSriastradh 181403b705cfSriastradhstatic void 181503b705cfSriastradhi965_emit_composite_primitive_affine_source(intel_screen_private *intel, 181603b705cfSriastradh int srcX, int srcY, 181703b705cfSriastradh int maskX, int maskY, 181803b705cfSriastradh int dstX, int dstY, 181903b705cfSriastradh int w, int h) 182003b705cfSriastradh{ 182103b705cfSriastradh float src_x[3], src_y[3]; 182203b705cfSriastradh 182313496ba1Ssnj if (!intel_uxa_get_transformed_coordinates(srcX, srcY, 182403b705cfSriastradh intel->transform[0], 182503b705cfSriastradh &src_x[0], 182603b705cfSriastradh &src_y[0])) 182703b705cfSriastradh return; 182803b705cfSriastradh 182913496ba1Ssnj if (!intel_uxa_get_transformed_coordinates(srcX, srcY + h, 183003b705cfSriastradh intel->transform[0], 183103b705cfSriastradh &src_x[1], 183203b705cfSriastradh &src_y[1])) 183303b705cfSriastradh return; 183403b705cfSriastradh 183513496ba1Ssnj if (!intel_uxa_get_transformed_coordinates(srcX + w, srcY + h, 183603b705cfSriastradh intel->transform[0], 183703b705cfSriastradh &src_x[2], 183803b705cfSriastradh &src_y[2])) 183903b705cfSriastradh return; 184003b705cfSriastradh 184103b705cfSriastradh OUT_VERTEX(dstX + w); 184203b705cfSriastradh OUT_VERTEX(dstY + h); 184303b705cfSriastradh OUT_VERTEX(src_x[2] * intel->scale_units[0][0]); 184403b705cfSriastradh OUT_VERTEX(src_y[2] * intel->scale_units[0][1]); 184503b705cfSriastradh 184603b705cfSriastradh OUT_VERTEX(dstX); 184703b705cfSriastradh OUT_VERTEX(dstY + h); 184803b705cfSriastradh OUT_VERTEX(src_x[1] * intel->scale_units[0][0]); 184903b705cfSriastradh OUT_VERTEX(src_y[1] * intel->scale_units[0][1]); 185003b705cfSriastradh 185103b705cfSriastradh OUT_VERTEX(dstX); 185203b705cfSriastradh OUT_VERTEX(dstY); 185303b705cfSriastradh OUT_VERTEX(src_x[0] * intel->scale_units[0][0]); 185403b705cfSriastradh OUT_VERTEX(src_y[0] * intel->scale_units[0][1]); 185503b705cfSriastradh} 185603b705cfSriastradh 185703b705cfSriastradhstatic void 185803b705cfSriastradhi965_emit_composite_primitive_identity_source_mask(intel_screen_private *intel, 185903b705cfSriastradh int srcX, int srcY, 186003b705cfSriastradh int maskX, int maskY, 186103b705cfSriastradh int dstX, int dstY, 186203b705cfSriastradh int w, int h) 186303b705cfSriastradh{ 186403b705cfSriastradh OUT_VERTEX(dstX + w); 186503b705cfSriastradh OUT_VERTEX(dstY + h); 186603b705cfSriastradh OUT_VERTEX((srcX + w) * intel->scale_units[0][0]); 186703b705cfSriastradh OUT_VERTEX((srcY + h) * intel->scale_units[0][1]); 186803b705cfSriastradh OUT_VERTEX((maskX + w) * intel->scale_units[1][0]); 186903b705cfSriastradh OUT_VERTEX((maskY + h) * intel->scale_units[1][1]); 187003b705cfSriastradh 187103b705cfSriastradh OUT_VERTEX(dstX); 187203b705cfSriastradh OUT_VERTEX(dstY + h); 187303b705cfSriastradh OUT_VERTEX(srcX * intel->scale_units[0][0]); 187403b705cfSriastradh OUT_VERTEX((srcY + h) * intel->scale_units[0][1]); 187503b705cfSriastradh OUT_VERTEX(maskX * intel->scale_units[1][0]); 187603b705cfSriastradh OUT_VERTEX((maskY + h) * intel->scale_units[1][1]); 187703b705cfSriastradh 187803b705cfSriastradh OUT_VERTEX(dstX); 187903b705cfSriastradh OUT_VERTEX(dstY); 188003b705cfSriastradh OUT_VERTEX(srcX * intel->scale_units[0][0]); 188103b705cfSriastradh OUT_VERTEX(srcY * intel->scale_units[0][1]); 188203b705cfSriastradh OUT_VERTEX(maskX * intel->scale_units[1][0]); 188303b705cfSriastradh OUT_VERTEX(maskY * intel->scale_units[1][1]); 188403b705cfSriastradh} 188503b705cfSriastradh 188603b705cfSriastradhstatic void 188703b705cfSriastradhi965_emit_composite_primitive(intel_screen_private *intel, 188803b705cfSriastradh int srcX, int srcY, 188903b705cfSriastradh int maskX, int maskY, 189003b705cfSriastradh int dstX, int dstY, 189103b705cfSriastradh int w, int h) 189203b705cfSriastradh{ 189303b705cfSriastradh float src_x[3], src_y[3], src_w[3], mask_x[3], mask_y[3], mask_w[3]; 189403b705cfSriastradh Bool is_affine = intel->gen4_render_state->composite_op.is_affine; 189503b705cfSriastradh 189603b705cfSriastradh if (is_affine) { 189713496ba1Ssnj if (!intel_uxa_get_transformed_coordinates(srcX, srcY, 189803b705cfSriastradh intel->transform[0], 189903b705cfSriastradh &src_x[0], 190003b705cfSriastradh &src_y[0])) 190103b705cfSriastradh return; 190203b705cfSriastradh 190313496ba1Ssnj if (!intel_uxa_get_transformed_coordinates(srcX, srcY + h, 190403b705cfSriastradh intel->transform[0], 190503b705cfSriastradh &src_x[1], 190603b705cfSriastradh &src_y[1])) 190703b705cfSriastradh return; 190803b705cfSriastradh 190913496ba1Ssnj if (!intel_uxa_get_transformed_coordinates(srcX + w, srcY + h, 191003b705cfSriastradh intel->transform[0], 191103b705cfSriastradh &src_x[2], 191203b705cfSriastradh &src_y[2])) 191303b705cfSriastradh return; 191403b705cfSriastradh } else { 191513496ba1Ssnj if (!intel_uxa_get_transformed_coordinates_3d(srcX, srcY, 191603b705cfSriastradh intel->transform[0], 191703b705cfSriastradh &src_x[0], 191803b705cfSriastradh &src_y[0], 191903b705cfSriastradh &src_w[0])) 192003b705cfSriastradh return; 192103b705cfSriastradh 192213496ba1Ssnj if (!intel_uxa_get_transformed_coordinates_3d(srcX, srcY + h, 192303b705cfSriastradh intel->transform[0], 192403b705cfSriastradh &src_x[1], 192503b705cfSriastradh &src_y[1], 192603b705cfSriastradh &src_w[1])) 192703b705cfSriastradh return; 192803b705cfSriastradh 192913496ba1Ssnj if (!intel_uxa_get_transformed_coordinates_3d(srcX + w, srcY + h, 193003b705cfSriastradh intel->transform[0], 193103b705cfSriastradh &src_x[2], 193203b705cfSriastradh &src_y[2], 193303b705cfSriastradh &src_w[2])) 193403b705cfSriastradh return; 193503b705cfSriastradh } 193603b705cfSriastradh 193703b705cfSriastradh if (intel->render_mask) { 193803b705cfSriastradh if (is_affine) { 193913496ba1Ssnj if (!intel_uxa_get_transformed_coordinates(maskX, maskY, 194003b705cfSriastradh intel->transform[1], 194103b705cfSriastradh &mask_x[0], 194203b705cfSriastradh &mask_y[0])) 194303b705cfSriastradh return; 194403b705cfSriastradh 194513496ba1Ssnj if (!intel_uxa_get_transformed_coordinates(maskX, maskY + h, 194603b705cfSriastradh intel->transform[1], 194703b705cfSriastradh &mask_x[1], 194803b705cfSriastradh &mask_y[1])) 194903b705cfSriastradh return; 195003b705cfSriastradh 195113496ba1Ssnj if (!intel_uxa_get_transformed_coordinates(maskX + w, maskY + h, 195203b705cfSriastradh intel->transform[1], 195303b705cfSriastradh &mask_x[2], 195403b705cfSriastradh &mask_y[2])) 195503b705cfSriastradh return; 195603b705cfSriastradh } else { 195713496ba1Ssnj if (!intel_uxa_get_transformed_coordinates_3d(maskX, maskY, 195803b705cfSriastradh intel->transform[1], 195903b705cfSriastradh &mask_x[0], 196003b705cfSriastradh &mask_y[0], 196103b705cfSriastradh &mask_w[0])) 196203b705cfSriastradh return; 196303b705cfSriastradh 196413496ba1Ssnj if (!intel_uxa_get_transformed_coordinates_3d(maskX, maskY + h, 196503b705cfSriastradh intel->transform[1], 196603b705cfSriastradh &mask_x[1], 196703b705cfSriastradh &mask_y[1], 196803b705cfSriastradh &mask_w[1])) 196903b705cfSriastradh return; 197003b705cfSriastradh 197113496ba1Ssnj if (!intel_uxa_get_transformed_coordinates_3d(maskX + w, maskY + h, 197203b705cfSriastradh intel->transform[1], 197303b705cfSriastradh &mask_x[2], 197403b705cfSriastradh &mask_y[2], 197503b705cfSriastradh &mask_w[2])) 197603b705cfSriastradh return; 197703b705cfSriastradh } 197803b705cfSriastradh } 197903b705cfSriastradh 198003b705cfSriastradh OUT_VERTEX(dstX + w); 198103b705cfSriastradh OUT_VERTEX(dstY + h); 198203b705cfSriastradh OUT_VERTEX(src_x[2] * intel->scale_units[0][0]); 198303b705cfSriastradh OUT_VERTEX(src_y[2] * intel->scale_units[0][1]); 198403b705cfSriastradh if (!is_affine) 198503b705cfSriastradh OUT_VERTEX(src_w[2]); 198603b705cfSriastradh if (intel->render_mask) { 198703b705cfSriastradh OUT_VERTEX(mask_x[2] * intel->scale_units[1][0]); 198803b705cfSriastradh OUT_VERTEX(mask_y[2] * intel->scale_units[1][1]); 198903b705cfSriastradh if (!is_affine) 199003b705cfSriastradh OUT_VERTEX(mask_w[2]); 199103b705cfSriastradh } 199203b705cfSriastradh 199303b705cfSriastradh OUT_VERTEX(dstX); 199403b705cfSriastradh OUT_VERTEX(dstY + h); 199503b705cfSriastradh OUT_VERTEX(src_x[1] * intel->scale_units[0][0]); 199603b705cfSriastradh OUT_VERTEX(src_y[1] * intel->scale_units[0][1]); 199703b705cfSriastradh if (!is_affine) 199803b705cfSriastradh OUT_VERTEX(src_w[1]); 199903b705cfSriastradh if (intel->render_mask) { 200003b705cfSriastradh OUT_VERTEX(mask_x[1] * intel->scale_units[1][0]); 200103b705cfSriastradh OUT_VERTEX(mask_y[1] * intel->scale_units[1][1]); 200203b705cfSriastradh if (!is_affine) 200303b705cfSriastradh OUT_VERTEX(mask_w[1]); 200403b705cfSriastradh } 200503b705cfSriastradh 200603b705cfSriastradh OUT_VERTEX(dstX); 200703b705cfSriastradh OUT_VERTEX(dstY); 200803b705cfSriastradh OUT_VERTEX(src_x[0] * intel->scale_units[0][0]); 200903b705cfSriastradh OUT_VERTEX(src_y[0] * intel->scale_units[0][1]); 201003b705cfSriastradh if (!is_affine) 201103b705cfSriastradh OUT_VERTEX(src_w[0]); 201203b705cfSriastradh if (intel->render_mask) { 201303b705cfSriastradh OUT_VERTEX(mask_x[0] * intel->scale_units[1][0]); 201403b705cfSriastradh OUT_VERTEX(mask_y[0] * intel->scale_units[1][1]); 201503b705cfSriastradh if (!is_affine) 201603b705cfSriastradh OUT_VERTEX(mask_w[0]); 201703b705cfSriastradh } 201803b705cfSriastradh} 201903b705cfSriastradh 202003b705cfSriastradhBool 202103b705cfSriastradhi965_prepare_composite(int op, PicturePtr source_picture, 202203b705cfSriastradh PicturePtr mask_picture, PicturePtr dest_picture, 202303b705cfSriastradh PixmapPtr source, PixmapPtr mask, PixmapPtr dest) 202403b705cfSriastradh{ 202503b705cfSriastradh ScrnInfoPtr scrn = xf86ScreenToScrn(dest_picture->pDrawable->pScreen); 202603b705cfSriastradh intel_screen_private *intel = intel_get_screen_private(scrn); 202703b705cfSriastradh struct gen4_render_state *render_state = intel->gen4_render_state; 202803b705cfSriastradh gen4_composite_op *composite_op = &render_state->composite_op; 202903b705cfSriastradh 203003b705cfSriastradh composite_op->src_filter = 203103b705cfSriastradh sampler_state_filter_from_picture(source_picture->filter); 203203b705cfSriastradh if (composite_op->src_filter == SS_INVALID_FILTER) { 203313496ba1Ssnj intel_uxa_debug_fallback(scrn, "Bad src filter 0x%x\n", 203403b705cfSriastradh source_picture->filter); 203503b705cfSriastradh return FALSE; 203603b705cfSriastradh } 203703b705cfSriastradh composite_op->src_extend = 203803b705cfSriastradh sampler_state_extend_from_picture(source_picture->repeatType); 203903b705cfSriastradh if (composite_op->src_extend == SS_INVALID_EXTEND) { 204013496ba1Ssnj intel_uxa_debug_fallback(scrn, "Bad src repeat 0x%x\n", 204103b705cfSriastradh source_picture->repeatType); 204203b705cfSriastradh return FALSE; 204303b705cfSriastradh } 204403b705cfSriastradh 204503b705cfSriastradh if (mask_picture) { 204603b705cfSriastradh if (mask_picture->componentAlpha && 204703b705cfSriastradh PICT_FORMAT_RGB(mask_picture->format)) { 204803b705cfSriastradh /* Check if it's component alpha that relies on a source alpha and on 204903b705cfSriastradh * the source value. We can only get one of those into the single 205003b705cfSriastradh * source value that we get to blend with. 205103b705cfSriastradh */ 205203b705cfSriastradh if (i965_blend_op[op].src_alpha && 205303b705cfSriastradh (i965_blend_op[op].src_blend != BRW_BLENDFACTOR_ZERO)) { 205413496ba1Ssnj intel_uxa_debug_fallback(scrn, 205503b705cfSriastradh "Component alpha not supported " 205603b705cfSriastradh "with source alpha and source " 205703b705cfSriastradh "value blending.\n"); 205803b705cfSriastradh return FALSE; 205903b705cfSriastradh } 206003b705cfSriastradh } 206103b705cfSriastradh 206203b705cfSriastradh composite_op->mask_filter = 206303b705cfSriastradh sampler_state_filter_from_picture(mask_picture->filter); 206403b705cfSriastradh if (composite_op->mask_filter == SS_INVALID_FILTER) { 206513496ba1Ssnj intel_uxa_debug_fallback(scrn, "Bad mask filter 0x%x\n", 206603b705cfSriastradh mask_picture->filter); 206703b705cfSriastradh return FALSE; 206803b705cfSriastradh } 206903b705cfSriastradh composite_op->mask_extend = 207003b705cfSriastradh sampler_state_extend_from_picture(mask_picture->repeatType); 207103b705cfSriastradh if (composite_op->mask_extend == SS_INVALID_EXTEND) { 207213496ba1Ssnj intel_uxa_debug_fallback(scrn, "Bad mask repeat 0x%x\n", 207303b705cfSriastradh mask_picture->repeatType); 207403b705cfSriastradh return FALSE; 207503b705cfSriastradh } 207603b705cfSriastradh } else { 207703b705cfSriastradh composite_op->mask_filter = SS_FILTER_NEAREST; 207803b705cfSriastradh composite_op->mask_extend = SS_EXTEND_NONE; 207903b705cfSriastradh } 208003b705cfSriastradh 208103b705cfSriastradh /* Flush any pending writes prior to relocating the textures. */ 208213496ba1Ssnj if (intel_uxa_pixmap_is_dirty(source) || intel_uxa_pixmap_is_dirty(mask)) 208303b705cfSriastradh intel_batch_emit_flush(scrn); 208403b705cfSriastradh 208503b705cfSriastradh composite_op->op = op; 208603b705cfSriastradh intel->render_source_picture = source_picture; 208703b705cfSriastradh intel->render_mask_picture = mask_picture; 208803b705cfSriastradh intel->render_dest_picture = dest_picture; 208903b705cfSriastradh intel->render_source = source; 209003b705cfSriastradh intel->render_mask = mask; 209103b705cfSriastradh intel->render_dest = dest; 209203b705cfSriastradh 209303b705cfSriastradh intel->scale_units[0][0] = 1. / source->drawable.width; 209403b705cfSriastradh intel->scale_units[0][1] = 1. / source->drawable.height; 209503b705cfSriastradh 209603b705cfSriastradh intel->transform[0] = source_picture->transform; 209713496ba1Ssnj composite_op->is_affine = intel_uxa_transform_is_affine(intel->transform[0]); 209803b705cfSriastradh 209903b705cfSriastradh if (mask_picture == NULL) { 210003b705cfSriastradh intel->transform[1] = NULL; 210103b705cfSriastradh intel->scale_units[1][0] = -1; 210203b705cfSriastradh intel->scale_units[1][1] = -1; 210303b705cfSriastradh } else { 210403b705cfSriastradh assert(mask != NULL); 210503b705cfSriastradh intel->transform[1] = mask_picture->transform; 210603b705cfSriastradh intel->scale_units[1][0] = 1. / mask->drawable.width; 210703b705cfSriastradh intel->scale_units[1][1] = 1. / mask->drawable.height; 210803b705cfSriastradh composite_op->is_affine &= 210913496ba1Ssnj intel_uxa_transform_is_affine(intel->transform[1]); 211003b705cfSriastradh } 211103b705cfSriastradh 211203b705cfSriastradh if (mask) { 211342542f5fSchristos assert(mask_picture != NULL); 211403b705cfSriastradh if (mask_picture->componentAlpha && 211503b705cfSriastradh PICT_FORMAT_RGB(mask_picture->format)) { 211603b705cfSriastradh if (i965_blend_op[op].src_alpha) { 211703b705cfSriastradh if (composite_op->is_affine) 211803b705cfSriastradh composite_op->wm_kernel = 211903b705cfSriastradh WM_KERNEL_MASKCA_SRCALPHA_AFFINE; 212003b705cfSriastradh else 212103b705cfSriastradh composite_op->wm_kernel = 212203b705cfSriastradh WM_KERNEL_MASKCA_SRCALPHA_PROJECTIVE; 212303b705cfSriastradh } else { 212403b705cfSriastradh if (composite_op->is_affine) 212503b705cfSriastradh composite_op->wm_kernel = 212603b705cfSriastradh WM_KERNEL_MASKCA_AFFINE; 212703b705cfSriastradh else 212803b705cfSriastradh composite_op->wm_kernel = 212903b705cfSriastradh WM_KERNEL_MASKCA_PROJECTIVE; 213003b705cfSriastradh } 213103b705cfSriastradh } else { 213203b705cfSriastradh if (composite_op->is_affine) 213303b705cfSriastradh composite_op->wm_kernel = 213403b705cfSriastradh WM_KERNEL_MASKNOCA_AFFINE; 213503b705cfSriastradh else 213603b705cfSriastradh composite_op->wm_kernel = 213703b705cfSriastradh WM_KERNEL_MASKNOCA_PROJECTIVE; 213803b705cfSriastradh } 213903b705cfSriastradh } else { 214003b705cfSriastradh if (composite_op->is_affine) 214103b705cfSriastradh composite_op->wm_kernel = WM_KERNEL_NOMASK_AFFINE; 214203b705cfSriastradh else 214303b705cfSriastradh composite_op->wm_kernel = WM_KERNEL_NOMASK_PROJECTIVE; 214403b705cfSriastradh } 214503b705cfSriastradh 214603b705cfSriastradh intel->prim_emit = i965_emit_composite_primitive; 214703b705cfSriastradh if (!mask) { 214803b705cfSriastradh if (intel->transform[0] == NULL) 214903b705cfSriastradh intel->prim_emit = i965_emit_composite_primitive_identity_source; 215003b705cfSriastradh else if (composite_op->is_affine) 215103b705cfSriastradh intel->prim_emit = i965_emit_composite_primitive_affine_source; 215203b705cfSriastradh } else { 215303b705cfSriastradh if (intel->transform[0] == NULL && intel->transform[1] == NULL) 215403b705cfSriastradh intel->prim_emit = i965_emit_composite_primitive_identity_source_mask; 215503b705cfSriastradh } 215603b705cfSriastradh 215703b705cfSriastradh intel->floats_per_vertex = 215803b705cfSriastradh 2 + (mask ? 2 : 1) * (composite_op->is_affine ? 2: 3); 215903b705cfSriastradh 216003b705cfSriastradh if (!i965_composite_check_aperture(intel)) { 216103b705cfSriastradh intel_batch_submit(scrn); 216203b705cfSriastradh if (!i965_composite_check_aperture(intel)) { 216313496ba1Ssnj intel_uxa_debug_fallback(scrn, 216403b705cfSriastradh "Couldn't fit render operation " 216503b705cfSriastradh "in aperture\n"); 216603b705cfSriastradh return FALSE; 216703b705cfSriastradh } 216803b705cfSriastradh } 216903b705cfSriastradh 217003b705cfSriastradh if (sizeof(intel->surface_data) - intel->surface_used < 217103b705cfSriastradh 4 * SURFACE_STATE_PADDED_SIZE) 217203b705cfSriastradh i965_surface_flush(intel); 217303b705cfSriastradh 217403b705cfSriastradh intel->needs_render_state_emit = TRUE; 217503b705cfSriastradh 217603b705cfSriastradh return TRUE; 217703b705cfSriastradh} 217803b705cfSriastradh 217903b705cfSriastradhstatic void i965_select_vertex_buffer(struct intel_screen_private *intel) 218003b705cfSriastradh{ 218103b705cfSriastradh int id = intel->gen4_render_state->composite_op.vertex_id; 218203b705cfSriastradh int modifyenable = 0; 218303b705cfSriastradh 218403b705cfSriastradh if (intel->vertex_id & (1 << id)) 218503b705cfSriastradh return; 218603b705cfSriastradh 218703b705cfSriastradh if (INTEL_INFO(intel)->gen >= 070) 218803b705cfSriastradh modifyenable = GEN7_VB0_ADDRESS_MODIFYENABLE; 218903b705cfSriastradh 219003b705cfSriastradh /* Set up the pointer to our (single) vertex buffer */ 219103b705cfSriastradh OUT_BATCH(BRW_3DSTATE_VERTEX_BUFFERS | 3); 219203b705cfSriastradh 219303b705cfSriastradh /* XXX could use multiple vbo to reduce relocations if 219403b705cfSriastradh * frequently switching between vertex sizes, like rgb10text. 219503b705cfSriastradh */ 219603b705cfSriastradh if (INTEL_INFO(intel)->gen >= 060) { 219703b705cfSriastradh OUT_BATCH((id << GEN6_VB0_BUFFER_INDEX_SHIFT) | 219803b705cfSriastradh GEN6_VB0_VERTEXDATA | 219903b705cfSriastradh modifyenable | 220003b705cfSriastradh (4*intel->floats_per_vertex << VB0_BUFFER_PITCH_SHIFT)); 220103b705cfSriastradh } else { 220203b705cfSriastradh OUT_BATCH((id << VB0_BUFFER_INDEX_SHIFT) | 220303b705cfSriastradh VB0_VERTEXDATA | 220403b705cfSriastradh (4*intel->floats_per_vertex << VB0_BUFFER_PITCH_SHIFT)); 220503b705cfSriastradh } 220603b705cfSriastradh OUT_RELOC(intel->vertex_bo, I915_GEM_DOMAIN_VERTEX, 0, 0); 220703b705cfSriastradh if (INTEL_INFO(intel)->gen >= 050) 220803b705cfSriastradh OUT_RELOC(intel->vertex_bo, 220903b705cfSriastradh I915_GEM_DOMAIN_VERTEX, 0, 221003b705cfSriastradh sizeof(intel->vertex_ptr) - 1); 221103b705cfSriastradh else 221203b705cfSriastradh OUT_BATCH(0); 221303b705cfSriastradh OUT_BATCH(0); // ignore for VERTEXDATA, but still there 221403b705cfSriastradh 221503b705cfSriastradh intel->vertex_id |= 1 << id; 221603b705cfSriastradh} 221703b705cfSriastradh 221803b705cfSriastradhstatic void i965_bind_surfaces(struct intel_screen_private *intel) 221903b705cfSriastradh{ 222003b705cfSriastradh uint32_t *binding_table; 222103b705cfSriastradh 222203b705cfSriastradh assert(intel->surface_used + 4 * SURFACE_STATE_PADDED_SIZE <= sizeof(intel->surface_data)); 222303b705cfSriastradh 222403b705cfSriastradh binding_table = (uint32_t*) (intel->surface_data + intel->surface_used); 222503b705cfSriastradh intel->surface_table = intel->surface_used; 222603b705cfSriastradh intel->surface_used += SURFACE_STATE_PADDED_SIZE; 222703b705cfSriastradh 222803b705cfSriastradh binding_table[0] = 222903b705cfSriastradh i965_set_picture_surface_state(intel, 223003b705cfSriastradh intel->render_dest_picture, 223103b705cfSriastradh intel->render_dest, 223203b705cfSriastradh TRUE); 223303b705cfSriastradh binding_table[1] = 223403b705cfSriastradh i965_set_picture_surface_state(intel, 223503b705cfSriastradh intel->render_source_picture, 223603b705cfSriastradh intel->render_source, 223703b705cfSriastradh FALSE); 223803b705cfSriastradh if (intel->render_mask) { 223903b705cfSriastradh binding_table[2] = 224003b705cfSriastradh i965_set_picture_surface_state(intel, 224103b705cfSriastradh intel->render_mask_picture, 224203b705cfSriastradh intel->render_mask, 224303b705cfSriastradh FALSE); 224403b705cfSriastradh } 224503b705cfSriastradh} 224603b705cfSriastradh 224703b705cfSriastradhvoid 224803b705cfSriastradhi965_composite(PixmapPtr dest, int srcX, int srcY, int maskX, int maskY, 224903b705cfSriastradh int dstX, int dstY, int w, int h) 225003b705cfSriastradh{ 225103b705cfSriastradh ScrnInfoPtr scrn = xf86ScreenToScrn(dest->drawable.pScreen); 225203b705cfSriastradh intel_screen_private *intel = intel_get_screen_private(scrn); 225303b705cfSriastradh 225403b705cfSriastradh intel_batch_start_atomic(scrn, 200); 225503b705cfSriastradh if (intel->needs_render_state_emit) { 225603b705cfSriastradh i965_bind_surfaces(intel); 225703b705cfSriastradh 225803b705cfSriastradh if (INTEL_INFO(intel)->gen >= 060) 225903b705cfSriastradh gen6_emit_composite_state(intel); 226003b705cfSriastradh else 226103b705cfSriastradh i965_emit_composite_state(intel); 226203b705cfSriastradh } 226303b705cfSriastradh 226403b705cfSriastradh if (intel->floats_per_vertex != intel->last_floats_per_vertex) { 226503b705cfSriastradh intel->vertex_index = (intel->vertex_used + intel->floats_per_vertex - 1) / intel->floats_per_vertex; 226603b705cfSriastradh intel->vertex_used = intel->vertex_index * intel->floats_per_vertex; 226703b705cfSriastradh intel->last_floats_per_vertex = intel->floats_per_vertex; 226803b705cfSriastradh } 226903b705cfSriastradh if (intel_vertex_space(intel) < 3*4*intel->floats_per_vertex) { 227003b705cfSriastradh i965_vertex_flush(intel); 227103b705cfSriastradh intel_next_vertex(intel); 227203b705cfSriastradh intel->vertex_index = 0; 227303b705cfSriastradh } 227403b705cfSriastradh i965_select_vertex_buffer(intel); 227503b705cfSriastradh 227603b705cfSriastradh if (intel->vertex_offset == 0) { 227703b705cfSriastradh if (INTEL_INFO(intel)->gen >= 070) { 227803b705cfSriastradh OUT_BATCH(BRW_3DPRIMITIVE | (7 - 2)); 227903b705cfSriastradh OUT_BATCH(BRW_3DPRIMITIVE_VERTEX_SEQUENTIAL | 228003b705cfSriastradh _3DPRIM_RECTLIST); 228103b705cfSriastradh } else { 228203b705cfSriastradh OUT_BATCH(BRW_3DPRIMITIVE | 228303b705cfSriastradh BRW_3DPRIMITIVE_VERTEX_SEQUENTIAL | 228403b705cfSriastradh (_3DPRIM_RECTLIST << BRW_3DPRIMITIVE_TOPOLOGY_SHIFT) | 228503b705cfSriastradh (0 << 9) | 228603b705cfSriastradh 4); 228703b705cfSriastradh } 228803b705cfSriastradh intel->vertex_offset = intel->batch_used; 228903b705cfSriastradh OUT_BATCH(0); /* vertex count, to be filled in later */ 229003b705cfSriastradh OUT_BATCH(intel->vertex_index); 229103b705cfSriastradh OUT_BATCH(1); /* single instance */ 229203b705cfSriastradh OUT_BATCH(0); /* start instance location */ 229303b705cfSriastradh OUT_BATCH(0); /* index buffer offset, ignored */ 229403b705cfSriastradh intel->vertex_count = intel->vertex_index; 229503b705cfSriastradh } 229603b705cfSriastradh 229703b705cfSriastradh intel->prim_emit(intel, 229803b705cfSriastradh srcX, srcY, 229903b705cfSriastradh maskX, maskY, 230003b705cfSriastradh dstX, dstY, 230103b705cfSriastradh w, h); 230203b705cfSriastradh intel->vertex_index += 3; 230303b705cfSriastradh 230403b705cfSriastradh if (INTEL_INFO(intel)->gen < 050) { 230503b705cfSriastradh /* XXX OMG! */ 230603b705cfSriastradh i965_vertex_flush(intel); 230703b705cfSriastradh OUT_BATCH(MI_FLUSH | MI_INHIBIT_RENDER_CACHE_FLUSH); 230803b705cfSriastradh } 230903b705cfSriastradh 231003b705cfSriastradh intel_batch_end_atomic(scrn); 231103b705cfSriastradh} 231203b705cfSriastradh 231303b705cfSriastradhvoid i965_batch_commit_notify(intel_screen_private *intel) 231403b705cfSriastradh{ 231503b705cfSriastradh intel->needs_render_state_emit = TRUE; 231603b705cfSriastradh intel->needs_3d_invariant = TRUE; 231703b705cfSriastradh intel->last_floats_per_vertex = 0; 231803b705cfSriastradh intel->vertex_index = 0; 231903b705cfSriastradh 232003b705cfSriastradh intel->gen4_render_state->composite_op.vertex_id = -1; 232103b705cfSriastradh 232203b705cfSriastradh intel->gen6_render_state.num_sf_outputs = 0; 232303b705cfSriastradh intel->gen6_render_state.samplers = NULL; 232403b705cfSriastradh intel->gen6_render_state.blend = -1; 232503b705cfSriastradh intel->gen6_render_state.kernel = NULL; 232603b705cfSriastradh intel->gen6_render_state.drawrect = -1; 232703b705cfSriastradh 232803b705cfSriastradh assert(intel->surface_reloc == 0); 232903b705cfSriastradh} 233003b705cfSriastradh 233103b705cfSriastradh/** 233203b705cfSriastradh * Called at EnterVT so we can set up our offsets into the state buffer. 233303b705cfSriastradh */ 233403b705cfSriastradhvoid gen4_render_state_init(ScrnInfoPtr scrn) 233503b705cfSriastradh{ 233603b705cfSriastradh intel_screen_private *intel = intel_get_screen_private(scrn); 233703b705cfSriastradh struct gen4_render_state *render; 233803b705cfSriastradh const struct wm_kernel_info *wm_kernels; 233903b705cfSriastradh sampler_state_filter_t src_filter; 234003b705cfSriastradh sampler_state_extend_t src_extend; 234103b705cfSriastradh sampler_state_filter_t mask_filter; 234203b705cfSriastradh sampler_state_extend_t mask_extend; 234303b705cfSriastradh drm_intel_bo *sf_kernel_bo, *sf_kernel_mask_bo; 234403b705cfSriastradh drm_intel_bo *border_color_bo; 234503b705cfSriastradh int m; 234603b705cfSriastradh 234703b705cfSriastradh intel->needs_3d_invariant = TRUE; 234803b705cfSriastradh 234903b705cfSriastradh intel->surface_bo = 235003b705cfSriastradh drm_intel_bo_alloc(intel->bufmgr, "surface data", 235103b705cfSriastradh sizeof(intel->surface_data), 4096); 235203b705cfSriastradh assert(intel->surface_bo); 235303b705cfSriastradh 235403b705cfSriastradh intel->surface_used = 0; 235503b705cfSriastradh 235603b705cfSriastradh if (intel->gen4_render_state == NULL) { 235703b705cfSriastradh intel->gen4_render_state = calloc(1, sizeof(*render)); 235803b705cfSriastradh assert(intel->gen4_render_state != NULL); 235903b705cfSriastradh } 236003b705cfSriastradh 236103b705cfSriastradh if (INTEL_INFO(intel)->gen >= 060) 236203b705cfSriastradh return gen6_render_state_init(scrn); 236303b705cfSriastradh 236403b705cfSriastradh render = intel->gen4_render_state; 236503b705cfSriastradh render->composite_op.vertex_id = -1; 236603b705cfSriastradh 236703b705cfSriastradh render->vs_state_bo = gen4_create_vs_unit_state(intel); 236803b705cfSriastradh 236903b705cfSriastradh /* Set up the two SF states (one for blending with a mask, one without) */ 237003b705cfSriastradh if (IS_GEN5(intel)) { 237113496ba1Ssnj sf_kernel_bo = intel_uxa_bo_alloc_for_data(intel, 237203b705cfSriastradh sf_kernel_static_gen5, 237303b705cfSriastradh sizeof 237403b705cfSriastradh (sf_kernel_static_gen5), 237503b705cfSriastradh "sf kernel gen5"); 237603b705cfSriastradh sf_kernel_mask_bo = 237713496ba1Ssnj intel_uxa_bo_alloc_for_data(intel, sf_kernel_mask_static_gen5, 237803b705cfSriastradh sizeof(sf_kernel_mask_static_gen5), 237903b705cfSriastradh "sf mask kernel"); 238003b705cfSriastradh } else { 238113496ba1Ssnj sf_kernel_bo = intel_uxa_bo_alloc_for_data(intel, 238203b705cfSriastradh sf_kernel_static, 238303b705cfSriastradh sizeof(sf_kernel_static), 238403b705cfSriastradh "sf kernel"); 238513496ba1Ssnj sf_kernel_mask_bo = intel_uxa_bo_alloc_for_data(intel, 238603b705cfSriastradh sf_kernel_mask_static, 238703b705cfSriastradh sizeof 238803b705cfSriastradh (sf_kernel_mask_static), 238903b705cfSriastradh "sf mask kernel"); 239003b705cfSriastradh } 239103b705cfSriastradh render->sf_state_bo = gen4_create_sf_state(intel, sf_kernel_bo); 239203b705cfSriastradh render->sf_mask_state_bo = gen4_create_sf_state(intel, sf_kernel_mask_bo); 239303b705cfSriastradh drm_intel_bo_unreference(sf_kernel_bo); 239403b705cfSriastradh drm_intel_bo_unreference(sf_kernel_mask_bo); 239503b705cfSriastradh 239603b705cfSriastradh wm_kernels = IS_GEN5(intel) ? wm_kernels_gen5 : wm_kernels_gen4; 239703b705cfSriastradh for (m = 0; m < KERNEL_COUNT; m++) { 239803b705cfSriastradh render->wm_kernel_bo[m] = 239913496ba1Ssnj intel_uxa_bo_alloc_for_data(intel, 240003b705cfSriastradh wm_kernels[m].data, 240103b705cfSriastradh wm_kernels[m].size, 240203b705cfSriastradh "WM kernel"); 240303b705cfSriastradh } 240403b705cfSriastradh 240503b705cfSriastradh /* Set up the WM states: each filter/extend type for source and mask, per 240603b705cfSriastradh * kernel. 240703b705cfSriastradh */ 240803b705cfSriastradh border_color_bo = sampler_border_color_create(intel); 240903b705cfSriastradh for (src_filter = 0; src_filter < FILTER_COUNT; src_filter++) { 241003b705cfSriastradh for (src_extend = 0; src_extend < EXTEND_COUNT; src_extend++) { 241103b705cfSriastradh for (mask_filter = 0; mask_filter < FILTER_COUNT; mask_filter++) { 241203b705cfSriastradh for (mask_extend = 0; mask_extend < EXTEND_COUNT; mask_extend++) { 241303b705cfSriastradh drm_intel_bo *sampler_state_bo; 241403b705cfSriastradh 241503b705cfSriastradh sampler_state_bo = 241603b705cfSriastradh i965_create_sampler_state(intel, 241703b705cfSriastradh src_filter, src_extend, 241803b705cfSriastradh mask_filter, mask_extend, 241903b705cfSriastradh border_color_bo); 242003b705cfSriastradh 242103b705cfSriastradh for (m = 0; m < KERNEL_COUNT; m++) { 242203b705cfSriastradh render->wm_state_bo[m][src_filter][src_extend][mask_filter][mask_extend] = 242303b705cfSriastradh gen4_create_wm_state 242403b705cfSriastradh (intel, 242503b705cfSriastradh wm_kernels[m]. has_mask, 242603b705cfSriastradh render->wm_kernel_bo[m], 242703b705cfSriastradh sampler_state_bo); 242803b705cfSriastradh } 242903b705cfSriastradh drm_intel_bo_unreference(sampler_state_bo); 243003b705cfSriastradh } 243103b705cfSriastradh } 243203b705cfSriastradh } 243303b705cfSriastradh } 243403b705cfSriastradh drm_intel_bo_unreference(border_color_bo); 243503b705cfSriastradh 243603b705cfSriastradh render->cc_state_bo = gen4_create_cc_unit_state(intel); 243703b705cfSriastradh} 243803b705cfSriastradh 243903b705cfSriastradh/** 244003b705cfSriastradh * Called at LeaveVT. 244103b705cfSriastradh */ 244203b705cfSriastradhvoid gen4_render_state_cleanup(ScrnInfoPtr scrn) 244303b705cfSriastradh{ 244403b705cfSriastradh intel_screen_private *intel = intel_get_screen_private(scrn); 244503b705cfSriastradh struct gen4_render_state *render_state = intel->gen4_render_state; 244603b705cfSriastradh int i, j, k, l, m; 244703b705cfSriastradh 244803b705cfSriastradh drm_intel_bo_unreference(intel->surface_bo); 244903b705cfSriastradh drm_intel_bo_unreference(render_state->vs_state_bo); 245003b705cfSriastradh drm_intel_bo_unreference(render_state->sf_state_bo); 245103b705cfSriastradh drm_intel_bo_unreference(render_state->sf_mask_state_bo); 245203b705cfSriastradh 245303b705cfSriastradh for (i = 0; i < KERNEL_COUNT; i++) 245403b705cfSriastradh drm_intel_bo_unreference(render_state->wm_kernel_bo[i]); 245503b705cfSriastradh 245603b705cfSriastradh for (i = 0; i < FILTER_COUNT; i++) 245703b705cfSriastradh for (j = 0; j < EXTEND_COUNT; j++) 245803b705cfSriastradh for (k = 0; k < FILTER_COUNT; k++) 245903b705cfSriastradh for (l = 0; l < EXTEND_COUNT; l++) 246003b705cfSriastradh for (m = 0; m < KERNEL_COUNT; m++) 246103b705cfSriastradh drm_intel_bo_unreference 246203b705cfSriastradh (render_state-> 246303b705cfSriastradh wm_state_bo[m][i][j][k] 246403b705cfSriastradh [l]); 246503b705cfSriastradh 246603b705cfSriastradh for (i = 0; i < FILTER_COUNT; i++) 246703b705cfSriastradh for (j = 0; j < EXTEND_COUNT; j++) 246803b705cfSriastradh for (k = 0; k < FILTER_COUNT; k++) 246903b705cfSriastradh for (l = 0; l < EXTEND_COUNT; l++) 247003b705cfSriastradh drm_intel_bo_unreference(render_state->ps_sampler_state_bo[i][j][k][l]); 247103b705cfSriastradh 247203b705cfSriastradh drm_intel_bo_unreference(render_state->cc_state_bo); 247303b705cfSriastradh 247403b705cfSriastradh drm_intel_bo_unreference(render_state->cc_vp_bo); 247503b705cfSriastradh drm_intel_bo_unreference(render_state->gen6_blend_bo); 247603b705cfSriastradh drm_intel_bo_unreference(render_state->gen6_depth_stencil_bo); 247703b705cfSriastradh 247803b705cfSriastradh free(intel->gen4_render_state); 247903b705cfSriastradh intel->gen4_render_state = NULL; 248003b705cfSriastradh} 248103b705cfSriastradh 248203b705cfSriastradh/* 248303b705cfSriastradh * for GEN6+ 248403b705cfSriastradh */ 248503b705cfSriastradh#define GEN6_BLEND_STATE_PADDED_SIZE ALIGN(sizeof(struct gen6_blend_state), 64) 248603b705cfSriastradh 248703b705cfSriastradhstatic drm_intel_bo * 248803b705cfSriastradhgen6_composite_create_cc_state(intel_screen_private *intel) 248903b705cfSriastradh{ 249003b705cfSriastradh struct gen6_color_calc_state *state; 249103b705cfSriastradh drm_intel_bo *cc_bo; 249203b705cfSriastradh int ret; 249303b705cfSriastradh 249403b705cfSriastradh cc_bo = drm_intel_bo_alloc(intel->bufmgr, 249503b705cfSriastradh "gen6 CC state", 249603b705cfSriastradh sizeof(*state), 249703b705cfSriastradh 4096); 249803b705cfSriastradh assert(cc_bo); 249903b705cfSriastradh 250003b705cfSriastradh ret = drm_intel_bo_map(cc_bo, TRUE); 250103b705cfSriastradh assert(ret == 0); 250203b705cfSriastradh 250303b705cfSriastradh state = memset(cc_bo->virtual, 0, sizeof(*state)); 250403b705cfSriastradh state->constant_r = 1.0; 250503b705cfSriastradh state->constant_g = 0.0; 250603b705cfSriastradh state->constant_b = 1.0; 250703b705cfSriastradh state->constant_a = 1.0; 250803b705cfSriastradh drm_intel_bo_unmap(cc_bo); 250903b705cfSriastradh 251003b705cfSriastradh return cc_bo; 251103b705cfSriastradh (void)ret; 251203b705cfSriastradh} 251303b705cfSriastradh 251403b705cfSriastradhstatic drm_intel_bo * 251503b705cfSriastradhgen6_composite_create_blend_state(intel_screen_private *intel) 251603b705cfSriastradh{ 251703b705cfSriastradh drm_intel_bo *blend_bo; 251803b705cfSriastradh int src, dst, ret; 251903b705cfSriastradh 252003b705cfSriastradh blend_bo = drm_intel_bo_alloc(intel->bufmgr, 252103b705cfSriastradh "gen6 BLEND state", 252203b705cfSriastradh BRW_BLENDFACTOR_COUNT * BRW_BLENDFACTOR_COUNT * GEN6_BLEND_STATE_PADDED_SIZE, 252303b705cfSriastradh 4096); 252403b705cfSriastradh assert(blend_bo); 252503b705cfSriastradh 252603b705cfSriastradh ret = drm_intel_bo_map(blend_bo, TRUE); 252703b705cfSriastradh assert(ret == 0); 252803b705cfSriastradh 252903b705cfSriastradh memset(blend_bo->virtual, 0, blend_bo->size); 253003b705cfSriastradh for (src = 0; src < BRW_BLENDFACTOR_COUNT; src++) { 253103b705cfSriastradh for (dst = 0; dst < BRW_BLENDFACTOR_COUNT; dst++) { 253203b705cfSriastradh uint32_t blend_state_offset = (src * BRW_BLENDFACTOR_COUNT + dst) * GEN6_BLEND_STATE_PADDED_SIZE; 253303b705cfSriastradh struct gen6_blend_state *blend; 253403b705cfSriastradh 253503b705cfSriastradh blend = (struct gen6_blend_state *)((char *)blend_bo->virtual + blend_state_offset); 253603b705cfSriastradh blend->blend0.dest_blend_factor = dst; 253703b705cfSriastradh blend->blend0.source_blend_factor = src; 253803b705cfSriastradh blend->blend0.blend_func = BRW_BLENDFUNCTION_ADD; 253903b705cfSriastradh blend->blend0.blend_enable = 1; 254003b705cfSriastradh 254103b705cfSriastradh blend->blend1.post_blend_clamp_enable = 1; 254203b705cfSriastradh blend->blend1.pre_blend_clamp_enable = 1; 254303b705cfSriastradh } 254403b705cfSriastradh } 254503b705cfSriastradh 254603b705cfSriastradh drm_intel_bo_unmap(blend_bo); 254703b705cfSriastradh return blend_bo; 254803b705cfSriastradh (void)ret; 254903b705cfSriastradh} 255003b705cfSriastradh 255103b705cfSriastradhstatic drm_intel_bo * 255203b705cfSriastradhgen6_composite_create_depth_stencil_state(intel_screen_private *intel) 255303b705cfSriastradh{ 255403b705cfSriastradh drm_intel_bo *depth_stencil_bo; 255503b705cfSriastradh int ret; 255603b705cfSriastradh 255703b705cfSriastradh depth_stencil_bo = 255803b705cfSriastradh drm_intel_bo_alloc(intel->bufmgr, 255903b705cfSriastradh "gen6 DEPTH_STENCIL state", 256003b705cfSriastradh sizeof(struct gen6_depth_stencil_state), 256103b705cfSriastradh 4096); 256203b705cfSriastradh assert(depth_stencil_bo); 256303b705cfSriastradh 256403b705cfSriastradh ret = drm_intel_bo_map(depth_stencil_bo, TRUE); 256503b705cfSriastradh assert(ret == 0); 256603b705cfSriastradh 256703b705cfSriastradh memset(depth_stencil_bo->virtual, 0, 256803b705cfSriastradh sizeof(struct gen6_depth_stencil_state)); 256903b705cfSriastradh drm_intel_bo_unmap(depth_stencil_bo); 257003b705cfSriastradh 257103b705cfSriastradh return depth_stencil_bo; 257203b705cfSriastradh (void)ret; 257303b705cfSriastradh} 257403b705cfSriastradh 257503b705cfSriastradhstatic void 257603b705cfSriastradhgen6_composite_state_base_address(intel_screen_private *intel) 257703b705cfSriastradh{ 257803b705cfSriastradh OUT_BATCH(BRW_STATE_BASE_ADDRESS | (10 - 2)); 257903b705cfSriastradh OUT_BATCH(BASE_ADDRESS_MODIFY); /* General state base address */ 258003b705cfSriastradh intel->surface_reloc = intel->batch_used; 258103b705cfSriastradh intel_batch_emit_dword(intel, 258203b705cfSriastradh intel->surface_bo->offset | BASE_ADDRESS_MODIFY); 258303b705cfSriastradh OUT_BATCH(BASE_ADDRESS_MODIFY); /* Dynamic state base address */ 258403b705cfSriastradh OUT_BATCH(BASE_ADDRESS_MODIFY); /* Indirect object base address */ 258503b705cfSriastradh OUT_BATCH(BASE_ADDRESS_MODIFY); /* Instruction base address */ 258603b705cfSriastradh OUT_BATCH(BASE_ADDRESS_MODIFY); /* General state upper bound */ 258703b705cfSriastradh OUT_BATCH(BASE_ADDRESS_MODIFY); /* Dynamic state upper bound */ 258803b705cfSriastradh OUT_BATCH(BASE_ADDRESS_MODIFY); /* Indirect object upper bound */ 258903b705cfSriastradh OUT_BATCH(BASE_ADDRESS_MODIFY); /* Instruction access upper bound */ 259003b705cfSriastradh} 259103b705cfSriastradh 259203b705cfSriastradhstatic void 259303b705cfSriastradhgen6_composite_cc_state_pointers(intel_screen_private *intel, 259403b705cfSriastradh uint32_t blend_offset) 259503b705cfSriastradh{ 259603b705cfSriastradh struct gen4_render_state *render_state = intel->gen4_render_state; 259703b705cfSriastradh drm_intel_bo *cc_bo = NULL; 259803b705cfSriastradh drm_intel_bo *depth_stencil_bo = NULL; 259903b705cfSriastradh 260003b705cfSriastradh if (intel->gen6_render_state.blend == blend_offset) 260103b705cfSriastradh return; 260203b705cfSriastradh 260303b705cfSriastradh if (intel->gen6_render_state.blend == -1) { 260403b705cfSriastradh cc_bo = render_state->cc_state_bo; 260503b705cfSriastradh depth_stencil_bo = render_state->gen6_depth_stencil_bo; 260603b705cfSriastradh } 260703b705cfSriastradh if (INTEL_INFO(intel)->gen >= 070) { 260803b705cfSriastradh gen7_upload_cc_state_pointers(intel, render_state->gen6_blend_bo, cc_bo, depth_stencil_bo, blend_offset); 260903b705cfSriastradh } else { 261003b705cfSriastradh gen6_upload_cc_state_pointers(intel, render_state->gen6_blend_bo, cc_bo, depth_stencil_bo, blend_offset); 261103b705cfSriastradh } 261203b705cfSriastradh 261303b705cfSriastradh intel->gen6_render_state.blend = blend_offset; 261403b705cfSriastradh} 261503b705cfSriastradh 261603b705cfSriastradhstatic void 261703b705cfSriastradhgen6_composite_sampler_state_pointers(intel_screen_private *intel, 261803b705cfSriastradh drm_intel_bo *bo) 261903b705cfSriastradh{ 262003b705cfSriastradh if (intel->gen6_render_state.samplers == bo) 262103b705cfSriastradh return; 262203b705cfSriastradh 262303b705cfSriastradh intel->gen6_render_state.samplers = bo; 262403b705cfSriastradh 262503b705cfSriastradh if (INTEL_INFO(intel)->gen >= 070) 262603b705cfSriastradh gen7_upload_sampler_state_pointers(intel, bo); 262703b705cfSriastradh else 262803b705cfSriastradh gen6_upload_sampler_state_pointers(intel, bo); 262903b705cfSriastradh} 263003b705cfSriastradh 263103b705cfSriastradhstatic void 263203b705cfSriastradhgen6_composite_wm_constants(intel_screen_private *intel) 263303b705cfSriastradh{ 263403b705cfSriastradh Bool ivb = INTEL_INFO(intel)->gen >= 070; 263503b705cfSriastradh /* disable WM constant buffer */ 263603b705cfSriastradh OUT_BATCH(GEN6_3DSTATE_CONSTANT_PS | ((ivb ? 7 : 5) - 2)); 263703b705cfSriastradh OUT_BATCH(0); 263803b705cfSriastradh OUT_BATCH(0); 263903b705cfSriastradh OUT_BATCH(0); 264003b705cfSriastradh OUT_BATCH(0); 264103b705cfSriastradh if (ivb) { 264203b705cfSriastradh OUT_BATCH(0); 264303b705cfSriastradh OUT_BATCH(0); 264403b705cfSriastradh } 264503b705cfSriastradh} 264603b705cfSriastradh 264703b705cfSriastradhstatic void 264803b705cfSriastradhgen6_composite_sf_state(intel_screen_private *intel, 264903b705cfSriastradh Bool has_mask) 265003b705cfSriastradh{ 265103b705cfSriastradh int num_sf_outputs = has_mask ? 2 : 1; 265203b705cfSriastradh 265303b705cfSriastradh if (intel->gen6_render_state.num_sf_outputs == num_sf_outputs) 265403b705cfSriastradh return; 265503b705cfSriastradh 265603b705cfSriastradh intel->gen6_render_state.num_sf_outputs = num_sf_outputs; 265703b705cfSriastradh 265803b705cfSriastradh if (INTEL_INFO(intel)->gen >= 070) 265903b705cfSriastradh gen7_upload_sf_state(intel, num_sf_outputs, 1); 266003b705cfSriastradh else 266103b705cfSriastradh gen6_upload_sf_state(intel, num_sf_outputs, 1); 266203b705cfSriastradh} 266303b705cfSriastradh 266403b705cfSriastradhstatic void 266503b705cfSriastradhgen6_composite_wm_state(intel_screen_private *intel, 266603b705cfSriastradh Bool has_mask, 266703b705cfSriastradh drm_intel_bo *bo) 266803b705cfSriastradh{ 266903b705cfSriastradh int num_surfaces = has_mask ? 3 : 2; 267003b705cfSriastradh int num_sf_outputs = has_mask ? 2 : 1; 267103b705cfSriastradh 267203b705cfSriastradh if (intel->gen6_render_state.kernel == bo) 267303b705cfSriastradh return; 267403b705cfSriastradh 267503b705cfSriastradh intel->gen6_render_state.kernel = bo; 267603b705cfSriastradh 267703b705cfSriastradh OUT_BATCH(GEN6_3DSTATE_WM | (9 - 2)); 267803b705cfSriastradh OUT_RELOC(bo, 267903b705cfSriastradh I915_GEM_DOMAIN_INSTRUCTION, 0, 268003b705cfSriastradh 0); 268103b705cfSriastradh OUT_BATCH((1 << GEN6_3DSTATE_WM_SAMPLER_COUNT_SHITF) | 268203b705cfSriastradh (num_surfaces << GEN6_3DSTATE_WM_BINDING_TABLE_ENTRY_COUNT_SHIFT)); 268303b705cfSriastradh OUT_BATCH(0); 268403b705cfSriastradh OUT_BATCH((6 << GEN6_3DSTATE_WM_DISPATCH_START_GRF_0_SHIFT)); /* DW4 */ 268503b705cfSriastradh OUT_BATCH(((40 - 1) << GEN6_3DSTATE_WM_MAX_THREADS_SHIFT) | 268603b705cfSriastradh GEN6_3DSTATE_WM_DISPATCH_ENABLE | 268703b705cfSriastradh GEN6_3DSTATE_WM_16_DISPATCH_ENABLE); 268803b705cfSriastradh OUT_BATCH((num_sf_outputs << GEN6_3DSTATE_WM_NUM_SF_OUTPUTS_SHIFT) | 268903b705cfSriastradh GEN6_3DSTATE_WM_PERSPECTIVE_PIXEL_BARYCENTRIC); 269003b705cfSriastradh OUT_BATCH(0); 269103b705cfSriastradh OUT_BATCH(0); 269203b705cfSriastradh} 269303b705cfSriastradh 269403b705cfSriastradhstatic void 269503b705cfSriastradhgen7_composite_wm_state(intel_screen_private *intel, 269603b705cfSriastradh Bool has_mask, 269703b705cfSriastradh drm_intel_bo *bo) 269803b705cfSriastradh{ 269903b705cfSriastradh int num_surfaces = has_mask ? 3 : 2; 270003b705cfSriastradh unsigned int max_threads_shift = GEN7_PS_MAX_THREADS_SHIFT_IVB; 270103b705cfSriastradh unsigned int num_samples = 0; 270203b705cfSriastradh 270303b705cfSriastradh if (IS_HSW(intel)) { 270403b705cfSriastradh max_threads_shift = GEN7_PS_MAX_THREADS_SHIFT_HSW; 270503b705cfSriastradh num_samples = 1 << GEN7_PS_SAMPLE_MASK_SHIFT_HSW; 270603b705cfSriastradh } 270703b705cfSriastradh 270803b705cfSriastradh if (intel->gen6_render_state.kernel == bo) 270903b705cfSriastradh return; 271003b705cfSriastradh 271103b705cfSriastradh intel->gen6_render_state.kernel = bo; 271203b705cfSriastradh 271303b705cfSriastradh OUT_BATCH(GEN6_3DSTATE_WM | (3 - 2)); 271403b705cfSriastradh OUT_BATCH(GEN7_WM_DISPATCH_ENABLE | 271503b705cfSriastradh GEN7_WM_PERSPECTIVE_PIXEL_BARYCENTRIC); 271603b705cfSriastradh OUT_BATCH(0); 271703b705cfSriastradh 271803b705cfSriastradh OUT_BATCH(GEN7_3DSTATE_PS | (8 - 2)); 271903b705cfSriastradh OUT_RELOC(bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0); 272003b705cfSriastradh OUT_BATCH((1 << GEN7_PS_SAMPLER_COUNT_SHIFT) | 272103b705cfSriastradh (num_surfaces << GEN7_PS_BINDING_TABLE_ENTRY_COUNT_SHIFT)); 272203b705cfSriastradh OUT_BATCH(0); /* scratch space base offset */ 272303b705cfSriastradh OUT_BATCH(((48 - 1) << max_threads_shift) | num_samples | 272403b705cfSriastradh GEN7_PS_ATTRIBUTE_ENABLE | 272503b705cfSriastradh GEN7_PS_16_DISPATCH_ENABLE); 272603b705cfSriastradh OUT_BATCH((6 << GEN7_PS_DISPATCH_START_GRF_SHIFT_0)); 272703b705cfSriastradh OUT_BATCH(0); /* kernel 1 pointer */ 272803b705cfSriastradh OUT_BATCH(0); /* kernel 2 pointer */ 272903b705cfSriastradh} 273003b705cfSriastradh 273103b705cfSriastradh 273203b705cfSriastradhstatic void 273303b705cfSriastradhgen6_composite_drawing_rectangle(intel_screen_private *intel, 273403b705cfSriastradh PixmapPtr dest) 273503b705cfSriastradh{ 273603b705cfSriastradh uint32_t dw = 273703b705cfSriastradh DRAW_YMAX(dest->drawable.height - 1) | 273803b705cfSriastradh DRAW_XMAX(dest->drawable.width - 1); 273903b705cfSriastradh 274003b705cfSriastradh /* XXX cacomposite depends upon the implicit non-pipelined flush */ 274103b705cfSriastradh if (0 && intel->gen6_render_state.drawrect == dw) 274203b705cfSriastradh return; 274303b705cfSriastradh intel->gen6_render_state.drawrect = dw; 274403b705cfSriastradh 274503b705cfSriastradh OUT_BATCH(BRW_3DSTATE_DRAWING_RECTANGLE | (4 - 2)); 274603b705cfSriastradh OUT_BATCH(0x00000000); /* ymin, xmin */ 274703b705cfSriastradh OUT_BATCH(dw); /* ymax, xmax */ 274803b705cfSriastradh OUT_BATCH(0x00000000); /* yorigin, xorigin */ 274903b705cfSriastradh} 275003b705cfSriastradh 275103b705cfSriastradhstatic void 275203b705cfSriastradhgen6_composite_vertex_element_state(intel_screen_private *intel, 275303b705cfSriastradh Bool has_mask, 275403b705cfSriastradh Bool is_affine) 275503b705cfSriastradh{ 275603b705cfSriastradh /* 275703b705cfSriastradh * vertex data in vertex buffer 275803b705cfSriastradh * position: (x, y) 275903b705cfSriastradh * texture coordinate 0: (u0, v0) if (is_affine is TRUE) else (u0, v0, w0) 276003b705cfSriastradh * texture coordinate 1 if (has_mask is TRUE): same as above 276103b705cfSriastradh */ 276203b705cfSriastradh gen4_composite_op *composite_op = &intel->gen4_render_state->composite_op; 276303b705cfSriastradh int nelem = has_mask ? 2 : 1; 276403b705cfSriastradh int selem = is_affine ? 2 : 3; 276503b705cfSriastradh uint32_t w_component; 276603b705cfSriastradh uint32_t src_format; 276703b705cfSriastradh int id; 276803b705cfSriastradh 276903b705cfSriastradh id = has_mask << 1 | is_affine; 277003b705cfSriastradh 277103b705cfSriastradh if (composite_op->vertex_id == id) 277203b705cfSriastradh return; 277303b705cfSriastradh 277403b705cfSriastradh composite_op->vertex_id = id; 277503b705cfSriastradh 277603b705cfSriastradh if (is_affine) { 277703b705cfSriastradh src_format = BRW_SURFACEFORMAT_R32G32_FLOAT; 277803b705cfSriastradh w_component = BRW_VFCOMPONENT_STORE_1_FLT; 277903b705cfSriastradh } else { 278003b705cfSriastradh src_format = BRW_SURFACEFORMAT_R32G32B32_FLOAT; 278103b705cfSriastradh w_component = BRW_VFCOMPONENT_STORE_SRC; 278203b705cfSriastradh } 278303b705cfSriastradh 278403b705cfSriastradh /* The VUE layout 278503b705cfSriastradh * dword 0-3: pad (0.0, 0.0, 0.0. 0.0) 278603b705cfSriastradh * dword 4-7: position (x, y, 1.0, 1.0), 278703b705cfSriastradh * dword 8-11: texture coordinate 0 (u0, v0, w0, 1.0) 278803b705cfSriastradh * dword 12-15: texture coordinate 1 (u1, v1, w1, 1.0) 278903b705cfSriastradh * 279003b705cfSriastradh * dword 4-15 are fetched from vertex buffer 279103b705cfSriastradh */ 279203b705cfSriastradh OUT_BATCH(BRW_3DSTATE_VERTEX_ELEMENTS | 279303b705cfSriastradh ((2 * (2 + nelem)) + 1 - 2)); 279403b705cfSriastradh 279503b705cfSriastradh OUT_BATCH((id << GEN6_VE0_VERTEX_BUFFER_INDEX_SHIFT) | GEN6_VE0_VALID | 279603b705cfSriastradh (BRW_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) | 279703b705cfSriastradh (0 << VE0_OFFSET_SHIFT)); 279803b705cfSriastradh OUT_BATCH((BRW_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_0_SHIFT) | 279903b705cfSriastradh (BRW_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_1_SHIFT) | 280003b705cfSriastradh (BRW_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_2_SHIFT) | 280103b705cfSriastradh (BRW_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_3_SHIFT)); 280203b705cfSriastradh 280303b705cfSriastradh /* x,y */ 280403b705cfSriastradh OUT_BATCH((id << GEN6_VE0_VERTEX_BUFFER_INDEX_SHIFT) | GEN6_VE0_VALID | 280503b705cfSriastradh (BRW_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) | 280603b705cfSriastradh (0 << VE0_OFFSET_SHIFT)); /* offsets vb in bytes */ 280703b705cfSriastradh OUT_BATCH((BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) | 280803b705cfSriastradh (BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) | 280903b705cfSriastradh (BRW_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT) | 281003b705cfSriastradh (BRW_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT)); 281103b705cfSriastradh 281203b705cfSriastradh /* u0, v0, w0 */ 281303b705cfSriastradh OUT_BATCH((id << GEN6_VE0_VERTEX_BUFFER_INDEX_SHIFT) | GEN6_VE0_VALID | 281403b705cfSriastradh (src_format << VE0_FORMAT_SHIFT) | 281503b705cfSriastradh ((2 * 4) << VE0_OFFSET_SHIFT)); /* offset vb in bytes */ 281603b705cfSriastradh OUT_BATCH((BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) | 281703b705cfSriastradh (BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) | 281803b705cfSriastradh (w_component << VE1_VFCOMPONENT_2_SHIFT) | 281903b705cfSriastradh (BRW_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT)); 282003b705cfSriastradh 282103b705cfSriastradh /* u1, v1, w1 */ 282203b705cfSriastradh if (has_mask) { 282303b705cfSriastradh OUT_BATCH((id << GEN6_VE0_VERTEX_BUFFER_INDEX_SHIFT) | 282403b705cfSriastradh GEN6_VE0_VALID | 282503b705cfSriastradh (src_format << VE0_FORMAT_SHIFT) | 282603b705cfSriastradh (((2 + selem) * 4) << VE0_OFFSET_SHIFT)); /* vb offset in bytes */ 282703b705cfSriastradh OUT_BATCH((BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) | 282803b705cfSriastradh (BRW_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) | 282903b705cfSriastradh (w_component << VE1_VFCOMPONENT_2_SHIFT) | 283003b705cfSriastradh (BRW_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT)); 283103b705cfSriastradh } 283203b705cfSriastradh} 283303b705cfSriastradh 283403b705cfSriastradhstatic void 283503b705cfSriastradhgen6_emit_composite_state(struct intel_screen_private *intel) 283603b705cfSriastradh{ 283703b705cfSriastradh struct gen4_render_state *render = intel->gen4_render_state; 283803b705cfSriastradh gen4_composite_op *composite_op = &render->composite_op; 283903b705cfSriastradh sampler_state_filter_t src_filter = composite_op->src_filter; 284003b705cfSriastradh sampler_state_filter_t mask_filter = composite_op->mask_filter; 284103b705cfSriastradh sampler_state_extend_t src_extend = composite_op->src_extend; 284203b705cfSriastradh sampler_state_extend_t mask_extend = composite_op->mask_extend; 284303b705cfSriastradh Bool is_affine = composite_op->is_affine; 284403b705cfSriastradh Bool has_mask = intel->render_mask != NULL; 284503b705cfSriastradh Bool ivb = INTEL_INFO(intel)->gen >= 070; 284603b705cfSriastradh uint32_t src, dst; 284703b705cfSriastradh drm_intel_bo *ps_sampler_state_bo = render->ps_sampler_state_bo[src_filter][src_extend][mask_filter][mask_extend]; 284803b705cfSriastradh 284903b705cfSriastradh intel->needs_render_state_emit = FALSE; 285003b705cfSriastradh if (intel->needs_3d_invariant) { 285103b705cfSriastradh gen6_upload_invariant_states(intel); 285203b705cfSriastradh 285303b705cfSriastradh if (ivb) { 285403b705cfSriastradh gen7_upload_viewport_state_pointers(intel, render->cc_vp_bo); 285503b705cfSriastradh gen7_upload_urb(intel); 285603b705cfSriastradh gen7_upload_bypass_states(intel); 285703b705cfSriastradh gen7_upload_depth_buffer_state(intel); 285803b705cfSriastradh } else { 285903b705cfSriastradh gen6_upload_invariant_states(intel); 286003b705cfSriastradh gen6_upload_viewport_state_pointers(intel, render->cc_vp_bo); 286103b705cfSriastradh gen6_upload_urb(intel); 286203b705cfSriastradh 286303b705cfSriastradh gen6_upload_gs_state(intel); 286403b705cfSriastradh gen6_upload_depth_buffer_state(intel); 286503b705cfSriastradh } 286603b705cfSriastradh gen6_composite_wm_constants(intel); 286703b705cfSriastradh gen6_upload_vs_state(intel); 286803b705cfSriastradh gen6_upload_clip_state(intel); 286903b705cfSriastradh 287003b705cfSriastradh intel->needs_3d_invariant = FALSE; 287103b705cfSriastradh } 287203b705cfSriastradh 287303b705cfSriastradh i965_get_blend_cntl(composite_op->op, 287403b705cfSriastradh intel->render_mask_picture, 287503b705cfSriastradh intel->render_dest_picture->format, 287603b705cfSriastradh &src, &dst); 287703b705cfSriastradh 287803b705cfSriastradh if (intel->surface_reloc == 0) 287903b705cfSriastradh gen6_composite_state_base_address(intel); 288003b705cfSriastradh 288103b705cfSriastradh gen6_composite_cc_state_pointers(intel, 288203b705cfSriastradh (src * BRW_BLENDFACTOR_COUNT + dst) * GEN6_BLEND_STATE_PADDED_SIZE); 288303b705cfSriastradh gen6_composite_sampler_state_pointers(intel, ps_sampler_state_bo); 288403b705cfSriastradh gen6_composite_sf_state(intel, has_mask); 288503b705cfSriastradh if (ivb) { 288603b705cfSriastradh gen7_composite_wm_state(intel, has_mask, 288703b705cfSriastradh render->wm_kernel_bo[composite_op->wm_kernel]); 288803b705cfSriastradh gen7_upload_binding_table(intel, intel->surface_table); 288903b705cfSriastradh } else { 289003b705cfSriastradh gen6_composite_wm_state(intel, has_mask, 289103b705cfSriastradh render->wm_kernel_bo[composite_op->wm_kernel]); 289203b705cfSriastradh gen6_upload_binding_table(intel, intel->surface_table); 289303b705cfSriastradh } 289403b705cfSriastradh gen6_composite_drawing_rectangle(intel, intel->render_dest); 289503b705cfSriastradh gen6_composite_vertex_element_state(intel, has_mask, is_affine); 289603b705cfSriastradh} 289703b705cfSriastradh 289803b705cfSriastradhstatic void 289903b705cfSriastradhgen6_render_state_init(ScrnInfoPtr scrn) 290003b705cfSriastradh{ 290103b705cfSriastradh intel_screen_private *intel = intel_get_screen_private(scrn); 290203b705cfSriastradh struct gen4_render_state *render; 290303b705cfSriastradh sampler_state_filter_t src_filter; 290403b705cfSriastradh sampler_state_filter_t mask_filter; 290503b705cfSriastradh sampler_state_extend_t src_extend; 290603b705cfSriastradh sampler_state_extend_t mask_extend; 290703b705cfSriastradh int m; 290803b705cfSriastradh drm_intel_bo *border_color_bo; 290903b705cfSriastradh const struct wm_kernel_info *wm_kernels; 291003b705cfSriastradh 291103b705cfSriastradh render= intel->gen4_render_state; 291203b705cfSriastradh render->composite_op.vertex_id = -1; 291303b705cfSriastradh 291403b705cfSriastradh intel->gen6_render_state.num_sf_outputs = 0; 291503b705cfSriastradh intel->gen6_render_state.samplers = NULL; 291603b705cfSriastradh intel->gen6_render_state.blend = -1; 291703b705cfSriastradh intel->gen6_render_state.kernel = NULL; 291803b705cfSriastradh intel->gen6_render_state.drawrect = -1; 291903b705cfSriastradh 292003b705cfSriastradh wm_kernels = IS_GEN7(intel) ? wm_kernels_gen7 : wm_kernels_gen6; 292103b705cfSriastradh for (m = 0; m < KERNEL_COUNT; m++) { 292203b705cfSriastradh render->wm_kernel_bo[m] = 292313496ba1Ssnj intel_uxa_bo_alloc_for_data(intel, 292403b705cfSriastradh wm_kernels[m].data, 292503b705cfSriastradh wm_kernels[m].size, 292603b705cfSriastradh "WM kernel gen6/7"); 292703b705cfSriastradh } 292803b705cfSriastradh 292903b705cfSriastradh border_color_bo = sampler_border_color_create(intel); 293003b705cfSriastradh 293103b705cfSriastradh for (src_filter = 0; src_filter < FILTER_COUNT; src_filter++) { 293203b705cfSriastradh for (src_extend = 0; src_extend < EXTEND_COUNT; src_extend++) { 293303b705cfSriastradh for (mask_filter = 0; mask_filter < FILTER_COUNT; mask_filter++) { 293403b705cfSriastradh for (mask_extend = 0; mask_extend < EXTEND_COUNT; mask_extend++) { 293503b705cfSriastradh render->ps_sampler_state_bo[src_filter][src_extend][mask_filter][mask_extend] = 293603b705cfSriastradh i965_create_sampler_state(intel, 293703b705cfSriastradh src_filter, src_extend, 293803b705cfSriastradh mask_filter, mask_extend, 293903b705cfSriastradh border_color_bo); 294003b705cfSriastradh } 294103b705cfSriastradh } 294203b705cfSriastradh } 294303b705cfSriastradh } 294403b705cfSriastradh 294503b705cfSriastradh drm_intel_bo_unreference(border_color_bo); 294603b705cfSriastradh render->cc_vp_bo = gen4_create_cc_viewport(intel); 294703b705cfSriastradh render->cc_state_bo = gen6_composite_create_cc_state(intel); 294803b705cfSriastradh render->gen6_blend_bo = gen6_composite_create_blend_state(intel); 294903b705cfSriastradh render->gen6_depth_stencil_bo = gen6_composite_create_depth_stencil_state(intel); 295003b705cfSriastradh} 295103b705cfSriastradh 295203b705cfSriastradhvoid i965_vertex_flush(struct intel_screen_private *intel) 295303b705cfSriastradh{ 295403b705cfSriastradh if (intel->vertex_offset) { 295503b705cfSriastradh intel->batch_ptr[intel->vertex_offset] = 295603b705cfSriastradh intel->vertex_index - intel->vertex_count; 295703b705cfSriastradh intel->vertex_offset = 0; 295803b705cfSriastradh } 295903b705cfSriastradh} 296003b705cfSriastradh 296103b705cfSriastradhvoid i965_batch_flush(struct intel_screen_private *intel) 296203b705cfSriastradh{ 296303b705cfSriastradh if (intel->surface_used) 296403b705cfSriastradh i965_surface_flush(intel); 296503b705cfSriastradh} 2966