1bf215546Sopenharmony_ci/************************************************************************** 2bf215546Sopenharmony_ci * 3bf215546Sopenharmony_ci * Copyright 2008 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#include "compiler/nir/nir.h" 29bf215546Sopenharmony_ci#include "draw/draw_context.h" 30bf215546Sopenharmony_ci#include "util/format/u_format.h" 31bf215546Sopenharmony_ci#include "util/format/u_format_s3tc.h" 32bf215546Sopenharmony_ci#include "util/os_misc.h" 33bf215546Sopenharmony_ci#include "util/u_inlines.h" 34bf215546Sopenharmony_ci#include "util/u_memory.h" 35bf215546Sopenharmony_ci#include "util/u_screen.h" 36bf215546Sopenharmony_ci#include "util/u_string.h" 37bf215546Sopenharmony_ci 38bf215546Sopenharmony_ci#include "i915_context.h" 39bf215546Sopenharmony_ci#include "i915_debug.h" 40bf215546Sopenharmony_ci#include "i915_public.h" 41bf215546Sopenharmony_ci#include "i915_reg.h" 42bf215546Sopenharmony_ci#include "i915_resource.h" 43bf215546Sopenharmony_ci#include "i915_screen.h" 44bf215546Sopenharmony_ci#include "i915_winsys.h" 45bf215546Sopenharmony_ci 46bf215546Sopenharmony_ci/* 47bf215546Sopenharmony_ci * Probe functions 48bf215546Sopenharmony_ci */ 49bf215546Sopenharmony_ci 50bf215546Sopenharmony_cistatic const char * 51bf215546Sopenharmony_cii915_get_vendor(struct pipe_screen *screen) 52bf215546Sopenharmony_ci{ 53bf215546Sopenharmony_ci return "Mesa Project"; 54bf215546Sopenharmony_ci} 55bf215546Sopenharmony_ci 56bf215546Sopenharmony_cistatic const char * 57bf215546Sopenharmony_cii915_get_device_vendor(struct pipe_screen *screen) 58bf215546Sopenharmony_ci{ 59bf215546Sopenharmony_ci return "Intel"; 60bf215546Sopenharmony_ci} 61bf215546Sopenharmony_ci 62bf215546Sopenharmony_cistatic const char * 63bf215546Sopenharmony_cii915_get_name(struct pipe_screen *screen) 64bf215546Sopenharmony_ci{ 65bf215546Sopenharmony_ci static char buffer[128]; 66bf215546Sopenharmony_ci const char *chipset; 67bf215546Sopenharmony_ci 68bf215546Sopenharmony_ci switch (i915_screen(screen)->iws->pci_id) { 69bf215546Sopenharmony_ci case PCI_CHIP_I915_G: 70bf215546Sopenharmony_ci chipset = "915G"; 71bf215546Sopenharmony_ci break; 72bf215546Sopenharmony_ci case PCI_CHIP_I915_GM: 73bf215546Sopenharmony_ci chipset = "915GM"; 74bf215546Sopenharmony_ci break; 75bf215546Sopenharmony_ci case PCI_CHIP_I945_G: 76bf215546Sopenharmony_ci chipset = "945G"; 77bf215546Sopenharmony_ci break; 78bf215546Sopenharmony_ci case PCI_CHIP_I945_GM: 79bf215546Sopenharmony_ci chipset = "945GM"; 80bf215546Sopenharmony_ci break; 81bf215546Sopenharmony_ci case PCI_CHIP_I945_GME: 82bf215546Sopenharmony_ci chipset = "945GME"; 83bf215546Sopenharmony_ci break; 84bf215546Sopenharmony_ci case PCI_CHIP_G33_G: 85bf215546Sopenharmony_ci chipset = "G33"; 86bf215546Sopenharmony_ci break; 87bf215546Sopenharmony_ci case PCI_CHIP_Q35_G: 88bf215546Sopenharmony_ci chipset = "Q35"; 89bf215546Sopenharmony_ci break; 90bf215546Sopenharmony_ci case PCI_CHIP_Q33_G: 91bf215546Sopenharmony_ci chipset = "Q33"; 92bf215546Sopenharmony_ci break; 93bf215546Sopenharmony_ci case PCI_CHIP_PINEVIEW_G: 94bf215546Sopenharmony_ci chipset = "Pineview G"; 95bf215546Sopenharmony_ci break; 96bf215546Sopenharmony_ci case PCI_CHIP_PINEVIEW_M: 97bf215546Sopenharmony_ci chipset = "Pineview M"; 98bf215546Sopenharmony_ci break; 99bf215546Sopenharmony_ci default: 100bf215546Sopenharmony_ci chipset = "unknown"; 101bf215546Sopenharmony_ci break; 102bf215546Sopenharmony_ci } 103bf215546Sopenharmony_ci 104bf215546Sopenharmony_ci snprintf(buffer, sizeof(buffer), "i915 (chipset: %s)", chipset); 105bf215546Sopenharmony_ci return buffer; 106bf215546Sopenharmony_ci} 107bf215546Sopenharmony_ci 108bf215546Sopenharmony_cistatic const nir_shader_compiler_options i915_compiler_options = { 109bf215546Sopenharmony_ci .fdot_replicates = true, 110bf215546Sopenharmony_ci .fuse_ffma32 = true, 111bf215546Sopenharmony_ci .lower_bitops = true, /* required for !CAP_INTEGERS nir_to_tgsi */ 112bf215546Sopenharmony_ci .lower_extract_byte = true, 113bf215546Sopenharmony_ci .lower_extract_word = true, 114bf215546Sopenharmony_ci .lower_fdiv = true, 115bf215546Sopenharmony_ci .lower_fdph = true, 116bf215546Sopenharmony_ci .lower_flrp32 = true, 117bf215546Sopenharmony_ci .lower_fmod = true, 118bf215546Sopenharmony_ci .lower_rotate = true, 119bf215546Sopenharmony_ci .lower_sincos = true, 120bf215546Sopenharmony_ci .lower_uniforms_to_ubo = true, 121bf215546Sopenharmony_ci .lower_vector_cmp = true, 122bf215546Sopenharmony_ci .use_interpolated_input_intrinsics = true, 123bf215546Sopenharmony_ci .force_indirect_unrolling = nir_var_all, 124bf215546Sopenharmony_ci .force_indirect_unrolling_sampler = true, 125bf215546Sopenharmony_ci .max_unroll_iterations = 32, 126bf215546Sopenharmony_ci .no_integers = true, 127bf215546Sopenharmony_ci}; 128bf215546Sopenharmony_ci 129bf215546Sopenharmony_cistatic const struct nir_shader_compiler_options gallivm_nir_options = { 130bf215546Sopenharmony_ci .fdot_replicates = true, 131bf215546Sopenharmony_ci .lower_bitops = true, /* required for !CAP_INTEGERS nir_to_tgsi */ 132bf215546Sopenharmony_ci .lower_scmp = true, 133bf215546Sopenharmony_ci .lower_flrp32 = true, 134bf215546Sopenharmony_ci .lower_flrp64 = true, 135bf215546Sopenharmony_ci .lower_fsat = true, 136bf215546Sopenharmony_ci .lower_bitfield_insert_to_shifts = true, 137bf215546Sopenharmony_ci .lower_bitfield_extract_to_shifts = true, 138bf215546Sopenharmony_ci .lower_fdph = true, 139bf215546Sopenharmony_ci .lower_ffma16 = true, 140bf215546Sopenharmony_ci .lower_ffma32 = true, 141bf215546Sopenharmony_ci .lower_ffma64 = true, 142bf215546Sopenharmony_ci .lower_fmod = true, 143bf215546Sopenharmony_ci .lower_hadd = true, 144bf215546Sopenharmony_ci .lower_uadd_sat = true, 145bf215546Sopenharmony_ci .lower_usub_sat = true, 146bf215546Sopenharmony_ci .lower_iadd_sat = true, 147bf215546Sopenharmony_ci .lower_ldexp = true, 148bf215546Sopenharmony_ci .lower_pack_snorm_2x16 = true, 149bf215546Sopenharmony_ci .lower_pack_snorm_4x8 = true, 150bf215546Sopenharmony_ci .lower_pack_unorm_2x16 = true, 151bf215546Sopenharmony_ci .lower_pack_unorm_4x8 = true, 152bf215546Sopenharmony_ci .lower_pack_half_2x16 = true, 153bf215546Sopenharmony_ci .lower_pack_split = true, 154bf215546Sopenharmony_ci .lower_unpack_snorm_2x16 = true, 155bf215546Sopenharmony_ci .lower_unpack_snorm_4x8 = true, 156bf215546Sopenharmony_ci .lower_unpack_unorm_2x16 = true, 157bf215546Sopenharmony_ci .lower_unpack_unorm_4x8 = true, 158bf215546Sopenharmony_ci .lower_unpack_half_2x16 = true, 159bf215546Sopenharmony_ci .lower_extract_byte = true, 160bf215546Sopenharmony_ci .lower_extract_word = true, 161bf215546Sopenharmony_ci .lower_rotate = true, 162bf215546Sopenharmony_ci .lower_uadd_carry = true, 163bf215546Sopenharmony_ci .lower_usub_borrow = true, 164bf215546Sopenharmony_ci .lower_mul_2x32_64 = true, 165bf215546Sopenharmony_ci .lower_ifind_msb = true, 166bf215546Sopenharmony_ci .max_unroll_iterations = 32, 167bf215546Sopenharmony_ci .use_interpolated_input_intrinsics = true, 168bf215546Sopenharmony_ci .lower_cs_local_index_to_id = true, 169bf215546Sopenharmony_ci .lower_uniforms_to_ubo = true, 170bf215546Sopenharmony_ci .lower_vector_cmp = true, 171bf215546Sopenharmony_ci .lower_device_index_to_zero = true, 172bf215546Sopenharmony_ci /* .support_16bit_alu = true, */ 173bf215546Sopenharmony_ci}; 174bf215546Sopenharmony_ci 175bf215546Sopenharmony_cistatic const void * 176bf215546Sopenharmony_cii915_get_compiler_options(struct pipe_screen *pscreen, enum pipe_shader_ir ir, 177bf215546Sopenharmony_ci enum pipe_shader_type shader) 178bf215546Sopenharmony_ci{ 179bf215546Sopenharmony_ci assert(ir == PIPE_SHADER_IR_NIR); 180bf215546Sopenharmony_ci if (shader == PIPE_SHADER_FRAGMENT) 181bf215546Sopenharmony_ci return &i915_compiler_options; 182bf215546Sopenharmony_ci else 183bf215546Sopenharmony_ci return &gallivm_nir_options; 184bf215546Sopenharmony_ci} 185bf215546Sopenharmony_ci 186bf215546Sopenharmony_cistatic void 187bf215546Sopenharmony_cii915_optimize_nir(struct nir_shader *s) 188bf215546Sopenharmony_ci{ 189bf215546Sopenharmony_ci bool progress; 190bf215546Sopenharmony_ci 191bf215546Sopenharmony_ci do { 192bf215546Sopenharmony_ci progress = false; 193bf215546Sopenharmony_ci 194bf215546Sopenharmony_ci NIR_PASS_V(s, nir_lower_vars_to_ssa); 195bf215546Sopenharmony_ci 196bf215546Sopenharmony_ci NIR_PASS(progress, s, nir_copy_prop); 197bf215546Sopenharmony_ci NIR_PASS(progress, s, nir_opt_algebraic); 198bf215546Sopenharmony_ci NIR_PASS(progress, s, nir_opt_constant_folding); 199bf215546Sopenharmony_ci NIR_PASS(progress, s, nir_opt_remove_phis); 200bf215546Sopenharmony_ci NIR_PASS(progress, s, nir_opt_conditional_discard); 201bf215546Sopenharmony_ci NIR_PASS(progress, s, nir_opt_dce); 202bf215546Sopenharmony_ci NIR_PASS(progress, s, nir_opt_dead_cf); 203bf215546Sopenharmony_ci NIR_PASS(progress, s, nir_opt_cse); 204bf215546Sopenharmony_ci NIR_PASS(progress, s, nir_opt_find_array_copies); 205bf215546Sopenharmony_ci NIR_PASS(progress, s, nir_opt_if, nir_opt_if_aggressive_last_continue | nir_opt_if_optimize_phi_true_false); 206bf215546Sopenharmony_ci NIR_PASS(progress, s, nir_opt_peephole_select, ~0 /* flatten all IFs. */, 207bf215546Sopenharmony_ci true, true); 208bf215546Sopenharmony_ci NIR_PASS(progress, s, nir_opt_algebraic); 209bf215546Sopenharmony_ci NIR_PASS(progress, s, nir_opt_constant_folding); 210bf215546Sopenharmony_ci NIR_PASS(progress, s, nir_opt_shrink_stores, true); 211bf215546Sopenharmony_ci NIR_PASS(progress, s, nir_opt_shrink_vectors); 212bf215546Sopenharmony_ci NIR_PASS(progress, s, nir_opt_trivial_continues); 213bf215546Sopenharmony_ci NIR_PASS(progress, s, nir_opt_undef); 214bf215546Sopenharmony_ci NIR_PASS(progress, s, nir_opt_loop_unroll); 215bf215546Sopenharmony_ci 216bf215546Sopenharmony_ci } while (progress); 217bf215546Sopenharmony_ci 218bf215546Sopenharmony_ci NIR_PASS(progress, s, nir_remove_dead_variables, nir_var_function_temp, 219bf215546Sopenharmony_ci NULL); 220bf215546Sopenharmony_ci} 221bf215546Sopenharmony_ci 222bf215546Sopenharmony_cistatic char *i915_check_control_flow(nir_shader *s) 223bf215546Sopenharmony_ci{ 224bf215546Sopenharmony_ci if (s->info.stage == MESA_SHADER_FRAGMENT) { 225bf215546Sopenharmony_ci nir_function_impl *impl = nir_shader_get_entrypoint(s); 226bf215546Sopenharmony_ci nir_block *first = nir_start_block(impl); 227bf215546Sopenharmony_ci nir_cf_node *next = nir_cf_node_next(&first->cf_node); 228bf215546Sopenharmony_ci 229bf215546Sopenharmony_ci if (next) { 230bf215546Sopenharmony_ci switch (next->type) { 231bf215546Sopenharmony_ci case nir_cf_node_if: 232bf215546Sopenharmony_ci return "if/then statements not supported by i915 fragment shaders, should have been flattened by peephole_select."; 233bf215546Sopenharmony_ci case nir_cf_node_loop: 234bf215546Sopenharmony_ci return "looping not supported i915 fragment shaders, all loops must be statically unrollable."; 235bf215546Sopenharmony_ci default: 236bf215546Sopenharmony_ci return "Unknown control flow type"; 237bf215546Sopenharmony_ci } 238bf215546Sopenharmony_ci } 239bf215546Sopenharmony_ci } 240bf215546Sopenharmony_ci 241bf215546Sopenharmony_ci return NULL; 242bf215546Sopenharmony_ci} 243bf215546Sopenharmony_ci 244bf215546Sopenharmony_cistatic char * 245bf215546Sopenharmony_cii915_finalize_nir(struct pipe_screen *pscreen, void *nir) 246bf215546Sopenharmony_ci{ 247bf215546Sopenharmony_ci nir_shader *s = nir; 248bf215546Sopenharmony_ci 249bf215546Sopenharmony_ci if (s->info.stage == MESA_SHADER_FRAGMENT) 250bf215546Sopenharmony_ci i915_optimize_nir(s); 251bf215546Sopenharmony_ci 252bf215546Sopenharmony_ci /* st_program.c's parameter list optimization requires that future nir 253bf215546Sopenharmony_ci * variants don't reallocate the uniform storage, so we have to remove 254bf215546Sopenharmony_ci * uniforms that occupy storage. But we don't want to remove samplers, 255bf215546Sopenharmony_ci * because they're needed for YUV variant lowering. 256bf215546Sopenharmony_ci */ 257bf215546Sopenharmony_ci nir_remove_dead_derefs(s); 258bf215546Sopenharmony_ci nir_foreach_uniform_variable_safe(var, s) 259bf215546Sopenharmony_ci { 260bf215546Sopenharmony_ci if (var->data.mode == nir_var_uniform && 261bf215546Sopenharmony_ci (glsl_type_get_image_count(var->type) || 262bf215546Sopenharmony_ci glsl_type_get_sampler_count(var->type))) 263bf215546Sopenharmony_ci continue; 264bf215546Sopenharmony_ci 265bf215546Sopenharmony_ci exec_node_remove(&var->node); 266bf215546Sopenharmony_ci } 267bf215546Sopenharmony_ci nir_validate_shader(s, "after uniform var removal"); 268bf215546Sopenharmony_ci 269bf215546Sopenharmony_ci nir_sweep(s); 270bf215546Sopenharmony_ci 271bf215546Sopenharmony_ci char *msg = i915_check_control_flow(s); 272bf215546Sopenharmony_ci if (msg) 273bf215546Sopenharmony_ci return strdup(msg); 274bf215546Sopenharmony_ci 275bf215546Sopenharmony_ci return NULL; 276bf215546Sopenharmony_ci} 277bf215546Sopenharmony_ci 278bf215546Sopenharmony_cistatic int 279bf215546Sopenharmony_cii915_get_shader_param(struct pipe_screen *screen, enum pipe_shader_type shader, 280bf215546Sopenharmony_ci enum pipe_shader_cap cap) 281bf215546Sopenharmony_ci{ 282bf215546Sopenharmony_ci switch (cap) { 283bf215546Sopenharmony_ci case PIPE_SHADER_CAP_PREFERRED_IR: 284bf215546Sopenharmony_ci return PIPE_SHADER_IR_NIR; 285bf215546Sopenharmony_ci case PIPE_SHADER_CAP_SUPPORTED_IRS: 286bf215546Sopenharmony_ci return (1 << PIPE_SHADER_IR_NIR) | (1 << PIPE_SHADER_IR_TGSI); 287bf215546Sopenharmony_ci 288bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INTEGERS: 289bf215546Sopenharmony_ci /* mesa/st requires that this cap is the same across stages, and the FS 290bf215546Sopenharmony_ci * can't do ints. 291bf215546Sopenharmony_ci */ 292bf215546Sopenharmony_ci return 0; 293bf215546Sopenharmony_ci 294bf215546Sopenharmony_ci /* i915 can't do these, and even if gallivm NIR can we call nir_to_tgsi 295bf215546Sopenharmony_ci * manually and TGSI can't. 296bf215546Sopenharmony_ci */ 297bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INT16: 298bf215546Sopenharmony_ci case PIPE_SHADER_CAP_FP16: 299bf215546Sopenharmony_ci case PIPE_SHADER_CAP_FP16_DERIVATIVES: 300bf215546Sopenharmony_ci case PIPE_SHADER_CAP_FP16_CONST_BUFFERS: 301bf215546Sopenharmony_ci return 0; 302bf215546Sopenharmony_ci 303bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR: 304bf215546Sopenharmony_ci /* While draw could normally handle this for the VS, the NIR lowering 305bf215546Sopenharmony_ci * to regs can't handle our non-native-integers, so we have to lower to 306bf215546Sopenharmony_ci * if ladders. 307bf215546Sopenharmony_ci */ 308bf215546Sopenharmony_ci return 0; 309bf215546Sopenharmony_ci 310bf215546Sopenharmony_ci default: 311bf215546Sopenharmony_ci break; 312bf215546Sopenharmony_ci } 313bf215546Sopenharmony_ci 314bf215546Sopenharmony_ci switch (shader) { 315bf215546Sopenharmony_ci case PIPE_SHADER_VERTEX: 316bf215546Sopenharmony_ci switch (cap) { 317bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: 318bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS: 319bf215546Sopenharmony_ci return 0; 320bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_SHADER_BUFFERS: 321bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_SHADER_IMAGES: 322bf215546Sopenharmony_ci return 0; 323bf215546Sopenharmony_ci default: 324bf215546Sopenharmony_ci return draw_get_shader_param(shader, cap); 325bf215546Sopenharmony_ci } 326bf215546Sopenharmony_ci case PIPE_SHADER_FRAGMENT: 327bf215546Sopenharmony_ci /* XXX: some of these are just shader model 2.0 values, fix this! */ 328bf215546Sopenharmony_ci switch (cap) { 329bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_INSTRUCTIONS: 330bf215546Sopenharmony_ci return I915_MAX_ALU_INSN + I915_MAX_TEX_INSN; 331bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS: 332bf215546Sopenharmony_ci return I915_MAX_ALU_INSN; 333bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS: 334bf215546Sopenharmony_ci return I915_MAX_TEX_INSN; 335bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS: 336bf215546Sopenharmony_ci return 4; 337bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH: 338bf215546Sopenharmony_ci return 0; 339bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_INPUTS: 340bf215546Sopenharmony_ci return 10; 341bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_OUTPUTS: 342bf215546Sopenharmony_ci return 1; 343bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_CONST_BUFFER0_SIZE: 344bf215546Sopenharmony_ci return 32 * sizeof(float[4]); 345bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_CONST_BUFFERS: 346bf215546Sopenharmony_ci return 1; 347bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_TEMPS: 348bf215546Sopenharmony_ci /* 16 inter-phase temps, 3 intra-phase temps. i915c reported 16. too. */ 349bf215546Sopenharmony_ci return 16; 350bf215546Sopenharmony_ci case PIPE_SHADER_CAP_CONT_SUPPORTED: 351bf215546Sopenharmony_ci case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED: 352bf215546Sopenharmony_ci return 0; 353bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR: 354bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR: 355bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR: 356bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR: 357bf215546Sopenharmony_ci case PIPE_SHADER_CAP_SUBROUTINES: 358bf215546Sopenharmony_ci return 0; 359bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INT64_ATOMICS: 360bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INT16: 361bf215546Sopenharmony_ci case PIPE_SHADER_CAP_GLSL_16BIT_CONSTS: 362bf215546Sopenharmony_ci return 0; 363bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: 364bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS: 365bf215546Sopenharmony_ci return I915_TEX_UNITS; 366bf215546Sopenharmony_ci case PIPE_SHADER_CAP_DROUND_SUPPORTED: 367bf215546Sopenharmony_ci case PIPE_SHADER_CAP_DFRACEXP_DLDEXP_SUPPORTED: 368bf215546Sopenharmony_ci case PIPE_SHADER_CAP_LDEXP_SUPPORTED: 369bf215546Sopenharmony_ci case PIPE_SHADER_CAP_TGSI_ANY_INOUT_DECL_RANGE: 370bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_SHADER_BUFFERS: 371bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_SHADER_IMAGES: 372bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTERS: 373bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER_BUFFERS: 374bf215546Sopenharmony_ci return 0; 375bf215546Sopenharmony_ci 376bf215546Sopenharmony_ci default: 377bf215546Sopenharmony_ci debug_printf("%s: Unknown cap %u.\n", __FUNCTION__, cap); 378bf215546Sopenharmony_ci return 0; 379bf215546Sopenharmony_ci } 380bf215546Sopenharmony_ci break; 381bf215546Sopenharmony_ci default: 382bf215546Sopenharmony_ci return 0; 383bf215546Sopenharmony_ci } 384bf215546Sopenharmony_ci} 385bf215546Sopenharmony_ci 386bf215546Sopenharmony_cistatic int 387bf215546Sopenharmony_cii915_get_param(struct pipe_screen *screen, enum pipe_cap cap) 388bf215546Sopenharmony_ci{ 389bf215546Sopenharmony_ci struct i915_screen *is = i915_screen(screen); 390bf215546Sopenharmony_ci 391bf215546Sopenharmony_ci switch (cap) { 392bf215546Sopenharmony_ci /* Supported features (boolean caps). */ 393bf215546Sopenharmony_ci case PIPE_CAP_ANISOTROPIC_FILTER: 394bf215546Sopenharmony_ci case PIPE_CAP_NPOT_TEXTURES: 395bf215546Sopenharmony_ci case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES: 396bf215546Sopenharmony_ci case PIPE_CAP_POINT_SPRITE: 397bf215546Sopenharmony_ci case PIPE_CAP_PRIMITIVE_RESTART: /* draw module */ 398bf215546Sopenharmony_ci case PIPE_CAP_PRIMITIVE_RESTART_FIXED_INDEX: 399bf215546Sopenharmony_ci case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR: 400bf215546Sopenharmony_ci case PIPE_CAP_BLEND_EQUATION_SEPARATE: 401bf215546Sopenharmony_ci case PIPE_CAP_VS_INSTANCEID: 402bf215546Sopenharmony_ci case PIPE_CAP_VERTEX_COLOR_CLAMPED: 403bf215546Sopenharmony_ci case PIPE_CAP_USER_VERTEX_BUFFERS: 404bf215546Sopenharmony_ci case PIPE_CAP_MIXED_COLOR_DEPTH_BITS: 405bf215546Sopenharmony_ci case PIPE_CAP_TGSI_TEXCOORD: 406bf215546Sopenharmony_ci return 1; 407bf215546Sopenharmony_ci 408bf215546Sopenharmony_ci case PIPE_CAP_TEXTURE_TRANSFER_MODES: 409bf215546Sopenharmony_ci case PIPE_CAP_PCI_GROUP: 410bf215546Sopenharmony_ci case PIPE_CAP_PCI_BUS: 411bf215546Sopenharmony_ci case PIPE_CAP_PCI_DEVICE: 412bf215546Sopenharmony_ci case PIPE_CAP_PCI_FUNCTION: 413bf215546Sopenharmony_ci return 0; 414bf215546Sopenharmony_ci 415bf215546Sopenharmony_ci case PIPE_CAP_ALLOW_MAPPED_BUFFERS_DURING_EXECUTION: 416bf215546Sopenharmony_ci return 0; 417bf215546Sopenharmony_ci 418bf215546Sopenharmony_ci case PIPE_CAP_SHAREABLE_SHADERS: 419bf215546Sopenharmony_ci /* Can't expose shareable shaders because the draw shaders reference the 420bf215546Sopenharmony_ci * draw module's state, which is per-context. 421bf215546Sopenharmony_ci */ 422bf215546Sopenharmony_ci return 0; 423bf215546Sopenharmony_ci 424bf215546Sopenharmony_ci case PIPE_CAP_MAX_GS_INVOCATIONS: 425bf215546Sopenharmony_ci return 32; 426bf215546Sopenharmony_ci 427bf215546Sopenharmony_ci case PIPE_CAP_MAX_SHADER_BUFFER_SIZE_UINT: 428bf215546Sopenharmony_ci return 1 << 27; 429bf215546Sopenharmony_ci 430bf215546Sopenharmony_ci case PIPE_CAP_MAX_VIEWPORTS: 431bf215546Sopenharmony_ci return 1; 432bf215546Sopenharmony_ci 433bf215546Sopenharmony_ci case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT: 434bf215546Sopenharmony_ci return 64; 435bf215546Sopenharmony_ci 436bf215546Sopenharmony_ci case PIPE_CAP_GLSL_FEATURE_LEVEL: 437bf215546Sopenharmony_ci case PIPE_CAP_GLSL_FEATURE_LEVEL_COMPATIBILITY: 438bf215546Sopenharmony_ci return 120; 439bf215546Sopenharmony_ci 440bf215546Sopenharmony_ci case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT: 441bf215546Sopenharmony_ci return 16; 442bf215546Sopenharmony_ci 443bf215546Sopenharmony_ci /* Texturing. */ 444bf215546Sopenharmony_ci case PIPE_CAP_MAX_TEXTURE_2D_SIZE: 445bf215546Sopenharmony_ci return 1 << (I915_MAX_TEXTURE_2D_LEVELS - 1); 446bf215546Sopenharmony_ci case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: 447bf215546Sopenharmony_ci return I915_MAX_TEXTURE_3D_LEVELS; 448bf215546Sopenharmony_ci case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: 449bf215546Sopenharmony_ci return 1 << (I915_MAX_TEXTURE_2D_LEVELS - 1); 450bf215546Sopenharmony_ci 451bf215546Sopenharmony_ci /* Render targets. */ 452bf215546Sopenharmony_ci case PIPE_CAP_MAX_RENDER_TARGETS: 453bf215546Sopenharmony_ci return 1; 454bf215546Sopenharmony_ci 455bf215546Sopenharmony_ci case PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE: 456bf215546Sopenharmony_ci return 2048; 457bf215546Sopenharmony_ci 458bf215546Sopenharmony_ci /* Fragment coordinate conventions. */ 459bf215546Sopenharmony_ci case PIPE_CAP_FS_COORD_ORIGIN_UPPER_LEFT: 460bf215546Sopenharmony_ci case PIPE_CAP_FS_COORD_PIXEL_CENTER_HALF_INTEGER: 461bf215546Sopenharmony_ci return 1; 462bf215546Sopenharmony_ci case PIPE_CAP_ENDIANNESS: 463bf215546Sopenharmony_ci return PIPE_ENDIAN_LITTLE; 464bf215546Sopenharmony_ci case PIPE_CAP_MAX_VARYINGS: 465bf215546Sopenharmony_ci return 10; 466bf215546Sopenharmony_ci 467bf215546Sopenharmony_ci case PIPE_CAP_NIR_IMAGES_AS_DEREF: 468bf215546Sopenharmony_ci return 0; 469bf215546Sopenharmony_ci 470bf215546Sopenharmony_ci case PIPE_CAP_VENDOR_ID: 471bf215546Sopenharmony_ci return 0x8086; 472bf215546Sopenharmony_ci case PIPE_CAP_DEVICE_ID: 473bf215546Sopenharmony_ci return is->iws->pci_id; 474bf215546Sopenharmony_ci case PIPE_CAP_ACCELERATED: 475bf215546Sopenharmony_ci return 1; 476bf215546Sopenharmony_ci case PIPE_CAP_VIDEO_MEMORY: { 477bf215546Sopenharmony_ci /* Once a batch uses more than 75% of the maximum mappable size, we 478bf215546Sopenharmony_ci * assume that there's some fragmentation, and we start doing extra 479bf215546Sopenharmony_ci * flushing, etc. That's the big cliff apps will care about. 480bf215546Sopenharmony_ci */ 481bf215546Sopenharmony_ci const int gpu_mappable_megabytes = 482bf215546Sopenharmony_ci is->iws->aperture_size(is->iws) * 3 / 4; 483bf215546Sopenharmony_ci uint64_t system_memory; 484bf215546Sopenharmony_ci 485bf215546Sopenharmony_ci if (!os_get_total_physical_memory(&system_memory)) 486bf215546Sopenharmony_ci return 0; 487bf215546Sopenharmony_ci 488bf215546Sopenharmony_ci return MIN2(gpu_mappable_megabytes, (int)(system_memory >> 20)); 489bf215546Sopenharmony_ci } 490bf215546Sopenharmony_ci case PIPE_CAP_UMA: 491bf215546Sopenharmony_ci return 1; 492bf215546Sopenharmony_ci 493bf215546Sopenharmony_ci default: 494bf215546Sopenharmony_ci return u_pipe_screen_get_param_defaults(screen, cap); 495bf215546Sopenharmony_ci } 496bf215546Sopenharmony_ci} 497bf215546Sopenharmony_ci 498bf215546Sopenharmony_cistatic float 499bf215546Sopenharmony_cii915_get_paramf(struct pipe_screen *screen, enum pipe_capf cap) 500bf215546Sopenharmony_ci{ 501bf215546Sopenharmony_ci switch (cap) { 502bf215546Sopenharmony_ci case PIPE_CAPF_MIN_LINE_WIDTH: 503bf215546Sopenharmony_ci case PIPE_CAPF_MIN_LINE_WIDTH_AA: 504bf215546Sopenharmony_ci case PIPE_CAPF_MIN_POINT_SIZE: 505bf215546Sopenharmony_ci case PIPE_CAPF_MIN_POINT_SIZE_AA: 506bf215546Sopenharmony_ci return 1; 507bf215546Sopenharmony_ci 508bf215546Sopenharmony_ci case PIPE_CAPF_POINT_SIZE_GRANULARITY: 509bf215546Sopenharmony_ci case PIPE_CAPF_LINE_WIDTH_GRANULARITY: 510bf215546Sopenharmony_ci return 0.1; 511bf215546Sopenharmony_ci 512bf215546Sopenharmony_ci case PIPE_CAPF_MAX_LINE_WIDTH: 513bf215546Sopenharmony_ci FALLTHROUGH; 514bf215546Sopenharmony_ci case PIPE_CAPF_MAX_LINE_WIDTH_AA: 515bf215546Sopenharmony_ci return 7.5; 516bf215546Sopenharmony_ci 517bf215546Sopenharmony_ci case PIPE_CAPF_MAX_POINT_SIZE: 518bf215546Sopenharmony_ci FALLTHROUGH; 519bf215546Sopenharmony_ci case PIPE_CAPF_MAX_POINT_SIZE_AA: 520bf215546Sopenharmony_ci return 255.0; 521bf215546Sopenharmony_ci 522bf215546Sopenharmony_ci case PIPE_CAPF_MAX_TEXTURE_ANISOTROPY: 523bf215546Sopenharmony_ci return 4.0; 524bf215546Sopenharmony_ci 525bf215546Sopenharmony_ci case PIPE_CAPF_MAX_TEXTURE_LOD_BIAS: 526bf215546Sopenharmony_ci return 16.0; 527bf215546Sopenharmony_ci 528bf215546Sopenharmony_ci case PIPE_CAPF_MIN_CONSERVATIVE_RASTER_DILATE: 529bf215546Sopenharmony_ci FALLTHROUGH; 530bf215546Sopenharmony_ci case PIPE_CAPF_MAX_CONSERVATIVE_RASTER_DILATE: 531bf215546Sopenharmony_ci FALLTHROUGH; 532bf215546Sopenharmony_ci case PIPE_CAPF_CONSERVATIVE_RASTER_DILATE_GRANULARITY: 533bf215546Sopenharmony_ci return 0.0f; 534bf215546Sopenharmony_ci 535bf215546Sopenharmony_ci default: 536bf215546Sopenharmony_ci debug_printf("%s: Unknown cap %u.\n", __FUNCTION__, cap); 537bf215546Sopenharmony_ci return 0; 538bf215546Sopenharmony_ci } 539bf215546Sopenharmony_ci} 540bf215546Sopenharmony_ci 541bf215546Sopenharmony_cibool 542bf215546Sopenharmony_cii915_is_format_supported(struct pipe_screen *screen, enum pipe_format format, 543bf215546Sopenharmony_ci enum pipe_texture_target target, unsigned sample_count, 544bf215546Sopenharmony_ci unsigned storage_sample_count, unsigned tex_usage) 545bf215546Sopenharmony_ci{ 546bf215546Sopenharmony_ci static const enum pipe_format tex_supported[] = { 547bf215546Sopenharmony_ci PIPE_FORMAT_B8G8R8A8_UNORM, PIPE_FORMAT_B8G8R8A8_SRGB, 548bf215546Sopenharmony_ci PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_FORMAT_R8G8B8A8_UNORM, 549bf215546Sopenharmony_ci PIPE_FORMAT_R8G8B8X8_UNORM, PIPE_FORMAT_B4G4R4A4_UNORM, 550bf215546Sopenharmony_ci PIPE_FORMAT_B5G6R5_UNORM, PIPE_FORMAT_B5G5R5A1_UNORM, 551bf215546Sopenharmony_ci PIPE_FORMAT_B10G10R10A2_UNORM, PIPE_FORMAT_L8_UNORM, PIPE_FORMAT_A8_UNORM, 552bf215546Sopenharmony_ci PIPE_FORMAT_I8_UNORM, PIPE_FORMAT_L8A8_UNORM, PIPE_FORMAT_UYVY, 553bf215546Sopenharmony_ci PIPE_FORMAT_YUYV, 554bf215546Sopenharmony_ci /* XXX why not? 555bf215546Sopenharmony_ci PIPE_FORMAT_Z16_UNORM, */ 556bf215546Sopenharmony_ci PIPE_FORMAT_DXT1_RGB, PIPE_FORMAT_DXT1_SRGB, PIPE_FORMAT_DXT1_RGBA, 557bf215546Sopenharmony_ci PIPE_FORMAT_DXT1_SRGBA, PIPE_FORMAT_DXT3_RGBA, PIPE_FORMAT_DXT3_SRGBA, 558bf215546Sopenharmony_ci PIPE_FORMAT_DXT5_RGBA, PIPE_FORMAT_DXT5_SRGBA, PIPE_FORMAT_Z24X8_UNORM, 559bf215546Sopenharmony_ci PIPE_FORMAT_FXT1_RGB, PIPE_FORMAT_FXT1_RGBA, 560bf215546Sopenharmony_ci PIPE_FORMAT_Z24_UNORM_S8_UINT, PIPE_FORMAT_NONE /* list terminator */ 561bf215546Sopenharmony_ci }; 562bf215546Sopenharmony_ci static const enum pipe_format render_supported[] = { 563bf215546Sopenharmony_ci PIPE_FORMAT_B8G8R8A8_UNORM, PIPE_FORMAT_B8G8R8X8_UNORM, 564bf215546Sopenharmony_ci PIPE_FORMAT_R8G8B8A8_UNORM, PIPE_FORMAT_R8G8B8X8_UNORM, 565bf215546Sopenharmony_ci PIPE_FORMAT_B5G6R5_UNORM, PIPE_FORMAT_B5G5R5A1_UNORM, 566bf215546Sopenharmony_ci PIPE_FORMAT_B4G4R4A4_UNORM, PIPE_FORMAT_B10G10R10A2_UNORM, 567bf215546Sopenharmony_ci PIPE_FORMAT_L8_UNORM, PIPE_FORMAT_A8_UNORM, 568bf215546Sopenharmony_ci PIPE_FORMAT_I8_UNORM, PIPE_FORMAT_NONE /* list terminator */ 569bf215546Sopenharmony_ci }; 570bf215546Sopenharmony_ci static const enum pipe_format depth_supported[] = { 571bf215546Sopenharmony_ci /* XXX why not? 572bf215546Sopenharmony_ci PIPE_FORMAT_Z16_UNORM, */ 573bf215546Sopenharmony_ci PIPE_FORMAT_Z24X8_UNORM, PIPE_FORMAT_Z24_UNORM_S8_UINT, 574bf215546Sopenharmony_ci PIPE_FORMAT_NONE /* list terminator */ 575bf215546Sopenharmony_ci }; 576bf215546Sopenharmony_ci const enum pipe_format *list; 577bf215546Sopenharmony_ci uint32_t i; 578bf215546Sopenharmony_ci 579bf215546Sopenharmony_ci if (sample_count > 1) 580bf215546Sopenharmony_ci return false; 581bf215546Sopenharmony_ci 582bf215546Sopenharmony_ci if (MAX2(1, sample_count) != MAX2(1, storage_sample_count)) 583bf215546Sopenharmony_ci return false; 584bf215546Sopenharmony_ci 585bf215546Sopenharmony_ci if (tex_usage & PIPE_BIND_DEPTH_STENCIL) 586bf215546Sopenharmony_ci list = depth_supported; 587bf215546Sopenharmony_ci else if (tex_usage & PIPE_BIND_RENDER_TARGET) 588bf215546Sopenharmony_ci list = render_supported; 589bf215546Sopenharmony_ci else if (tex_usage & PIPE_BIND_SAMPLER_VIEW) 590bf215546Sopenharmony_ci list = tex_supported; 591bf215546Sopenharmony_ci else 592bf215546Sopenharmony_ci return true; /* PIPE_BIND_{VERTEX,INDEX}_BUFFER */ 593bf215546Sopenharmony_ci 594bf215546Sopenharmony_ci for (i = 0; list[i] != PIPE_FORMAT_NONE; i++) { 595bf215546Sopenharmony_ci if (list[i] == format) 596bf215546Sopenharmony_ci return true; 597bf215546Sopenharmony_ci } 598bf215546Sopenharmony_ci 599bf215546Sopenharmony_ci return false; 600bf215546Sopenharmony_ci} 601bf215546Sopenharmony_ci 602bf215546Sopenharmony_ci/* 603bf215546Sopenharmony_ci * Fence functions 604bf215546Sopenharmony_ci */ 605bf215546Sopenharmony_ci 606bf215546Sopenharmony_cistatic void 607bf215546Sopenharmony_cii915_fence_reference(struct pipe_screen *screen, struct pipe_fence_handle **ptr, 608bf215546Sopenharmony_ci struct pipe_fence_handle *fence) 609bf215546Sopenharmony_ci{ 610bf215546Sopenharmony_ci struct i915_screen *is = i915_screen(screen); 611bf215546Sopenharmony_ci 612bf215546Sopenharmony_ci is->iws->fence_reference(is->iws, ptr, fence); 613bf215546Sopenharmony_ci} 614bf215546Sopenharmony_ci 615bf215546Sopenharmony_cistatic bool 616bf215546Sopenharmony_cii915_fence_finish(struct pipe_screen *screen, struct pipe_context *ctx, 617bf215546Sopenharmony_ci struct pipe_fence_handle *fence, uint64_t timeout) 618bf215546Sopenharmony_ci{ 619bf215546Sopenharmony_ci struct i915_screen *is = i915_screen(screen); 620bf215546Sopenharmony_ci 621bf215546Sopenharmony_ci if (!timeout) 622bf215546Sopenharmony_ci return is->iws->fence_signalled(is->iws, fence) == 1; 623bf215546Sopenharmony_ci 624bf215546Sopenharmony_ci return is->iws->fence_finish(is->iws, fence) == 1; 625bf215546Sopenharmony_ci} 626bf215546Sopenharmony_ci 627bf215546Sopenharmony_ci/* 628bf215546Sopenharmony_ci * Generic functions 629bf215546Sopenharmony_ci */ 630bf215546Sopenharmony_ci 631bf215546Sopenharmony_cistatic void 632bf215546Sopenharmony_cii915_destroy_screen(struct pipe_screen *screen) 633bf215546Sopenharmony_ci{ 634bf215546Sopenharmony_ci struct i915_screen *is = i915_screen(screen); 635bf215546Sopenharmony_ci 636bf215546Sopenharmony_ci if (is->iws) 637bf215546Sopenharmony_ci is->iws->destroy(is->iws); 638bf215546Sopenharmony_ci 639bf215546Sopenharmony_ci FREE(is); 640bf215546Sopenharmony_ci} 641bf215546Sopenharmony_ci 642bf215546Sopenharmony_ci/** 643bf215546Sopenharmony_ci * Create a new i915_screen object 644bf215546Sopenharmony_ci */ 645bf215546Sopenharmony_cistruct pipe_screen * 646bf215546Sopenharmony_cii915_screen_create(struct i915_winsys *iws) 647bf215546Sopenharmony_ci{ 648bf215546Sopenharmony_ci struct i915_screen *is = CALLOC_STRUCT(i915_screen); 649bf215546Sopenharmony_ci 650bf215546Sopenharmony_ci if (!is) 651bf215546Sopenharmony_ci return NULL; 652bf215546Sopenharmony_ci 653bf215546Sopenharmony_ci switch (iws->pci_id) { 654bf215546Sopenharmony_ci case PCI_CHIP_I915_G: 655bf215546Sopenharmony_ci case PCI_CHIP_I915_GM: 656bf215546Sopenharmony_ci is->is_i945 = false; 657bf215546Sopenharmony_ci break; 658bf215546Sopenharmony_ci 659bf215546Sopenharmony_ci case PCI_CHIP_I945_G: 660bf215546Sopenharmony_ci case PCI_CHIP_I945_GM: 661bf215546Sopenharmony_ci case PCI_CHIP_I945_GME: 662bf215546Sopenharmony_ci case PCI_CHIP_G33_G: 663bf215546Sopenharmony_ci case PCI_CHIP_Q33_G: 664bf215546Sopenharmony_ci case PCI_CHIP_Q35_G: 665bf215546Sopenharmony_ci case PCI_CHIP_PINEVIEW_G: 666bf215546Sopenharmony_ci case PCI_CHIP_PINEVIEW_M: 667bf215546Sopenharmony_ci is->is_i945 = true; 668bf215546Sopenharmony_ci break; 669bf215546Sopenharmony_ci 670bf215546Sopenharmony_ci default: 671bf215546Sopenharmony_ci debug_printf("%s: unknown pci id 0x%x, cannot create screen\n", 672bf215546Sopenharmony_ci __FUNCTION__, iws->pci_id); 673bf215546Sopenharmony_ci FREE(is); 674bf215546Sopenharmony_ci return NULL; 675bf215546Sopenharmony_ci } 676bf215546Sopenharmony_ci 677bf215546Sopenharmony_ci is->iws = iws; 678bf215546Sopenharmony_ci 679bf215546Sopenharmony_ci is->base.destroy = i915_destroy_screen; 680bf215546Sopenharmony_ci 681bf215546Sopenharmony_ci is->base.get_name = i915_get_name; 682bf215546Sopenharmony_ci is->base.get_vendor = i915_get_vendor; 683bf215546Sopenharmony_ci is->base.get_device_vendor = i915_get_device_vendor; 684bf215546Sopenharmony_ci is->base.get_param = i915_get_param; 685bf215546Sopenharmony_ci is->base.get_shader_param = i915_get_shader_param; 686bf215546Sopenharmony_ci is->base.get_paramf = i915_get_paramf; 687bf215546Sopenharmony_ci is->base.get_compiler_options = i915_get_compiler_options; 688bf215546Sopenharmony_ci is->base.finalize_nir = i915_finalize_nir; 689bf215546Sopenharmony_ci is->base.is_format_supported = i915_is_format_supported; 690bf215546Sopenharmony_ci 691bf215546Sopenharmony_ci is->base.context_create = i915_create_context; 692bf215546Sopenharmony_ci 693bf215546Sopenharmony_ci is->base.fence_reference = i915_fence_reference; 694bf215546Sopenharmony_ci is->base.fence_finish = i915_fence_finish; 695bf215546Sopenharmony_ci 696bf215546Sopenharmony_ci i915_init_screen_resource_functions(is); 697bf215546Sopenharmony_ci 698bf215546Sopenharmony_ci i915_debug_init(is); 699bf215546Sopenharmony_ci 700bf215546Sopenharmony_ci return &is->base; 701bf215546Sopenharmony_ci} 702