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 * on the rights to use, copy, modify, merge, publish, distribute, sub 8bf215546Sopenharmony_ci * license, and/or sell copies of the Software, and to permit persons to whom 9bf215546Sopenharmony_ci * the Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 19bf215546Sopenharmony_ci * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20bf215546Sopenharmony_ci * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 21bf215546Sopenharmony_ci * USE OR OTHER DEALINGS IN THE SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci#ifndef IRIS_RESOURCE_H 24bf215546Sopenharmony_ci#define IRIS_RESOURCE_H 25bf215546Sopenharmony_ci 26bf215546Sopenharmony_ci#include "pipe/p_state.h" 27bf215546Sopenharmony_ci#include "util/u_inlines.h" 28bf215546Sopenharmony_ci#include "util/u_range.h" 29bf215546Sopenharmony_ci#include "util/u_threaded_context.h" 30bf215546Sopenharmony_ci#include "intel/isl/isl.h" 31bf215546Sopenharmony_ci#include "iris_bufmgr.h" 32bf215546Sopenharmony_ci 33bf215546Sopenharmony_cistruct iris_batch; 34bf215546Sopenharmony_cistruct iris_context; 35bf215546Sopenharmony_cistruct shader_info; 36bf215546Sopenharmony_ci 37bf215546Sopenharmony_ci#define IRIS_MAX_MIPLEVELS 15 38bf215546Sopenharmony_ci 39bf215546Sopenharmony_cistruct iris_format_info { 40bf215546Sopenharmony_ci enum isl_format fmt; 41bf215546Sopenharmony_ci struct isl_swizzle swizzle; 42bf215546Sopenharmony_ci}; 43bf215546Sopenharmony_ci 44bf215546Sopenharmony_ci#define IRIS_RESOURCE_FLAG_SHADER_MEMZONE (PIPE_RESOURCE_FLAG_DRV_PRIV << 0) 45bf215546Sopenharmony_ci#define IRIS_RESOURCE_FLAG_SURFACE_MEMZONE (PIPE_RESOURCE_FLAG_DRV_PRIV << 1) 46bf215546Sopenharmony_ci#define IRIS_RESOURCE_FLAG_DYNAMIC_MEMZONE (PIPE_RESOURCE_FLAG_DRV_PRIV << 2) 47bf215546Sopenharmony_ci#define IRIS_RESOURCE_FLAG_BINDLESS_MEMZONE (PIPE_RESOURCE_FLAG_DRV_PRIV << 3) 48bf215546Sopenharmony_ci#define IRIS_RESOURCE_FLAG_DEVICE_MEM (PIPE_RESOURCE_FLAG_DRV_PRIV << 4) 49bf215546Sopenharmony_ci 50bf215546Sopenharmony_ci/** 51bf215546Sopenharmony_ci * Resources represent a GPU buffer object or image (mipmap tree). 52bf215546Sopenharmony_ci * 53bf215546Sopenharmony_ci * They contain the storage (BO) and layout information (ISL surface). 54bf215546Sopenharmony_ci */ 55bf215546Sopenharmony_cistruct iris_resource { 56bf215546Sopenharmony_ci struct threaded_resource base; 57bf215546Sopenharmony_ci enum pipe_format internal_format; 58bf215546Sopenharmony_ci 59bf215546Sopenharmony_ci /** 60bf215546Sopenharmony_ci * The ISL surface layout information for this resource. 61bf215546Sopenharmony_ci * 62bf215546Sopenharmony_ci * This is not filled out for PIPE_BUFFER resources, but is guaranteed 63bf215546Sopenharmony_ci * to be zeroed. Note that this also guarantees that res->surf.tiling 64bf215546Sopenharmony_ci * will be ISL_TILING_LINEAR, so it's safe to check that. 65bf215546Sopenharmony_ci */ 66bf215546Sopenharmony_ci struct isl_surf surf; 67bf215546Sopenharmony_ci 68bf215546Sopenharmony_ci /** Backing storage for the resource */ 69bf215546Sopenharmony_ci struct iris_bo *bo; 70bf215546Sopenharmony_ci 71bf215546Sopenharmony_ci /** offset at which data starts in the BO */ 72bf215546Sopenharmony_ci uint64_t offset; 73bf215546Sopenharmony_ci 74bf215546Sopenharmony_ci /** 75bf215546Sopenharmony_ci * A bitfield of PIPE_BIND_* indicating how this resource was bound 76bf215546Sopenharmony_ci * in the past. Only meaningful for PIPE_BUFFER; used for flushing. 77bf215546Sopenharmony_ci */ 78bf215546Sopenharmony_ci unsigned bind_history; 79bf215546Sopenharmony_ci 80bf215546Sopenharmony_ci /** 81bf215546Sopenharmony_ci * A bitfield of MESA_SHADER_* stages indicating where this resource 82bf215546Sopenharmony_ci * was bound. 83bf215546Sopenharmony_ci */ 84bf215546Sopenharmony_ci unsigned bind_stages; 85bf215546Sopenharmony_ci 86bf215546Sopenharmony_ci /** 87bf215546Sopenharmony_ci * For PIPE_BUFFER resources, a range which may contain valid data. 88bf215546Sopenharmony_ci * 89bf215546Sopenharmony_ci * This is a conservative estimate of what part of the buffer contains 90bf215546Sopenharmony_ci * valid data that we have to preserve. The rest of the buffer is 91bf215546Sopenharmony_ci * considered invalid, and we can promote writes to that region to 92bf215546Sopenharmony_ci * be unsynchronized writes, avoiding blit copies. 93bf215546Sopenharmony_ci */ 94bf215546Sopenharmony_ci struct util_range valid_buffer_range; 95bf215546Sopenharmony_ci 96bf215546Sopenharmony_ci /** 97bf215546Sopenharmony_ci * Auxiliary buffer information (CCS, MCS, or HiZ). 98bf215546Sopenharmony_ci */ 99bf215546Sopenharmony_ci struct { 100bf215546Sopenharmony_ci /** The surface layout for the auxiliary buffer. */ 101bf215546Sopenharmony_ci struct isl_surf surf; 102bf215546Sopenharmony_ci 103bf215546Sopenharmony_ci /** The buffer object containing the auxiliary data. */ 104bf215546Sopenharmony_ci struct iris_bo *bo; 105bf215546Sopenharmony_ci 106bf215546Sopenharmony_ci /** Offset into 'bo' where the auxiliary surface starts. */ 107bf215546Sopenharmony_ci uint32_t offset; 108bf215546Sopenharmony_ci 109bf215546Sopenharmony_ci struct { 110bf215546Sopenharmony_ci struct isl_surf surf; 111bf215546Sopenharmony_ci 112bf215546Sopenharmony_ci /** Offset into 'bo' where the auxiliary surface starts. */ 113bf215546Sopenharmony_ci uint32_t offset; 114bf215546Sopenharmony_ci } extra_aux; 115bf215546Sopenharmony_ci 116bf215546Sopenharmony_ci /** 117bf215546Sopenharmony_ci * When importing resources with a clear color, we may not know the 118bf215546Sopenharmony_ci * clear color on the CPU at first. 119bf215546Sopenharmony_ci */ 120bf215546Sopenharmony_ci bool clear_color_unknown; 121bf215546Sopenharmony_ci 122bf215546Sopenharmony_ci /** 123bf215546Sopenharmony_ci * Fast clear color for this surface. For depth surfaces, the clear 124bf215546Sopenharmony_ci * value is stored as a float32 in the red component. 125bf215546Sopenharmony_ci * 126bf215546Sopenharmony_ci * Do not rely on this value if clear_color_unknown is set. 127bf215546Sopenharmony_ci */ 128bf215546Sopenharmony_ci union isl_color_value clear_color; 129bf215546Sopenharmony_ci 130bf215546Sopenharmony_ci /** Buffer object containing the indirect clear color. */ 131bf215546Sopenharmony_ci struct iris_bo *clear_color_bo; 132bf215546Sopenharmony_ci 133bf215546Sopenharmony_ci /** Offset into bo where the clear color can be found. */ 134bf215546Sopenharmony_ci uint64_t clear_color_offset; 135bf215546Sopenharmony_ci 136bf215546Sopenharmony_ci /** 137bf215546Sopenharmony_ci * \brief The type of auxiliary compression used by this resource. 138bf215546Sopenharmony_ci * 139bf215546Sopenharmony_ci * This describes the type of auxiliary compression that is intended to 140bf215546Sopenharmony_ci * be used by this resource. An aux usage of ISL_AUX_USAGE_NONE means 141bf215546Sopenharmony_ci * that auxiliary compression is permanently disabled. An aux usage 142bf215546Sopenharmony_ci * other than ISL_AUX_USAGE_NONE does not imply that auxiliary 143bf215546Sopenharmony_ci * compression will always be enabled for this surface. 144bf215546Sopenharmony_ci */ 145bf215546Sopenharmony_ci enum isl_aux_usage usage; 146bf215546Sopenharmony_ci 147bf215546Sopenharmony_ci /** 148bf215546Sopenharmony_ci * \brief Maps miptree slices to their current aux state. 149bf215546Sopenharmony_ci * 150bf215546Sopenharmony_ci * This two-dimensional array is indexed as [level][layer] and stores an 151bf215546Sopenharmony_ci * aux state for each slice. 152bf215546Sopenharmony_ci */ 153bf215546Sopenharmony_ci enum isl_aux_state **state; 154bf215546Sopenharmony_ci } aux; 155bf215546Sopenharmony_ci 156bf215546Sopenharmony_ci /** 157bf215546Sopenharmony_ci * For external surfaces, this is format that was used to create or import 158bf215546Sopenharmony_ci * the surface. For internal surfaces, this will always be 159bf215546Sopenharmony_ci * PIPE_FORMAT_NONE. 160bf215546Sopenharmony_ci */ 161bf215546Sopenharmony_ci enum pipe_format external_format; 162bf215546Sopenharmony_ci 163bf215546Sopenharmony_ci /** 164bf215546Sopenharmony_ci * For external surfaces, this is DRM format modifier that was used to 165bf215546Sopenharmony_ci * create or import the surface. For internal surfaces, this will always 166bf215546Sopenharmony_ci * be DRM_FORMAT_MOD_INVALID. 167bf215546Sopenharmony_ci */ 168bf215546Sopenharmony_ci const struct isl_drm_modifier_info *mod_info; 169bf215546Sopenharmony_ci 170bf215546Sopenharmony_ci /** 171bf215546Sopenharmony_ci * The screen the resource was originally created with, stored for refcounting. 172bf215546Sopenharmony_ci */ 173bf215546Sopenharmony_ci struct pipe_screen *orig_screen; 174bf215546Sopenharmony_ci}; 175bf215546Sopenharmony_ci 176bf215546Sopenharmony_ci/** 177bf215546Sopenharmony_ci * A simple <resource, offset> tuple for storing a reference to a 178bf215546Sopenharmony_ci * piece of state stored in a GPU buffer object. 179bf215546Sopenharmony_ci */ 180bf215546Sopenharmony_cistruct iris_state_ref { 181bf215546Sopenharmony_ci struct pipe_resource *res; 182bf215546Sopenharmony_ci uint32_t offset; 183bf215546Sopenharmony_ci}; 184bf215546Sopenharmony_ci 185bf215546Sopenharmony_ci/** 186bf215546Sopenharmony_ci * The SURFACE_STATE descriptors for a resource. 187bf215546Sopenharmony_ci */ 188bf215546Sopenharmony_cistruct iris_surface_state { 189bf215546Sopenharmony_ci /** 190bf215546Sopenharmony_ci * CPU-side copy of the packed SURFACE_STATE structures, already 191bf215546Sopenharmony_ci * aligned so they can be uploaded as a contiguous pile of bytes. 192bf215546Sopenharmony_ci * 193bf215546Sopenharmony_ci * This can be updated and re-uploaded if (e.g.) addresses need to change. 194bf215546Sopenharmony_ci */ 195bf215546Sopenharmony_ci uint32_t *cpu; 196bf215546Sopenharmony_ci 197bf215546Sopenharmony_ci /** 198bf215546Sopenharmony_ci * A bitfield of ISL_AUX_USAGE_* modes that are present in the surface 199bf215546Sopenharmony_ci * states. 200bf215546Sopenharmony_ci */ 201bf215546Sopenharmony_ci unsigned aux_usages; 202bf215546Sopenharmony_ci 203bf215546Sopenharmony_ci /** 204bf215546Sopenharmony_ci * How many states are there? (Each aux mode has its own state.) 205bf215546Sopenharmony_ci */ 206bf215546Sopenharmony_ci unsigned num_states; 207bf215546Sopenharmony_ci 208bf215546Sopenharmony_ci /** 209bf215546Sopenharmony_ci * Address of the resource (res->bo->address). Note that "Surface 210bf215546Sopenharmony_ci * Base Address" may be offset from this value. 211bf215546Sopenharmony_ci */ 212bf215546Sopenharmony_ci uint64_t bo_address; 213bf215546Sopenharmony_ci 214bf215546Sopenharmony_ci /** A reference to the GPU buffer holding our uploaded SURFACE_STATE */ 215bf215546Sopenharmony_ci struct iris_state_ref ref; 216bf215546Sopenharmony_ci}; 217bf215546Sopenharmony_ci 218bf215546Sopenharmony_ci/** 219bf215546Sopenharmony_ci * Gallium CSO for sampler views (texture views). 220bf215546Sopenharmony_ci * 221bf215546Sopenharmony_ci * In addition to the normal pipe_resource, this adds an ISL view 222bf215546Sopenharmony_ci * which may reinterpret the format or restrict levels/layers. 223bf215546Sopenharmony_ci * 224bf215546Sopenharmony_ci * These can also be linear texture buffers. 225bf215546Sopenharmony_ci */ 226bf215546Sopenharmony_cistruct iris_sampler_view { 227bf215546Sopenharmony_ci struct pipe_sampler_view base; 228bf215546Sopenharmony_ci struct isl_view view; 229bf215546Sopenharmony_ci 230bf215546Sopenharmony_ci union isl_color_value clear_color; 231bf215546Sopenharmony_ci 232bf215546Sopenharmony_ci /* A short-cut (not a reference) to the actual resource being viewed. 233bf215546Sopenharmony_ci * Multi-planar (or depth+stencil) images may have multiple resources 234bf215546Sopenharmony_ci * chained together; this skips having to traverse base->texture->*. 235bf215546Sopenharmony_ci */ 236bf215546Sopenharmony_ci struct iris_resource *res; 237bf215546Sopenharmony_ci 238bf215546Sopenharmony_ci /** The resource (BO) holding our SURFACE_STATE. */ 239bf215546Sopenharmony_ci struct iris_surface_state surface_state; 240bf215546Sopenharmony_ci}; 241bf215546Sopenharmony_ci 242bf215546Sopenharmony_ci/** 243bf215546Sopenharmony_ci * Image view representation. 244bf215546Sopenharmony_ci */ 245bf215546Sopenharmony_cistruct iris_image_view { 246bf215546Sopenharmony_ci struct pipe_image_view base; 247bf215546Sopenharmony_ci 248bf215546Sopenharmony_ci /** The resource (BO) holding our SURFACE_STATE. */ 249bf215546Sopenharmony_ci struct iris_surface_state surface_state; 250bf215546Sopenharmony_ci}; 251bf215546Sopenharmony_ci 252bf215546Sopenharmony_ci/** 253bf215546Sopenharmony_ci * Gallium CSO for surfaces (framebuffer attachments). 254bf215546Sopenharmony_ci * 255bf215546Sopenharmony_ci * A view of a surface that can be bound to a color render target or 256bf215546Sopenharmony_ci * depth/stencil attachment. 257bf215546Sopenharmony_ci */ 258bf215546Sopenharmony_cistruct iris_surface { 259bf215546Sopenharmony_ci struct pipe_surface base; 260bf215546Sopenharmony_ci struct isl_view view; 261bf215546Sopenharmony_ci struct isl_view read_view; 262bf215546Sopenharmony_ci union isl_color_value clear_color; 263bf215546Sopenharmony_ci 264bf215546Sopenharmony_ci /** The resource (BO) holding our SURFACE_STATE. */ 265bf215546Sopenharmony_ci struct iris_surface_state surface_state; 266bf215546Sopenharmony_ci /** The resource (BO) holding our SURFACE_STATE for read. */ 267bf215546Sopenharmony_ci struct iris_surface_state surface_state_read; 268bf215546Sopenharmony_ci}; 269bf215546Sopenharmony_ci 270bf215546Sopenharmony_ci/** 271bf215546Sopenharmony_ci * Transfer object - information about a buffer mapping. 272bf215546Sopenharmony_ci */ 273bf215546Sopenharmony_cistruct iris_transfer { 274bf215546Sopenharmony_ci struct threaded_transfer base; 275bf215546Sopenharmony_ci struct util_debug_callback *dbg; 276bf215546Sopenharmony_ci void *buffer; 277bf215546Sopenharmony_ci void *ptr; 278bf215546Sopenharmony_ci 279bf215546Sopenharmony_ci /** A linear staging resource for GPU-based copy_region transfers. */ 280bf215546Sopenharmony_ci struct pipe_resource *staging; 281bf215546Sopenharmony_ci struct blorp_context *blorp; 282bf215546Sopenharmony_ci struct iris_batch *batch; 283bf215546Sopenharmony_ci 284bf215546Sopenharmony_ci bool dest_had_defined_contents; 285bf215546Sopenharmony_ci 286bf215546Sopenharmony_ci void (*unmap)(struct iris_transfer *); 287bf215546Sopenharmony_ci}; 288bf215546Sopenharmony_ci 289bf215546Sopenharmony_ci/** 290bf215546Sopenharmony_ci * Memory Object 291bf215546Sopenharmony_ci */ 292bf215546Sopenharmony_cistruct iris_memory_object { 293bf215546Sopenharmony_ci struct pipe_memory_object b; 294bf215546Sopenharmony_ci struct iris_bo *bo; 295bf215546Sopenharmony_ci uint64_t format; 296bf215546Sopenharmony_ci unsigned stride; 297bf215546Sopenharmony_ci}; 298bf215546Sopenharmony_ci 299bf215546Sopenharmony_ci/** 300bf215546Sopenharmony_ci * Unwrap a pipe_resource to get the underlying iris_bo (for convenience). 301bf215546Sopenharmony_ci */ 302bf215546Sopenharmony_cistatic inline struct iris_bo * 303bf215546Sopenharmony_ciiris_resource_bo(struct pipe_resource *p_res) 304bf215546Sopenharmony_ci{ 305bf215546Sopenharmony_ci struct iris_resource *res = (void *) p_res; 306bf215546Sopenharmony_ci return res->bo; 307bf215546Sopenharmony_ci} 308bf215546Sopenharmony_ci 309bf215546Sopenharmony_cistatic inline uint32_t 310bf215546Sopenharmony_ciiris_mocs(const struct iris_bo *bo, 311bf215546Sopenharmony_ci const struct isl_device *dev, 312bf215546Sopenharmony_ci isl_surf_usage_flags_t usage) 313bf215546Sopenharmony_ci{ 314bf215546Sopenharmony_ci return isl_mocs(dev, usage, bo && iris_bo_is_external(bo)); 315bf215546Sopenharmony_ci} 316bf215546Sopenharmony_ci 317bf215546Sopenharmony_cistruct iris_format_info iris_format_for_usage(const struct intel_device_info *, 318bf215546Sopenharmony_ci enum pipe_format pf, 319bf215546Sopenharmony_ci isl_surf_usage_flags_t usage); 320bf215546Sopenharmony_ci 321bf215546Sopenharmony_cistruct pipe_resource *iris_resource_get_separate_stencil(struct pipe_resource *); 322bf215546Sopenharmony_ci 323bf215546Sopenharmony_civoid iris_get_depth_stencil_resources(struct pipe_resource *res, 324bf215546Sopenharmony_ci struct iris_resource **out_z, 325bf215546Sopenharmony_ci struct iris_resource **out_s); 326bf215546Sopenharmony_cibool iris_resource_set_clear_color(struct iris_context *ice, 327bf215546Sopenharmony_ci struct iris_resource *res, 328bf215546Sopenharmony_ci union isl_color_value color); 329bf215546Sopenharmony_ci 330bf215546Sopenharmony_civoid iris_replace_buffer_storage(struct pipe_context *ctx, 331bf215546Sopenharmony_ci struct pipe_resource *dst, 332bf215546Sopenharmony_ci struct pipe_resource *src, 333bf215546Sopenharmony_ci unsigned num_rebinds, 334bf215546Sopenharmony_ci uint32_t rebind_mask, 335bf215546Sopenharmony_ci uint32_t delete_buffer_id); 336bf215546Sopenharmony_ci 337bf215546Sopenharmony_ci 338bf215546Sopenharmony_civoid iris_init_screen_resource_functions(struct pipe_screen *pscreen); 339bf215546Sopenharmony_ci 340bf215546Sopenharmony_civoid iris_dirty_for_history(struct iris_context *ice, 341bf215546Sopenharmony_ci struct iris_resource *res); 342bf215546Sopenharmony_ci 343bf215546Sopenharmony_ciunsigned iris_get_num_logical_layers(const struct iris_resource *res, 344bf215546Sopenharmony_ci unsigned level); 345bf215546Sopenharmony_ci 346bf215546Sopenharmony_civoid iris_resource_disable_aux(struct iris_resource *res); 347bf215546Sopenharmony_ci 348bf215546Sopenharmony_ci#define INTEL_REMAINING_LAYERS UINT32_MAX 349bf215546Sopenharmony_ci#define INTEL_REMAINING_LEVELS UINT32_MAX 350bf215546Sopenharmony_ci 351bf215546Sopenharmony_civoid 352bf215546Sopenharmony_ciiris_hiz_exec(struct iris_context *ice, 353bf215546Sopenharmony_ci struct iris_batch *batch, 354bf215546Sopenharmony_ci struct iris_resource *res, 355bf215546Sopenharmony_ci unsigned int level, unsigned int start_layer, 356bf215546Sopenharmony_ci unsigned int num_layers, enum isl_aux_op op, 357bf215546Sopenharmony_ci bool update_clear_depth); 358bf215546Sopenharmony_ci 359bf215546Sopenharmony_ci/** 360bf215546Sopenharmony_ci * Prepare a miptree for access 361bf215546Sopenharmony_ci * 362bf215546Sopenharmony_ci * This function should be called prior to any access to miptree in order to 363bf215546Sopenharmony_ci * perform any needed resolves. 364bf215546Sopenharmony_ci * 365bf215546Sopenharmony_ci * \param[in] start_level The first mip level to be accessed 366bf215546Sopenharmony_ci * 367bf215546Sopenharmony_ci * \param[in] num_levels The number of miplevels to be accessed or 368bf215546Sopenharmony_ci * INTEL_REMAINING_LEVELS to indicate every level 369bf215546Sopenharmony_ci * above start_level will be accessed 370bf215546Sopenharmony_ci * 371bf215546Sopenharmony_ci * \param[in] start_layer The first array slice or 3D layer to be accessed 372bf215546Sopenharmony_ci * 373bf215546Sopenharmony_ci * \param[in] num_layers The number of array slices or 3D layers be 374bf215546Sopenharmony_ci * accessed or INTEL_REMAINING_LAYERS to indicate 375bf215546Sopenharmony_ci * every layer above start_layer will be accessed 376bf215546Sopenharmony_ci * 377bf215546Sopenharmony_ci * \param[in] aux_supported Whether or not the access will support the 378bf215546Sopenharmony_ci * miptree's auxiliary compression format; this 379bf215546Sopenharmony_ci * must be false for uncompressed miptrees 380bf215546Sopenharmony_ci * 381bf215546Sopenharmony_ci * \param[in] fast_clear_supported Whether or not the access will support 382bf215546Sopenharmony_ci * fast clears in the miptree's auxiliary 383bf215546Sopenharmony_ci * compression format 384bf215546Sopenharmony_ci */ 385bf215546Sopenharmony_civoid 386bf215546Sopenharmony_ciiris_resource_prepare_access(struct iris_context *ice, 387bf215546Sopenharmony_ci struct iris_resource *res, 388bf215546Sopenharmony_ci uint32_t start_level, uint32_t num_levels, 389bf215546Sopenharmony_ci uint32_t start_layer, uint32_t num_layers, 390bf215546Sopenharmony_ci enum isl_aux_usage aux_usage, 391bf215546Sopenharmony_ci bool fast_clear_supported); 392bf215546Sopenharmony_ci 393bf215546Sopenharmony_ci/** 394bf215546Sopenharmony_ci * Complete a write operation 395bf215546Sopenharmony_ci * 396bf215546Sopenharmony_ci * This function should be called after any operation writes to a miptree. 397bf215546Sopenharmony_ci * This will update the miptree's compression state so that future resolves 398bf215546Sopenharmony_ci * happen correctly. Technically, this function can be called before the 399bf215546Sopenharmony_ci * write occurs but the caller must ensure that they don't interlace 400bf215546Sopenharmony_ci * iris_resource_prepare_access and iris_resource_finish_write calls to 401bf215546Sopenharmony_ci * overlapping layer/level ranges. 402bf215546Sopenharmony_ci * 403bf215546Sopenharmony_ci * \param[in] level The mip level that was written 404bf215546Sopenharmony_ci * 405bf215546Sopenharmony_ci * \param[in] start_layer The first array slice or 3D layer written 406bf215546Sopenharmony_ci * 407bf215546Sopenharmony_ci * \param[in] num_layers The number of array slices or 3D layers 408bf215546Sopenharmony_ci * written or INTEL_REMAINING_LAYERS to indicate 409bf215546Sopenharmony_ci * every layer above start_layer was written 410bf215546Sopenharmony_ci * 411bf215546Sopenharmony_ci * \param[in] written_with_aux Whether or not the write was done with 412bf215546Sopenharmony_ci * auxiliary compression enabled 413bf215546Sopenharmony_ci */ 414bf215546Sopenharmony_civoid 415bf215546Sopenharmony_ciiris_resource_finish_write(struct iris_context *ice, 416bf215546Sopenharmony_ci struct iris_resource *res, uint32_t level, 417bf215546Sopenharmony_ci uint32_t start_layer, uint32_t num_layers, 418bf215546Sopenharmony_ci enum isl_aux_usage aux_usage); 419bf215546Sopenharmony_ci 420bf215546Sopenharmony_ci/** Get the auxiliary compression state of a miptree slice */ 421bf215546Sopenharmony_cienum isl_aux_state 422bf215546Sopenharmony_ciiris_resource_get_aux_state(const struct iris_resource *res, 423bf215546Sopenharmony_ci uint32_t level, uint32_t layer); 424bf215546Sopenharmony_ci 425bf215546Sopenharmony_ci/** 426bf215546Sopenharmony_ci * Set the auxiliary compression state of a miptree slice range 427bf215546Sopenharmony_ci * 428bf215546Sopenharmony_ci * This function directly sets the auxiliary compression state of a slice 429bf215546Sopenharmony_ci * range of a miptree. It only modifies data structures and does not do any 430bf215546Sopenharmony_ci * resolves. This should only be called by code which directly performs 431bf215546Sopenharmony_ci * compression operations such as fast clears and resolves. Most code should 432bf215546Sopenharmony_ci * use iris_resource_prepare_access or iris_resource_finish_write. 433bf215546Sopenharmony_ci */ 434bf215546Sopenharmony_civoid 435bf215546Sopenharmony_ciiris_resource_set_aux_state(struct iris_context *ice, 436bf215546Sopenharmony_ci struct iris_resource *res, uint32_t level, 437bf215546Sopenharmony_ci uint32_t start_layer, uint32_t num_layers, 438bf215546Sopenharmony_ci enum isl_aux_state aux_state); 439bf215546Sopenharmony_ci 440bf215546Sopenharmony_ci/** 441bf215546Sopenharmony_ci * Prepare a miptree for raw access 442bf215546Sopenharmony_ci * 443bf215546Sopenharmony_ci * This helper prepares the miptree for access that knows nothing about any 444bf215546Sopenharmony_ci * sort of compression whatsoever. This is useful when mapping the surface or 445bf215546Sopenharmony_ci * using it with the blitter. 446bf215546Sopenharmony_ci */ 447bf215546Sopenharmony_cistatic inline void 448bf215546Sopenharmony_ciiris_resource_access_raw(struct iris_context *ice, 449bf215546Sopenharmony_ci struct iris_resource *res, 450bf215546Sopenharmony_ci uint32_t level, uint32_t layer, 451bf215546Sopenharmony_ci uint32_t num_layers, 452bf215546Sopenharmony_ci bool write) 453bf215546Sopenharmony_ci{ 454bf215546Sopenharmony_ci iris_resource_prepare_access(ice, res, level, 1, layer, num_layers, 455bf215546Sopenharmony_ci ISL_AUX_USAGE_NONE, false); 456bf215546Sopenharmony_ci if (write) { 457bf215546Sopenharmony_ci iris_resource_finish_write(ice, res, level, layer, num_layers, 458bf215546Sopenharmony_ci ISL_AUX_USAGE_NONE); 459bf215546Sopenharmony_ci } 460bf215546Sopenharmony_ci} 461bf215546Sopenharmony_ci 462bf215546Sopenharmony_cienum isl_aux_usage iris_resource_texture_aux_usage(struct iris_context *ice, 463bf215546Sopenharmony_ci const struct iris_resource *res, 464bf215546Sopenharmony_ci enum isl_format view_fmt); 465bf215546Sopenharmony_civoid iris_resource_prepare_texture(struct iris_context *ice, 466bf215546Sopenharmony_ci struct iris_resource *res, 467bf215546Sopenharmony_ci enum isl_format view_format, 468bf215546Sopenharmony_ci uint32_t start_level, uint32_t num_levels, 469bf215546Sopenharmony_ci uint32_t start_layer, uint32_t num_layers); 470bf215546Sopenharmony_ci 471bf215546Sopenharmony_cienum isl_aux_usage iris_image_view_aux_usage(struct iris_context *ice, 472bf215546Sopenharmony_ci const struct pipe_image_view *pview, 473bf215546Sopenharmony_ci const struct shader_info *info); 474bf215546Sopenharmony_cienum isl_format iris_image_view_get_format(struct iris_context *ice, 475bf215546Sopenharmony_ci const struct pipe_image_view *img); 476bf215546Sopenharmony_ci 477bf215546Sopenharmony_cibool iris_has_invalid_primary(const struct iris_resource *res, 478bf215546Sopenharmony_ci unsigned start_level, unsigned num_levels, 479bf215546Sopenharmony_ci unsigned start_layer, unsigned num_layers); 480bf215546Sopenharmony_ci 481bf215546Sopenharmony_civoid iris_resource_check_level_layer(const struct iris_resource *res, 482bf215546Sopenharmony_ci uint32_t level, uint32_t layer); 483bf215546Sopenharmony_ci 484bf215546Sopenharmony_cibool iris_resource_level_has_hiz(const struct iris_resource *res, 485bf215546Sopenharmony_ci uint32_t level); 486bf215546Sopenharmony_ci 487bf215546Sopenharmony_cibool iris_sample_with_depth_aux(const struct intel_device_info *devinfo, 488bf215546Sopenharmony_ci const struct iris_resource *res); 489bf215546Sopenharmony_ci 490bf215546Sopenharmony_cibool iris_can_sample_mcs_with_clear(const struct intel_device_info *devinfo, 491bf215546Sopenharmony_ci const struct iris_resource *res); 492bf215546Sopenharmony_ci 493bf215546Sopenharmony_cibool iris_has_color_unresolved(const struct iris_resource *res, 494bf215546Sopenharmony_ci unsigned start_level, unsigned num_levels, 495bf215546Sopenharmony_ci unsigned start_layer, unsigned num_layers); 496bf215546Sopenharmony_ci 497bf215546Sopenharmony_cibool iris_render_formats_color_compatible(enum isl_format a, 498bf215546Sopenharmony_ci enum isl_format b, 499bf215546Sopenharmony_ci union isl_color_value color, 500bf215546Sopenharmony_ci bool clear_color_unknown); 501bf215546Sopenharmony_cienum isl_aux_usage iris_resource_render_aux_usage(struct iris_context *ice, 502bf215546Sopenharmony_ci struct iris_resource *res, 503bf215546Sopenharmony_ci uint32_t level, 504bf215546Sopenharmony_ci enum isl_format render_fmt, 505bf215546Sopenharmony_ci bool draw_aux_disabled); 506bf215546Sopenharmony_civoid iris_resource_prepare_render(struct iris_context *ice, 507bf215546Sopenharmony_ci struct iris_resource *res, uint32_t level, 508bf215546Sopenharmony_ci uint32_t start_layer, uint32_t layer_count, 509bf215546Sopenharmony_ci enum isl_aux_usage aux_usage); 510bf215546Sopenharmony_civoid iris_resource_finish_render(struct iris_context *ice, 511bf215546Sopenharmony_ci struct iris_resource *res, uint32_t level, 512bf215546Sopenharmony_ci uint32_t start_layer, uint32_t layer_count, 513bf215546Sopenharmony_ci enum isl_aux_usage aux_usage); 514bf215546Sopenharmony_ci#endif 515