1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2017 Intel Corporation 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice shall be included 12bf215546Sopenharmony_ci * in all copies or substantial portions of the Software. 13bf215546Sopenharmony_ci * 14bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20bf215546Sopenharmony_ci * DEALINGS IN THE SOFTWARE. 21bf215546Sopenharmony_ci */ 22bf215546Sopenharmony_ci 23bf215546Sopenharmony_ci#include <stdio.h> 24bf215546Sopenharmony_ci#include <time.h> 25bf215546Sopenharmony_ci#include "pipe/p_defines.h" 26bf215546Sopenharmony_ci#include "pipe/p_state.h" 27bf215546Sopenharmony_ci#include "util/debug.h" 28bf215546Sopenharmony_ci#include "util/ralloc.h" 29bf215546Sopenharmony_ci#include "util/u_inlines.h" 30bf215546Sopenharmony_ci#include "util/format/u_format.h" 31bf215546Sopenharmony_ci#include "util/u_upload_mgr.h" 32bf215546Sopenharmony_ci#include "drm-uapi/i915_drm.h" 33bf215546Sopenharmony_ci#include "iris_context.h" 34bf215546Sopenharmony_ci#include "iris_resource.h" 35bf215546Sopenharmony_ci#include "iris_screen.h" 36bf215546Sopenharmony_ci#include "iris_utrace.h" 37bf215546Sopenharmony_ci#include "common/intel_defines.h" 38bf215546Sopenharmony_ci#include "common/intel_sample_positions.h" 39bf215546Sopenharmony_ci 40bf215546Sopenharmony_ci/** 41bf215546Sopenharmony_ci * The pipe->set_debug_callback() driver hook. 42bf215546Sopenharmony_ci */ 43bf215546Sopenharmony_cistatic void 44bf215546Sopenharmony_ciiris_set_debug_callback(struct pipe_context *ctx, 45bf215546Sopenharmony_ci const struct util_debug_callback *cb) 46bf215546Sopenharmony_ci{ 47bf215546Sopenharmony_ci struct iris_context *ice = (struct iris_context *)ctx; 48bf215546Sopenharmony_ci struct iris_screen *screen = (struct iris_screen *)ctx->screen; 49bf215546Sopenharmony_ci 50bf215546Sopenharmony_ci util_queue_finish(&screen->shader_compiler_queue); 51bf215546Sopenharmony_ci 52bf215546Sopenharmony_ci if (cb) 53bf215546Sopenharmony_ci ice->dbg = *cb; 54bf215546Sopenharmony_ci else 55bf215546Sopenharmony_ci memset(&ice->dbg, 0, sizeof(ice->dbg)); 56bf215546Sopenharmony_ci} 57bf215546Sopenharmony_ci 58bf215546Sopenharmony_ci/** 59bf215546Sopenharmony_ci * Called from the batch module when it detects a GPU hang. 60bf215546Sopenharmony_ci * 61bf215546Sopenharmony_ci * In this case, we've lost our GEM context, and can't rely on any existing 62bf215546Sopenharmony_ci * state on the GPU. We must mark everything dirty and wipe away any saved 63bf215546Sopenharmony_ci * assumptions about the last known state of the GPU. 64bf215546Sopenharmony_ci */ 65bf215546Sopenharmony_civoid 66bf215546Sopenharmony_ciiris_lost_context_state(struct iris_batch *batch) 67bf215546Sopenharmony_ci{ 68bf215546Sopenharmony_ci struct iris_context *ice = batch->ice; 69bf215546Sopenharmony_ci 70bf215546Sopenharmony_ci if (batch->name == IRIS_BATCH_RENDER) { 71bf215546Sopenharmony_ci batch->screen->vtbl.init_render_context(batch); 72bf215546Sopenharmony_ci } else if (batch->name == IRIS_BATCH_COMPUTE) { 73bf215546Sopenharmony_ci batch->screen->vtbl.init_compute_context(batch); 74bf215546Sopenharmony_ci } else if (batch->name == IRIS_BATCH_BLITTER) { 75bf215546Sopenharmony_ci /* No state to set up */ 76bf215546Sopenharmony_ci } else { 77bf215546Sopenharmony_ci unreachable("unhandled batch reset"); 78bf215546Sopenharmony_ci } 79bf215546Sopenharmony_ci 80bf215546Sopenharmony_ci ice->state.dirty = ~0ull; 81bf215546Sopenharmony_ci ice->state.stage_dirty = ~0ull; 82bf215546Sopenharmony_ci ice->state.current_hash_scale = 0; 83bf215546Sopenharmony_ci memset(&ice->shaders.urb, 0, sizeof(ice->shaders.urb)); 84bf215546Sopenharmony_ci memset(ice->state.last_block, 0, sizeof(ice->state.last_block)); 85bf215546Sopenharmony_ci memset(ice->state.last_grid, 0, sizeof(ice->state.last_grid)); 86bf215546Sopenharmony_ci ice->state.last_grid_dim = 0; 87bf215546Sopenharmony_ci batch->last_binder_address = ~0ull; 88bf215546Sopenharmony_ci batch->last_aux_map_state = 0; 89bf215546Sopenharmony_ci batch->screen->vtbl.lost_genx_state(ice, batch); 90bf215546Sopenharmony_ci} 91bf215546Sopenharmony_ci 92bf215546Sopenharmony_cistatic enum pipe_reset_status 93bf215546Sopenharmony_ciiris_get_device_reset_status(struct pipe_context *ctx) 94bf215546Sopenharmony_ci{ 95bf215546Sopenharmony_ci struct iris_context *ice = (struct iris_context *)ctx; 96bf215546Sopenharmony_ci 97bf215546Sopenharmony_ci enum pipe_reset_status worst_reset = PIPE_NO_RESET; 98bf215546Sopenharmony_ci 99bf215546Sopenharmony_ci /* Check the reset status of each batch's hardware context, and take the 100bf215546Sopenharmony_ci * worst status (if one was guilty, proclaim guilt). 101bf215546Sopenharmony_ci */ 102bf215546Sopenharmony_ci iris_foreach_batch(ice, batch) { 103bf215546Sopenharmony_ci /* This will also recreate the hardware contexts as necessary, so any 104bf215546Sopenharmony_ci * future queries will show no resets. We only want to report once. 105bf215546Sopenharmony_ci */ 106bf215546Sopenharmony_ci enum pipe_reset_status batch_reset = 107bf215546Sopenharmony_ci iris_batch_check_for_reset(batch); 108bf215546Sopenharmony_ci 109bf215546Sopenharmony_ci if (batch_reset == PIPE_NO_RESET) 110bf215546Sopenharmony_ci continue; 111bf215546Sopenharmony_ci 112bf215546Sopenharmony_ci if (worst_reset == PIPE_NO_RESET) { 113bf215546Sopenharmony_ci worst_reset = batch_reset; 114bf215546Sopenharmony_ci } else { 115bf215546Sopenharmony_ci /* GUILTY < INNOCENT < UNKNOWN */ 116bf215546Sopenharmony_ci worst_reset = MIN2(worst_reset, batch_reset); 117bf215546Sopenharmony_ci } 118bf215546Sopenharmony_ci } 119bf215546Sopenharmony_ci 120bf215546Sopenharmony_ci if (worst_reset != PIPE_NO_RESET && ice->reset.reset) 121bf215546Sopenharmony_ci ice->reset.reset(ice->reset.data, worst_reset); 122bf215546Sopenharmony_ci 123bf215546Sopenharmony_ci return worst_reset; 124bf215546Sopenharmony_ci} 125bf215546Sopenharmony_ci 126bf215546Sopenharmony_cistatic void 127bf215546Sopenharmony_ciiris_set_device_reset_callback(struct pipe_context *ctx, 128bf215546Sopenharmony_ci const struct pipe_device_reset_callback *cb) 129bf215546Sopenharmony_ci{ 130bf215546Sopenharmony_ci struct iris_context *ice = (struct iris_context *)ctx; 131bf215546Sopenharmony_ci 132bf215546Sopenharmony_ci if (cb) 133bf215546Sopenharmony_ci ice->reset = *cb; 134bf215546Sopenharmony_ci else 135bf215546Sopenharmony_ci memset(&ice->reset, 0, sizeof(ice->reset)); 136bf215546Sopenharmony_ci} 137bf215546Sopenharmony_ci 138bf215546Sopenharmony_cistatic void 139bf215546Sopenharmony_ciiris_get_sample_position(struct pipe_context *ctx, 140bf215546Sopenharmony_ci unsigned sample_count, 141bf215546Sopenharmony_ci unsigned sample_index, 142bf215546Sopenharmony_ci float *out_value) 143bf215546Sopenharmony_ci{ 144bf215546Sopenharmony_ci union { 145bf215546Sopenharmony_ci struct { 146bf215546Sopenharmony_ci float x[16]; 147bf215546Sopenharmony_ci float y[16]; 148bf215546Sopenharmony_ci } a; 149bf215546Sopenharmony_ci struct { 150bf215546Sopenharmony_ci float _0XOffset, _1XOffset, _2XOffset, _3XOffset, 151bf215546Sopenharmony_ci _4XOffset, _5XOffset, _6XOffset, _7XOffset, 152bf215546Sopenharmony_ci _8XOffset, _9XOffset, _10XOffset, _11XOffset, 153bf215546Sopenharmony_ci _12XOffset, _13XOffset, _14XOffset, _15XOffset; 154bf215546Sopenharmony_ci float _0YOffset, _1YOffset, _2YOffset, _3YOffset, 155bf215546Sopenharmony_ci _4YOffset, _5YOffset, _6YOffset, _7YOffset, 156bf215546Sopenharmony_ci _8YOffset, _9YOffset, _10YOffset, _11YOffset, 157bf215546Sopenharmony_ci _12YOffset, _13YOffset, _14YOffset, _15YOffset; 158bf215546Sopenharmony_ci } v; 159bf215546Sopenharmony_ci } u; 160bf215546Sopenharmony_ci switch (sample_count) { 161bf215546Sopenharmony_ci case 1: INTEL_SAMPLE_POS_1X(u.v._); break; 162bf215546Sopenharmony_ci case 2: INTEL_SAMPLE_POS_2X(u.v._); break; 163bf215546Sopenharmony_ci case 4: INTEL_SAMPLE_POS_4X(u.v._); break; 164bf215546Sopenharmony_ci case 8: INTEL_SAMPLE_POS_8X(u.v._); break; 165bf215546Sopenharmony_ci case 16: INTEL_SAMPLE_POS_16X(u.v._); break; 166bf215546Sopenharmony_ci default: unreachable("invalid sample count"); 167bf215546Sopenharmony_ci } 168bf215546Sopenharmony_ci 169bf215546Sopenharmony_ci out_value[0] = u.a.x[sample_index]; 170bf215546Sopenharmony_ci out_value[1] = u.a.y[sample_index]; 171bf215546Sopenharmony_ci} 172bf215546Sopenharmony_ci 173bf215546Sopenharmony_cistatic bool 174bf215546Sopenharmony_cicreate_dirty_dmabuf_set(struct iris_context *ice) 175bf215546Sopenharmony_ci{ 176bf215546Sopenharmony_ci assert(ice->dirty_dmabufs == NULL); 177bf215546Sopenharmony_ci 178bf215546Sopenharmony_ci ice->dirty_dmabufs = _mesa_pointer_set_create(ice); 179bf215546Sopenharmony_ci return ice->dirty_dmabufs != NULL; 180bf215546Sopenharmony_ci} 181bf215546Sopenharmony_ci 182bf215546Sopenharmony_civoid 183bf215546Sopenharmony_ciiris_mark_dirty_dmabuf(struct iris_context *ice, 184bf215546Sopenharmony_ci struct pipe_resource *res) 185bf215546Sopenharmony_ci{ 186bf215546Sopenharmony_ci if (!_mesa_set_search(ice->dirty_dmabufs, res)) { 187bf215546Sopenharmony_ci _mesa_set_add(ice->dirty_dmabufs, res); 188bf215546Sopenharmony_ci pipe_reference(NULL, &res->reference); 189bf215546Sopenharmony_ci } 190bf215546Sopenharmony_ci} 191bf215546Sopenharmony_ci 192bf215546Sopenharmony_cistatic void 193bf215546Sopenharmony_ciclear_dirty_dmabuf_set(struct iris_context *ice) 194bf215546Sopenharmony_ci{ 195bf215546Sopenharmony_ci set_foreach(ice->dirty_dmabufs, entry) { 196bf215546Sopenharmony_ci struct pipe_resource *res = (struct pipe_resource *)entry->key; 197bf215546Sopenharmony_ci if (pipe_reference(&res->reference, NULL)) 198bf215546Sopenharmony_ci res->screen->resource_destroy(res->screen, res); 199bf215546Sopenharmony_ci } 200bf215546Sopenharmony_ci 201bf215546Sopenharmony_ci _mesa_set_clear(ice->dirty_dmabufs, NULL); 202bf215546Sopenharmony_ci} 203bf215546Sopenharmony_ci 204bf215546Sopenharmony_civoid 205bf215546Sopenharmony_ciiris_flush_dirty_dmabufs(struct iris_context *ice) 206bf215546Sopenharmony_ci{ 207bf215546Sopenharmony_ci set_foreach(ice->dirty_dmabufs, entry) { 208bf215546Sopenharmony_ci struct pipe_resource *res = (struct pipe_resource *)entry->key; 209bf215546Sopenharmony_ci ice->ctx.flush_resource(&ice->ctx, res); 210bf215546Sopenharmony_ci } 211bf215546Sopenharmony_ci 212bf215546Sopenharmony_ci clear_dirty_dmabuf_set(ice); 213bf215546Sopenharmony_ci} 214bf215546Sopenharmony_ci 215bf215546Sopenharmony_ci/** 216bf215546Sopenharmony_ci * Destroy a context, freeing any associated memory. 217bf215546Sopenharmony_ci */ 218bf215546Sopenharmony_civoid 219bf215546Sopenharmony_ciiris_destroy_context(struct pipe_context *ctx) 220bf215546Sopenharmony_ci{ 221bf215546Sopenharmony_ci struct iris_context *ice = (struct iris_context *)ctx; 222bf215546Sopenharmony_ci struct iris_screen *screen = (struct iris_screen *)ctx->screen; 223bf215546Sopenharmony_ci 224bf215546Sopenharmony_ci if (ctx->stream_uploader) 225bf215546Sopenharmony_ci u_upload_destroy(ctx->stream_uploader); 226bf215546Sopenharmony_ci if (ctx->const_uploader) 227bf215546Sopenharmony_ci u_upload_destroy(ctx->const_uploader); 228bf215546Sopenharmony_ci 229bf215546Sopenharmony_ci clear_dirty_dmabuf_set(ice); 230bf215546Sopenharmony_ci 231bf215546Sopenharmony_ci screen->vtbl.destroy_state(ice); 232bf215546Sopenharmony_ci 233bf215546Sopenharmony_ci for (unsigned i = 0; i < ARRAY_SIZE(ice->shaders.scratch_surfs); i++) 234bf215546Sopenharmony_ci pipe_resource_reference(&ice->shaders.scratch_surfs[i].res, NULL); 235bf215546Sopenharmony_ci 236bf215546Sopenharmony_ci for (unsigned i = 0; i < ARRAY_SIZE(ice->shaders.scratch_bos); i++) { 237bf215546Sopenharmony_ci for (unsigned j = 0; j < ARRAY_SIZE(ice->shaders.scratch_bos[i]); j++) 238bf215546Sopenharmony_ci iris_bo_unreference(ice->shaders.scratch_bos[i][j]); 239bf215546Sopenharmony_ci } 240bf215546Sopenharmony_ci 241bf215546Sopenharmony_ci iris_destroy_program_cache(ice); 242bf215546Sopenharmony_ci if (screen->measure.config) 243bf215546Sopenharmony_ci iris_destroy_ctx_measure(ice); 244bf215546Sopenharmony_ci 245bf215546Sopenharmony_ci u_upload_destroy(ice->state.surface_uploader); 246bf215546Sopenharmony_ci u_upload_destroy(ice->state.bindless_uploader); 247bf215546Sopenharmony_ci u_upload_destroy(ice->state.dynamic_uploader); 248bf215546Sopenharmony_ci u_upload_destroy(ice->query_buffer_uploader); 249bf215546Sopenharmony_ci 250bf215546Sopenharmony_ci iris_destroy_batches(ice); 251bf215546Sopenharmony_ci iris_destroy_binder(&ice->state.binder); 252bf215546Sopenharmony_ci 253bf215546Sopenharmony_ci iris_utrace_fini(ice); 254bf215546Sopenharmony_ci 255bf215546Sopenharmony_ci slab_destroy_child(&ice->transfer_pool); 256bf215546Sopenharmony_ci slab_destroy_child(&ice->transfer_pool_unsync); 257bf215546Sopenharmony_ci 258bf215546Sopenharmony_ci ralloc_free(ice); 259bf215546Sopenharmony_ci} 260bf215546Sopenharmony_ci 261bf215546Sopenharmony_ci#define genX_call(devinfo, func, ...) \ 262bf215546Sopenharmony_ci switch ((devinfo)->verx10) { \ 263bf215546Sopenharmony_ci case 125: \ 264bf215546Sopenharmony_ci gfx125_##func(__VA_ARGS__); \ 265bf215546Sopenharmony_ci break; \ 266bf215546Sopenharmony_ci case 120: \ 267bf215546Sopenharmony_ci gfx12_##func(__VA_ARGS__); \ 268bf215546Sopenharmony_ci break; \ 269bf215546Sopenharmony_ci case 110: \ 270bf215546Sopenharmony_ci gfx11_##func(__VA_ARGS__); \ 271bf215546Sopenharmony_ci break; \ 272bf215546Sopenharmony_ci case 90: \ 273bf215546Sopenharmony_ci gfx9_##func(__VA_ARGS__); \ 274bf215546Sopenharmony_ci break; \ 275bf215546Sopenharmony_ci case 80: \ 276bf215546Sopenharmony_ci gfx8_##func(__VA_ARGS__); \ 277bf215546Sopenharmony_ci break; \ 278bf215546Sopenharmony_ci default: \ 279bf215546Sopenharmony_ci unreachable("Unknown hardware generation"); \ 280bf215546Sopenharmony_ci } 281bf215546Sopenharmony_ci 282bf215546Sopenharmony_ci/** 283bf215546Sopenharmony_ci * Create a context. 284bf215546Sopenharmony_ci * 285bf215546Sopenharmony_ci * This is where each context begins. 286bf215546Sopenharmony_ci */ 287bf215546Sopenharmony_cistruct pipe_context * 288bf215546Sopenharmony_ciiris_create_context(struct pipe_screen *pscreen, void *priv, unsigned flags) 289bf215546Sopenharmony_ci{ 290bf215546Sopenharmony_ci struct iris_screen *screen = (struct iris_screen*)pscreen; 291bf215546Sopenharmony_ci const struct intel_device_info *devinfo = &screen->devinfo; 292bf215546Sopenharmony_ci struct iris_context *ice = rzalloc(NULL, struct iris_context); 293bf215546Sopenharmony_ci 294bf215546Sopenharmony_ci if (!ice) 295bf215546Sopenharmony_ci return NULL; 296bf215546Sopenharmony_ci 297bf215546Sopenharmony_ci struct pipe_context *ctx = &ice->ctx; 298bf215546Sopenharmony_ci 299bf215546Sopenharmony_ci ctx->screen = pscreen; 300bf215546Sopenharmony_ci ctx->priv = priv; 301bf215546Sopenharmony_ci 302bf215546Sopenharmony_ci ctx->stream_uploader = u_upload_create_default(ctx); 303bf215546Sopenharmony_ci if (!ctx->stream_uploader) { 304bf215546Sopenharmony_ci free(ctx); 305bf215546Sopenharmony_ci return NULL; 306bf215546Sopenharmony_ci } 307bf215546Sopenharmony_ci ctx->const_uploader = u_upload_create(ctx, 1024 * 1024, 308bf215546Sopenharmony_ci PIPE_BIND_CONSTANT_BUFFER, 309bf215546Sopenharmony_ci PIPE_USAGE_IMMUTABLE, 310bf215546Sopenharmony_ci IRIS_RESOURCE_FLAG_DEVICE_MEM); 311bf215546Sopenharmony_ci if (!ctx->const_uploader) { 312bf215546Sopenharmony_ci u_upload_destroy(ctx->stream_uploader); 313bf215546Sopenharmony_ci free(ctx); 314bf215546Sopenharmony_ci return NULL; 315bf215546Sopenharmony_ci } 316bf215546Sopenharmony_ci 317bf215546Sopenharmony_ci if (!create_dirty_dmabuf_set(ice)) { 318bf215546Sopenharmony_ci ralloc_free(ice); 319bf215546Sopenharmony_ci return NULL; 320bf215546Sopenharmony_ci } 321bf215546Sopenharmony_ci 322bf215546Sopenharmony_ci ctx->destroy = iris_destroy_context; 323bf215546Sopenharmony_ci ctx->set_debug_callback = iris_set_debug_callback; 324bf215546Sopenharmony_ci ctx->set_device_reset_callback = iris_set_device_reset_callback; 325bf215546Sopenharmony_ci ctx->get_device_reset_status = iris_get_device_reset_status; 326bf215546Sopenharmony_ci ctx->get_sample_position = iris_get_sample_position; 327bf215546Sopenharmony_ci 328bf215546Sopenharmony_ci iris_init_context_fence_functions(ctx); 329bf215546Sopenharmony_ci iris_init_blit_functions(ctx); 330bf215546Sopenharmony_ci iris_init_clear_functions(ctx); 331bf215546Sopenharmony_ci iris_init_program_functions(ctx); 332bf215546Sopenharmony_ci iris_init_resource_functions(ctx); 333bf215546Sopenharmony_ci iris_init_flush_functions(ctx); 334bf215546Sopenharmony_ci iris_init_perfquery_functions(ctx); 335bf215546Sopenharmony_ci 336bf215546Sopenharmony_ci iris_init_program_cache(ice); 337bf215546Sopenharmony_ci iris_init_binder(ice); 338bf215546Sopenharmony_ci 339bf215546Sopenharmony_ci slab_create_child(&ice->transfer_pool, &screen->transfer_pool); 340bf215546Sopenharmony_ci slab_create_child(&ice->transfer_pool_unsync, &screen->transfer_pool); 341bf215546Sopenharmony_ci 342bf215546Sopenharmony_ci ice->state.surface_uploader = 343bf215546Sopenharmony_ci u_upload_create(ctx, 64 * 1024, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE, 344bf215546Sopenharmony_ci IRIS_RESOURCE_FLAG_SURFACE_MEMZONE | 345bf215546Sopenharmony_ci IRIS_RESOURCE_FLAG_DEVICE_MEM); 346bf215546Sopenharmony_ci ice->state.bindless_uploader = 347bf215546Sopenharmony_ci u_upload_create(ctx, 64 * 1024, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE, 348bf215546Sopenharmony_ci IRIS_RESOURCE_FLAG_BINDLESS_MEMZONE | 349bf215546Sopenharmony_ci IRIS_RESOURCE_FLAG_DEVICE_MEM); 350bf215546Sopenharmony_ci ice->state.dynamic_uploader = 351bf215546Sopenharmony_ci u_upload_create(ctx, 64 * 1024, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE, 352bf215546Sopenharmony_ci IRIS_RESOURCE_FLAG_DYNAMIC_MEMZONE | 353bf215546Sopenharmony_ci IRIS_RESOURCE_FLAG_DEVICE_MEM); 354bf215546Sopenharmony_ci 355bf215546Sopenharmony_ci ice->query_buffer_uploader = 356bf215546Sopenharmony_ci u_upload_create(ctx, 16 * 1024, PIPE_BIND_CUSTOM, PIPE_USAGE_STAGING, 357bf215546Sopenharmony_ci 0); 358bf215546Sopenharmony_ci 359bf215546Sopenharmony_ci genX_call(devinfo, init_state, ice); 360bf215546Sopenharmony_ci genX_call(devinfo, init_blorp, ice); 361bf215546Sopenharmony_ci genX_call(devinfo, init_query, ice); 362bf215546Sopenharmony_ci 363bf215546Sopenharmony_ci int priority = 0; 364bf215546Sopenharmony_ci if (flags & PIPE_CONTEXT_HIGH_PRIORITY) 365bf215546Sopenharmony_ci priority = INTEL_CONTEXT_HIGH_PRIORITY; 366bf215546Sopenharmony_ci if (flags & PIPE_CONTEXT_LOW_PRIORITY) 367bf215546Sopenharmony_ci priority = INTEL_CONTEXT_LOW_PRIORITY; 368bf215546Sopenharmony_ci 369bf215546Sopenharmony_ci if (INTEL_DEBUG(DEBUG_BATCH)) 370bf215546Sopenharmony_ci ice->state.sizes = _mesa_hash_table_u64_create(ice); 371bf215546Sopenharmony_ci 372bf215546Sopenharmony_ci /* Do this before initializing the batches */ 373bf215546Sopenharmony_ci iris_utrace_init(ice); 374bf215546Sopenharmony_ci 375bf215546Sopenharmony_ci iris_init_batches(ice, priority); 376bf215546Sopenharmony_ci 377bf215546Sopenharmony_ci screen->vtbl.init_render_context(&ice->batches[IRIS_BATCH_RENDER]); 378bf215546Sopenharmony_ci screen->vtbl.init_compute_context(&ice->batches[IRIS_BATCH_COMPUTE]); 379bf215546Sopenharmony_ci 380bf215546Sopenharmony_ci if (!(flags & PIPE_CONTEXT_PREFER_THREADED)) 381bf215546Sopenharmony_ci return ctx; 382bf215546Sopenharmony_ci 383bf215546Sopenharmony_ci /* Clover doesn't support u_threaded_context */ 384bf215546Sopenharmony_ci if (flags & PIPE_CONTEXT_COMPUTE_ONLY) 385bf215546Sopenharmony_ci return ctx; 386bf215546Sopenharmony_ci 387bf215546Sopenharmony_ci return threaded_context_create(ctx, &screen->transfer_pool, 388bf215546Sopenharmony_ci iris_replace_buffer_storage, 389bf215546Sopenharmony_ci NULL, /* TODO: asynchronous flushes? */ 390bf215546Sopenharmony_ci &ice->thrctx); 391bf215546Sopenharmony_ci} 392