1 /* 2 * Copyright © 2012 Intel Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 * IN THE SOFTWARE. 22 */ 23 24 #ifndef BLORP_H 25 #define BLORP_H 26 27 #include <stdint.h> 28 #include <stdbool.h> 29 30 #include "isl/isl.h" 31 32 struct brw_context; 33 struct brw_stage_prog_data; 34 35 #ifdef __cplusplus 36 extern "C" { 37 #endif 38 39 struct blorp_batch; 40 struct blorp_params; 41 42 struct blorp_context { 43 void *driver_ctx; 44 45 const struct isl_device *isl_dev; 46 47 const struct brw_compiler *compiler; 48 49 struct { 50 uint32_t tex; 51 uint32_t rb; 52 uint32_t vb; 53 } mocs; 54 55 bool (*lookup_shader)(struct blorp_context *blorp, 56 const void *key, uint32_t key_size, 57 uint32_t *kernel_out, void *prog_data_out); 58 void (*upload_shader)(struct blorp_context *blorp, 59 const void *key, uint32_t key_size, 60 const void *kernel, uint32_t kernel_size, 61 const struct brw_stage_prog_data *prog_data, 62 uint32_t prog_data_size, 63 uint32_t *kernel_out, void *prog_data_out); 64 void (*exec)(struct blorp_batch *batch, const struct blorp_params *params); 65 }; 66 67 void blorp_init(struct blorp_context *blorp, void *driver_ctx, 68 struct isl_device *isl_dev); 69 void blorp_finish(struct blorp_context *blorp); 70 71 enum blorp_batch_flags { 72 /** 73 * This flag indicates that blorp should *not* re-emit the depth and 74 * stencil buffer packets. Instead, the driver guarantees that all depth 75 * and stencil images passed in will match what is currently set in the 76 * hardware. 77 */ 78 BLORP_BATCH_NO_EMIT_DEPTH_STENCIL = (1 << 0), 79 }; 80 81 struct blorp_batch { 82 struct blorp_context *blorp; 83 void *driver_batch; 84 enum blorp_batch_flags flags; 85 }; 86 87 void blorp_batch_init(struct blorp_context *blorp, struct blorp_batch *batch, 88 void *driver_batch, enum blorp_batch_flags flags); 89 void blorp_batch_finish(struct blorp_batch *batch); 90 91 struct blorp_address { 92 void *buffer; 93 uint32_t read_domains; 94 uint32_t write_domain; 95 uint32_t offset; 96 }; 97 98 struct blorp_surf 99 { 100 const struct isl_surf *surf; 101 struct blorp_address addr; 102 103 const struct isl_surf *aux_surf; 104 struct blorp_address aux_addr; 105 enum isl_aux_usage aux_usage; 106 107 union isl_color_value clear_color; 108 }; 109 110 void 111 blorp_blit(struct blorp_batch *batch, 112 const struct blorp_surf *src_surf, 113 unsigned src_level, unsigned src_layer, 114 enum isl_format src_format, struct isl_swizzle src_swizzle, 115 const struct blorp_surf *dst_surf, 116 unsigned dst_level, unsigned dst_layer, 117 enum isl_format dst_format, struct isl_swizzle dst_swizzle, 118 float src_x0, float src_y0, 119 float src_x1, float src_y1, 120 float dst_x0, float dst_y0, 121 float dst_x1, float dst_y1, 122 uint32_t filter, bool mirror_x, bool mirror_y); 123 124 void 125 blorp_copy(struct blorp_batch *batch, 126 const struct blorp_surf *src_surf, 127 unsigned src_level, unsigned src_layer, 128 const struct blorp_surf *dst_surf, 129 unsigned dst_level, unsigned dst_layer, 130 uint32_t src_x, uint32_t src_y, 131 uint32_t dst_x, uint32_t dst_y, 132 uint32_t src_width, uint32_t src_height); 133 134 void 135 blorp_fast_clear(struct blorp_batch *batch, 136 const struct blorp_surf *surf, enum isl_format format, 137 uint32_t level, uint32_t start_layer, uint32_t num_layers, 138 uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1); 139 140 void 141 blorp_clear(struct blorp_batch *batch, 142 const struct blorp_surf *surf, 143 enum isl_format format, struct isl_swizzle swizzle, 144 uint32_t level, uint32_t start_layer, uint32_t num_layers, 145 uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, 146 union isl_color_value clear_color, 147 const bool color_write_disable[4]); 148 149 void 150 blorp_clear_depth_stencil(struct blorp_batch *batch, 151 const struct blorp_surf *depth, 152 const struct blorp_surf *stencil, 153 uint32_t level, uint32_t start_layer, 154 uint32_t num_layers, 155 uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, 156 bool clear_depth, float depth_value, 157 uint8_t stencil_mask, uint8_t stencil_value); 158 bool 159 blorp_can_hiz_clear_depth(uint8_t gen, enum isl_format format, 160 uint32_t num_samples, 161 uint32_t x0, uint32_t y0, 162 uint32_t x1, uint32_t y1); 163 164 void 165 blorp_gen8_hiz_clear_attachments(struct blorp_batch *batch, 166 uint32_t num_samples, 167 uint32_t x0, uint32_t y0, 168 uint32_t x1, uint32_t y1, 169 bool clear_depth, bool clear_stencil, 170 uint8_t stencil_value); 171 void 172 blorp_clear_attachments(struct blorp_batch *batch, 173 uint32_t binding_table_offset, 174 enum isl_format depth_format, 175 uint32_t num_samples, 176 uint32_t start_layer, uint32_t num_layers, 177 uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, 178 bool clear_color, union isl_color_value color_value, 179 bool clear_depth, float depth_value, 180 uint8_t stencil_mask, uint8_t stencil_value); 181 182 enum blorp_fast_clear_op { 183 BLORP_FAST_CLEAR_OP_NONE = 0, 184 BLORP_FAST_CLEAR_OP_CLEAR, 185 BLORP_FAST_CLEAR_OP_RESOLVE_PARTIAL, 186 BLORP_FAST_CLEAR_OP_RESOLVE_FULL, 187 }; 188 189 void 190 blorp_ccs_resolve(struct blorp_batch *batch, 191 struct blorp_surf *surf, uint32_t level, uint32_t layer, 192 enum isl_format format, 193 enum blorp_fast_clear_op resolve_op); 194 195 /** 196 * For an overview of the HiZ operations, see the following sections of the 197 * Sandy Bridge PRM, Volume 1, Part2: 198 * - 7.5.3.1 Depth Buffer Clear 199 * - 7.5.3.2 Depth Buffer Resolve 200 * - 7.5.3.3 Hierarchical Depth Buffer Resolve 201 * 202 * Of these, two get entered in the resolve map as needing to be done to the 203 * buffer: depth resolve and hiz resolve. 204 */ 205 enum blorp_hiz_op { 206 BLORP_HIZ_OP_NONE, 207 BLORP_HIZ_OP_DEPTH_CLEAR, 208 BLORP_HIZ_OP_DEPTH_RESOLVE, 209 BLORP_HIZ_OP_HIZ_RESOLVE, 210 }; 211 212 void 213 blorp_gen6_hiz_op(struct blorp_batch *batch, 214 struct blorp_surf *surf, unsigned level, unsigned layer, 215 enum blorp_hiz_op op); 216 217 #ifdef __cplusplus 218 } /* end extern "C" */ 219 #endif /* __cplusplus */ 220 221 #endif /* BLORP_H */ 222