etnaviv: Rework resource status tracking
[mesa.git] / src / gallium / drivers / etnaviv / etnaviv_context.c
1 /*
2 * Copyright (c) 2012-2015 Etnaviv Project
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, sub license,
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
12 * next paragraph) shall be included in all copies or substantial portions
13 * of the 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 NON-INFRINGEMENT. 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
21 * DEALINGS IN THE SOFTWARE.
22 *
23 * Authors:
24 * Wladimir J. van der Laan <laanwj@gmail.com>
25 * Christian Gmeiner <christian.gmeiner@gmail.com>
26 */
27
28 #include "etnaviv_context.h"
29
30 #include "etnaviv_blend.h"
31 #include "etnaviv_clear_blit.h"
32 #include "etnaviv_compiler.h"
33 #include "etnaviv_debug.h"
34 #include "etnaviv_emit.h"
35 #include "etnaviv_fence.h"
36 #include "etnaviv_query.h"
37 #include "etnaviv_query_hw.h"
38 #include "etnaviv_rasterizer.h"
39 #include "etnaviv_resource.h"
40 #include "etnaviv_screen.h"
41 #include "etnaviv_shader.h"
42 #include "etnaviv_state.h"
43 #include "etnaviv_surface.h"
44 #include "etnaviv_texture.h"
45 #include "etnaviv_transfer.h"
46 #include "etnaviv_translate.h"
47 #include "etnaviv_zsa.h"
48
49 #include "pipe/p_context.h"
50 #include "pipe/p_state.h"
51 #include "util/hash_table.h"
52 #include "util/u_blitter.h"
53 #include "util/u_helpers.h"
54 #include "util/u_memory.h"
55 #include "util/u_prim.h"
56 #include "util/u_upload_mgr.h"
57
58 #include "hw/common.xml.h"
59
60 static void
61 etna_context_destroy(struct pipe_context *pctx)
62 {
63 struct etna_context *ctx = etna_context(pctx);
64 struct etna_screen *screen = ctx->screen;
65
66 mtx_lock(&screen->lock);
67 if (ctx->used_resources_read) {
68
69 /*
70 * There should be no resources tracked in the context when it's being
71 * destroyed. Be sure there are none to avoid memory leaks on buggy
72 * programs.
73 */
74 set_foreach(ctx->used_resources_read, entry) {
75 struct etna_resource *rsc = (struct etna_resource *)entry->key;
76
77 _mesa_set_remove_key(rsc->pending_ctx, ctx);
78 }
79 _mesa_set_destroy(ctx->used_resources_read, NULL);
80
81 }
82 if (ctx->used_resources_write) {
83
84 /*
85 * There should be no resources tracked in the context when it's being
86 * destroyed. Be sure there are none to avoid memory leaks on buggy
87 * programs.
88 */
89 set_foreach(ctx->used_resources_write, entry) {
90 struct etna_resource *rsc = (struct etna_resource *)entry->key;
91
92 _mesa_set_remove_key(rsc->pending_ctx, ctx);
93 }
94 _mesa_set_destroy(ctx->used_resources_write, NULL);
95
96 }
97 mtx_unlock(&screen->lock);
98
99 if (ctx->dummy_rt)
100 etna_bo_del(ctx->dummy_rt);
101
102 util_copy_framebuffer_state(&ctx->framebuffer_s, NULL);
103
104 if (ctx->primconvert)
105 util_primconvert_destroy(ctx->primconvert);
106
107 if (ctx->blitter)
108 util_blitter_destroy(ctx->blitter);
109
110 if (pctx->stream_uploader)
111 u_upload_destroy(pctx->stream_uploader);
112
113 if (ctx->stream)
114 etna_cmd_stream_del(ctx->stream);
115
116 slab_destroy_child(&ctx->transfer_pool);
117
118 if (ctx->in_fence_fd != -1)
119 close(ctx->in_fence_fd);
120
121 FREE(pctx);
122 }
123
124 /* Update render state where needed based on draw operation */
125 static void
126 etna_update_state_for_draw(struct etna_context *ctx, const struct pipe_draw_info *info)
127 {
128 /* Handle primitive restart:
129 * - If not an indexed draw, we don't care about the state of the primitive restart bit.
130 * - Otherwise, set the bit in INDEX_STREAM_CONTROL in the index buffer state
131 * accordingly
132 * - If the value of the INDEX_STREAM_CONTROL register changed due to this, or
133 * primitive restart is enabled and the restart index changed, mark the index
134 * buffer state as dirty
135 */
136
137 if (info->index_size) {
138 uint32_t new_control = ctx->index_buffer.FE_INDEX_STREAM_CONTROL;
139
140 if (info->primitive_restart)
141 new_control |= VIVS_FE_INDEX_STREAM_CONTROL_PRIMITIVE_RESTART;
142 else
143 new_control &= ~VIVS_FE_INDEX_STREAM_CONTROL_PRIMITIVE_RESTART;
144
145 if (ctx->index_buffer.FE_INDEX_STREAM_CONTROL != new_control ||
146 (info->primitive_restart && ctx->index_buffer.FE_PRIMITIVE_RESTART_INDEX != info->restart_index)) {
147 ctx->index_buffer.FE_INDEX_STREAM_CONTROL = new_control;
148 ctx->index_buffer.FE_PRIMITIVE_RESTART_INDEX = info->restart_index;
149 ctx->dirty |= ETNA_DIRTY_INDEX_BUFFER;
150 }
151 }
152 }
153
154 static bool
155 etna_get_vs(struct etna_context *ctx, struct etna_shader_key key)
156 {
157 const struct etna_shader_variant *old = ctx->shader.vs;
158
159 ctx->shader.vs = etna_shader_variant(ctx->shader.bind_vs, key, &ctx->debug);
160
161 if (!ctx->shader.vs)
162 return false;
163
164 if (old != ctx->shader.vs)
165 ctx->dirty |= ETNA_DIRTY_SHADER;
166
167 return true;
168 }
169
170 static bool
171 etna_get_fs(struct etna_context *ctx, struct etna_shader_key key)
172 {
173 const struct etna_shader_variant *old = ctx->shader.fs;
174
175 ctx->shader.fs = etna_shader_variant(ctx->shader.bind_fs, key, &ctx->debug);
176
177 if (!ctx->shader.fs)
178 return false;
179
180 if (old != ctx->shader.fs)
181 ctx->dirty |= ETNA_DIRTY_SHADER;
182
183 return true;
184 }
185
186 static void
187 etna_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
188 {
189 struct etna_context *ctx = etna_context(pctx);
190 struct pipe_framebuffer_state *pfb = &ctx->framebuffer_s;
191 uint32_t draw_mode;
192 unsigned i;
193
194 if (!info->count_from_stream_output && !info->indirect &&
195 !info->primitive_restart &&
196 !u_trim_pipe_prim(info->mode, (unsigned*)&info->count))
197 return;
198
199 if (ctx->vertex_elements == NULL || ctx->vertex_elements->num_elements == 0)
200 return; /* Nothing to do */
201
202 if (!(ctx->prim_hwsupport & (1 << info->mode))) {
203 struct primconvert_context *primconvert = ctx->primconvert;
204 util_primconvert_save_rasterizer_state(primconvert, ctx->rasterizer);
205 util_primconvert_draw_vbo(primconvert, info);
206 return;
207 }
208
209 int prims = u_decomposed_prims_for_vertices(info->mode, info->count);
210 if (unlikely(prims <= 0)) {
211 DBG("Invalid draw primitive mode=%i or no primitives to be drawn", info->mode);
212 return;
213 }
214
215 draw_mode = translate_draw_mode(info->mode);
216 if (draw_mode == ETNA_NO_MATCH) {
217 BUG("Unsupported draw mode");
218 return;
219 }
220
221 /* Upload a user index buffer. */
222 unsigned index_offset = 0;
223 struct pipe_resource *indexbuf = NULL;
224
225 if (info->index_size) {
226 indexbuf = info->has_user_indices ? NULL : info->index.resource;
227 if (info->has_user_indices &&
228 !util_upload_index_buffer(pctx, info, &indexbuf, &index_offset)) {
229 BUG("Index buffer upload failed.");
230 return;
231 }
232 /* Add start to index offset, when rendering indexed */
233 index_offset += info->start * info->index_size;
234
235 ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.bo = etna_resource(indexbuf)->bo;
236 ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.offset = index_offset;
237 ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.flags = ETNA_RELOC_READ;
238 ctx->index_buffer.FE_INDEX_STREAM_CONTROL = translate_index_size(info->index_size);
239
240 if (!ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.bo) {
241 BUG("Unsupported or no index buffer");
242 return;
243 }
244 } else {
245 ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.bo = 0;
246 ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.offset = 0;
247 ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.flags = 0;
248 ctx->index_buffer.FE_INDEX_STREAM_CONTROL = 0;
249 }
250 ctx->dirty |= ETNA_DIRTY_INDEX_BUFFER;
251
252 struct etna_shader_key key = {
253 .front_ccw = ctx->rasterizer->front_ccw,
254 };
255
256 if (pfb->cbufs[0])
257 key.frag_rb_swap = !!translate_rs_format_rb_swap(pfb->cbufs[0]->format);
258
259 if (!etna_get_vs(ctx, key) || !etna_get_fs(ctx, key)) {
260 BUG("compiled shaders are not okay");
261 return;
262 }
263
264 /* Update any derived state */
265 if (!etna_state_update(ctx))
266 return;
267
268 /*
269 * Figure out the buffers/features we need:
270 */
271 if (etna_depth_enabled(ctx))
272 resource_written(ctx, pfb->zsbuf->texture);
273
274 if (etna_stencil_enabled(ctx))
275 resource_written(ctx, pfb->zsbuf->texture);
276
277 for (i = 0; i < pfb->nr_cbufs; i++) {
278 struct pipe_resource *surf;
279
280 if (!pfb->cbufs[i])
281 continue;
282
283 surf = pfb->cbufs[i]->texture;
284 resource_written(ctx, surf);
285 }
286
287 /* Mark constant buffers as being read */
288 resource_read(ctx, ctx->constant_buffer[PIPE_SHADER_VERTEX].buffer);
289 resource_read(ctx, ctx->constant_buffer[PIPE_SHADER_FRAGMENT].buffer);
290
291 /* Mark VBOs as being read */
292 foreach_bit(i, ctx->vertex_buffer.enabled_mask) {
293 assert(!ctx->vertex_buffer.vb[i].is_user_buffer);
294 resource_read(ctx, ctx->vertex_buffer.vb[i].buffer.resource);
295 }
296
297 /* Mark index buffer as being read */
298 resource_read(ctx, indexbuf);
299
300 /* Mark textures as being read */
301 for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
302 if (ctx->sampler_view[i]) {
303 resource_read(ctx, ctx->sampler_view[i]->texture);
304
305 /* if texture was modified since the last update,
306 * we need to clear the texture cache and possibly
307 * resolve/update ts
308 */
309 etna_update_sampler_source(ctx->sampler_view[i], i);
310 }
311 }
312
313 list_for_each_entry(struct etna_hw_query, hq, &ctx->active_hw_queries, node)
314 resource_written(ctx, hq->prsc);
315
316 ctx->stats.prims_emitted += u_reduced_prims_for_vertices(info->mode, info->count);
317 ctx->stats.draw_calls++;
318
319 /* Update state for this draw operation */
320 etna_update_state_for_draw(ctx, info);
321
322 /* First, sync state, then emit DRAW_PRIMITIVES or DRAW_INDEXED_PRIMITIVES */
323 etna_emit_state(ctx);
324
325 if (ctx->specs.halti >= 2) {
326 /* On HALTI2+ (GC3000 and higher) only use instanced drawing commands, as the blob does */
327 etna_draw_instanced(ctx->stream, info->index_size, draw_mode, 1,
328 info->count, info->index_size ? info->index_bias : info->start);
329 } else {
330 if (info->index_size)
331 etna_draw_indexed_primitives(ctx->stream, draw_mode, 0, prims, info->index_bias);
332 else
333 etna_draw_primitives(ctx->stream, draw_mode, info->start, prims);
334 }
335
336 if (DBG_ENABLED(ETNA_DBG_DRAW_STALL)) {
337 /* Stall the FE after every draw operation. This allows better
338 * debug of GPU hang conditions, as the FE will indicate which
339 * draw op has caused the hang. */
340 etna_stall(ctx->stream, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE);
341 }
342
343 if (DBG_ENABLED(ETNA_DBG_FLUSH_ALL))
344 pctx->flush(pctx, NULL, 0);
345
346 if (ctx->framebuffer_s.cbufs[0])
347 etna_resource(ctx->framebuffer_s.cbufs[0]->texture)->seqno++;
348 if (ctx->framebuffer_s.zsbuf)
349 etna_resource(ctx->framebuffer_s.zsbuf->texture)->seqno++;
350 if (info->index_size && indexbuf != info->index.resource)
351 pipe_resource_reference(&indexbuf, NULL);
352 }
353
354 static void etna_reset_gpu_state(struct etna_context *ctx)
355 {
356 struct etna_cmd_stream *stream = ctx->stream;
357
358 etna_set_state(stream, VIVS_GL_API_MODE, VIVS_GL_API_MODE_OPENGL);
359 etna_set_state(stream, VIVS_GL_VERTEX_ELEMENT_CONFIG, 0x00000001);
360 /* blob sets this to 0x40000031 on GC7000, seems to make no difference,
361 * but keep it in mind if depth behaves strangely. */
362 etna_set_state(stream, VIVS_RA_EARLY_DEPTH, 0x00000031);
363 etna_set_state(stream, VIVS_PA_W_CLIP_LIMIT, 0x34000001);
364 etna_set_state(stream, VIVS_PA_FLAGS, 0x00000000); /* blob sets ZCONVERT_BYPASS on GC3000+, this messes up z for us */
365 etna_set_state(stream, VIVS_PA_VIEWPORT_UNK00A80, 0x38a01404);
366 etna_set_state(stream, VIVS_PA_VIEWPORT_UNK00A84, fui(8192.0));
367 etna_set_state(stream, VIVS_PA_ZFARCLIPPING, 0x00000000);
368 etna_set_state(stream, VIVS_RA_HDEPTH_CONTROL, 0x00007000);
369 etna_set_state(stream, VIVS_PE_STENCIL_CONFIG_EXT2, 0x00000000);
370 etna_set_state(stream, VIVS_PS_CONTROL_EXT, 0x00000000);
371
372 /* There is no HALTI0 specific state */
373 if (ctx->specs.halti >= 1) { /* Only on HALTI1+ */
374 etna_set_state(stream, VIVS_VS_HALTI1_UNK00884, 0x00000808);
375 }
376 if (ctx->specs.halti >= 2) { /* Only on HALTI2+ */
377 etna_set_state(stream, VIVS_RA_UNK00E0C, 0x00000000);
378 }
379 if (ctx->specs.halti >= 3) { /* Only on HALTI3+ */
380 etna_set_state(stream, VIVS_PS_HALTI3_UNK0103C, 0x76543210);
381 }
382 if (ctx->specs.halti >= 4) { /* Only on HALTI4+ */
383 etna_set_state(stream, VIVS_PS_MSAA_CONFIG, 0x6fffffff & 0xf70fffff & 0xfff6ffff &
384 0xffff6fff & 0xfffff6ff & 0xffffff7f);
385 etna_set_state(stream, VIVS_PE_HALTI4_UNK014C0, 0x00000000);
386 }
387 if (ctx->specs.halti >= 5) { /* Only on HALTI5+ */
388 etna_set_state(stream, VIVS_NTE_DESCRIPTOR_UNK14C40, 0x00000001);
389 etna_set_state(stream, VIVS_FE_HALTI5_UNK007D8, 0x00000002);
390 etna_set_state(stream, VIVS_FE_HALTI5_ID_CONFIG, 0x00000000);
391 etna_set_state(stream, VIVS_PS_SAMPLER_BASE, 0x00000000);
392 etna_set_state(stream, VIVS_VS_SAMPLER_BASE, 0x00000020);
393 etna_set_state(stream, VIVS_SH_CONFIG, VIVS_SH_CONFIG_RTNE_ROUNDING);
394 } else { /* Only on pre-HALTI5 */
395 etna_set_state(stream, VIVS_GL_UNK03834, 0x00000000);
396 etna_set_state(stream, VIVS_GL_UNK03838, 0x00000000);
397 etna_set_state(stream, VIVS_GL_UNK03854, 0x00000000);
398 }
399
400 if (!ctx->specs.use_blt) {
401 /* Enable SINGLE_BUFFER for resolve, if supported */
402 etna_set_state(stream, VIVS_RS_SINGLE_BUFFER, COND(ctx->specs.single_buffer, VIVS_RS_SINGLE_BUFFER_ENABLE));
403 }
404
405 ctx->dirty = ~0L;
406 ctx->dirty_sampler_views = ~0L;
407 }
408
409 static void
410 etna_flush(struct pipe_context *pctx, struct pipe_fence_handle **fence,
411 enum pipe_flush_flags flags)
412 {
413 struct etna_context *ctx = etna_context(pctx);
414 struct etna_screen *screen = ctx->screen;
415 int out_fence_fd = -1;
416
417 mtx_lock(&screen->lock);
418
419 list_for_each_entry(struct etna_hw_query, hq, &ctx->active_hw_queries, node)
420 etna_hw_query_suspend(hq, ctx);
421
422 etna_cmd_stream_flush(ctx->stream, ctx->in_fence_fd,
423 (flags & PIPE_FLUSH_FENCE_FD) ? &out_fence_fd : NULL);
424
425 list_for_each_entry(struct etna_hw_query, hq, &ctx->active_hw_queries, node)
426 etna_hw_query_resume(hq, ctx);
427
428 if (fence)
429 *fence = etna_fence_create(pctx, out_fence_fd);
430
431 /*
432 * Go through all _resources_ pending in this _context_ and mark them as
433 * not pending in this _context_ anymore, since they were just flushed.
434 */
435 set_foreach(ctx->used_resources_read, entry) {
436 struct etna_resource *rsc = (struct etna_resource *)entry->key;
437 struct pipe_resource *referenced = &rsc->base;
438
439 _mesa_set_remove_key(rsc->pending_ctx, ctx);
440
441 pipe_resource_reference(&referenced, NULL);
442 }
443 _mesa_set_clear(ctx->used_resources_read, NULL);
444
445 set_foreach(ctx->used_resources_write, entry) {
446 struct etna_resource *rsc = (struct etna_resource *)entry->key;
447 struct pipe_resource *referenced = &rsc->base;
448
449 _mesa_set_remove_key(rsc->pending_ctx, ctx);
450
451 pipe_resource_reference(&referenced, NULL);
452 }
453 _mesa_set_clear(ctx->used_resources_write, NULL);
454
455 mtx_unlock(&screen->lock);
456
457 etna_reset_gpu_state(ctx);
458 }
459
460 static void
461 etna_context_force_flush(struct etna_cmd_stream *stream, void *priv)
462 {
463 struct pipe_context *pctx = priv;
464
465 pctx->flush(pctx, NULL, 0);
466
467 }
468
469 static void
470 etna_set_debug_callback(struct pipe_context *pctx,
471 const struct pipe_debug_callback *cb)
472 {
473 struct etna_context *ctx = etna_context(pctx);
474
475 if (cb)
476 ctx->debug = *cb;
477 else
478 memset(&ctx->debug, 0, sizeof(ctx->debug));
479 }
480
481 struct pipe_context *
482 etna_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
483 {
484 struct etna_context *ctx = CALLOC_STRUCT(etna_context);
485 struct etna_screen *screen;
486 struct pipe_context *pctx;
487
488 if (ctx == NULL)
489 return NULL;
490
491 pctx = &ctx->base;
492 pctx->priv = ctx;
493 pctx->screen = pscreen;
494 pctx->stream_uploader = u_upload_create_default(pctx);
495 if (!pctx->stream_uploader)
496 goto fail;
497 pctx->const_uploader = pctx->stream_uploader;
498
499 screen = etna_screen(pscreen);
500 ctx->stream = etna_cmd_stream_new(screen->pipe, 0x2000,
501 &etna_context_force_flush, pctx);
502 if (ctx->stream == NULL)
503 goto fail;
504
505 ctx->used_resources_read = _mesa_set_create(NULL, _mesa_hash_pointer,
506 _mesa_key_pointer_equal);
507 if (!ctx->used_resources_read)
508 goto fail;
509
510 ctx->used_resources_write = _mesa_set_create(NULL, _mesa_hash_pointer,
511 _mesa_key_pointer_equal);
512 if (!ctx->used_resources_write)
513 goto fail;
514
515 /* context ctxate setup */
516 ctx->specs = screen->specs;
517 ctx->screen = screen;
518 /* need some sane default in case state tracker doesn't set some state: */
519 ctx->sample_mask = 0xffff;
520
521 /* Set sensible defaults for state */
522 etna_reset_gpu_state(ctx);
523
524 ctx->in_fence_fd = -1;
525
526 pctx->destroy = etna_context_destroy;
527 pctx->draw_vbo = etna_draw_vbo;
528 pctx->flush = etna_flush;
529 pctx->set_debug_callback = etna_set_debug_callback;
530 pctx->create_fence_fd = etna_create_fence_fd;
531 pctx->fence_server_sync = etna_fence_server_sync;
532
533 /* creation of compile states */
534 pctx->create_blend_state = etna_blend_state_create;
535 pctx->create_rasterizer_state = etna_rasterizer_state_create;
536 pctx->create_depth_stencil_alpha_state = etna_zsa_state_create;
537
538 etna_clear_blit_init(pctx);
539 etna_query_context_init(pctx);
540 etna_state_init(pctx);
541 etna_surface_init(pctx);
542 etna_shader_init(pctx);
543 etna_texture_init(pctx);
544 etna_transfer_init(pctx);
545
546 ctx->blitter = util_blitter_create(pctx);
547 if (!ctx->blitter)
548 goto fail;
549
550 /* Generate the bitmask of supported draw primitives. */
551 ctx->prim_hwsupport = 1 << PIPE_PRIM_POINTS |
552 1 << PIPE_PRIM_LINES |
553 1 << PIPE_PRIM_LINE_STRIP |
554 1 << PIPE_PRIM_TRIANGLES |
555 1 << PIPE_PRIM_TRIANGLE_FAN;
556
557 /* TODO: The bug relates only to indexed draws, but here we signal
558 * that there is no support for triangle strips at all. This should
559 * be refined.
560 */
561 if (VIV_FEATURE(ctx->screen, chipMinorFeatures2, BUG_FIXES8))
562 ctx->prim_hwsupport |= 1 << PIPE_PRIM_TRIANGLE_STRIP;
563
564 if (VIV_FEATURE(ctx->screen, chipMinorFeatures2, LINE_LOOP))
565 ctx->prim_hwsupport |= 1 << PIPE_PRIM_LINE_LOOP;
566
567 ctx->primconvert = util_primconvert_create(pctx, ctx->prim_hwsupport);
568 if (!ctx->primconvert)
569 goto fail;
570
571 slab_create_child(&ctx->transfer_pool, &screen->transfer_pool);
572 list_inithead(&ctx->active_hw_queries);
573
574 /* create dummy RT buffer, used when rendering with no color buffer */
575 ctx->dummy_rt = etna_bo_new(ctx->screen->dev, 64 * 64 * 4,
576 DRM_ETNA_GEM_CACHE_WC);
577 if (!ctx->dummy_rt)
578 goto fail;
579
580 ctx->dummy_rt_reloc.bo = ctx->dummy_rt;
581 ctx->dummy_rt_reloc.offset = 0;
582 ctx->dummy_rt_reloc.flags = ETNA_RELOC_READ | ETNA_RELOC_WRITE;
583
584 return pctx;
585
586 fail:
587 pctx->destroy(pctx);
588
589 return NULL;
590 }