1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright © 2018 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 shall be included
12bf215546Sopenharmony_ci * in all copies or substantial portions of the Software.
13bf215546Sopenharmony_ci *
14bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20bf215546Sopenharmony_ci * DEALINGS IN THE SOFTWARE.
21bf215546Sopenharmony_ci */
22bf215546Sopenharmony_ci
23bf215546Sopenharmony_ci/**
24bf215546Sopenharmony_ci * @file crocus_blorp.c
25bf215546Sopenharmony_ci *
26bf215546Sopenharmony_ci * ============================= GENXML CODE =============================
27bf215546Sopenharmony_ci *              [This file is compiled once per generation.]
28bf215546Sopenharmony_ci * =======================================================================
29bf215546Sopenharmony_ci *
30bf215546Sopenharmony_ci * GenX specific code for working with BLORP (blitting, resolves, clears
31bf215546Sopenharmony_ci * on the 3D engine).  This provides the driver-specific hooks needed to
32bf215546Sopenharmony_ci * implement the BLORP API.
33bf215546Sopenharmony_ci *
34bf215546Sopenharmony_ci * See crocus_blit.c, crocus_clear.c, and so on.
35bf215546Sopenharmony_ci */
36bf215546Sopenharmony_ci
37bf215546Sopenharmony_ci#include <assert.h>
38bf215546Sopenharmony_ci
39bf215546Sopenharmony_ci#include "crocus_batch.h"
40bf215546Sopenharmony_ci#include "crocus_resource.h"
41bf215546Sopenharmony_ci#include "crocus_context.h"
42bf215546Sopenharmony_ci
43bf215546Sopenharmony_ci#include "util/u_upload_mgr.h"
44bf215546Sopenharmony_ci#include "intel/common/intel_l3_config.h"
45bf215546Sopenharmony_ci
46bf215546Sopenharmony_ci#include "blorp/blorp_genX_exec.h"
47bf215546Sopenharmony_ci
48bf215546Sopenharmony_ci#if GFX_VER <= 5
49bf215546Sopenharmony_ci#include "gen4_blorp_exec.h"
50bf215546Sopenharmony_ci#endif
51bf215546Sopenharmony_ci
52bf215546Sopenharmony_cistatic uint32_t *
53bf215546Sopenharmony_cistream_state(struct crocus_batch *batch,
54bf215546Sopenharmony_ci             unsigned size,
55bf215546Sopenharmony_ci             unsigned alignment,
56bf215546Sopenharmony_ci             uint32_t *out_offset,
57bf215546Sopenharmony_ci             struct crocus_bo **out_bo)
58bf215546Sopenharmony_ci{
59bf215546Sopenharmony_ci   uint32_t offset = ALIGN(batch->state.used, alignment);
60bf215546Sopenharmony_ci
61bf215546Sopenharmony_ci   if (offset + size >= STATE_SZ && !batch->no_wrap) {
62bf215546Sopenharmony_ci      crocus_batch_flush(batch);
63bf215546Sopenharmony_ci      offset = ALIGN(batch->state.used, alignment);
64bf215546Sopenharmony_ci   } else if (offset + size >= batch->state.bo->size) {
65bf215546Sopenharmony_ci      const unsigned new_size =
66bf215546Sopenharmony_ci         MIN2(batch->state.bo->size + batch->state.bo->size / 2,
67bf215546Sopenharmony_ci              MAX_STATE_SIZE);
68bf215546Sopenharmony_ci      crocus_grow_buffer(batch, true, batch->state.used, new_size);
69bf215546Sopenharmony_ci      assert(offset + size < batch->state.bo->size);
70bf215546Sopenharmony_ci   }
71bf215546Sopenharmony_ci
72bf215546Sopenharmony_ci   crocus_record_state_size(batch->state_sizes, offset, size);
73bf215546Sopenharmony_ci
74bf215546Sopenharmony_ci   batch->state.used = offset + size;
75bf215546Sopenharmony_ci   *out_offset = offset;
76bf215546Sopenharmony_ci
77bf215546Sopenharmony_ci   /* If the caller has asked for a BO, we leave them the responsibility of
78bf215546Sopenharmony_ci    * adding bo->gtt_offset (say, by handing an address to genxml).  If not,
79bf215546Sopenharmony_ci    * we assume they want the offset from a base address.
80bf215546Sopenharmony_ci    */
81bf215546Sopenharmony_ci   if (out_bo)
82bf215546Sopenharmony_ci      *out_bo = batch->state.bo;
83bf215546Sopenharmony_ci
84bf215546Sopenharmony_ci   return (uint32_t *)batch->state.map + (offset >> 2);
85bf215546Sopenharmony_ci}
86bf215546Sopenharmony_ci
87bf215546Sopenharmony_cistatic void *
88bf215546Sopenharmony_ciblorp_emit_dwords(struct blorp_batch *blorp_batch, unsigned n)
89bf215546Sopenharmony_ci{
90bf215546Sopenharmony_ci   struct crocus_batch *batch = blorp_batch->driver_batch;
91bf215546Sopenharmony_ci   return crocus_get_command_space(batch, n * sizeof(uint32_t));
92bf215546Sopenharmony_ci}
93bf215546Sopenharmony_ci
94bf215546Sopenharmony_cistatic uint64_t
95bf215546Sopenharmony_ciblorp_emit_reloc(struct blorp_batch *blorp_batch, UNUSED void *location,
96bf215546Sopenharmony_ci                 struct blorp_address addr, uint32_t delta)
97bf215546Sopenharmony_ci{
98bf215546Sopenharmony_ci   struct crocus_batch *batch = blorp_batch->driver_batch;
99bf215546Sopenharmony_ci   uint32_t offset;
100bf215546Sopenharmony_ci
101bf215546Sopenharmony_ci   if (GFX_VER < 6 && crocus_ptr_in_state_buffer(batch, location)) {
102bf215546Sopenharmony_ci      offset = (char *)location - (char *)batch->state.map;
103bf215546Sopenharmony_ci      return crocus_state_reloc(batch, offset,
104bf215546Sopenharmony_ci                                addr.buffer, addr.offset + delta,
105bf215546Sopenharmony_ci                                addr.reloc_flags);
106bf215546Sopenharmony_ci   }
107bf215546Sopenharmony_ci
108bf215546Sopenharmony_ci   assert(!crocus_ptr_in_state_buffer(batch, location));
109bf215546Sopenharmony_ci
110bf215546Sopenharmony_ci   offset = (char *)location - (char *)batch->command.map;
111bf215546Sopenharmony_ci   return crocus_command_reloc(batch, offset,
112bf215546Sopenharmony_ci                               addr.buffer, addr.offset + delta,
113bf215546Sopenharmony_ci                               addr.reloc_flags);
114bf215546Sopenharmony_ci}
115bf215546Sopenharmony_ci
116bf215546Sopenharmony_cistatic void
117bf215546Sopenharmony_ciblorp_surface_reloc(struct blorp_batch *blorp_batch, uint32_t ss_offset,
118bf215546Sopenharmony_ci                    struct blorp_address addr, uint32_t delta)
119bf215546Sopenharmony_ci{
120bf215546Sopenharmony_ci   struct crocus_batch *batch = blorp_batch->driver_batch;
121bf215546Sopenharmony_ci   struct crocus_bo *bo = addr.buffer;
122bf215546Sopenharmony_ci
123bf215546Sopenharmony_ci   uint64_t reloc_val =
124bf215546Sopenharmony_ci      crocus_state_reloc(batch, ss_offset, bo, addr.offset + delta,
125bf215546Sopenharmony_ci                         addr.reloc_flags);
126bf215546Sopenharmony_ci
127bf215546Sopenharmony_ci   void *reloc_ptr = (void *)batch->state.map + ss_offset;
128bf215546Sopenharmony_ci   *(uint32_t *)reloc_ptr = reloc_val;
129bf215546Sopenharmony_ci}
130bf215546Sopenharmony_ci
131bf215546Sopenharmony_cistatic uint64_t
132bf215546Sopenharmony_ciblorp_get_surface_address(struct blorp_batch *blorp_batch,
133bf215546Sopenharmony_ci                          struct blorp_address addr)
134bf215546Sopenharmony_ci{
135bf215546Sopenharmony_ci   /* We'll let blorp_surface_reloc write the address. */
136bf215546Sopenharmony_ci   return 0ull;
137bf215546Sopenharmony_ci}
138bf215546Sopenharmony_ci
139bf215546Sopenharmony_ci#if GFX_VER >= 7
140bf215546Sopenharmony_cistatic struct blorp_address
141bf215546Sopenharmony_ciblorp_get_surface_base_address(struct blorp_batch *blorp_batch)
142bf215546Sopenharmony_ci{
143bf215546Sopenharmony_ci   struct crocus_batch *batch = blorp_batch->driver_batch;
144bf215546Sopenharmony_ci   return (struct blorp_address) {
145bf215546Sopenharmony_ci      .buffer = batch->state.bo,
146bf215546Sopenharmony_ci      .offset = 0
147bf215546Sopenharmony_ci   };
148bf215546Sopenharmony_ci}
149bf215546Sopenharmony_ci#endif
150bf215546Sopenharmony_ci
151bf215546Sopenharmony_cistatic void *
152bf215546Sopenharmony_ciblorp_alloc_dynamic_state(struct blorp_batch *blorp_batch,
153bf215546Sopenharmony_ci                          uint32_t size,
154bf215546Sopenharmony_ci                          uint32_t alignment,
155bf215546Sopenharmony_ci                          uint32_t *offset)
156bf215546Sopenharmony_ci{
157bf215546Sopenharmony_ci   struct crocus_batch *batch = blorp_batch->driver_batch;
158bf215546Sopenharmony_ci
159bf215546Sopenharmony_ci   return stream_state(batch, size, alignment, offset, NULL);
160bf215546Sopenharmony_ci}
161bf215546Sopenharmony_ci
162bf215546Sopenharmony_ciUNUSED static void *
163bf215546Sopenharmony_ciblorp_alloc_general_state(struct blorp_batch *blorp_batch,
164bf215546Sopenharmony_ci                          uint32_t size,
165bf215546Sopenharmony_ci                          uint32_t alignment,
166bf215546Sopenharmony_ci                          uint32_t *offset)
167bf215546Sopenharmony_ci{
168bf215546Sopenharmony_ci   /* Use dynamic state range for general state on crocus. */
169bf215546Sopenharmony_ci   return blorp_alloc_dynamic_state(blorp_batch, size, alignment, offset);
170bf215546Sopenharmony_ci}
171bf215546Sopenharmony_ci
172bf215546Sopenharmony_cistatic void
173bf215546Sopenharmony_ciblorp_alloc_binding_table(struct blorp_batch *blorp_batch,
174bf215546Sopenharmony_ci                          unsigned num_entries,
175bf215546Sopenharmony_ci                          unsigned state_size,
176bf215546Sopenharmony_ci                          unsigned state_alignment,
177bf215546Sopenharmony_ci                          uint32_t *bt_offset,
178bf215546Sopenharmony_ci                          uint32_t *surface_offsets,
179bf215546Sopenharmony_ci                          void **surface_maps)
180bf215546Sopenharmony_ci{
181bf215546Sopenharmony_ci   struct crocus_batch *batch = blorp_batch->driver_batch;
182bf215546Sopenharmony_ci   uint32_t *bt_map = stream_state(batch, num_entries * sizeof(uint32_t), 32,
183bf215546Sopenharmony_ci                                   bt_offset, NULL);
184bf215546Sopenharmony_ci
185bf215546Sopenharmony_ci   for (unsigned i = 0; i < num_entries; i++) {
186bf215546Sopenharmony_ci      surface_maps[i] = stream_state(batch,
187bf215546Sopenharmony_ci                                     state_size, state_alignment,
188bf215546Sopenharmony_ci                                     &(surface_offsets)[i], NULL);
189bf215546Sopenharmony_ci      bt_map[i] = surface_offsets[i];
190bf215546Sopenharmony_ci   }
191bf215546Sopenharmony_ci}
192bf215546Sopenharmony_ci
193bf215546Sopenharmony_cistatic uint32_t
194bf215546Sopenharmony_ciblorp_binding_table_offset_to_pointer(struct blorp_batch *batch,
195bf215546Sopenharmony_ci                                      uint32_t offset)
196bf215546Sopenharmony_ci{
197bf215546Sopenharmony_ci   return offset;
198bf215546Sopenharmony_ci}
199bf215546Sopenharmony_ci
200bf215546Sopenharmony_cistatic void *
201bf215546Sopenharmony_ciblorp_alloc_vertex_buffer(struct blorp_batch *blorp_batch,
202bf215546Sopenharmony_ci                          uint32_t size,
203bf215546Sopenharmony_ci                          struct blorp_address *addr)
204bf215546Sopenharmony_ci{
205bf215546Sopenharmony_ci   struct crocus_batch *batch = blorp_batch->driver_batch;
206bf215546Sopenharmony_ci   struct crocus_bo *bo;
207bf215546Sopenharmony_ci   uint32_t offset;
208bf215546Sopenharmony_ci
209bf215546Sopenharmony_ci   void *map = stream_state(batch, size, 64,
210bf215546Sopenharmony_ci                            &offset, &bo);
211bf215546Sopenharmony_ci
212bf215546Sopenharmony_ci   *addr = (struct blorp_address) {
213bf215546Sopenharmony_ci      .buffer = bo,
214bf215546Sopenharmony_ci      .offset = offset,
215bf215546Sopenharmony_ci      .reloc_flags = RELOC_32BIT,
216bf215546Sopenharmony_ci#if GFX_VER >= 7
217bf215546Sopenharmony_ci      .mocs = crocus_mocs(bo, &batch->screen->isl_dev),
218bf215546Sopenharmony_ci#endif
219bf215546Sopenharmony_ci   };
220bf215546Sopenharmony_ci
221bf215546Sopenharmony_ci   return map;
222bf215546Sopenharmony_ci}
223bf215546Sopenharmony_ci
224bf215546Sopenharmony_ci/**
225bf215546Sopenharmony_ci */
226bf215546Sopenharmony_cistatic void
227bf215546Sopenharmony_ciblorp_vf_invalidate_for_vb_48b_transitions(struct blorp_batch *blorp_batch,
228bf215546Sopenharmony_ci                                           const struct blorp_address *addrs,
229bf215546Sopenharmony_ci                                           UNUSED uint32_t *sizes,
230bf215546Sopenharmony_ci                                           unsigned num_vbs)
231bf215546Sopenharmony_ci{
232bf215546Sopenharmony_ci}
233bf215546Sopenharmony_ci
234bf215546Sopenharmony_cistatic struct blorp_address
235bf215546Sopenharmony_ciblorp_get_workaround_address(struct blorp_batch *blorp_batch)
236bf215546Sopenharmony_ci{
237bf215546Sopenharmony_ci   struct crocus_batch *batch = blorp_batch->driver_batch;
238bf215546Sopenharmony_ci
239bf215546Sopenharmony_ci   return (struct blorp_address) {
240bf215546Sopenharmony_ci      .buffer = batch->ice->workaround_bo,
241bf215546Sopenharmony_ci      .offset = batch->ice->workaround_offset,
242bf215546Sopenharmony_ci   };
243bf215546Sopenharmony_ci}
244bf215546Sopenharmony_ci
245bf215546Sopenharmony_cistatic void
246bf215546Sopenharmony_ciblorp_flush_range(UNUSED struct blorp_batch *blorp_batch,
247bf215546Sopenharmony_ci                  UNUSED void *start,
248bf215546Sopenharmony_ci                  UNUSED size_t size)
249bf215546Sopenharmony_ci{
250bf215546Sopenharmony_ci   /* All allocated states come from the batch which we will flush before we
251bf215546Sopenharmony_ci    * submit it.  There's nothing for us to do here.
252bf215546Sopenharmony_ci    */
253bf215546Sopenharmony_ci}
254bf215546Sopenharmony_ci
255bf215546Sopenharmony_ci#if GFX_VER >= 7
256bf215546Sopenharmony_cistatic const struct intel_l3_config *
257bf215546Sopenharmony_ciblorp_get_l3_config(struct blorp_batch *blorp_batch)
258bf215546Sopenharmony_ci{
259bf215546Sopenharmony_ci   struct crocus_batch *batch = blorp_batch->driver_batch;
260bf215546Sopenharmony_ci   return batch->screen->l3_config_3d;
261bf215546Sopenharmony_ci}
262bf215546Sopenharmony_ci#else /* GFX_VER < 7 */
263bf215546Sopenharmony_cistatic void
264bf215546Sopenharmony_ciblorp_emit_urb_config(struct blorp_batch *blorp_batch,
265bf215546Sopenharmony_ci                      unsigned vs_entry_size,
266bf215546Sopenharmony_ci                      UNUSED unsigned sf_entry_size)
267bf215546Sopenharmony_ci{
268bf215546Sopenharmony_ci   struct crocus_batch *batch = blorp_batch->driver_batch;
269bf215546Sopenharmony_ci#if GFX_VER <= 5
270bf215546Sopenharmony_ci   batch->screen->vtbl.calculate_urb_fence(batch, 0, vs_entry_size, sf_entry_size);
271bf215546Sopenharmony_ci#else
272bf215546Sopenharmony_ci   genX(crocus_upload_urb)(batch, vs_entry_size, false, vs_entry_size);
273bf215546Sopenharmony_ci#endif
274bf215546Sopenharmony_ci}
275bf215546Sopenharmony_ci#endif
276bf215546Sopenharmony_ci
277bf215546Sopenharmony_cistatic void
278bf215546Sopenharmony_cicrocus_blorp_exec(struct blorp_batch *blorp_batch,
279bf215546Sopenharmony_ci                  const struct blorp_params *params)
280bf215546Sopenharmony_ci{
281bf215546Sopenharmony_ci   struct crocus_context *ice = blorp_batch->blorp->driver_ctx;
282bf215546Sopenharmony_ci   struct crocus_batch *batch = blorp_batch->driver_batch;
283bf215546Sopenharmony_ci
284bf215546Sopenharmony_ci   /* Flush the sampler and render caches.  We definitely need to flush the
285bf215546Sopenharmony_ci    * sampler cache so that we get updated contents from the render cache for
286bf215546Sopenharmony_ci    * the glBlitFramebuffer() source.  Also, we are sometimes warned in the
287bf215546Sopenharmony_ci    * docs to flush the cache between reinterpretations of the same surface
288bf215546Sopenharmony_ci    * data with different formats, which blorp does for stencil and depth
289bf215546Sopenharmony_ci    * data.
290bf215546Sopenharmony_ci    */
291bf215546Sopenharmony_ci   if (params->src.enabled)
292bf215546Sopenharmony_ci      crocus_cache_flush_for_read(batch, params->src.addr.buffer);
293bf215546Sopenharmony_ci   if (params->dst.enabled) {
294bf215546Sopenharmony_ci      crocus_cache_flush_for_render(batch, params->dst.addr.buffer,
295bf215546Sopenharmony_ci                                    params->dst.view.format,
296bf215546Sopenharmony_ci                                    params->dst.aux_usage);
297bf215546Sopenharmony_ci   }
298bf215546Sopenharmony_ci   if (params->depth.enabled)
299bf215546Sopenharmony_ci      crocus_cache_flush_for_depth(batch, params->depth.addr.buffer);
300bf215546Sopenharmony_ci   if (params->stencil.enabled)
301bf215546Sopenharmony_ci      crocus_cache_flush_for_depth(batch, params->stencil.addr.buffer);
302bf215546Sopenharmony_ci
303bf215546Sopenharmony_ci   crocus_require_command_space(batch, 1400);
304bf215546Sopenharmony_ci   crocus_require_statebuffer_space(batch, 600);
305bf215546Sopenharmony_ci   batch->no_wrap = true;
306bf215546Sopenharmony_ci
307bf215546Sopenharmony_ci#if GFX_VER == 8
308bf215546Sopenharmony_ci   genX(crocus_update_pma_fix)(ice, batch, false);
309bf215546Sopenharmony_ci#endif
310bf215546Sopenharmony_ci
311bf215546Sopenharmony_ci#if GFX_VER == 6
312bf215546Sopenharmony_ci   /* Emit workaround flushes when we switch from drawing to blorping. */
313bf215546Sopenharmony_ci   crocus_emit_post_sync_nonzero_flush(batch);
314bf215546Sopenharmony_ci#endif
315bf215546Sopenharmony_ci
316bf215546Sopenharmony_ci#if GFX_VER >= 6
317bf215546Sopenharmony_ci   crocus_emit_depth_stall_flushes(batch);
318bf215546Sopenharmony_ci#endif
319bf215546Sopenharmony_ci
320bf215546Sopenharmony_ci   blorp_emit(blorp_batch, GENX(3DSTATE_DRAWING_RECTANGLE), rect) {
321bf215546Sopenharmony_ci      rect.ClippedDrawingRectangleXMax = MAX2(params->x1, params->x0) - 1;
322bf215546Sopenharmony_ci      rect.ClippedDrawingRectangleYMax = MAX2(params->y1, params->y0) - 1;
323bf215546Sopenharmony_ci   }
324bf215546Sopenharmony_ci
325bf215546Sopenharmony_ci   batch->screen->vtbl.update_surface_base_address(batch);
326bf215546Sopenharmony_ci   crocus_handle_always_flush_cache(batch);
327bf215546Sopenharmony_ci
328bf215546Sopenharmony_ci   batch->contains_draw = true;
329bf215546Sopenharmony_ci   blorp_exec(blorp_batch, params);
330bf215546Sopenharmony_ci
331bf215546Sopenharmony_ci   batch->no_wrap = false;
332bf215546Sopenharmony_ci   crocus_handle_always_flush_cache(batch);
333bf215546Sopenharmony_ci
334bf215546Sopenharmony_ci   /* We've smashed all state compared to what the normal 3D pipeline
335bf215546Sopenharmony_ci    * rendering tracks for GL.
336bf215546Sopenharmony_ci    */
337bf215546Sopenharmony_ci
338bf215546Sopenharmony_ci   uint64_t skip_bits = (CROCUS_DIRTY_POLYGON_STIPPLE |
339bf215546Sopenharmony_ci                         CROCUS_DIRTY_GEN7_SO_BUFFERS |
340bf215546Sopenharmony_ci                         CROCUS_DIRTY_SO_DECL_LIST |
341bf215546Sopenharmony_ci                         CROCUS_DIRTY_LINE_STIPPLE |
342bf215546Sopenharmony_ci                         CROCUS_ALL_DIRTY_FOR_COMPUTE |
343bf215546Sopenharmony_ci                         CROCUS_DIRTY_GEN6_SCISSOR_RECT |
344bf215546Sopenharmony_ci                         CROCUS_DIRTY_GEN75_VF |
345bf215546Sopenharmony_ci                         CROCUS_DIRTY_SF_CL_VIEWPORT);
346bf215546Sopenharmony_ci
347bf215546Sopenharmony_ci   uint64_t skip_stage_bits = (CROCUS_ALL_STAGE_DIRTY_FOR_COMPUTE |
348bf215546Sopenharmony_ci                               CROCUS_STAGE_DIRTY_UNCOMPILED_VS |
349bf215546Sopenharmony_ci                               CROCUS_STAGE_DIRTY_UNCOMPILED_TCS |
350bf215546Sopenharmony_ci                               CROCUS_STAGE_DIRTY_UNCOMPILED_TES |
351bf215546Sopenharmony_ci                               CROCUS_STAGE_DIRTY_UNCOMPILED_GS |
352bf215546Sopenharmony_ci                               CROCUS_STAGE_DIRTY_UNCOMPILED_FS |
353bf215546Sopenharmony_ci                               CROCUS_STAGE_DIRTY_SAMPLER_STATES_VS |
354bf215546Sopenharmony_ci                               CROCUS_STAGE_DIRTY_SAMPLER_STATES_TCS |
355bf215546Sopenharmony_ci                               CROCUS_STAGE_DIRTY_SAMPLER_STATES_TES |
356bf215546Sopenharmony_ci                               CROCUS_STAGE_DIRTY_SAMPLER_STATES_GS);
357bf215546Sopenharmony_ci
358bf215546Sopenharmony_ci   if (!ice->shaders.uncompiled[MESA_SHADER_TESS_EVAL]) {
359bf215546Sopenharmony_ci      /* BLORP disabled tessellation, that's fine for the next draw */
360bf215546Sopenharmony_ci     skip_stage_bits |= CROCUS_STAGE_DIRTY_TCS |
361bf215546Sopenharmony_ci                        CROCUS_STAGE_DIRTY_TES |
362bf215546Sopenharmony_ci                        CROCUS_STAGE_DIRTY_CONSTANTS_TCS |
363bf215546Sopenharmony_ci                        CROCUS_STAGE_DIRTY_CONSTANTS_TES |
364bf215546Sopenharmony_ci                        CROCUS_STAGE_DIRTY_BINDINGS_TCS |
365bf215546Sopenharmony_ci                        CROCUS_STAGE_DIRTY_BINDINGS_TES;
366bf215546Sopenharmony_ci   }
367bf215546Sopenharmony_ci
368bf215546Sopenharmony_ci   if (!ice->shaders.uncompiled[MESA_SHADER_GEOMETRY]) {
369bf215546Sopenharmony_ci      /* BLORP disabled geometry shaders, that's fine for the next draw */
370bf215546Sopenharmony_ci     skip_stage_bits |= CROCUS_STAGE_DIRTY_GS |
371bf215546Sopenharmony_ci                        CROCUS_STAGE_DIRTY_CONSTANTS_GS |
372bf215546Sopenharmony_ci                        CROCUS_STAGE_DIRTY_BINDINGS_GS;
373bf215546Sopenharmony_ci   }
374bf215546Sopenharmony_ci
375bf215546Sopenharmony_ci   /* we can skip flagging CROCUS_DIRTY_DEPTH_BUFFER, if
376bf215546Sopenharmony_ci    * BLORP_BATCH_NO_EMIT_DEPTH_STENCIL is set.
377bf215546Sopenharmony_ci    */
378bf215546Sopenharmony_ci   if (blorp_batch->flags & BLORP_BATCH_NO_EMIT_DEPTH_STENCIL)
379bf215546Sopenharmony_ci      skip_bits |= CROCUS_DIRTY_DEPTH_BUFFER;
380bf215546Sopenharmony_ci
381bf215546Sopenharmony_ci   if (!params->wm_prog_data)
382bf215546Sopenharmony_ci      skip_bits |= CROCUS_DIRTY_GEN6_BLEND_STATE;
383bf215546Sopenharmony_ci
384bf215546Sopenharmony_ci   ice->state.dirty |= ~skip_bits;
385bf215546Sopenharmony_ci   ice->state.stage_dirty |= ~skip_stage_bits;
386bf215546Sopenharmony_ci
387bf215546Sopenharmony_ci   ice->urb.vsize = 0;
388bf215546Sopenharmony_ci   ice->urb.gs_present = false;
389bf215546Sopenharmony_ci   ice->urb.gsize = 0;
390bf215546Sopenharmony_ci   ice->urb.tess_present = false;
391bf215546Sopenharmony_ci   ice->urb.hsize = 0;
392bf215546Sopenharmony_ci   ice->urb.dsize = 0;
393bf215546Sopenharmony_ci
394bf215546Sopenharmony_ci   if (params->dst.enabled) {
395bf215546Sopenharmony_ci      crocus_render_cache_add_bo(batch, params->dst.addr.buffer,
396bf215546Sopenharmony_ci                                 params->dst.view.format,
397bf215546Sopenharmony_ci                                 params->dst.aux_usage);
398bf215546Sopenharmony_ci   }
399bf215546Sopenharmony_ci   if (params->depth.enabled)
400bf215546Sopenharmony_ci      crocus_depth_cache_add_bo(batch, params->depth.addr.buffer);
401bf215546Sopenharmony_ci   if (params->stencil.enabled)
402bf215546Sopenharmony_ci      crocus_depth_cache_add_bo(batch, params->stencil.addr.buffer);
403bf215546Sopenharmony_ci}
404bf215546Sopenharmony_ci
405bf215546Sopenharmony_cistatic void
406bf215546Sopenharmony_ciblorp_measure_start(struct blorp_batch *blorp_batch,
407bf215546Sopenharmony_ci                    const struct blorp_params *params)
408bf215546Sopenharmony_ci{
409bf215546Sopenharmony_ci}
410bf215546Sopenharmony_ci
411bf215546Sopenharmony_cistatic void
412bf215546Sopenharmony_ciblorp_measure_end(struct blorp_batch *blorp_batch,
413bf215546Sopenharmony_ci                  const struct blorp_params *params)
414bf215546Sopenharmony_ci{
415bf215546Sopenharmony_ci}
416bf215546Sopenharmony_ci
417bf215546Sopenharmony_civoid
418bf215546Sopenharmony_cigenX(crocus_init_blorp)(struct crocus_context *ice)
419bf215546Sopenharmony_ci{
420bf215546Sopenharmony_ci   struct crocus_screen *screen = (struct crocus_screen *)ice->ctx.screen;
421bf215546Sopenharmony_ci
422bf215546Sopenharmony_ci   blorp_init(&ice->blorp, ice, &screen->isl_dev, NULL);
423bf215546Sopenharmony_ci   ice->blorp.compiler = screen->compiler;
424bf215546Sopenharmony_ci   ice->blorp.lookup_shader = crocus_blorp_lookup_shader;
425bf215546Sopenharmony_ci   ice->blorp.upload_shader = crocus_blorp_upload_shader;
426bf215546Sopenharmony_ci   ice->blorp.exec = crocus_blorp_exec;
427bf215546Sopenharmony_ci}
428