2 * Copyright © 2018 Intel Corporation
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 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
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
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 NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
25 #include "iris_batch.h"
26 #include "iris_resource.h"
27 #include "iris_context.h"
29 #include "blorp/blorp_genX_exec.h"
30 #include "util/u_upload_mgr.h"
33 stream_state(struct iris_batch
*batch
,
34 struct u_upload_mgr
*uploader
,
38 struct iris_bo
**out_bo
)
40 struct pipe_resource
*res
= NULL
;
43 u_upload_alloc(uploader
, 0, size
, alignment
, out_offset
, &res
, &ptr
);
45 *out_bo
= iris_resource_bo(res
);
46 iris_use_pinned_bo(batch
, *out_bo
, false);
48 *out_offset
+= iris_bo_offset_from_base_address(*out_bo
);
50 pipe_resource_reference(&res
, NULL
);
56 blorp_emit_dwords(struct blorp_batch
*blorp_batch
, unsigned n
)
58 struct iris_batch
*batch
= blorp_batch
->driver_batch
;
59 return iris_get_command_space(batch
, n
* sizeof(uint32_t));
63 blorp_emit_reloc(struct blorp_batch
*blorp_batch
, UNUSED
void *location
,
64 struct blorp_address addr
, uint32_t delta
)
66 struct iris_batch
*batch
= blorp_batch
->driver_batch
;
67 struct iris_bo
*bo
= addr
.buffer
;
68 uint64_t result
= addr
.offset
+ delta
;
71 iris_use_pinned_bo(batch
, bo
, addr
.reloc_flags
& RELOC_WRITE
);
72 /* Assume this is a general address, not relative to a base. */
73 result
+= bo
->gtt_offset
;
80 blorp_surface_reloc(struct blorp_batch
*blorp_batch
, uint32_t ss_offset
,
81 struct blorp_address addr
, uint32_t delta
)
83 /* Don't do anything, blorp_alloc_binding_table already added the BO. */
86 UNUSED
static struct blorp_address
87 blorp_get_surface_base_address(UNUSED
struct blorp_batch
*blorp_batch
)
89 return (struct blorp_address
) { .offset
= IRIS_MEMZONE_SURFACE_START
};
93 blorp_alloc_dynamic_state(struct blorp_batch
*blorp_batch
,
98 struct iris_context
*ice
= blorp_batch
->blorp
->driver_ctx
;
99 struct iris_batch
*batch
= blorp_batch
->driver_batch
;
102 return stream_state(batch
, ice
->state
.dynamic_uploader
,
103 size
, alignment
, offset
, &bo
);
107 blorp_alloc_binding_table(struct blorp_batch
*blorp_batch
,
108 unsigned num_entries
,
110 unsigned state_alignment
,
112 uint32_t *surface_offsets
,
115 struct iris_context
*ice
= blorp_batch
->blorp
->driver_ctx
;
116 struct iris_batch
*batch
= blorp_batch
->driver_batch
;
119 uint32_t *bt_map
= iris_binder_reserve(&ice
->state
.binder
,
120 num_entries
* sizeof(uint32_t),
123 for (unsigned i
= 0; i
< num_entries
; i
++) {
124 surface_maps
[i
] = stream_state(batch
, ice
->state
.surface_uploader
,
125 state_size
, state_alignment
,
126 &surface_offsets
[i
], &bo
);
127 bt_map
[i
] = surface_offsets
[i
];
132 blorp_alloc_vertex_buffer(struct blorp_batch
*blorp_batch
,
134 struct blorp_address
*addr
)
136 struct iris_context
*ice
= blorp_batch
->blorp
->driver_ctx
;
137 struct iris_batch
*batch
= blorp_batch
->driver_batch
;
141 void *map
= stream_state(batch
, ice
->ctx
.stream_uploader
, size
, 64,
144 *addr
= (struct blorp_address
) {
147 // XXX: Broadwell MOCS
148 .mocs
= I915_MOCS_CACHED
,
154 static struct blorp_address
155 blorp_get_workaround_page(struct blorp_batch
*blorp_batch
)
157 struct iris_batch
*batch
= blorp_batch
->driver_batch
;
159 return (struct blorp_address
) { .buffer
= batch
->screen
->workaround_bo
};
163 blorp_flush_range(UNUSED
struct blorp_batch
*blorp_batch
,
167 /* All allocated states come from the batch which we will flush before we
168 * submit it. There's nothing for us to do here.
173 blorp_emit_urb_config(struct blorp_batch
*blorp_batch
,
174 unsigned vs_entry_size
,
175 UNUSED
unsigned sf_entry_size
)
179 if (ice
->urb
.vsize
>= vs_entry_size
)
182 gen7_upload_urb(ice
, vs_entry_size
, false, false);
187 iris_blorp_exec(struct blorp_batch
*blorp_batch
,
188 const struct blorp_params
*params
)
190 struct iris_context
*ice
= blorp_batch
->blorp
->driver_ctx
;
191 struct iris_batch
*batch
= blorp_batch
->driver_batch
;
193 /* Flush the sampler and render caches. We definitely need to flush the
194 * sampler cache so that we get updated contents from the render cache for
195 * the glBlitFramebuffer() source. Also, we are sometimes warned in the
196 * docs to flush the cache between reinterpretations of the same surface
197 * data with different formats, which blorp does for stencil and depth
200 if (params
->src
.enabled
)
201 iris_cache_flush_for_read(batch
, params
->src
.addr
.buffer
);
202 if (params
->dst
.enabled
) {
203 iris_cache_flush_for_render(batch
, params
->dst
.addr
.buffer
,
204 params
->dst
.view
.format
,
205 params
->dst
.aux_usage
);
207 if (params
->depth
.enabled
)
208 iris_cache_flush_for_depth(batch
, params
->depth
.addr
.buffer
);
209 if (params
->stencil
.enabled
)
210 iris_cache_flush_for_depth(batch
, params
->stencil
.addr
.buffer
);
212 iris_require_command_space(batch
, 1400);
213 //iris_require_statebuffer_space(ice, 600); // XXX: THIS. Need this.
214 batch
->no_wrap
= true;
216 // XXX: Emit L3 state
219 // XXX: PMA - gen8_write_pma_stall_bits(ice, 0);
222 // XXX: knock this off...land Jason's i965 patches...
223 blorp_emit(blorp_batch
, GENX(3DSTATE_DRAWING_RECTANGLE
), rect
) {
224 rect
.ClippedDrawingRectangleXMax
= MAX2(params
->x1
, params
->x0
) - 1;
225 rect
.ClippedDrawingRectangleYMax
= MAX2(params
->y1
, params
->y0
) - 1;
228 blorp_exec(blorp_batch
, params
);
230 batch
->no_wrap
= false;
232 // XXX: aperture checks?
234 /* We've smashed all state compared to what the normal 3D pipeline
235 * rendering tracks for GL.
237 // XXX: skip some if (!(batch->flags & BLORP_BATCH_NO_EMIT_DEPTH_STENCIL))
238 ice
->state
.dirty
|= ~(IRIS_DIRTY_POLYGON_STIPPLE
|
239 IRIS_DIRTY_LINE_STIPPLE
);
242 ice
->state
.dirty
|= IRIS_DIRTY_VERTEX_BUFFERS
|
243 IRIS_DIRTY_COLOR_CALC_STATE
|
244 IRIS_DIRTY_CONSTANTS_VS
|
245 IRIS_DIRTY_CONSTANTS_TCS
|
246 IRIS_DIRTY_CONSTANTS_TES
|
247 IRIS_DIRTY_CONSTANTS_GS
|
248 IRIS_DIRTY_CONSTANTS_PS
|
249 IRIS_DIRTY_CONSTANTS_PS
|
250 IRIS_DIRTY_SAMPLER_STATES_VS
|
251 IRIS_DIRTY_SAMPLER_STATES_TCS
|
252 IRIS_DIRTY_SAMPLER_STATES_TES
|
253 IRIS_DIRTY_SAMPLER_STATES_GS
|
254 IRIS_DIRTY_SAMPLER_STATES_PS
|
255 IRIS_DIRTY_SAMPLER_STATES_PS
|
256 IRIS_DIRTY_MULTISAMPLE
|
257 IRIS_DIRTY_SAMPLE_MASK
|
261 // IRIS_DIRTY_STREAMOUT |
265 IRIS_DIRTY_CC_VIEWPORT
|
268 if (params
->dst
.enabled
) {
269 iris_render_cache_add_bo(batch
, params
->dst
.addr
.buffer
,
270 params
->dst
.view
.format
,
271 params
->dst
.aux_usage
);
273 if (params
->depth
.enabled
)
274 iris_depth_cache_add_bo(batch
, params
->depth
.addr
.buffer
);
275 if (params
->stencil
.enabled
)
276 iris_depth_cache_add_bo(batch
, params
->stencil
.addr
.buffer
);
280 genX(init_blorp
)(struct iris_context
*ice
)
282 ice
->vtbl
.blorp_exec
= iris_blorp_exec
;