intel/blorp: Fix a couple asserts around image copy rectangles
[mesa.git] / src / intel / blorp / blorp.h
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_wm_prog_key;
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 void *prog_data, uint32_t prog_data_size,
62 uint32_t *kernel_out, void *prog_data_out);
63 void (*exec)(struct blorp_batch *batch, const struct blorp_params *params);
64 };
65
66 void blorp_init(struct blorp_context *blorp, void *driver_ctx,
67 struct isl_device *isl_dev);
68 void blorp_finish(struct blorp_context *blorp);
69
70 enum blorp_batch_flags {
71 /**
72 * This flag indicates that blorp should *not* re-emit the depth and
73 * stencil buffer packets. Instead, the driver guarantees that all depth
74 * and stencil images passed in will match what is currently set in the
75 * hardware.
76 */
77 BLORP_BATCH_NO_EMIT_DEPTH_STENCIL = (1 << 0),
78 };
79
80 struct blorp_batch {
81 struct blorp_context *blorp;
82 void *driver_batch;
83 enum blorp_batch_flags flags;
84 };
85
86 void blorp_batch_init(struct blorp_context *blorp, struct blorp_batch *batch,
87 void *driver_batch, enum blorp_batch_flags flags);
88 void blorp_batch_finish(struct blorp_batch *batch);
89
90 struct blorp_address {
91 void *buffer;
92 uint32_t read_domains;
93 uint32_t write_domain;
94 uint32_t offset;
95 };
96
97 struct blorp_surf
98 {
99 const struct isl_surf *surf;
100 struct blorp_address addr;
101
102 const struct isl_surf *aux_surf;
103 struct blorp_address aux_addr;
104 enum isl_aux_usage aux_usage;
105
106 union isl_color_value clear_color;
107 };
108
109 void
110 blorp_blit(struct blorp_batch *batch,
111 const struct blorp_surf *src_surf,
112 unsigned src_level, unsigned src_layer,
113 enum isl_format src_format, struct isl_swizzle src_swizzle,
114 const struct blorp_surf *dst_surf,
115 unsigned dst_level, unsigned dst_layer,
116 enum isl_format dst_format, struct isl_swizzle dst_swizzle,
117 float src_x0, float src_y0,
118 float src_x1, float src_y1,
119 float dst_x0, float dst_y0,
120 float dst_x1, float dst_y1,
121 uint32_t filter, bool mirror_x, bool mirror_y);
122
123 void
124 blorp_copy(struct blorp_batch *batch,
125 const struct blorp_surf *src_surf,
126 unsigned src_level, unsigned src_layer,
127 const struct blorp_surf *dst_surf,
128 unsigned dst_level, unsigned dst_layer,
129 uint32_t src_x, uint32_t src_y,
130 uint32_t dst_x, uint32_t dst_y,
131 uint32_t src_width, uint32_t src_height);
132
133 void
134 blorp_fast_clear(struct blorp_batch *batch,
135 const struct blorp_surf *surf, enum isl_format format,
136 uint32_t level, uint32_t start_layer, uint32_t num_layers,
137 uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1);
138
139 void
140 blorp_clear(struct blorp_batch *batch,
141 const struct blorp_surf *surf,
142 enum isl_format format, struct isl_swizzle swizzle,
143 uint32_t level, uint32_t start_layer, uint32_t num_layers,
144 uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1,
145 union isl_color_value clear_color,
146 const bool color_write_disable[4]);
147
148 void
149 blorp_clear_depth_stencil(struct blorp_batch *batch,
150 const struct blorp_surf *depth,
151 const struct blorp_surf *stencil,
152 uint32_t level, uint32_t start_layer,
153 uint32_t num_layers,
154 uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1,
155 bool clear_depth, float depth_value,
156 uint8_t stencil_mask, uint8_t stencil_value);
157
158 void
159 blorp_ccs_resolve(struct blorp_batch *batch,
160 struct blorp_surf *surf, enum isl_format format);
161
162 /**
163 * For an overview of the HiZ operations, see the following sections of the
164 * Sandy Bridge PRM, Volume 1, Part2:
165 * - 7.5.3.1 Depth Buffer Clear
166 * - 7.5.3.2 Depth Buffer Resolve
167 * - 7.5.3.3 Hierarchical Depth Buffer Resolve
168 *
169 * Of these, two get entered in the resolve map as needing to be done to the
170 * buffer: depth resolve and hiz resolve.
171 */
172 enum blorp_hiz_op {
173 BLORP_HIZ_OP_NONE,
174 BLORP_HIZ_OP_DEPTH_CLEAR,
175 BLORP_HIZ_OP_DEPTH_RESOLVE,
176 BLORP_HIZ_OP_HIZ_RESOLVE,
177 };
178
179 void
180 blorp_gen6_hiz_op(struct blorp_batch *batch,
181 struct blorp_surf *surf, unsigned level, unsigned layer,
182 enum blorp_hiz_op op);
183
184 #ifdef __cplusplus
185 } /* end extern "C" */
186 #endif /* __cplusplus */
187
188 #endif /* BLORP_H */