2 * Copyright (c) 2017-2019 Lima Project
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:
11 * The above copyright notice and this permission notice (including the
12 * next paragraph) shall be included in all copies or substantial portions
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.
25 #include "util/u_memory.h"
26 #include "util/u_blitter.h"
27 #include "util/format/u_format.h"
28 #include "util/u_inlines.h"
29 #include "util/u_math.h"
30 #include "util/u_debug.h"
31 #include "util/u_transfer.h"
32 #include "util/u_surface.h"
33 #include "util/hash_table.h"
34 #include "util/ralloc.h"
35 #include "util/u_drm.h"
36 #include "renderonly/renderonly.h"
38 #include "state_tracker/drm_driver.h"
40 #include "drm-uapi/drm_fourcc.h"
41 #include "drm-uapi/lima_drm.h"
43 #include "lima_screen.h"
44 #include "lima_context.h"
45 #include "lima_resource.h"
47 #include "lima_util.h"
49 #include "pan_minmax_cache.h"
50 #include "pan_tiling.h"
52 static struct pipe_resource
*
53 lima_resource_create_scanout(struct pipe_screen
*pscreen
,
54 const struct pipe_resource
*templat
,
55 unsigned width
, unsigned height
)
57 struct lima_screen
*screen
= lima_screen(pscreen
);
58 struct renderonly_scanout
*scanout
;
59 struct winsys_handle handle
;
60 struct pipe_resource
*pres
;
62 struct pipe_resource scanout_templat
= *templat
;
63 scanout_templat
.width0
= width
;
64 scanout_templat
.height0
= height
;
65 scanout_templat
.screen
= pscreen
;
67 scanout
= renderonly_scanout_for_resource(&scanout_templat
,
72 assert(handle
.type
== WINSYS_HANDLE_TYPE_FD
);
73 pres
= pscreen
->resource_from_handle(pscreen
, templat
, &handle
,
74 PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE
);
78 renderonly_scanout_destroy(scanout
, screen
->ro
);
82 struct lima_resource
*res
= lima_resource(pres
);
83 res
->scanout
= scanout
;
89 setup_miptree(struct lima_resource
*res
,
90 unsigned width0
, unsigned height0
,
91 bool should_align_dimensions
)
93 struct pipe_resource
*pres
= &res
->base
;
95 unsigned width
= width0
;
96 unsigned height
= height0
;
97 unsigned depth
= pres
->depth0
;
100 for (level
= 0; level
<= pres
->last_level
; level
++) {
101 uint32_t actual_level_size
;
103 unsigned aligned_width
;
104 unsigned aligned_height
;
106 if (should_align_dimensions
) {
107 aligned_width
= align(width
, 16);
108 aligned_height
= align(height
, 16);
110 aligned_width
= width
;
111 aligned_height
= height
;
114 stride
= util_format_get_stride(pres
->format
, aligned_width
);
115 actual_level_size
= stride
*
116 util_format_get_nblocksy(pres
->format
, aligned_height
) *
117 pres
->array_size
* depth
;
119 res
->levels
[level
].width
= aligned_width
;
120 res
->levels
[level
].stride
= stride
;
121 res
->levels
[level
].offset
= size
;
122 res
->levels
[level
].layer_stride
= util_format_get_stride(pres
->format
, align(width
, 16)) * align(height
, 16);
124 if (util_format_is_compressed(pres
->format
))
125 res
->levels
[level
].layer_stride
/= 4;
127 /* The start address of each level except the last level
128 * must be 64-aligned in order to be able to pass the
129 * addresses to the hardware. */
130 if (level
!= pres
->last_level
)
131 size
+= align(actual_level_size
, 64);
133 size
+= actual_level_size
; /* Save some memory */
135 width
= u_minify(width
, 1);
136 height
= u_minify(height
, 1);
137 depth
= u_minify(depth
, 1);
143 static struct pipe_resource
*
144 lima_resource_create_bo(struct pipe_screen
*pscreen
,
145 const struct pipe_resource
*templat
,
146 unsigned width
, unsigned height
,
147 bool should_align_dimensions
)
149 struct lima_screen
*screen
= lima_screen(pscreen
);
150 struct lima_resource
*res
;
151 struct pipe_resource
*pres
;
153 res
= CALLOC_STRUCT(lima_resource
);
157 res
->base
= *templat
;
158 res
->base
.screen
= pscreen
;
159 pipe_reference_init(&res
->base
.reference
, 1);
163 uint32_t size
= setup_miptree(res
, width
, height
, should_align_dimensions
);
164 size
= align(size
, LIMA_PAGE_SIZE
);
166 res
->bo
= lima_bo_create(screen
, size
, 0);
175 static struct pipe_resource
*
176 _lima_resource_create_with_modifiers(struct pipe_screen
*pscreen
,
177 const struct pipe_resource
*templat
,
178 const uint64_t *modifiers
,
181 struct lima_screen
*screen
= lima_screen(pscreen
);
182 bool should_tile
= lima_debug
& LIMA_DEBUG_NO_TILING
? false : true;
183 unsigned width
, height
;
184 bool should_align_dimensions
;
185 bool has_user_modifiers
= true;
187 if (count
== 1 && modifiers
[0] == DRM_FORMAT_MOD_INVALID
)
188 has_user_modifiers
= false;
190 /* VBOs/PBOs are untiled (and 1 height). */
191 if (templat
->target
== PIPE_BUFFER
)
194 if (templat
->bind
& (PIPE_BIND_LINEAR
| PIPE_BIND_SCANOUT
))
197 /* If there's no user modifiers and buffer is shared we use linear */
198 if (!has_user_modifiers
&& (templat
->bind
& PIPE_BIND_SHARED
))
201 if (has_user_modifiers
&&
202 !drm_find_modifier(DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED
,
206 if (should_tile
|| (templat
->bind
& PIPE_BIND_RENDER_TARGET
) ||
207 (templat
->bind
& PIPE_BIND_DEPTH_STENCIL
)) {
208 should_align_dimensions
= true;
209 width
= align(templat
->width0
, 16);
210 height
= align(templat
->height0
, 16);
213 should_align_dimensions
= false;
214 width
= templat
->width0
;
215 height
= templat
->height0
;
218 struct pipe_resource
*pres
;
219 if (screen
->ro
&& (templat
->bind
& PIPE_BIND_SCANOUT
))
220 pres
= lima_resource_create_scanout(pscreen
, templat
, width
, height
);
222 pres
= lima_resource_create_bo(pscreen
, templat
, width
, height
,
223 should_align_dimensions
);
226 struct lima_resource
*res
= lima_resource(pres
);
227 res
->tiled
= should_tile
;
229 if (templat
->bind
& PIPE_BIND_INDEX_BUFFER
)
230 res
->index_cache
= CALLOC_STRUCT(panfrost_minmax_cache
);
232 debug_printf("%s: pres=%p width=%u height=%u depth=%u target=%d "
233 "bind=%x usage=%d tile=%d last_level=%d\n", __func__
,
234 pres
, pres
->width0
, pres
->height0
, pres
->depth0
,
235 pres
->target
, pres
->bind
, pres
->usage
, should_tile
, templat
->last_level
);
240 static struct pipe_resource
*
241 lima_resource_create(struct pipe_screen
*pscreen
,
242 const struct pipe_resource
*templat
)
244 const uint64_t mod
= DRM_FORMAT_MOD_INVALID
;
246 return _lima_resource_create_with_modifiers(pscreen
, templat
, &mod
, 1);
249 static struct pipe_resource
*
250 lima_resource_create_with_modifiers(struct pipe_screen
*pscreen
,
251 const struct pipe_resource
*templat
,
252 const uint64_t *modifiers
,
255 struct pipe_resource tmpl
= *templat
;
257 /* gbm_bo_create_with_modifiers & gbm_surface_create_with_modifiers
258 * don't have usage parameter, but buffer created by these functions
259 * may be used for scanout. So we assume buffer created by this
260 * function always enable scanout if linear modifier is permitted.
262 if (drm_find_modifier(DRM_FORMAT_MOD_LINEAR
, modifiers
, count
))
263 tmpl
.bind
|= PIPE_BIND_SCANOUT
;
265 return _lima_resource_create_with_modifiers(pscreen
, &tmpl
, modifiers
, count
);
269 lima_resource_destroy(struct pipe_screen
*pscreen
, struct pipe_resource
*pres
)
271 struct lima_screen
*screen
= lima_screen(pscreen
);
272 struct lima_resource
*res
= lima_resource(pres
);
275 lima_bo_unreference(res
->bo
);
278 renderonly_scanout_destroy(res
->scanout
, screen
->ro
);
280 if (res
->damage
.region
)
281 FREE(res
->damage
.region
);
283 if (res
->index_cache
)
284 FREE(res
->index_cache
);
289 static struct pipe_resource
*
290 lima_resource_from_handle(struct pipe_screen
*pscreen
,
291 const struct pipe_resource
*templat
,
292 struct winsys_handle
*handle
, unsigned usage
)
294 struct lima_resource
*res
;
295 struct lima_screen
*screen
= lima_screen(pscreen
);
297 res
= CALLOC_STRUCT(lima_resource
);
301 struct pipe_resource
*pres
= &res
->base
;
303 pres
->screen
= pscreen
;
304 pipe_reference_init(&pres
->reference
, 1);
305 res
->levels
[0].offset
= 0;
306 res
->levels
[0].stride
= handle
->stride
;
308 res
->bo
= lima_bo_import(screen
, handle
);
314 /* check alignment for the buffer */
315 if (pres
->bind
& PIPE_BIND_RENDER_TARGET
) {
316 unsigned width
, height
, stride
, size
;
318 width
= align(pres
->width0
, 16);
319 height
= align(pres
->height0
, 16);
320 stride
= util_format_get_stride(pres
->format
, width
);
321 size
= util_format_get_2d_size(pres
->format
, stride
, height
);
323 if (res
->levels
[0].stride
!= stride
|| res
->bo
->size
< size
) {
324 debug_error("import buffer not properly aligned\n");
328 res
->levels
[0].width
= width
;
331 res
->levels
[0].width
= pres
->width0
;
333 switch (handle
->modifier
) {
334 case DRM_FORMAT_MOD_LINEAR
:
337 case DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED
:
340 case DRM_FORMAT_MOD_INVALID
:
341 /* Modifier wasn't specified and it's shared buffer. We create these
342 * as linear, so disable tiling.
347 fprintf(stderr
, "Attempted to import unsupported modifier 0x%llx\n",
348 (long long)handle
->modifier
);
355 lima_resource_destroy(pscreen
, pres
);
360 lima_resource_get_handle(struct pipe_screen
*pscreen
,
361 struct pipe_context
*pctx
,
362 struct pipe_resource
*pres
,
363 struct winsys_handle
*handle
, unsigned usage
)
365 struct lima_screen
*screen
= lima_screen(pscreen
);
366 struct lima_resource
*res
= lima_resource(pres
);
369 handle
->modifier
= DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED
;
371 handle
->modifier
= DRM_FORMAT_MOD_LINEAR
;
373 if (handle
->type
== WINSYS_HANDLE_TYPE_KMS
&& screen
->ro
&&
374 renderonly_get_handle(res
->scanout
, handle
))
377 if (!lima_bo_export(res
->bo
, handle
))
380 handle
->stride
= res
->levels
[0].stride
;
385 get_scissor_from_box(struct pipe_scissor_state
*s
,
386 const struct pipe_box
*b
, int h
)
388 int y
= h
- (b
->y
+ b
->height
);
389 /* region in tile unit */
392 s
->maxx
= (b
->x
+ b
->width
+ 0xf) >> 4;
393 s
->maxy
= (y
+ b
->height
+ 0xf) >> 4;
397 get_damage_bound_box(struct pipe_resource
*pres
,
398 const struct pipe_box
*rects
,
400 struct pipe_scissor_state
*bound
)
402 struct pipe_box b
= rects
[0];
404 for (int i
= 1; i
< nrects
; i
++)
405 u_box_union_2d(&b
, &b
, rects
+ i
);
407 int ret
= u_box_clip_2d(&b
, &b
, pres
->width0
, pres
->height0
);
409 memset(bound
, 0, sizeof(*bound
));
411 get_scissor_from_box(bound
, &b
, pres
->height0
);
415 lima_resource_set_damage_region(struct pipe_screen
*pscreen
,
416 struct pipe_resource
*pres
,
418 const struct pipe_box
*rects
)
420 struct lima_resource
*res
= lima_resource(pres
);
421 struct lima_damage_region
*damage
= &res
->damage
;
424 if (damage
->region
) {
425 FREE(damage
->region
);
426 damage
->region
= NULL
;
427 damage
->num_region
= 0;
435 * TODO: currently only check if there is any single damage
436 * region that can cover the full render target; there may
437 * be some accurate way, but a single window size damage
438 * region is most of the case from weston
440 for (i
= 0; i
< nrects
; i
++) {
441 if (rects
[i
].x
<= 0 && rects
[i
].y
<= 0 &&
442 rects
[i
].x
+ rects
[i
].width
>= pres
->width0
&&
443 rects
[i
].y
+ rects
[i
].height
>= pres
->height0
)
447 struct pipe_scissor_state
*bound
= &damage
->bound
;
448 get_damage_bound_box(pres
, rects
, nrects
, bound
);
450 damage
->region
= CALLOC(nrects
, sizeof(*damage
->region
));
454 for (i
= 0; i
< nrects
; i
++)
455 get_scissor_from_box(damage
->region
+ i
, rects
+ i
,
458 /* is region aligned to tiles? */
459 damage
->aligned
= true;
460 for (i
= 0; i
< nrects
; i
++) {
461 if (rects
[i
].x
& 0xf || rects
[i
].y
& 0xf ||
462 rects
[i
].width
& 0xf || rects
[i
].height
& 0xf) {
463 damage
->aligned
= false;
468 damage
->num_region
= nrects
;
472 lima_resource_screen_init(struct lima_screen
*screen
)
474 screen
->base
.resource_create
= lima_resource_create
;
475 screen
->base
.resource_create_with_modifiers
= lima_resource_create_with_modifiers
;
476 screen
->base
.resource_from_handle
= lima_resource_from_handle
;
477 screen
->base
.resource_destroy
= lima_resource_destroy
;
478 screen
->base
.resource_get_handle
= lima_resource_get_handle
;
479 screen
->base
.set_damage_region
= lima_resource_set_damage_region
;
482 static struct pipe_surface
*
483 lima_surface_create(struct pipe_context
*pctx
,
484 struct pipe_resource
*pres
,
485 const struct pipe_surface
*surf_tmpl
)
487 struct lima_surface
*surf
= CALLOC_STRUCT(lima_surface
);
492 assert(surf_tmpl
->u
.tex
.first_layer
== surf_tmpl
->u
.tex
.last_layer
);
494 struct pipe_surface
*psurf
= &surf
->base
;
495 unsigned level
= surf_tmpl
->u
.tex
.level
;
497 pipe_reference_init(&psurf
->reference
, 1);
498 pipe_resource_reference(&psurf
->texture
, pres
);
500 psurf
->context
= pctx
;
501 psurf
->format
= surf_tmpl
->format
;
502 psurf
->width
= u_minify(pres
->width0
, level
);
503 psurf
->height
= u_minify(pres
->height0
, level
);
504 psurf
->u
.tex
.level
= level
;
505 psurf
->u
.tex
.first_layer
= surf_tmpl
->u
.tex
.first_layer
;
506 psurf
->u
.tex
.last_layer
= surf_tmpl
->u
.tex
.last_layer
;
508 surf
->tiled_w
= align(psurf
->width
, 16) >> 4;
509 surf
->tiled_h
= align(psurf
->height
, 16) >> 4;
517 lima_surface_destroy(struct pipe_context
*pctx
, struct pipe_surface
*psurf
)
519 struct lima_surface
*surf
= lima_surface(psurf
);
521 pipe_resource_reference(&psurf
->texture
, NULL
);
526 lima_transfer_map(struct pipe_context
*pctx
,
527 struct pipe_resource
*pres
,
530 const struct pipe_box
*box
,
531 struct pipe_transfer
**pptrans
)
533 struct lima_context
*ctx
= lima_context(pctx
);
534 struct lima_resource
*res
= lima_resource(pres
);
535 struct lima_bo
*bo
= res
->bo
;
536 struct lima_transfer
*trans
;
537 struct pipe_transfer
*ptrans
;
539 /* No direct mappings of tiled, since we need to manually
542 if (res
->tiled
&& (usage
& PIPE_TRANSFER_MAP_DIRECTLY
))
545 /* use once buffers are made sure to not read/write overlapped
546 * range, so no need to sync */
547 if (pres
->usage
!= PIPE_USAGE_STREAM
) {
548 if (usage
& PIPE_TRANSFER_READ_WRITE
) {
549 lima_flush_job_accessing_bo(ctx
, bo
, usage
& PIPE_TRANSFER_WRITE
);
551 unsigned op
= usage
& PIPE_TRANSFER_WRITE
?
552 LIMA_GEM_WAIT_WRITE
: LIMA_GEM_WAIT_READ
;
553 lima_bo_wait(bo
, op
, PIPE_TIMEOUT_INFINITE
);
557 if (!lima_bo_map(bo
))
560 trans
= slab_alloc(&ctx
->transfer_pool
);
564 memset(trans
, 0, sizeof(*trans
));
565 ptrans
= &trans
->base
;
567 pipe_resource_reference(&ptrans
->resource
, pres
);
568 ptrans
->level
= level
;
569 ptrans
->usage
= usage
;
575 ptrans
->stride
= util_format_get_stride(pres
->format
, ptrans
->box
.width
);
576 ptrans
->layer_stride
= ptrans
->stride
* ptrans
->box
.height
;
578 trans
->staging
= malloc(ptrans
->stride
* ptrans
->box
.height
* ptrans
->box
.depth
);
580 if (usage
& PIPE_TRANSFER_READ
) {
582 for (i
= 0; i
< ptrans
->box
.depth
; i
++)
583 panfrost_load_tiled_image(
584 trans
->staging
+ i
* ptrans
->stride
* ptrans
->box
.height
,
585 bo
->map
+ res
->levels
[level
].offset
+ (i
+ box
->z
) * res
->levels
[level
].layer_stride
,
586 ptrans
->box
.x
, ptrans
->box
.y
,
587 ptrans
->box
.width
, ptrans
->box
.height
,
589 res
->levels
[level
].stride
,
593 return trans
->staging
;
595 unsigned dpw
= PIPE_TRANSFER_MAP_DIRECTLY
| PIPE_TRANSFER_WRITE
|
596 PIPE_TRANSFER_PERSISTENT
;
597 if ((usage
& dpw
) == dpw
&& res
->index_cache
)
600 ptrans
->stride
= res
->levels
[level
].stride
;
601 ptrans
->layer_stride
= res
->levels
[level
].layer_stride
;
603 if ((usage
& PIPE_TRANSFER_WRITE
) && (usage
& PIPE_TRANSFER_MAP_DIRECTLY
))
604 panfrost_minmax_cache_invalidate(res
->index_cache
, ptrans
);
606 return bo
->map
+ res
->levels
[level
].offset
+
607 box
->z
* res
->levels
[level
].layer_stride
+
608 box
->y
/ util_format_get_blockheight(pres
->format
) * ptrans
->stride
+
609 box
->x
/ util_format_get_blockwidth(pres
->format
) *
610 util_format_get_blocksize(pres
->format
);
615 lima_transfer_flush_region(struct pipe_context
*pctx
,
616 struct pipe_transfer
*ptrans
,
617 const struct pipe_box
*box
)
623 lima_transfer_unmap(struct pipe_context
*pctx
,
624 struct pipe_transfer
*ptrans
)
626 struct lima_context
*ctx
= lima_context(pctx
);
627 struct lima_transfer
*trans
= lima_transfer(ptrans
);
628 struct lima_resource
*res
= lima_resource(ptrans
->resource
);
629 struct lima_bo
*bo
= res
->bo
;
630 struct pipe_resource
*pres
;
632 if (trans
->staging
) {
634 if (ptrans
->usage
& PIPE_TRANSFER_WRITE
) {
636 for (i
= 0; i
< ptrans
->box
.depth
; i
++)
637 panfrost_store_tiled_image(
638 bo
->map
+ res
->levels
[ptrans
->level
].offset
+ (i
+ ptrans
->box
.z
) * res
->levels
[ptrans
->level
].layer_stride
,
639 trans
->staging
+ i
* ptrans
->stride
* ptrans
->box
.height
,
640 ptrans
->box
.x
, ptrans
->box
.y
,
641 ptrans
->box
.width
, ptrans
->box
.height
,
642 res
->levels
[ptrans
->level
].stride
,
646 free(trans
->staging
);
649 panfrost_minmax_cache_invalidate(res
->index_cache
, ptrans
);
651 pipe_resource_reference(&ptrans
->resource
, NULL
);
652 slab_free(&ctx
->transfer_pool
, trans
);
656 lima_util_blitter_save_states(struct lima_context
*ctx
)
658 util_blitter_save_blend(ctx
->blitter
, (void *)ctx
->blend
);
659 util_blitter_save_depth_stencil_alpha(ctx
->blitter
, (void *)ctx
->zsa
);
660 util_blitter_save_stencil_ref(ctx
->blitter
, &ctx
->stencil_ref
);
661 util_blitter_save_rasterizer(ctx
->blitter
, (void *)ctx
->rasterizer
);
662 util_blitter_save_fragment_shader(ctx
->blitter
, ctx
->fs
);
663 util_blitter_save_vertex_shader(ctx
->blitter
, ctx
->vs
);
664 util_blitter_save_viewport(ctx
->blitter
,
665 &ctx
->viewport
.transform
);
666 util_blitter_save_scissor(ctx
->blitter
, &ctx
->scissor
);
667 util_blitter_save_vertex_elements(ctx
->blitter
,
668 ctx
->vertex_elements
);
669 util_blitter_save_vertex_buffer_slot(ctx
->blitter
,
670 ctx
->vertex_buffers
.vb
);
672 util_blitter_save_framebuffer(ctx
->blitter
, &ctx
->framebuffer
.base
);
674 util_blitter_save_fragment_sampler_states(ctx
->blitter
,
675 ctx
->tex_stateobj
.num_samplers
,
676 (void**)ctx
->tex_stateobj
.samplers
);
677 util_blitter_save_fragment_sampler_views(ctx
->blitter
,
678 ctx
->tex_stateobj
.num_textures
,
679 ctx
->tex_stateobj
.textures
);
683 lima_blit(struct pipe_context
*pctx
, const struct pipe_blit_info
*blit_info
)
685 struct lima_context
*ctx
= lima_context(pctx
);
686 struct pipe_blit_info info
= *blit_info
;
688 if (util_try_blit_via_copy_region(pctx
, &info
)) {
692 if (info
.mask
& PIPE_MASK_S
) {
693 debug_printf("lima: cannot blit stencil, skipping\n");
694 info
.mask
&= ~PIPE_MASK_S
;
697 if (!util_blitter_is_blit_supported(ctx
->blitter
, &info
)) {
698 debug_printf("lima: blit unsupported %s -> %s\n",
699 util_format_short_name(info
.src
.resource
->format
),
700 util_format_short_name(info
.dst
.resource
->format
));
704 lima_util_blitter_save_states(ctx
);
706 util_blitter_blit(ctx
->blitter
, &info
);
710 lima_flush_resource(struct pipe_context
*pctx
, struct pipe_resource
*resource
)
716 lima_resource_context_init(struct lima_context
*ctx
)
718 ctx
->base
.create_surface
= lima_surface_create
;
719 ctx
->base
.surface_destroy
= lima_surface_destroy
;
721 /* TODO: optimize these functions to read/write data directly
722 * from/to target instead of creating a staging memory for tiled
725 ctx
->base
.buffer_subdata
= u_default_buffer_subdata
;
726 ctx
->base
.texture_subdata
= u_default_texture_subdata
;
727 ctx
->base
.resource_copy_region
= util_resource_copy_region
;
729 ctx
->base
.blit
= lima_blit
;
731 ctx
->base
.transfer_map
= lima_transfer_map
;
732 ctx
->base
.transfer_flush_region
= lima_transfer_flush_region
;
733 ctx
->base
.transfer_unmap
= lima_transfer_unmap
;
735 ctx
->base
.flush_resource
= lima_flush_resource
;