1bf215546Sopenharmony_ci/************************************************************************** 2bf215546Sopenharmony_ci * 3bf215546Sopenharmony_ci * Copyright 2007 VMware, Inc. 4bf215546Sopenharmony_ci * All Rights Reserved. 5bf215546Sopenharmony_ci * 6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the 8bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including 9bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish, 10bf215546Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to 11bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to 12bf215546Sopenharmony_ci * the following conditions: 13bf215546Sopenharmony_ci * 14bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the 15bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions 16bf215546Sopenharmony_ci * of the Software. 17bf215546Sopenharmony_ci * 18bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21bf215546Sopenharmony_ci * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 22bf215546Sopenharmony_ci * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23bf215546Sopenharmony_ci * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24bf215546Sopenharmony_ci * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25bf215546Sopenharmony_ci * 26bf215546Sopenharmony_ci **************************************************************************/ 27bf215546Sopenharmony_ci 28bf215546Sopenharmony_ci/* Authors: Keith Whitwell <keithw@vmware.com> 29bf215546Sopenharmony_ci */ 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_ci#include "compiler/nir/nir_builder.h" 32bf215546Sopenharmony_ci#include "draw/draw_context.h" 33bf215546Sopenharmony_ci#include "nir/nir_to_tgsi.h" 34bf215546Sopenharmony_ci#include "tgsi/tgsi_parse.h" 35bf215546Sopenharmony_ci#include "util/u_helpers.h" 36bf215546Sopenharmony_ci#include "util/u_inlines.h" 37bf215546Sopenharmony_ci#include "util/u_math.h" 38bf215546Sopenharmony_ci#include "util/u_memory.h" 39bf215546Sopenharmony_ci#include "util/u_transfer.h" 40bf215546Sopenharmony_ci#include "nir.h" 41bf215546Sopenharmony_ci 42bf215546Sopenharmony_ci#include "i915_context.h" 43bf215546Sopenharmony_ci#include "i915_fpc.h" 44bf215546Sopenharmony_ci#include "i915_reg.h" 45bf215546Sopenharmony_ci#include "i915_resource.h" 46bf215546Sopenharmony_ci#include "i915_state.h" 47bf215546Sopenharmony_ci#include "i915_state_inlines.h" 48bf215546Sopenharmony_ci 49bf215546Sopenharmony_ci/* The i915 (and related graphics cores) do not support GL_CLAMP. The 50bf215546Sopenharmony_ci * Intel drivers for "other operating systems" implement GL_CLAMP as 51bf215546Sopenharmony_ci * GL_CLAMP_TO_EDGE, so the same is done here. 52bf215546Sopenharmony_ci */ 53bf215546Sopenharmony_cistatic unsigned 54bf215546Sopenharmony_citranslate_wrap_mode(unsigned wrap) 55bf215546Sopenharmony_ci{ 56bf215546Sopenharmony_ci switch (wrap) { 57bf215546Sopenharmony_ci case PIPE_TEX_WRAP_REPEAT: 58bf215546Sopenharmony_ci return TEXCOORDMODE_WRAP; 59bf215546Sopenharmony_ci case PIPE_TEX_WRAP_CLAMP: 60bf215546Sopenharmony_ci return TEXCOORDMODE_CLAMP_EDGE; /* not quite correct */ 61bf215546Sopenharmony_ci case PIPE_TEX_WRAP_CLAMP_TO_EDGE: 62bf215546Sopenharmony_ci return TEXCOORDMODE_CLAMP_EDGE; 63bf215546Sopenharmony_ci case PIPE_TEX_WRAP_CLAMP_TO_BORDER: 64bf215546Sopenharmony_ci return TEXCOORDMODE_CLAMP_BORDER; 65bf215546Sopenharmony_ci case PIPE_TEX_WRAP_MIRROR_REPEAT: 66bf215546Sopenharmony_ci return TEXCOORDMODE_MIRROR; 67bf215546Sopenharmony_ci default: 68bf215546Sopenharmony_ci return TEXCOORDMODE_WRAP; 69bf215546Sopenharmony_ci } 70bf215546Sopenharmony_ci} 71bf215546Sopenharmony_ci 72bf215546Sopenharmony_cistatic unsigned 73bf215546Sopenharmony_citranslate_img_filter(unsigned filter) 74bf215546Sopenharmony_ci{ 75bf215546Sopenharmony_ci switch (filter) { 76bf215546Sopenharmony_ci case PIPE_TEX_FILTER_NEAREST: 77bf215546Sopenharmony_ci return FILTER_NEAREST; 78bf215546Sopenharmony_ci case PIPE_TEX_FILTER_LINEAR: 79bf215546Sopenharmony_ci return FILTER_LINEAR; 80bf215546Sopenharmony_ci default: 81bf215546Sopenharmony_ci assert(0); 82bf215546Sopenharmony_ci return FILTER_NEAREST; 83bf215546Sopenharmony_ci } 84bf215546Sopenharmony_ci} 85bf215546Sopenharmony_ci 86bf215546Sopenharmony_cistatic unsigned 87bf215546Sopenharmony_citranslate_mip_filter(unsigned filter) 88bf215546Sopenharmony_ci{ 89bf215546Sopenharmony_ci switch (filter) { 90bf215546Sopenharmony_ci case PIPE_TEX_MIPFILTER_NONE: 91bf215546Sopenharmony_ci return MIPFILTER_NONE; 92bf215546Sopenharmony_ci case PIPE_TEX_MIPFILTER_NEAREST: 93bf215546Sopenharmony_ci return MIPFILTER_NEAREST; 94bf215546Sopenharmony_ci case PIPE_TEX_MIPFILTER_LINEAR: 95bf215546Sopenharmony_ci return MIPFILTER_LINEAR; 96bf215546Sopenharmony_ci default: 97bf215546Sopenharmony_ci assert(0); 98bf215546Sopenharmony_ci return MIPFILTER_NONE; 99bf215546Sopenharmony_ci } 100bf215546Sopenharmony_ci} 101bf215546Sopenharmony_ci 102bf215546Sopenharmony_cistatic uint32_t 103bf215546Sopenharmony_cii915_remap_lis6_blend_dst_alpha(uint32_t lis6, uint32_t normal, uint32_t inv) 104bf215546Sopenharmony_ci{ 105bf215546Sopenharmony_ci uint32_t src = (lis6 >> S6_CBUF_SRC_BLEND_FACT_SHIFT) & BLENDFACT_MASK; 106bf215546Sopenharmony_ci lis6 &= ~SRC_BLND_FACT(BLENDFACT_MASK); 107bf215546Sopenharmony_ci if (src == BLENDFACT_DST_ALPHA) 108bf215546Sopenharmony_ci src = normal; 109bf215546Sopenharmony_ci else if (src == BLENDFACT_INV_DST_ALPHA) 110bf215546Sopenharmony_ci src = inv; 111bf215546Sopenharmony_ci lis6 |= SRC_BLND_FACT(src); 112bf215546Sopenharmony_ci 113bf215546Sopenharmony_ci uint32_t dst = (lis6 >> S6_CBUF_DST_BLEND_FACT_SHIFT) & BLENDFACT_MASK; 114bf215546Sopenharmony_ci lis6 &= ~DST_BLND_FACT(BLENDFACT_MASK); 115bf215546Sopenharmony_ci if (dst == BLENDFACT_DST_ALPHA) 116bf215546Sopenharmony_ci dst = normal; 117bf215546Sopenharmony_ci else if (dst == BLENDFACT_INV_DST_ALPHA) 118bf215546Sopenharmony_ci dst = inv; 119bf215546Sopenharmony_ci lis6 |= DST_BLND_FACT(dst); 120bf215546Sopenharmony_ci 121bf215546Sopenharmony_ci return lis6; 122bf215546Sopenharmony_ci} 123bf215546Sopenharmony_ci 124bf215546Sopenharmony_cistatic uint32_t 125bf215546Sopenharmony_cii915_remap_iab_blend_dst_alpha(uint32_t iab, uint32_t normal, uint32_t inv) 126bf215546Sopenharmony_ci{ 127bf215546Sopenharmony_ci uint32_t src = (iab >> IAB_SRC_FACTOR_SHIFT) & BLENDFACT_MASK; 128bf215546Sopenharmony_ci iab &= ~SRC_BLND_FACT(BLENDFACT_MASK); 129bf215546Sopenharmony_ci if (src == BLENDFACT_DST_ALPHA) 130bf215546Sopenharmony_ci src = normal; 131bf215546Sopenharmony_ci else if (src == BLENDFACT_INV_DST_ALPHA) 132bf215546Sopenharmony_ci src = inv; 133bf215546Sopenharmony_ci iab |= SRC_ABLND_FACT(src); 134bf215546Sopenharmony_ci 135bf215546Sopenharmony_ci uint32_t dst = (iab >> IAB_DST_FACTOR_SHIFT) & BLENDFACT_MASK; 136bf215546Sopenharmony_ci iab &= ~DST_BLND_FACT(BLENDFACT_MASK); 137bf215546Sopenharmony_ci if (dst == BLENDFACT_DST_ALPHA) 138bf215546Sopenharmony_ci dst = normal; 139bf215546Sopenharmony_ci else if (dst == BLENDFACT_INV_DST_ALPHA) 140bf215546Sopenharmony_ci dst = inv; 141bf215546Sopenharmony_ci iab |= DST_ABLND_FACT(dst); 142bf215546Sopenharmony_ci 143bf215546Sopenharmony_ci return iab; 144bf215546Sopenharmony_ci} 145bf215546Sopenharmony_ci 146bf215546Sopenharmony_ci/* None of this state is actually used for anything yet. 147bf215546Sopenharmony_ci */ 148bf215546Sopenharmony_cistatic void * 149bf215546Sopenharmony_cii915_create_blend_state(struct pipe_context *pipe, 150bf215546Sopenharmony_ci const struct pipe_blend_state *blend) 151bf215546Sopenharmony_ci{ 152bf215546Sopenharmony_ci struct i915_blend_state *cso_data = CALLOC_STRUCT(i915_blend_state); 153bf215546Sopenharmony_ci 154bf215546Sopenharmony_ci { 155bf215546Sopenharmony_ci unsigned eqRGB = blend->rt[0].rgb_func; 156bf215546Sopenharmony_ci unsigned srcRGB = blend->rt[0].rgb_src_factor; 157bf215546Sopenharmony_ci unsigned dstRGB = blend->rt[0].rgb_dst_factor; 158bf215546Sopenharmony_ci 159bf215546Sopenharmony_ci unsigned eqA = blend->rt[0].alpha_func; 160bf215546Sopenharmony_ci unsigned srcA = blend->rt[0].alpha_src_factor; 161bf215546Sopenharmony_ci unsigned dstA = blend->rt[0].alpha_dst_factor; 162bf215546Sopenharmony_ci 163bf215546Sopenharmony_ci /* Special handling for MIN/MAX filter modes handled at 164bf215546Sopenharmony_ci * frontend level. 165bf215546Sopenharmony_ci */ 166bf215546Sopenharmony_ci 167bf215546Sopenharmony_ci if (srcA != srcRGB || dstA != dstRGB || eqA != eqRGB) { 168bf215546Sopenharmony_ci 169bf215546Sopenharmony_ci cso_data->iab = (_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD | 170bf215546Sopenharmony_ci IAB_MODIFY_ENABLE | IAB_ENABLE | IAB_MODIFY_FUNC | 171bf215546Sopenharmony_ci IAB_MODIFY_SRC_FACTOR | IAB_MODIFY_DST_FACTOR | 172bf215546Sopenharmony_ci SRC_ABLND_FACT(i915_translate_blend_factor(srcA)) | 173bf215546Sopenharmony_ci DST_ABLND_FACT(i915_translate_blend_factor(dstA)) | 174bf215546Sopenharmony_ci (i915_translate_blend_func(eqA) << IAB_FUNC_SHIFT)); 175bf215546Sopenharmony_ci } else { 176bf215546Sopenharmony_ci cso_data->iab = 177bf215546Sopenharmony_ci (_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD | IAB_MODIFY_ENABLE | 0); 178bf215546Sopenharmony_ci } 179bf215546Sopenharmony_ci } 180bf215546Sopenharmony_ci 181bf215546Sopenharmony_ci cso_data->modes4 |= 182bf215546Sopenharmony_ci (_3DSTATE_MODES_4_CMD | ENABLE_LOGIC_OP_FUNC | 183bf215546Sopenharmony_ci LOGIC_OP_FUNC(i915_translate_logic_op(blend->logicop_func))); 184bf215546Sopenharmony_ci 185bf215546Sopenharmony_ci if (blend->logicop_enable) 186bf215546Sopenharmony_ci cso_data->LIS5 |= S5_LOGICOP_ENABLE; 187bf215546Sopenharmony_ci 188bf215546Sopenharmony_ci if (blend->dither) 189bf215546Sopenharmony_ci cso_data->LIS5 |= S5_COLOR_DITHER_ENABLE; 190bf215546Sopenharmony_ci 191bf215546Sopenharmony_ci /* We potentially do some fixup at emission for non-BGRA targets */ 192bf215546Sopenharmony_ci if ((blend->rt[0].colormask & PIPE_MASK_R) == 0) 193bf215546Sopenharmony_ci cso_data->LIS5 |= S5_WRITEDISABLE_RED; 194bf215546Sopenharmony_ci 195bf215546Sopenharmony_ci if ((blend->rt[0].colormask & PIPE_MASK_G) == 0) 196bf215546Sopenharmony_ci cso_data->LIS5 |= S5_WRITEDISABLE_GREEN; 197bf215546Sopenharmony_ci 198bf215546Sopenharmony_ci if ((blend->rt[0].colormask & PIPE_MASK_B) == 0) 199bf215546Sopenharmony_ci cso_data->LIS5 |= S5_WRITEDISABLE_BLUE; 200bf215546Sopenharmony_ci 201bf215546Sopenharmony_ci if ((blend->rt[0].colormask & PIPE_MASK_A) == 0) 202bf215546Sopenharmony_ci cso_data->LIS5 |= S5_WRITEDISABLE_ALPHA; 203bf215546Sopenharmony_ci 204bf215546Sopenharmony_ci if (blend->rt[0].blend_enable) { 205bf215546Sopenharmony_ci unsigned funcRGB = blend->rt[0].rgb_func; 206bf215546Sopenharmony_ci unsigned srcRGB = blend->rt[0].rgb_src_factor; 207bf215546Sopenharmony_ci unsigned dstRGB = blend->rt[0].rgb_dst_factor; 208bf215546Sopenharmony_ci 209bf215546Sopenharmony_ci cso_data->LIS6 |= 210bf215546Sopenharmony_ci (S6_CBUF_BLEND_ENABLE | 211bf215546Sopenharmony_ci SRC_BLND_FACT(i915_translate_blend_factor(srcRGB)) | 212bf215546Sopenharmony_ci DST_BLND_FACT(i915_translate_blend_factor(dstRGB)) | 213bf215546Sopenharmony_ci (i915_translate_blend_func(funcRGB) << S6_CBUF_BLEND_FUNC_SHIFT)); 214bf215546Sopenharmony_ci } 215bf215546Sopenharmony_ci 216bf215546Sopenharmony_ci cso_data->LIS6_alpha_in_g = i915_remap_lis6_blend_dst_alpha( 217bf215546Sopenharmony_ci cso_data->LIS6, BLENDFACT_DST_COLR, BLENDFACT_INV_DST_COLR); 218bf215546Sopenharmony_ci cso_data->LIS6_alpha_is_x = i915_remap_lis6_blend_dst_alpha( 219bf215546Sopenharmony_ci cso_data->LIS6, BLENDFACT_ONE, BLENDFACT_ZERO); 220bf215546Sopenharmony_ci 221bf215546Sopenharmony_ci cso_data->iab_alpha_in_g = i915_remap_iab_blend_dst_alpha( 222bf215546Sopenharmony_ci cso_data->iab, BLENDFACT_DST_COLR, BLENDFACT_INV_DST_COLR); 223bf215546Sopenharmony_ci cso_data->iab_alpha_is_x = i915_remap_iab_blend_dst_alpha( 224bf215546Sopenharmony_ci cso_data->iab, BLENDFACT_ONE, BLENDFACT_ZERO); 225bf215546Sopenharmony_ci 226bf215546Sopenharmony_ci return cso_data; 227bf215546Sopenharmony_ci} 228bf215546Sopenharmony_ci 229bf215546Sopenharmony_cistatic void 230bf215546Sopenharmony_cii915_bind_blend_state(struct pipe_context *pipe, void *blend) 231bf215546Sopenharmony_ci{ 232bf215546Sopenharmony_ci struct i915_context *i915 = i915_context(pipe); 233bf215546Sopenharmony_ci 234bf215546Sopenharmony_ci if (i915->blend == blend) 235bf215546Sopenharmony_ci return; 236bf215546Sopenharmony_ci 237bf215546Sopenharmony_ci i915->blend = (struct i915_blend_state *)blend; 238bf215546Sopenharmony_ci 239bf215546Sopenharmony_ci i915->dirty |= I915_NEW_BLEND; 240bf215546Sopenharmony_ci} 241bf215546Sopenharmony_ci 242bf215546Sopenharmony_cistatic void 243bf215546Sopenharmony_cii915_delete_blend_state(struct pipe_context *pipe, void *blend) 244bf215546Sopenharmony_ci{ 245bf215546Sopenharmony_ci FREE(blend); 246bf215546Sopenharmony_ci} 247bf215546Sopenharmony_ci 248bf215546Sopenharmony_cistatic void 249bf215546Sopenharmony_cii915_set_blend_color(struct pipe_context *pipe, 250bf215546Sopenharmony_ci const struct pipe_blend_color *blend_color) 251bf215546Sopenharmony_ci{ 252bf215546Sopenharmony_ci struct i915_context *i915 = i915_context(pipe); 253bf215546Sopenharmony_ci 254bf215546Sopenharmony_ci if (!blend_color) 255bf215546Sopenharmony_ci return; 256bf215546Sopenharmony_ci 257bf215546Sopenharmony_ci i915->blend_color = *blend_color; 258bf215546Sopenharmony_ci 259bf215546Sopenharmony_ci i915->dirty |= I915_NEW_BLEND; 260bf215546Sopenharmony_ci} 261bf215546Sopenharmony_ci 262bf215546Sopenharmony_cistatic void 263bf215546Sopenharmony_cii915_set_stencil_ref(struct pipe_context *pipe, 264bf215546Sopenharmony_ci const struct pipe_stencil_ref stencil_ref) 265bf215546Sopenharmony_ci{ 266bf215546Sopenharmony_ci struct i915_context *i915 = i915_context(pipe); 267bf215546Sopenharmony_ci 268bf215546Sopenharmony_ci i915->stencil_ref = stencil_ref; 269bf215546Sopenharmony_ci 270bf215546Sopenharmony_ci i915->dirty |= I915_NEW_DEPTH_STENCIL; 271bf215546Sopenharmony_ci} 272bf215546Sopenharmony_ci 273bf215546Sopenharmony_cistatic void * 274bf215546Sopenharmony_cii915_create_sampler_state(struct pipe_context *pipe, 275bf215546Sopenharmony_ci const struct pipe_sampler_state *sampler) 276bf215546Sopenharmony_ci{ 277bf215546Sopenharmony_ci struct i915_sampler_state *cso = CALLOC_STRUCT(i915_sampler_state); 278bf215546Sopenharmony_ci const unsigned ws = sampler->wrap_s; 279bf215546Sopenharmony_ci const unsigned wt = sampler->wrap_t; 280bf215546Sopenharmony_ci const unsigned wr = sampler->wrap_r; 281bf215546Sopenharmony_ci unsigned minFilt, magFilt; 282bf215546Sopenharmony_ci unsigned mipFilt; 283bf215546Sopenharmony_ci 284bf215546Sopenharmony_ci cso->templ = *sampler; 285bf215546Sopenharmony_ci 286bf215546Sopenharmony_ci mipFilt = translate_mip_filter(sampler->min_mip_filter); 287bf215546Sopenharmony_ci minFilt = translate_img_filter(sampler->min_img_filter); 288bf215546Sopenharmony_ci magFilt = translate_img_filter(sampler->mag_img_filter); 289bf215546Sopenharmony_ci 290bf215546Sopenharmony_ci if (sampler->max_anisotropy > 1) 291bf215546Sopenharmony_ci minFilt = magFilt = FILTER_ANISOTROPIC; 292bf215546Sopenharmony_ci 293bf215546Sopenharmony_ci if (sampler->max_anisotropy > 2) { 294bf215546Sopenharmony_ci cso->state[0] |= SS2_MAX_ANISO_4; 295bf215546Sopenharmony_ci } 296bf215546Sopenharmony_ci 297bf215546Sopenharmony_ci { 298bf215546Sopenharmony_ci int b = (int)(sampler->lod_bias * 16.0); 299bf215546Sopenharmony_ci b = CLAMP(b, -256, 255); 300bf215546Sopenharmony_ci cso->state[0] |= ((b << SS2_LOD_BIAS_SHIFT) & SS2_LOD_BIAS_MASK); 301bf215546Sopenharmony_ci } 302bf215546Sopenharmony_ci 303bf215546Sopenharmony_ci /* Shadow: 304bf215546Sopenharmony_ci */ 305bf215546Sopenharmony_ci if (sampler->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) { 306bf215546Sopenharmony_ci cso->state[0] |= (SS2_SHADOW_ENABLE | i915_translate_shadow_compare_func( 307bf215546Sopenharmony_ci sampler->compare_func)); 308bf215546Sopenharmony_ci 309bf215546Sopenharmony_ci minFilt = FILTER_4X4_FLAT; 310bf215546Sopenharmony_ci magFilt = FILTER_4X4_FLAT; 311bf215546Sopenharmony_ci } 312bf215546Sopenharmony_ci 313bf215546Sopenharmony_ci cso->state[0] |= 314bf215546Sopenharmony_ci ((minFilt << SS2_MIN_FILTER_SHIFT) | (mipFilt << SS2_MIP_FILTER_SHIFT) | 315bf215546Sopenharmony_ci (magFilt << SS2_MAG_FILTER_SHIFT)); 316bf215546Sopenharmony_ci 317bf215546Sopenharmony_ci cso->state[1] |= ((translate_wrap_mode(ws) << SS3_TCX_ADDR_MODE_SHIFT) | 318bf215546Sopenharmony_ci (translate_wrap_mode(wt) << SS3_TCY_ADDR_MODE_SHIFT) | 319bf215546Sopenharmony_ci (translate_wrap_mode(wr) << SS3_TCZ_ADDR_MODE_SHIFT)); 320bf215546Sopenharmony_ci 321bf215546Sopenharmony_ci if (sampler->normalized_coords) 322bf215546Sopenharmony_ci cso->state[1] |= SS3_NORMALIZED_COORDS; 323bf215546Sopenharmony_ci 324bf215546Sopenharmony_ci { 325bf215546Sopenharmony_ci int minlod = (int)(16.0 * sampler->min_lod); 326bf215546Sopenharmony_ci int maxlod = (int)(16.0 * sampler->max_lod); 327bf215546Sopenharmony_ci minlod = CLAMP(minlod, 0, 16 * 11); 328bf215546Sopenharmony_ci maxlod = CLAMP(maxlod, 0, 16 * 11); 329bf215546Sopenharmony_ci 330bf215546Sopenharmony_ci if (minlod > maxlod) 331bf215546Sopenharmony_ci maxlod = minlod; 332bf215546Sopenharmony_ci 333bf215546Sopenharmony_ci cso->minlod = minlod; 334bf215546Sopenharmony_ci cso->maxlod = maxlod; 335bf215546Sopenharmony_ci } 336bf215546Sopenharmony_ci 337bf215546Sopenharmony_ci { 338bf215546Sopenharmony_ci ubyte r = float_to_ubyte(sampler->border_color.f[0]); 339bf215546Sopenharmony_ci ubyte g = float_to_ubyte(sampler->border_color.f[1]); 340bf215546Sopenharmony_ci ubyte b = float_to_ubyte(sampler->border_color.f[2]); 341bf215546Sopenharmony_ci ubyte a = float_to_ubyte(sampler->border_color.f[3]); 342bf215546Sopenharmony_ci cso->state[2] = I915PACKCOLOR8888(r, g, b, a); 343bf215546Sopenharmony_ci } 344bf215546Sopenharmony_ci return cso; 345bf215546Sopenharmony_ci} 346bf215546Sopenharmony_ci 347bf215546Sopenharmony_cistatic void 348bf215546Sopenharmony_cii915_bind_sampler_states(struct pipe_context *pipe, 349bf215546Sopenharmony_ci enum pipe_shader_type shader, unsigned start, 350bf215546Sopenharmony_ci unsigned num, void **samplers) 351bf215546Sopenharmony_ci{ 352bf215546Sopenharmony_ci if (shader != PIPE_SHADER_FRAGMENT) { 353bf215546Sopenharmony_ci assert(num == 0); 354bf215546Sopenharmony_ci return; 355bf215546Sopenharmony_ci } 356bf215546Sopenharmony_ci 357bf215546Sopenharmony_ci struct i915_context *i915 = i915_context(pipe); 358bf215546Sopenharmony_ci unsigned i; 359bf215546Sopenharmony_ci 360bf215546Sopenharmony_ci /* Check for no-op */ 361bf215546Sopenharmony_ci if (num == i915->num_samplers && 362bf215546Sopenharmony_ci !memcmp(i915->fragment_sampler + start, samplers, num * sizeof(void *))) 363bf215546Sopenharmony_ci return; 364bf215546Sopenharmony_ci 365bf215546Sopenharmony_ci for (i = 0; i < num; ++i) 366bf215546Sopenharmony_ci i915->fragment_sampler[i + start] = samplers[i]; 367bf215546Sopenharmony_ci 368bf215546Sopenharmony_ci /* find highest non-null samplers[] entry */ 369bf215546Sopenharmony_ci { 370bf215546Sopenharmony_ci unsigned j = MAX2(i915->num_samplers, start + num); 371bf215546Sopenharmony_ci while (j > 0 && i915->fragment_sampler[j - 1] == NULL) 372bf215546Sopenharmony_ci j--; 373bf215546Sopenharmony_ci i915->num_samplers = j; 374bf215546Sopenharmony_ci } 375bf215546Sopenharmony_ci 376bf215546Sopenharmony_ci i915->dirty |= I915_NEW_SAMPLER; 377bf215546Sopenharmony_ci} 378bf215546Sopenharmony_ci 379bf215546Sopenharmony_cistatic void 380bf215546Sopenharmony_cii915_delete_sampler_state(struct pipe_context *pipe, void *sampler) 381bf215546Sopenharmony_ci{ 382bf215546Sopenharmony_ci FREE(sampler); 383bf215546Sopenharmony_ci} 384bf215546Sopenharmony_ci 385bf215546Sopenharmony_ci/** XXX move someday? Or consolidate all these simple state setters 386bf215546Sopenharmony_ci * into one file. 387bf215546Sopenharmony_ci */ 388bf215546Sopenharmony_ci 389bf215546Sopenharmony_cistatic uint32_t 390bf215546Sopenharmony_cii915_get_modes4_stencil(const struct pipe_stencil_state *stencil) 391bf215546Sopenharmony_ci{ 392bf215546Sopenharmony_ci int testmask = stencil->valuemask & 0xff; 393bf215546Sopenharmony_ci int writemask = stencil->writemask & 0xff; 394bf215546Sopenharmony_ci 395bf215546Sopenharmony_ci return (_3DSTATE_MODES_4_CMD | ENABLE_STENCIL_TEST_MASK | 396bf215546Sopenharmony_ci STENCIL_TEST_MASK(testmask) | ENABLE_STENCIL_WRITE_MASK | 397bf215546Sopenharmony_ci STENCIL_WRITE_MASK(writemask)); 398bf215546Sopenharmony_ci} 399bf215546Sopenharmony_ci 400bf215546Sopenharmony_cistatic uint32_t 401bf215546Sopenharmony_cii915_get_lis5_stencil(const struct pipe_stencil_state *stencil) 402bf215546Sopenharmony_ci{ 403bf215546Sopenharmony_ci int test = i915_translate_compare_func(stencil->func); 404bf215546Sopenharmony_ci int fop = i915_translate_stencil_op(stencil->fail_op); 405bf215546Sopenharmony_ci int dfop = i915_translate_stencil_op(stencil->zfail_op); 406bf215546Sopenharmony_ci int dpop = i915_translate_stencil_op(stencil->zpass_op); 407bf215546Sopenharmony_ci 408bf215546Sopenharmony_ci return (S5_STENCIL_TEST_ENABLE | S5_STENCIL_WRITE_ENABLE | 409bf215546Sopenharmony_ci (test << S5_STENCIL_TEST_FUNC_SHIFT) | 410bf215546Sopenharmony_ci (fop << S5_STENCIL_FAIL_SHIFT) | 411bf215546Sopenharmony_ci (dfop << S5_STENCIL_PASS_Z_FAIL_SHIFT) | 412bf215546Sopenharmony_ci (dpop << S5_STENCIL_PASS_Z_PASS_SHIFT)); 413bf215546Sopenharmony_ci} 414bf215546Sopenharmony_ci 415bf215546Sopenharmony_cistatic uint32_t 416bf215546Sopenharmony_cii915_get_bfo(const struct pipe_stencil_state *stencil) 417bf215546Sopenharmony_ci{ 418bf215546Sopenharmony_ci int test = i915_translate_compare_func(stencil->func); 419bf215546Sopenharmony_ci int fop = i915_translate_stencil_op(stencil->fail_op); 420bf215546Sopenharmony_ci int dfop = i915_translate_stencil_op(stencil->zfail_op); 421bf215546Sopenharmony_ci int dpop = i915_translate_stencil_op(stencil->zpass_op); 422bf215546Sopenharmony_ci 423bf215546Sopenharmony_ci return (_3DSTATE_BACKFACE_STENCIL_OPS | BFO_ENABLE_STENCIL_FUNCS | 424bf215546Sopenharmony_ci BFO_ENABLE_STENCIL_TWO_SIDE | BFO_ENABLE_STENCIL_REF | 425bf215546Sopenharmony_ci BFO_STENCIL_TWO_SIDE | (test << BFO_STENCIL_TEST_SHIFT) | 426bf215546Sopenharmony_ci (fop << BFO_STENCIL_FAIL_SHIFT) | 427bf215546Sopenharmony_ci (dfop << BFO_STENCIL_PASS_Z_FAIL_SHIFT) | 428bf215546Sopenharmony_ci (dpop << BFO_STENCIL_PASS_Z_PASS_SHIFT)); 429bf215546Sopenharmony_ci} 430bf215546Sopenharmony_ci 431bf215546Sopenharmony_cistatic uint32_t 432bf215546Sopenharmony_cii915_get_bfm(const struct pipe_stencil_state *stencil) 433bf215546Sopenharmony_ci{ 434bf215546Sopenharmony_ci return (_3DSTATE_BACKFACE_STENCIL_MASKS | BFM_ENABLE_STENCIL_TEST_MASK | 435bf215546Sopenharmony_ci BFM_ENABLE_STENCIL_WRITE_MASK | 436bf215546Sopenharmony_ci ((stencil->valuemask & 0xff) << BFM_STENCIL_TEST_MASK_SHIFT) | 437bf215546Sopenharmony_ci ((stencil->writemask & 0xff) << BFM_STENCIL_WRITE_MASK_SHIFT)); 438bf215546Sopenharmony_ci} 439bf215546Sopenharmony_ci 440bf215546Sopenharmony_cistatic void * 441bf215546Sopenharmony_cii915_create_depth_stencil_state( 442bf215546Sopenharmony_ci struct pipe_context *pipe, 443bf215546Sopenharmony_ci const struct pipe_depth_stencil_alpha_state *depth_stencil) 444bf215546Sopenharmony_ci{ 445bf215546Sopenharmony_ci struct i915_depth_stencil_state *cso = 446bf215546Sopenharmony_ci CALLOC_STRUCT(i915_depth_stencil_state); 447bf215546Sopenharmony_ci 448bf215546Sopenharmony_ci cso->stencil_modes4_cw = i915_get_modes4_stencil(&depth_stencil->stencil[0]); 449bf215546Sopenharmony_ci cso->stencil_modes4_ccw = 450bf215546Sopenharmony_ci i915_get_modes4_stencil(&depth_stencil->stencil[1]); 451bf215546Sopenharmony_ci 452bf215546Sopenharmony_ci if (depth_stencil->stencil[0].enabled) { 453bf215546Sopenharmony_ci cso->stencil_LIS5_cw = i915_get_lis5_stencil(&depth_stencil->stencil[0]); 454bf215546Sopenharmony_ci } 455bf215546Sopenharmony_ci 456bf215546Sopenharmony_ci if (depth_stencil->stencil[1].enabled) { 457bf215546Sopenharmony_ci cso->bfo_cw[0] = i915_get_bfo(&depth_stencil->stencil[1]); 458bf215546Sopenharmony_ci cso->bfo_cw[1] = i915_get_bfm(&depth_stencil->stencil[1]); 459bf215546Sopenharmony_ci 460bf215546Sopenharmony_ci /* Precompute the backface stencil settings if front winding order is 461bf215546Sopenharmony_ci * reversed -- HW doesn't have a bit to flip it for us. 462bf215546Sopenharmony_ci */ 463bf215546Sopenharmony_ci cso->stencil_LIS5_ccw = i915_get_lis5_stencil(&depth_stencil->stencil[1]); 464bf215546Sopenharmony_ci cso->bfo_ccw[0] = i915_get_bfo(&depth_stencil->stencil[0]); 465bf215546Sopenharmony_ci cso->bfo_ccw[1] = i915_get_bfm(&depth_stencil->stencil[0]); 466bf215546Sopenharmony_ci } else { 467bf215546Sopenharmony_ci /* This actually disables two-side stencil: The bit set is a 468bf215546Sopenharmony_ci * modify-enable bit to indicate we are changing the two-side 469bf215546Sopenharmony_ci * setting. Then there is a symbolic zero to show that we are 470bf215546Sopenharmony_ci * setting the flag to zero/off. 471bf215546Sopenharmony_ci */ 472bf215546Sopenharmony_ci cso->bfo_cw[0] = cso->bfo_ccw[0] = 473bf215546Sopenharmony_ci (_3DSTATE_BACKFACE_STENCIL_OPS | BFO_ENABLE_STENCIL_TWO_SIDE | 0); 474bf215546Sopenharmony_ci cso->bfo_cw[1] = cso->bfo_ccw[1] = 0; 475bf215546Sopenharmony_ci 476bf215546Sopenharmony_ci cso->stencil_LIS5_ccw = cso->stencil_LIS5_cw; 477bf215546Sopenharmony_ci } 478bf215546Sopenharmony_ci 479bf215546Sopenharmony_ci if (depth_stencil->depth_enabled) { 480bf215546Sopenharmony_ci int func = i915_translate_compare_func(depth_stencil->depth_func); 481bf215546Sopenharmony_ci 482bf215546Sopenharmony_ci cso->depth_LIS6 |= 483bf215546Sopenharmony_ci (S6_DEPTH_TEST_ENABLE | (func << S6_DEPTH_TEST_FUNC_SHIFT)); 484bf215546Sopenharmony_ci 485bf215546Sopenharmony_ci if (depth_stencil->depth_writemask) 486bf215546Sopenharmony_ci cso->depth_LIS6 |= S6_DEPTH_WRITE_ENABLE; 487bf215546Sopenharmony_ci } 488bf215546Sopenharmony_ci 489bf215546Sopenharmony_ci if (depth_stencil->alpha_enabled) { 490bf215546Sopenharmony_ci int test = i915_translate_compare_func(depth_stencil->alpha_func); 491bf215546Sopenharmony_ci ubyte refByte = float_to_ubyte(depth_stencil->alpha_ref_value); 492bf215546Sopenharmony_ci 493bf215546Sopenharmony_ci cso->depth_LIS6 |= 494bf215546Sopenharmony_ci (S6_ALPHA_TEST_ENABLE | (test << S6_ALPHA_TEST_FUNC_SHIFT) | 495bf215546Sopenharmony_ci (((unsigned)refByte) << S6_ALPHA_REF_SHIFT)); 496bf215546Sopenharmony_ci } 497bf215546Sopenharmony_ci 498bf215546Sopenharmony_ci return cso; 499bf215546Sopenharmony_ci} 500bf215546Sopenharmony_ci 501bf215546Sopenharmony_cistatic void 502bf215546Sopenharmony_cii915_bind_depth_stencil_state(struct pipe_context *pipe, void *depth_stencil) 503bf215546Sopenharmony_ci{ 504bf215546Sopenharmony_ci struct i915_context *i915 = i915_context(pipe); 505bf215546Sopenharmony_ci 506bf215546Sopenharmony_ci if (i915->depth_stencil == depth_stencil) 507bf215546Sopenharmony_ci return; 508bf215546Sopenharmony_ci 509bf215546Sopenharmony_ci i915->depth_stencil = (const struct i915_depth_stencil_state *)depth_stencil; 510bf215546Sopenharmony_ci 511bf215546Sopenharmony_ci i915->dirty |= I915_NEW_DEPTH_STENCIL; 512bf215546Sopenharmony_ci} 513bf215546Sopenharmony_ci 514bf215546Sopenharmony_cistatic void 515bf215546Sopenharmony_cii915_delete_depth_stencil_state(struct pipe_context *pipe, void *depth_stencil) 516bf215546Sopenharmony_ci{ 517bf215546Sopenharmony_ci FREE(depth_stencil); 518bf215546Sopenharmony_ci} 519bf215546Sopenharmony_ci 520bf215546Sopenharmony_cistatic void 521bf215546Sopenharmony_cii915_set_scissor_states(struct pipe_context *pipe, unsigned start_slot, 522bf215546Sopenharmony_ci unsigned num_scissors, 523bf215546Sopenharmony_ci const struct pipe_scissor_state *scissor) 524bf215546Sopenharmony_ci{ 525bf215546Sopenharmony_ci struct i915_context *i915 = i915_context(pipe); 526bf215546Sopenharmony_ci 527bf215546Sopenharmony_ci memcpy(&i915->scissor, scissor, sizeof(*scissor)); 528bf215546Sopenharmony_ci i915->dirty |= I915_NEW_SCISSOR; 529bf215546Sopenharmony_ci} 530bf215546Sopenharmony_ci 531bf215546Sopenharmony_cistatic void 532bf215546Sopenharmony_cii915_set_polygon_stipple(struct pipe_context *pipe, 533bf215546Sopenharmony_ci const struct pipe_poly_stipple *stipple) 534bf215546Sopenharmony_ci{ 535bf215546Sopenharmony_ci} 536bf215546Sopenharmony_ci 537bf215546Sopenharmony_cistatic void * 538bf215546Sopenharmony_cii915_create_fs_state(struct pipe_context *pipe, 539bf215546Sopenharmony_ci const struct pipe_shader_state *templ) 540bf215546Sopenharmony_ci{ 541bf215546Sopenharmony_ci struct i915_context *i915 = i915_context(pipe); 542bf215546Sopenharmony_ci struct i915_fragment_shader *ifs = CALLOC_STRUCT(i915_fragment_shader); 543bf215546Sopenharmony_ci if (!ifs) 544bf215546Sopenharmony_ci return NULL; 545bf215546Sopenharmony_ci 546bf215546Sopenharmony_ci ifs->draw_data = draw_create_fragment_shader(i915->draw, templ); 547bf215546Sopenharmony_ci 548bf215546Sopenharmony_ci if (templ->type == PIPE_SHADER_IR_NIR) { 549bf215546Sopenharmony_ci nir_shader *s = templ->ir.nir; 550bf215546Sopenharmony_ci 551bf215546Sopenharmony_ci static const struct nir_to_tgsi_options ntt_options = { 552bf215546Sopenharmony_ci .lower_fabs = true, 553bf215546Sopenharmony_ci }; 554bf215546Sopenharmony_ci ifs->state.tokens = nir_to_tgsi_options(s, pipe->screen, &ntt_options); 555bf215546Sopenharmony_ci } else { 556bf215546Sopenharmony_ci assert(templ->type == PIPE_SHADER_IR_TGSI); 557bf215546Sopenharmony_ci /* we need to keep a local copy of the tokens */ 558bf215546Sopenharmony_ci ifs->state.tokens = tgsi_dup_tokens(templ->tokens); 559bf215546Sopenharmony_ci } 560bf215546Sopenharmony_ci 561bf215546Sopenharmony_ci ifs->state.type = PIPE_SHADER_IR_TGSI; 562bf215546Sopenharmony_ci 563bf215546Sopenharmony_ci tgsi_scan_shader(ifs->state.tokens, &ifs->info); 564bf215546Sopenharmony_ci 565bf215546Sopenharmony_ci /* The shader's compiled to i915 instructions here */ 566bf215546Sopenharmony_ci i915_translate_fragment_program(i915, ifs); 567bf215546Sopenharmony_ci 568bf215546Sopenharmony_ci return ifs; 569bf215546Sopenharmony_ci} 570bf215546Sopenharmony_ci 571bf215546Sopenharmony_cistatic void 572bf215546Sopenharmony_cii915_bind_fs_state(struct pipe_context *pipe, void *shader) 573bf215546Sopenharmony_ci{ 574bf215546Sopenharmony_ci struct i915_context *i915 = i915_context(pipe); 575bf215546Sopenharmony_ci 576bf215546Sopenharmony_ci if (i915->fs == shader) 577bf215546Sopenharmony_ci return; 578bf215546Sopenharmony_ci 579bf215546Sopenharmony_ci i915->fs = (struct i915_fragment_shader *)shader; 580bf215546Sopenharmony_ci 581bf215546Sopenharmony_ci draw_bind_fragment_shader(i915->draw, 582bf215546Sopenharmony_ci (i915->fs ? i915->fs->draw_data : NULL)); 583bf215546Sopenharmony_ci 584bf215546Sopenharmony_ci /* Tell draw if we need to do point sprites so we can get PNTC. */ 585bf215546Sopenharmony_ci if (i915->fs) 586bf215546Sopenharmony_ci draw_wide_point_sprites(i915->draw, i915->fs->reads_pntc); 587bf215546Sopenharmony_ci 588bf215546Sopenharmony_ci i915->dirty |= I915_NEW_FS; 589bf215546Sopenharmony_ci} 590bf215546Sopenharmony_ci 591bf215546Sopenharmony_cistatic void 592bf215546Sopenharmony_cii915_delete_fs_state(struct pipe_context *pipe, void *shader) 593bf215546Sopenharmony_ci{ 594bf215546Sopenharmony_ci struct i915_fragment_shader *ifs = (struct i915_fragment_shader *)shader; 595bf215546Sopenharmony_ci 596bf215546Sopenharmony_ci FREE(ifs->program); 597bf215546Sopenharmony_ci ifs->program = NULL; 598bf215546Sopenharmony_ci FREE((struct tgsi_token *)ifs->state.tokens); 599bf215546Sopenharmony_ci ifs->state.tokens = NULL; 600bf215546Sopenharmony_ci 601bf215546Sopenharmony_ci ifs->program_len = 0; 602bf215546Sopenharmony_ci 603bf215546Sopenharmony_ci FREE(ifs); 604bf215546Sopenharmony_ci} 605bf215546Sopenharmony_ci 606bf215546Sopenharmony_cistatic void * 607bf215546Sopenharmony_cii915_create_vs_state(struct pipe_context *pipe, 608bf215546Sopenharmony_ci const struct pipe_shader_state *templ) 609bf215546Sopenharmony_ci{ 610bf215546Sopenharmony_ci struct i915_context *i915 = i915_context(pipe); 611bf215546Sopenharmony_ci 612bf215546Sopenharmony_ci struct pipe_shader_state from_nir = { PIPE_SHADER_IR_TGSI }; 613bf215546Sopenharmony_ci if (templ->type == PIPE_SHADER_IR_NIR) { 614bf215546Sopenharmony_ci nir_shader *s = templ->ir.nir; 615bf215546Sopenharmony_ci 616bf215546Sopenharmony_ci NIR_PASS_V(s, nir_lower_point_size, 1.0, 255.0); 617bf215546Sopenharmony_ci 618bf215546Sopenharmony_ci /* The gallivm draw path doesn't support non-native-integers NIR shaders, 619bf215546Sopenharmony_ci * st/mesa does native-integers for the screen as a whole rather than 620bf215546Sopenharmony_ci * per-stage, and i915 FS can't do native integers. So, convert to TGSI, 621bf215546Sopenharmony_ci * where the draw path *does* support non-native-integers. 622bf215546Sopenharmony_ci */ 623bf215546Sopenharmony_ci from_nir.tokens = nir_to_tgsi(s, pipe->screen); 624bf215546Sopenharmony_ci templ = &from_nir; 625bf215546Sopenharmony_ci } 626bf215546Sopenharmony_ci 627bf215546Sopenharmony_ci return draw_create_vertex_shader(i915->draw, templ); 628bf215546Sopenharmony_ci} 629bf215546Sopenharmony_ci 630bf215546Sopenharmony_cistatic void 631bf215546Sopenharmony_cii915_bind_vs_state(struct pipe_context *pipe, void *shader) 632bf215546Sopenharmony_ci{ 633bf215546Sopenharmony_ci struct i915_context *i915 = i915_context(pipe); 634bf215546Sopenharmony_ci 635bf215546Sopenharmony_ci if (i915->vs == shader) 636bf215546Sopenharmony_ci return; 637bf215546Sopenharmony_ci 638bf215546Sopenharmony_ci i915->vs = shader; 639bf215546Sopenharmony_ci 640bf215546Sopenharmony_ci /* just pass-through to draw module */ 641bf215546Sopenharmony_ci draw_bind_vertex_shader(i915->draw, (struct draw_vertex_shader *)shader); 642bf215546Sopenharmony_ci 643bf215546Sopenharmony_ci i915->dirty |= I915_NEW_VS; 644bf215546Sopenharmony_ci} 645bf215546Sopenharmony_ci 646bf215546Sopenharmony_cistatic void 647bf215546Sopenharmony_cii915_delete_vs_state(struct pipe_context *pipe, void *shader) 648bf215546Sopenharmony_ci{ 649bf215546Sopenharmony_ci struct i915_context *i915 = i915_context(pipe); 650bf215546Sopenharmony_ci 651bf215546Sopenharmony_ci /* just pass-through to draw module */ 652bf215546Sopenharmony_ci draw_delete_vertex_shader(i915->draw, (struct draw_vertex_shader *)shader); 653bf215546Sopenharmony_ci} 654bf215546Sopenharmony_ci 655bf215546Sopenharmony_cistatic void 656bf215546Sopenharmony_cii915_set_constant_buffer(struct pipe_context *pipe, 657bf215546Sopenharmony_ci enum pipe_shader_type shader, uint32_t index, 658bf215546Sopenharmony_ci bool take_ownership, 659bf215546Sopenharmony_ci const struct pipe_constant_buffer *cb) 660bf215546Sopenharmony_ci{ 661bf215546Sopenharmony_ci struct i915_context *i915 = i915_context(pipe); 662bf215546Sopenharmony_ci struct pipe_resource *buf = cb ? cb->buffer : NULL; 663bf215546Sopenharmony_ci unsigned new_num = 0; 664bf215546Sopenharmony_ci bool diff = true; 665bf215546Sopenharmony_ci 666bf215546Sopenharmony_ci /* XXX don't support geom shaders now */ 667bf215546Sopenharmony_ci if (shader == PIPE_SHADER_GEOMETRY) 668bf215546Sopenharmony_ci return; 669bf215546Sopenharmony_ci 670bf215546Sopenharmony_ci if (cb && cb->user_buffer) { 671bf215546Sopenharmony_ci buf = i915_user_buffer_create(pipe->screen, (void *)cb->user_buffer, 672bf215546Sopenharmony_ci cb->buffer_size, PIPE_BIND_CONSTANT_BUFFER); 673bf215546Sopenharmony_ci } 674bf215546Sopenharmony_ci 675bf215546Sopenharmony_ci /* if we have a new buffer compare it with the old one */ 676bf215546Sopenharmony_ci if (buf) { 677bf215546Sopenharmony_ci struct i915_buffer *ibuf = i915_buffer(buf); 678bf215546Sopenharmony_ci struct pipe_resource *old_buf = i915->constants[shader]; 679bf215546Sopenharmony_ci struct i915_buffer *old = old_buf ? i915_buffer(old_buf) : NULL; 680bf215546Sopenharmony_ci unsigned old_num = i915->current.num_user_constants[shader]; 681bf215546Sopenharmony_ci 682bf215546Sopenharmony_ci new_num = ibuf->b.width0 / 4 * sizeof(float); 683bf215546Sopenharmony_ci 684bf215546Sopenharmony_ci if (old_num == new_num) { 685bf215546Sopenharmony_ci if (old_num == 0) 686bf215546Sopenharmony_ci diff = false; 687bf215546Sopenharmony_ci#if 0 688bf215546Sopenharmony_ci /* XXX no point in running this code since st/mesa only uses user buffers */ 689bf215546Sopenharmony_ci /* Can't compare the buffer data since they are userbuffers */ 690bf215546Sopenharmony_ci else if (old && old->free_on_destroy) 691bf215546Sopenharmony_ci diff = memcmp(old->data, ibuf->data, ibuf->b.width0); 692bf215546Sopenharmony_ci#else 693bf215546Sopenharmony_ci (void)old; 694bf215546Sopenharmony_ci#endif 695bf215546Sopenharmony_ci } 696bf215546Sopenharmony_ci } else { 697bf215546Sopenharmony_ci diff = i915->current.num_user_constants[shader] != 0; 698bf215546Sopenharmony_ci } 699bf215546Sopenharmony_ci 700bf215546Sopenharmony_ci if (take_ownership) { 701bf215546Sopenharmony_ci pipe_resource_reference(&i915->constants[shader], NULL); 702bf215546Sopenharmony_ci i915->constants[shader] = buf; 703bf215546Sopenharmony_ci } else { 704bf215546Sopenharmony_ci pipe_resource_reference(&i915->constants[shader], buf); 705bf215546Sopenharmony_ci } 706bf215546Sopenharmony_ci i915->current.num_user_constants[shader] = new_num; 707bf215546Sopenharmony_ci 708bf215546Sopenharmony_ci if (diff) 709bf215546Sopenharmony_ci i915->dirty |= shader == PIPE_SHADER_VERTEX ? I915_NEW_VS_CONSTANTS 710bf215546Sopenharmony_ci : I915_NEW_FS_CONSTANTS; 711bf215546Sopenharmony_ci 712bf215546Sopenharmony_ci if (cb && cb->user_buffer) { 713bf215546Sopenharmony_ci pipe_resource_reference(&buf, NULL); 714bf215546Sopenharmony_ci } 715bf215546Sopenharmony_ci} 716bf215546Sopenharmony_ci 717bf215546Sopenharmony_cistatic void 718bf215546Sopenharmony_cii915_set_sampler_views(struct pipe_context *pipe, enum pipe_shader_type shader, 719bf215546Sopenharmony_ci unsigned start, unsigned num, 720bf215546Sopenharmony_ci unsigned unbind_num_trailing_slots, 721bf215546Sopenharmony_ci bool take_ownership, 722bf215546Sopenharmony_ci struct pipe_sampler_view **views) 723bf215546Sopenharmony_ci{ 724bf215546Sopenharmony_ci if (shader != PIPE_SHADER_FRAGMENT) { 725bf215546Sopenharmony_ci /* No support for VS samplers, because it would mean accessing the 726bf215546Sopenharmony_ci * write-combined maps of the textures, which is very slow. VS samplers 727bf215546Sopenharmony_ci * are not a required feature of GL2.1 or GLES2. 728bf215546Sopenharmony_ci */ 729bf215546Sopenharmony_ci assert(num == 0); 730bf215546Sopenharmony_ci return; 731bf215546Sopenharmony_ci } 732bf215546Sopenharmony_ci struct i915_context *i915 = i915_context(pipe); 733bf215546Sopenharmony_ci uint32_t i; 734bf215546Sopenharmony_ci 735bf215546Sopenharmony_ci assert(num <= PIPE_MAX_SAMPLERS); 736bf215546Sopenharmony_ci 737bf215546Sopenharmony_ci /* Check for no-op */ 738bf215546Sopenharmony_ci if (views && num == i915->num_fragment_sampler_views && 739bf215546Sopenharmony_ci !memcmp(i915->fragment_sampler_views, views, 740bf215546Sopenharmony_ci num * sizeof(struct pipe_sampler_view *))) { 741bf215546Sopenharmony_ci if (take_ownership) { 742bf215546Sopenharmony_ci for (unsigned i = 0; i < num; i++) { 743bf215546Sopenharmony_ci struct pipe_sampler_view *view = views[i]; 744bf215546Sopenharmony_ci pipe_sampler_view_reference(&view, NULL); 745bf215546Sopenharmony_ci } 746bf215546Sopenharmony_ci } 747bf215546Sopenharmony_ci return; 748bf215546Sopenharmony_ci } 749bf215546Sopenharmony_ci 750bf215546Sopenharmony_ci for (i = 0; i < num; i++) { 751bf215546Sopenharmony_ci if (take_ownership) { 752bf215546Sopenharmony_ci pipe_sampler_view_reference(&i915->fragment_sampler_views[i], NULL); 753bf215546Sopenharmony_ci i915->fragment_sampler_views[i] = views[i]; 754bf215546Sopenharmony_ci } else { 755bf215546Sopenharmony_ci pipe_sampler_view_reference(&i915->fragment_sampler_views[i], views[i]); 756bf215546Sopenharmony_ci } 757bf215546Sopenharmony_ci } 758bf215546Sopenharmony_ci 759bf215546Sopenharmony_ci for (i = num; i < i915->num_fragment_sampler_views; i++) 760bf215546Sopenharmony_ci pipe_sampler_view_reference(&i915->fragment_sampler_views[i], NULL); 761bf215546Sopenharmony_ci 762bf215546Sopenharmony_ci i915->num_fragment_sampler_views = num; 763bf215546Sopenharmony_ci 764bf215546Sopenharmony_ci i915->dirty |= I915_NEW_SAMPLER_VIEW; 765bf215546Sopenharmony_ci} 766bf215546Sopenharmony_ci 767bf215546Sopenharmony_cistruct pipe_sampler_view * 768bf215546Sopenharmony_cii915_create_sampler_view_custom(struct pipe_context *pipe, 769bf215546Sopenharmony_ci struct pipe_resource *texture, 770bf215546Sopenharmony_ci const struct pipe_sampler_view *templ, 771bf215546Sopenharmony_ci unsigned width0, unsigned height0) 772bf215546Sopenharmony_ci{ 773bf215546Sopenharmony_ci struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); 774bf215546Sopenharmony_ci 775bf215546Sopenharmony_ci if (view) { 776bf215546Sopenharmony_ci *view = *templ; 777bf215546Sopenharmony_ci view->reference.count = 1; 778bf215546Sopenharmony_ci view->texture = NULL; 779bf215546Sopenharmony_ci pipe_resource_reference(&view->texture, texture); 780bf215546Sopenharmony_ci view->context = pipe; 781bf215546Sopenharmony_ci } 782bf215546Sopenharmony_ci 783bf215546Sopenharmony_ci return view; 784bf215546Sopenharmony_ci} 785bf215546Sopenharmony_ci 786bf215546Sopenharmony_cistatic struct pipe_sampler_view * 787bf215546Sopenharmony_cii915_create_sampler_view(struct pipe_context *pipe, 788bf215546Sopenharmony_ci struct pipe_resource *texture, 789bf215546Sopenharmony_ci const struct pipe_sampler_view *templ) 790bf215546Sopenharmony_ci{ 791bf215546Sopenharmony_ci struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); 792bf215546Sopenharmony_ci 793bf215546Sopenharmony_ci if (view) { 794bf215546Sopenharmony_ci *view = *templ; 795bf215546Sopenharmony_ci view->reference.count = 1; 796bf215546Sopenharmony_ci view->texture = NULL; 797bf215546Sopenharmony_ci pipe_resource_reference(&view->texture, texture); 798bf215546Sopenharmony_ci view->context = pipe; 799bf215546Sopenharmony_ci } 800bf215546Sopenharmony_ci 801bf215546Sopenharmony_ci return view; 802bf215546Sopenharmony_ci} 803bf215546Sopenharmony_ci 804bf215546Sopenharmony_cistatic void 805bf215546Sopenharmony_cii915_sampler_view_destroy(struct pipe_context *pipe, 806bf215546Sopenharmony_ci struct pipe_sampler_view *view) 807bf215546Sopenharmony_ci{ 808bf215546Sopenharmony_ci pipe_resource_reference(&view->texture, NULL); 809bf215546Sopenharmony_ci FREE(view); 810bf215546Sopenharmony_ci} 811bf215546Sopenharmony_ci 812bf215546Sopenharmony_cistatic void 813bf215546Sopenharmony_cii915_set_framebuffer_state(struct pipe_context *pipe, 814bf215546Sopenharmony_ci const struct pipe_framebuffer_state *fb) 815bf215546Sopenharmony_ci{ 816bf215546Sopenharmony_ci struct i915_context *i915 = i915_context(pipe); 817bf215546Sopenharmony_ci 818bf215546Sopenharmony_ci i915->framebuffer.width = fb->width; 819bf215546Sopenharmony_ci i915->framebuffer.height = fb->height; 820bf215546Sopenharmony_ci i915->framebuffer.nr_cbufs = fb->nr_cbufs; 821bf215546Sopenharmony_ci if (fb->nr_cbufs) { 822bf215546Sopenharmony_ci pipe_surface_reference(&i915->framebuffer.cbufs[0], fb->cbufs[0]); 823bf215546Sopenharmony_ci 824bf215546Sopenharmony_ci struct i915_surface *surf = i915_surface(i915->framebuffer.cbufs[0]); 825bf215546Sopenharmony_ci if (i915->current.fixup_swizzle != surf->oc_swizzle) { 826bf215546Sopenharmony_ci i915->current.fixup_swizzle = surf->oc_swizzle; 827bf215546Sopenharmony_ci memcpy(i915->current.color_swizzle, surf->color_swizzle, 828bf215546Sopenharmony_ci sizeof(surf->color_swizzle)); 829bf215546Sopenharmony_ci i915->dirty |= I915_NEW_COLOR_SWIZZLE; 830bf215546Sopenharmony_ci } 831bf215546Sopenharmony_ci } else { 832bf215546Sopenharmony_ci pipe_surface_reference(&i915->framebuffer.cbufs[0], NULL); 833bf215546Sopenharmony_ci } 834bf215546Sopenharmony_ci pipe_surface_reference(&i915->framebuffer.zsbuf, fb->zsbuf); 835bf215546Sopenharmony_ci if (fb->zsbuf) 836bf215546Sopenharmony_ci draw_set_zs_format(i915->draw, fb->zsbuf->format); 837bf215546Sopenharmony_ci 838bf215546Sopenharmony_ci i915->dirty |= I915_NEW_FRAMEBUFFER; 839bf215546Sopenharmony_ci} 840bf215546Sopenharmony_ci 841bf215546Sopenharmony_cistatic void 842bf215546Sopenharmony_cii915_set_clip_state(struct pipe_context *pipe, 843bf215546Sopenharmony_ci const struct pipe_clip_state *clip) 844bf215546Sopenharmony_ci{ 845bf215546Sopenharmony_ci struct i915_context *i915 = i915_context(pipe); 846bf215546Sopenharmony_ci 847bf215546Sopenharmony_ci i915->clip = *clip; 848bf215546Sopenharmony_ci 849bf215546Sopenharmony_ci draw_set_clip_state(i915->draw, clip); 850bf215546Sopenharmony_ci 851bf215546Sopenharmony_ci i915->dirty |= I915_NEW_CLIP; 852bf215546Sopenharmony_ci} 853bf215546Sopenharmony_ci 854bf215546Sopenharmony_ci/* Called when gallium frontends notice changes to the viewport 855bf215546Sopenharmony_ci * matrix: 856bf215546Sopenharmony_ci */ 857bf215546Sopenharmony_cistatic void 858bf215546Sopenharmony_cii915_set_viewport_states(struct pipe_context *pipe, unsigned start_slot, 859bf215546Sopenharmony_ci unsigned num_viewports, 860bf215546Sopenharmony_ci const struct pipe_viewport_state *viewport) 861bf215546Sopenharmony_ci{ 862bf215546Sopenharmony_ci struct i915_context *i915 = i915_context(pipe); 863bf215546Sopenharmony_ci 864bf215546Sopenharmony_ci i915->viewport = *viewport; /* struct copy */ 865bf215546Sopenharmony_ci 866bf215546Sopenharmony_ci /* pass the viewport info to the draw module */ 867bf215546Sopenharmony_ci draw_set_viewport_states(i915->draw, start_slot, num_viewports, 868bf215546Sopenharmony_ci &i915->viewport); 869bf215546Sopenharmony_ci 870bf215546Sopenharmony_ci i915->dirty |= I915_NEW_VIEWPORT; 871bf215546Sopenharmony_ci} 872bf215546Sopenharmony_ci 873bf215546Sopenharmony_cistatic void * 874bf215546Sopenharmony_cii915_create_rasterizer_state(struct pipe_context *pipe, 875bf215546Sopenharmony_ci const struct pipe_rasterizer_state *rasterizer) 876bf215546Sopenharmony_ci{ 877bf215546Sopenharmony_ci struct i915_rasterizer_state *cso = CALLOC_STRUCT(i915_rasterizer_state); 878bf215546Sopenharmony_ci 879bf215546Sopenharmony_ci cso->templ = *rasterizer; 880bf215546Sopenharmony_ci cso->light_twoside = rasterizer->light_twoside; 881bf215546Sopenharmony_ci cso->ds[0].u = _3DSTATE_DEPTH_OFFSET_SCALE; 882bf215546Sopenharmony_ci cso->ds[1].f = rasterizer->offset_scale; 883bf215546Sopenharmony_ci if (rasterizer->poly_stipple_enable) { 884bf215546Sopenharmony_ci cso->st |= ST1_ENABLE; 885bf215546Sopenharmony_ci } 886bf215546Sopenharmony_ci 887bf215546Sopenharmony_ci if (rasterizer->scissor) 888bf215546Sopenharmony_ci cso->sc[0] = _3DSTATE_SCISSOR_ENABLE_CMD | ENABLE_SCISSOR_RECT; 889bf215546Sopenharmony_ci else 890bf215546Sopenharmony_ci cso->sc[0] = _3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT; 891bf215546Sopenharmony_ci 892bf215546Sopenharmony_ci switch (rasterizer->cull_face) { 893bf215546Sopenharmony_ci case PIPE_FACE_NONE: 894bf215546Sopenharmony_ci cso->LIS4 |= S4_CULLMODE_NONE; 895bf215546Sopenharmony_ci break; 896bf215546Sopenharmony_ci case PIPE_FACE_FRONT: 897bf215546Sopenharmony_ci if (rasterizer->front_ccw) 898bf215546Sopenharmony_ci cso->LIS4 |= S4_CULLMODE_CCW; 899bf215546Sopenharmony_ci else 900bf215546Sopenharmony_ci cso->LIS4 |= S4_CULLMODE_CW; 901bf215546Sopenharmony_ci break; 902bf215546Sopenharmony_ci case PIPE_FACE_BACK: 903bf215546Sopenharmony_ci if (rasterizer->front_ccw) 904bf215546Sopenharmony_ci cso->LIS4 |= S4_CULLMODE_CW; 905bf215546Sopenharmony_ci else 906bf215546Sopenharmony_ci cso->LIS4 |= S4_CULLMODE_CCW; 907bf215546Sopenharmony_ci break; 908bf215546Sopenharmony_ci case PIPE_FACE_FRONT_AND_BACK: 909bf215546Sopenharmony_ci cso->LIS4 |= S4_CULLMODE_BOTH; 910bf215546Sopenharmony_ci break; 911bf215546Sopenharmony_ci } 912bf215546Sopenharmony_ci 913bf215546Sopenharmony_ci { 914bf215546Sopenharmony_ci int line_width = CLAMP((int)(rasterizer->line_width * 2), 1, 0xf); 915bf215546Sopenharmony_ci 916bf215546Sopenharmony_ci cso->LIS4 |= line_width << S4_LINE_WIDTH_SHIFT; 917bf215546Sopenharmony_ci 918bf215546Sopenharmony_ci if (rasterizer->line_smooth) 919bf215546Sopenharmony_ci cso->LIS4 |= S4_LINE_ANTIALIAS_ENABLE; 920bf215546Sopenharmony_ci } 921bf215546Sopenharmony_ci 922bf215546Sopenharmony_ci { 923bf215546Sopenharmony_ci int point_size = CLAMP((int)rasterizer->point_size, 1, 0xff); 924bf215546Sopenharmony_ci 925bf215546Sopenharmony_ci cso->LIS4 |= point_size << S4_POINT_WIDTH_SHIFT; 926bf215546Sopenharmony_ci } 927bf215546Sopenharmony_ci 928bf215546Sopenharmony_ci if (rasterizer->flatshade) { 929bf215546Sopenharmony_ci cso->LIS4 |= 930bf215546Sopenharmony_ci (S4_FLATSHADE_ALPHA | S4_FLATSHADE_COLOR | S4_FLATSHADE_SPECULAR); 931bf215546Sopenharmony_ci } 932bf215546Sopenharmony_ci 933bf215546Sopenharmony_ci if (!rasterizer->flatshade_first) 934bf215546Sopenharmony_ci cso->LIS6 |= (2 << S6_TRISTRIP_PV_SHIFT); 935bf215546Sopenharmony_ci 936bf215546Sopenharmony_ci cso->LIS7 = fui(rasterizer->offset_units); 937bf215546Sopenharmony_ci 938bf215546Sopenharmony_ci return cso; 939bf215546Sopenharmony_ci} 940bf215546Sopenharmony_ci 941bf215546Sopenharmony_cistatic void 942bf215546Sopenharmony_cii915_bind_rasterizer_state(struct pipe_context *pipe, void *raster) 943bf215546Sopenharmony_ci{ 944bf215546Sopenharmony_ci struct i915_context *i915 = i915_context(pipe); 945bf215546Sopenharmony_ci 946bf215546Sopenharmony_ci if (i915->rasterizer == raster) 947bf215546Sopenharmony_ci return; 948bf215546Sopenharmony_ci 949bf215546Sopenharmony_ci i915->rasterizer = (struct i915_rasterizer_state *)raster; 950bf215546Sopenharmony_ci 951bf215546Sopenharmony_ci /* pass-through to draw module */ 952bf215546Sopenharmony_ci draw_set_rasterizer_state( 953bf215546Sopenharmony_ci i915->draw, (i915->rasterizer ? &(i915->rasterizer->templ) : NULL), 954bf215546Sopenharmony_ci raster); 955bf215546Sopenharmony_ci 956bf215546Sopenharmony_ci i915->dirty |= I915_NEW_RASTERIZER; 957bf215546Sopenharmony_ci} 958bf215546Sopenharmony_ci 959bf215546Sopenharmony_cistatic void 960bf215546Sopenharmony_cii915_delete_rasterizer_state(struct pipe_context *pipe, void *raster) 961bf215546Sopenharmony_ci{ 962bf215546Sopenharmony_ci FREE(raster); 963bf215546Sopenharmony_ci} 964bf215546Sopenharmony_ci 965bf215546Sopenharmony_cistatic void 966bf215546Sopenharmony_cii915_set_vertex_buffers(struct pipe_context *pipe, unsigned start_slot, 967bf215546Sopenharmony_ci unsigned count, unsigned unbind_num_trailing_slots, 968bf215546Sopenharmony_ci bool take_ownership, 969bf215546Sopenharmony_ci const struct pipe_vertex_buffer *buffers) 970bf215546Sopenharmony_ci{ 971bf215546Sopenharmony_ci struct i915_context *i915 = i915_context(pipe); 972bf215546Sopenharmony_ci struct draw_context *draw = i915->draw; 973bf215546Sopenharmony_ci 974bf215546Sopenharmony_ci util_set_vertex_buffers_count(i915->vertex_buffers, &i915->nr_vertex_buffers, 975bf215546Sopenharmony_ci buffers, start_slot, count, 976bf215546Sopenharmony_ci unbind_num_trailing_slots, take_ownership); 977bf215546Sopenharmony_ci 978bf215546Sopenharmony_ci /* pass-through to draw module */ 979bf215546Sopenharmony_ci draw_set_vertex_buffers(draw, start_slot, count, unbind_num_trailing_slots, 980bf215546Sopenharmony_ci buffers); 981bf215546Sopenharmony_ci} 982bf215546Sopenharmony_ci 983bf215546Sopenharmony_cistatic void * 984bf215546Sopenharmony_cii915_create_vertex_elements_state(struct pipe_context *pipe, unsigned count, 985bf215546Sopenharmony_ci const struct pipe_vertex_element *attribs) 986bf215546Sopenharmony_ci{ 987bf215546Sopenharmony_ci struct i915_velems_state *velems; 988bf215546Sopenharmony_ci assert(count <= PIPE_MAX_ATTRIBS); 989bf215546Sopenharmony_ci velems = 990bf215546Sopenharmony_ci (struct i915_velems_state *)MALLOC(sizeof(struct i915_velems_state)); 991bf215546Sopenharmony_ci if (velems) { 992bf215546Sopenharmony_ci velems->count = count; 993bf215546Sopenharmony_ci memcpy(velems->velem, attribs, sizeof(*attribs) * count); 994bf215546Sopenharmony_ci } 995bf215546Sopenharmony_ci return velems; 996bf215546Sopenharmony_ci} 997bf215546Sopenharmony_ci 998bf215546Sopenharmony_cistatic void 999bf215546Sopenharmony_cii915_bind_vertex_elements_state(struct pipe_context *pipe, void *velems) 1000bf215546Sopenharmony_ci{ 1001bf215546Sopenharmony_ci struct i915_context *i915 = i915_context(pipe); 1002bf215546Sopenharmony_ci struct i915_velems_state *i915_velems = (struct i915_velems_state *)velems; 1003bf215546Sopenharmony_ci 1004bf215546Sopenharmony_ci if (i915->velems == velems) 1005bf215546Sopenharmony_ci return; 1006bf215546Sopenharmony_ci 1007bf215546Sopenharmony_ci i915->velems = velems; 1008bf215546Sopenharmony_ci 1009bf215546Sopenharmony_ci /* pass-through to draw module */ 1010bf215546Sopenharmony_ci if (i915_velems) { 1011bf215546Sopenharmony_ci draw_set_vertex_elements(i915->draw, i915_velems->count, 1012bf215546Sopenharmony_ci i915_velems->velem); 1013bf215546Sopenharmony_ci } 1014bf215546Sopenharmony_ci} 1015bf215546Sopenharmony_ci 1016bf215546Sopenharmony_cistatic void 1017bf215546Sopenharmony_cii915_delete_vertex_elements_state(struct pipe_context *pipe, void *velems) 1018bf215546Sopenharmony_ci{ 1019bf215546Sopenharmony_ci FREE(velems); 1020bf215546Sopenharmony_ci} 1021bf215546Sopenharmony_ci 1022bf215546Sopenharmony_cistatic void 1023bf215546Sopenharmony_cii915_set_sample_mask(struct pipe_context *pipe, unsigned sample_mask) 1024bf215546Sopenharmony_ci{ 1025bf215546Sopenharmony_ci} 1026bf215546Sopenharmony_ci 1027bf215546Sopenharmony_civoid 1028bf215546Sopenharmony_cii915_init_state_functions(struct i915_context *i915) 1029bf215546Sopenharmony_ci{ 1030bf215546Sopenharmony_ci i915->base.create_blend_state = i915_create_blend_state; 1031bf215546Sopenharmony_ci i915->base.bind_blend_state = i915_bind_blend_state; 1032bf215546Sopenharmony_ci i915->base.delete_blend_state = i915_delete_blend_state; 1033bf215546Sopenharmony_ci 1034bf215546Sopenharmony_ci i915->base.create_sampler_state = i915_create_sampler_state; 1035bf215546Sopenharmony_ci i915->base.bind_sampler_states = i915_bind_sampler_states; 1036bf215546Sopenharmony_ci i915->base.delete_sampler_state = i915_delete_sampler_state; 1037bf215546Sopenharmony_ci 1038bf215546Sopenharmony_ci i915->base.create_depth_stencil_alpha_state = 1039bf215546Sopenharmony_ci i915_create_depth_stencil_state; 1040bf215546Sopenharmony_ci i915->base.bind_depth_stencil_alpha_state = i915_bind_depth_stencil_state; 1041bf215546Sopenharmony_ci i915->base.delete_depth_stencil_alpha_state = 1042bf215546Sopenharmony_ci i915_delete_depth_stencil_state; 1043bf215546Sopenharmony_ci 1044bf215546Sopenharmony_ci i915->base.create_rasterizer_state = i915_create_rasterizer_state; 1045bf215546Sopenharmony_ci i915->base.bind_rasterizer_state = i915_bind_rasterizer_state; 1046bf215546Sopenharmony_ci i915->base.delete_rasterizer_state = i915_delete_rasterizer_state; 1047bf215546Sopenharmony_ci i915->base.create_fs_state = i915_create_fs_state; 1048bf215546Sopenharmony_ci i915->base.bind_fs_state = i915_bind_fs_state; 1049bf215546Sopenharmony_ci i915->base.delete_fs_state = i915_delete_fs_state; 1050bf215546Sopenharmony_ci i915->base.create_vs_state = i915_create_vs_state; 1051bf215546Sopenharmony_ci i915->base.bind_vs_state = i915_bind_vs_state; 1052bf215546Sopenharmony_ci i915->base.delete_vs_state = i915_delete_vs_state; 1053bf215546Sopenharmony_ci i915->base.create_vertex_elements_state = i915_create_vertex_elements_state; 1054bf215546Sopenharmony_ci i915->base.bind_vertex_elements_state = i915_bind_vertex_elements_state; 1055bf215546Sopenharmony_ci i915->base.delete_vertex_elements_state = i915_delete_vertex_elements_state; 1056bf215546Sopenharmony_ci 1057bf215546Sopenharmony_ci i915->base.set_blend_color = i915_set_blend_color; 1058bf215546Sopenharmony_ci i915->base.set_stencil_ref = i915_set_stencil_ref; 1059bf215546Sopenharmony_ci i915->base.set_clip_state = i915_set_clip_state; 1060bf215546Sopenharmony_ci i915->base.set_sample_mask = i915_set_sample_mask; 1061bf215546Sopenharmony_ci i915->base.set_constant_buffer = i915_set_constant_buffer; 1062bf215546Sopenharmony_ci i915->base.set_framebuffer_state = i915_set_framebuffer_state; 1063bf215546Sopenharmony_ci 1064bf215546Sopenharmony_ci i915->base.set_polygon_stipple = i915_set_polygon_stipple; 1065bf215546Sopenharmony_ci i915->base.set_scissor_states = i915_set_scissor_states; 1066bf215546Sopenharmony_ci i915->base.set_sampler_views = i915_set_sampler_views; 1067bf215546Sopenharmony_ci i915->base.create_sampler_view = i915_create_sampler_view; 1068bf215546Sopenharmony_ci i915->base.sampler_view_destroy = i915_sampler_view_destroy; 1069bf215546Sopenharmony_ci i915->base.set_viewport_states = i915_set_viewport_states; 1070bf215546Sopenharmony_ci i915->base.set_vertex_buffers = i915_set_vertex_buffers; 1071bf215546Sopenharmony_ci} 1072