1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2012 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 (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 NONINFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21bf215546Sopenharmony_ci * IN THE SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#ifndef BLORP_H 25bf215546Sopenharmony_ci#define BLORP_H 26bf215546Sopenharmony_ci 27bf215546Sopenharmony_ci#include <stdint.h> 28bf215546Sopenharmony_ci#include <stdbool.h> 29bf215546Sopenharmony_ci 30bf215546Sopenharmony_ci#include "isl/isl.h" 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_cistruct brw_stage_prog_data; 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_ci#ifdef __cplusplus 35bf215546Sopenharmony_ciextern "C" { 36bf215546Sopenharmony_ci#endif 37bf215546Sopenharmony_ci 38bf215546Sopenharmony_cistruct blorp_batch; 39bf215546Sopenharmony_cistruct blorp_params; 40bf215546Sopenharmony_ci 41bf215546Sopenharmony_cistruct blorp_config { 42bf215546Sopenharmony_ci bool use_mesh_shading; 43bf215546Sopenharmony_ci}; 44bf215546Sopenharmony_ci 45bf215546Sopenharmony_cistruct blorp_context { 46bf215546Sopenharmony_ci void *driver_ctx; 47bf215546Sopenharmony_ci 48bf215546Sopenharmony_ci const struct isl_device *isl_dev; 49bf215546Sopenharmony_ci 50bf215546Sopenharmony_ci const struct brw_compiler *compiler; 51bf215546Sopenharmony_ci 52bf215546Sopenharmony_ci bool (*lookup_shader)(struct blorp_batch *batch, 53bf215546Sopenharmony_ci const void *key, uint32_t key_size, 54bf215546Sopenharmony_ci uint32_t *kernel_out, void *prog_data_out); 55bf215546Sopenharmony_ci bool (*upload_shader)(struct blorp_batch *batch, 56bf215546Sopenharmony_ci uint32_t stage, 57bf215546Sopenharmony_ci const void *key, uint32_t key_size, 58bf215546Sopenharmony_ci const void *kernel, uint32_t kernel_size, 59bf215546Sopenharmony_ci const struct brw_stage_prog_data *prog_data, 60bf215546Sopenharmony_ci uint32_t prog_data_size, 61bf215546Sopenharmony_ci uint32_t *kernel_out, void *prog_data_out); 62bf215546Sopenharmony_ci void (*exec)(struct blorp_batch *batch, const struct blorp_params *params); 63bf215546Sopenharmony_ci 64bf215546Sopenharmony_ci struct blorp_config config; 65bf215546Sopenharmony_ci}; 66bf215546Sopenharmony_ci 67bf215546Sopenharmony_civoid blorp_init(struct blorp_context *blorp, void *driver_ctx, 68bf215546Sopenharmony_ci struct isl_device *isl_dev, const struct blorp_config *config); 69bf215546Sopenharmony_civoid blorp_finish(struct blorp_context *blorp); 70bf215546Sopenharmony_ci 71bf215546Sopenharmony_cienum blorp_batch_flags { 72bf215546Sopenharmony_ci /** 73bf215546Sopenharmony_ci * This flag indicates that blorp should *not* re-emit the depth and 74bf215546Sopenharmony_ci * stencil buffer packets. Instead, the driver guarantees that all depth 75bf215546Sopenharmony_ci * and stencil images passed in will match what is currently set in the 76bf215546Sopenharmony_ci * hardware. 77bf215546Sopenharmony_ci */ 78bf215546Sopenharmony_ci BLORP_BATCH_NO_EMIT_DEPTH_STENCIL = (1 << 0), 79bf215546Sopenharmony_ci 80bf215546Sopenharmony_ci /* This flag indicates that the blorp call should be predicated. */ 81bf215546Sopenharmony_ci BLORP_BATCH_PREDICATE_ENABLE = (1 << 1), 82bf215546Sopenharmony_ci 83bf215546Sopenharmony_ci /* This flag indicates that blorp should *not* update the indirect clear 84bf215546Sopenharmony_ci * color buffer. 85bf215546Sopenharmony_ci */ 86bf215546Sopenharmony_ci BLORP_BATCH_NO_UPDATE_CLEAR_COLOR = (1 << 2), 87bf215546Sopenharmony_ci 88bf215546Sopenharmony_ci /* This flag indicates that blorp should use a compute program for the 89bf215546Sopenharmony_ci * operation. 90bf215546Sopenharmony_ci */ 91bf215546Sopenharmony_ci BLORP_BATCH_USE_COMPUTE = (1 << 3), 92bf215546Sopenharmony_ci 93bf215546Sopenharmony_ci /** Use the hardware blitter to perform any operations in this batch */ 94bf215546Sopenharmony_ci BLORP_BATCH_USE_BLITTER = (1 << 4), 95bf215546Sopenharmony_ci}; 96bf215546Sopenharmony_ci 97bf215546Sopenharmony_cistruct blorp_batch { 98bf215546Sopenharmony_ci struct blorp_context *blorp; 99bf215546Sopenharmony_ci void *driver_batch; 100bf215546Sopenharmony_ci enum blorp_batch_flags flags; 101bf215546Sopenharmony_ci}; 102bf215546Sopenharmony_ci 103bf215546Sopenharmony_civoid blorp_batch_init(struct blorp_context *blorp, struct blorp_batch *batch, 104bf215546Sopenharmony_ci void *driver_batch, enum blorp_batch_flags flags); 105bf215546Sopenharmony_civoid blorp_batch_finish(struct blorp_batch *batch); 106bf215546Sopenharmony_ci 107bf215546Sopenharmony_cistruct blorp_address { 108bf215546Sopenharmony_ci void *buffer; 109bf215546Sopenharmony_ci uint64_t offset; 110bf215546Sopenharmony_ci unsigned reloc_flags; 111bf215546Sopenharmony_ci uint32_t mocs; 112bf215546Sopenharmony_ci 113bf215546Sopenharmony_ci /** 114bf215546Sopenharmony_ci * True if this buffer is intended to live in device-local memory. 115bf215546Sopenharmony_ci * This is only a performance hint; it's OK to set it to true even 116bf215546Sopenharmony_ci * if eviction has temporarily forced the buffer to system memory. 117bf215546Sopenharmony_ci */ 118bf215546Sopenharmony_ci bool local_hint; 119bf215546Sopenharmony_ci}; 120bf215546Sopenharmony_ci 121bf215546Sopenharmony_cistruct blorp_surf 122bf215546Sopenharmony_ci{ 123bf215546Sopenharmony_ci const struct isl_surf *surf; 124bf215546Sopenharmony_ci struct blorp_address addr; 125bf215546Sopenharmony_ci 126bf215546Sopenharmony_ci const struct isl_surf *aux_surf; 127bf215546Sopenharmony_ci struct blorp_address aux_addr; 128bf215546Sopenharmony_ci enum isl_aux_usage aux_usage; 129bf215546Sopenharmony_ci 130bf215546Sopenharmony_ci union isl_color_value clear_color; 131bf215546Sopenharmony_ci 132bf215546Sopenharmony_ci /** 133bf215546Sopenharmony_ci * If set (bo != NULL), clear_color is ignored and the actual clear color 134bf215546Sopenharmony_ci * is fetched from this address. On gfx7-8, this is all of dword 7 of 135bf215546Sopenharmony_ci * RENDER_SURFACE_STATE and is the responsibility of the caller to ensure 136bf215546Sopenharmony_ci * that it contains a swizzle of RGBA and resource min LOD of 0. 137bf215546Sopenharmony_ci */ 138bf215546Sopenharmony_ci struct blorp_address clear_color_addr; 139bf215546Sopenharmony_ci 140bf215546Sopenharmony_ci /* Only allowed for simple 2D non-MSAA surfaces */ 141bf215546Sopenharmony_ci uint32_t tile_x_sa, tile_y_sa; 142bf215546Sopenharmony_ci}; 143bf215546Sopenharmony_ci 144bf215546Sopenharmony_cienum blorp_filter { 145bf215546Sopenharmony_ci BLORP_FILTER_NONE, 146bf215546Sopenharmony_ci BLORP_FILTER_NEAREST, 147bf215546Sopenharmony_ci BLORP_FILTER_BILINEAR, 148bf215546Sopenharmony_ci BLORP_FILTER_SAMPLE_0, 149bf215546Sopenharmony_ci BLORP_FILTER_AVERAGE, 150bf215546Sopenharmony_ci BLORP_FILTER_MIN_SAMPLE, 151bf215546Sopenharmony_ci BLORP_FILTER_MAX_SAMPLE, 152bf215546Sopenharmony_ci}; 153bf215546Sopenharmony_ci 154bf215546Sopenharmony_civoid 155bf215546Sopenharmony_ciblorp_blit(struct blorp_batch *batch, 156bf215546Sopenharmony_ci const struct blorp_surf *src_surf, 157bf215546Sopenharmony_ci unsigned src_level, float src_layer, 158bf215546Sopenharmony_ci enum isl_format src_format, struct isl_swizzle src_swizzle, 159bf215546Sopenharmony_ci const struct blorp_surf *dst_surf, 160bf215546Sopenharmony_ci unsigned dst_level, unsigned dst_layer, 161bf215546Sopenharmony_ci enum isl_format dst_format, struct isl_swizzle dst_swizzle, 162bf215546Sopenharmony_ci float src_x0, float src_y0, 163bf215546Sopenharmony_ci float src_x1, float src_y1, 164bf215546Sopenharmony_ci float dst_x0, float dst_y0, 165bf215546Sopenharmony_ci float dst_x1, float dst_y1, 166bf215546Sopenharmony_ci enum blorp_filter filter, 167bf215546Sopenharmony_ci bool mirror_x, bool mirror_y); 168bf215546Sopenharmony_ci 169bf215546Sopenharmony_civoid 170bf215546Sopenharmony_ciblorp_copy(struct blorp_batch *batch, 171bf215546Sopenharmony_ci const struct blorp_surf *src_surf, 172bf215546Sopenharmony_ci unsigned src_level, unsigned src_layer, 173bf215546Sopenharmony_ci const struct blorp_surf *dst_surf, 174bf215546Sopenharmony_ci unsigned dst_level, unsigned dst_layer, 175bf215546Sopenharmony_ci uint32_t src_x, uint32_t src_y, 176bf215546Sopenharmony_ci uint32_t dst_x, uint32_t dst_y, 177bf215546Sopenharmony_ci uint32_t src_width, uint32_t src_height); 178bf215546Sopenharmony_ci 179bf215546Sopenharmony_civoid 180bf215546Sopenharmony_ciblorp_buffer_copy(struct blorp_batch *batch, 181bf215546Sopenharmony_ci struct blorp_address src, 182bf215546Sopenharmony_ci struct blorp_address dst, 183bf215546Sopenharmony_ci uint64_t size); 184bf215546Sopenharmony_ci 185bf215546Sopenharmony_civoid 186bf215546Sopenharmony_ciblorp_fast_clear(struct blorp_batch *batch, 187bf215546Sopenharmony_ci const struct blorp_surf *surf, 188bf215546Sopenharmony_ci enum isl_format format, struct isl_swizzle swizzle, 189bf215546Sopenharmony_ci uint32_t level, uint32_t start_layer, uint32_t num_layers, 190bf215546Sopenharmony_ci uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1); 191bf215546Sopenharmony_ci 192bf215546Sopenharmony_cibool 193bf215546Sopenharmony_ciblorp_clear_supports_compute(struct blorp_context *blorp, 194bf215546Sopenharmony_ci uint8_t color_write_disable, bool blend_enabled, 195bf215546Sopenharmony_ci enum isl_aux_usage aux_usage); 196bf215546Sopenharmony_ci 197bf215546Sopenharmony_cibool 198bf215546Sopenharmony_ciblorp_copy_supports_compute(struct blorp_context *blorp, 199bf215546Sopenharmony_ci const struct isl_surf *src_surf, 200bf215546Sopenharmony_ci const struct isl_surf *dst_surf, 201bf215546Sopenharmony_ci enum isl_aux_usage dst_aux_usage); 202bf215546Sopenharmony_ci 203bf215546Sopenharmony_cibool 204bf215546Sopenharmony_ciblorp_blit_supports_compute(struct blorp_context *blorp, 205bf215546Sopenharmony_ci const struct isl_surf *src_surf, 206bf215546Sopenharmony_ci const struct isl_surf *dst_surf, 207bf215546Sopenharmony_ci enum isl_aux_usage dst_aux_usage); 208bf215546Sopenharmony_ci 209bf215546Sopenharmony_cibool 210bf215546Sopenharmony_ciblorp_copy_supports_blitter(struct blorp_context *blorp, 211bf215546Sopenharmony_ci const struct isl_surf *src_surf, 212bf215546Sopenharmony_ci const struct isl_surf *dst_surf, 213bf215546Sopenharmony_ci enum isl_aux_usage src_aux_usage, 214bf215546Sopenharmony_ci enum isl_aux_usage dst_aux_usage); 215bf215546Sopenharmony_ci 216bf215546Sopenharmony_civoid 217bf215546Sopenharmony_ciblorp_clear(struct blorp_batch *batch, 218bf215546Sopenharmony_ci const struct blorp_surf *surf, 219bf215546Sopenharmony_ci enum isl_format format, struct isl_swizzle swizzle, 220bf215546Sopenharmony_ci uint32_t level, uint32_t start_layer, uint32_t num_layers, 221bf215546Sopenharmony_ci uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, 222bf215546Sopenharmony_ci union isl_color_value clear_color, 223bf215546Sopenharmony_ci uint8_t color_write_disable); 224bf215546Sopenharmony_ci 225bf215546Sopenharmony_civoid 226bf215546Sopenharmony_ciblorp_clear_depth_stencil(struct blorp_batch *batch, 227bf215546Sopenharmony_ci const struct blorp_surf *depth, 228bf215546Sopenharmony_ci const struct blorp_surf *stencil, 229bf215546Sopenharmony_ci uint32_t level, uint32_t start_layer, 230bf215546Sopenharmony_ci uint32_t num_layers, 231bf215546Sopenharmony_ci uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, 232bf215546Sopenharmony_ci bool clear_depth, float depth_value, 233bf215546Sopenharmony_ci uint8_t stencil_mask, uint8_t stencil_value); 234bf215546Sopenharmony_cibool 235bf215546Sopenharmony_ciblorp_can_hiz_clear_depth(const struct intel_device_info *devinfo, 236bf215546Sopenharmony_ci const struct isl_surf *surf, 237bf215546Sopenharmony_ci enum isl_aux_usage aux_usage, 238bf215546Sopenharmony_ci uint32_t level, uint32_t layer, 239bf215546Sopenharmony_ci uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1); 240bf215546Sopenharmony_civoid 241bf215546Sopenharmony_ciblorp_hiz_clear_depth_stencil(struct blorp_batch *batch, 242bf215546Sopenharmony_ci const struct blorp_surf *depth, 243bf215546Sopenharmony_ci const struct blorp_surf *stencil, 244bf215546Sopenharmony_ci uint32_t level, 245bf215546Sopenharmony_ci uint32_t start_layer, uint32_t num_layers, 246bf215546Sopenharmony_ci uint32_t x0, uint32_t y0, 247bf215546Sopenharmony_ci uint32_t x1, uint32_t y1, 248bf215546Sopenharmony_ci bool clear_depth, float depth_value, 249bf215546Sopenharmony_ci bool clear_stencil, uint8_t stencil_value); 250bf215546Sopenharmony_ci 251bf215546Sopenharmony_ci 252bf215546Sopenharmony_civoid 253bf215546Sopenharmony_ciblorp_gfx8_hiz_clear_attachments(struct blorp_batch *batch, 254bf215546Sopenharmony_ci uint32_t num_samples, 255bf215546Sopenharmony_ci uint32_t x0, uint32_t y0, 256bf215546Sopenharmony_ci uint32_t x1, uint32_t y1, 257bf215546Sopenharmony_ci bool clear_depth, bool clear_stencil, 258bf215546Sopenharmony_ci uint8_t stencil_value); 259bf215546Sopenharmony_civoid 260bf215546Sopenharmony_ciblorp_clear_attachments(struct blorp_batch *batch, 261bf215546Sopenharmony_ci uint32_t binding_table_offset, 262bf215546Sopenharmony_ci enum isl_format depth_format, 263bf215546Sopenharmony_ci uint32_t num_samples, 264bf215546Sopenharmony_ci uint32_t start_layer, uint32_t num_layers, 265bf215546Sopenharmony_ci uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, 266bf215546Sopenharmony_ci bool clear_color, union isl_color_value color_value, 267bf215546Sopenharmony_ci bool clear_depth, float depth_value, 268bf215546Sopenharmony_ci uint8_t stencil_mask, uint8_t stencil_value); 269bf215546Sopenharmony_ci 270bf215546Sopenharmony_civoid 271bf215546Sopenharmony_ciblorp_ccs_resolve(struct blorp_batch *batch, 272bf215546Sopenharmony_ci struct blorp_surf *surf, uint32_t level, 273bf215546Sopenharmony_ci uint32_t start_layer, uint32_t num_layers, 274bf215546Sopenharmony_ci enum isl_format format, 275bf215546Sopenharmony_ci enum isl_aux_op resolve_op); 276bf215546Sopenharmony_ci 277bf215546Sopenharmony_civoid 278bf215546Sopenharmony_ciblorp_ccs_ambiguate(struct blorp_batch *batch, 279bf215546Sopenharmony_ci struct blorp_surf *surf, 280bf215546Sopenharmony_ci uint32_t level, uint32_t layer); 281bf215546Sopenharmony_ci 282bf215546Sopenharmony_civoid 283bf215546Sopenharmony_ciblorp_mcs_partial_resolve(struct blorp_batch *batch, 284bf215546Sopenharmony_ci struct blorp_surf *surf, 285bf215546Sopenharmony_ci enum isl_format format, 286bf215546Sopenharmony_ci uint32_t start_layer, uint32_t num_layers); 287bf215546Sopenharmony_ci 288bf215546Sopenharmony_civoid 289bf215546Sopenharmony_ciblorp_hiz_op(struct blorp_batch *batch, struct blorp_surf *surf, 290bf215546Sopenharmony_ci uint32_t level, uint32_t start_layer, uint32_t num_layers, 291bf215546Sopenharmony_ci enum isl_aux_op op); 292bf215546Sopenharmony_ci 293bf215546Sopenharmony_ci#ifdef __cplusplus 294bf215546Sopenharmony_ci} /* end extern "C" */ 295bf215546Sopenharmony_ci#endif /* __cplusplus */ 296bf215546Sopenharmony_ci 297bf215546Sopenharmony_ci#endif /* BLORP_H */ 298