1 /* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
4 * Copyright (C) 2012 Rob Clark <robclark@freedesktop.org>
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 * Rob Clark <robclark@freedesktop.org>
29 #include "util/u_format.h"
30 #include "util/u_format_zs.h"
31 #include "util/u_inlines.h"
32 #include "util/u_transfer.h"
33 #include "util/u_string.h"
34 #include "util/u_surface.h"
36 #include "freedreno_resource.h"
37 #include "freedreno_screen.h"
38 #include "freedreno_surface.h"
39 #include "freedreno_context.h"
40 #include "freedreno_query_hw.h"
41 #include "freedreno_util.h"
47 pending(struct fd_resource
*rsc
, enum fd_resource_status status
)
49 return (rsc
->status
& status
) ||
50 (rsc
->stencil
&& (rsc
->stencil
->status
& status
));
54 fd_invalidate_resource(struct fd_context
*ctx
, struct pipe_resource
*prsc
)
58 /* Go through the entire state and see if the resource is bound
59 * anywhere. If it is, mark the relevant state as dirty. This is called on
64 for (i
= 1; i
< PIPE_MAX_CONSTANT_BUFFERS
&& !(ctx
->dirty
& FD_DIRTY_CONSTBUF
); i
++) {
65 if (ctx
->constbuf
[PIPE_SHADER_VERTEX
].cb
[i
].buffer
== prsc
)
66 ctx
->dirty
|= FD_DIRTY_CONSTBUF
;
67 if (ctx
->constbuf
[PIPE_SHADER_FRAGMENT
].cb
[i
].buffer
== prsc
)
68 ctx
->dirty
|= FD_DIRTY_CONSTBUF
;
72 for (i
= 0; i
< ctx
->vtx
.vertexbuf
.count
&& !(ctx
->dirty
& FD_DIRTY_VTXBUF
); i
++) {
73 if (ctx
->vtx
.vertexbuf
.vb
[i
].buffer
== prsc
)
74 ctx
->dirty
|= FD_DIRTY_VTXBUF
;
78 if (ctx
->indexbuf
.buffer
== prsc
)
79 ctx
->dirty
|= FD_DIRTY_INDEXBUF
;
82 for (i
= 0; i
< ctx
->verttex
.num_textures
&& !(ctx
->dirty
& FD_DIRTY_VERTTEX
); i
++) {
83 if (ctx
->verttex
.textures
[i
] && (ctx
->verttex
.textures
[i
]->texture
== prsc
))
84 ctx
->dirty
|= FD_DIRTY_VERTTEX
;
86 for (i
= 0; i
< ctx
->fragtex
.num_textures
&& !(ctx
->dirty
& FD_DIRTY_FRAGTEX
); i
++) {
87 if (ctx
->fragtex
.textures
[i
] && (ctx
->fragtex
.textures
[i
]->texture
== prsc
))
88 ctx
->dirty
|= FD_DIRTY_FRAGTEX
;
93 realloc_bo(struct fd_resource
*rsc
, uint32_t size
)
95 struct fd_screen
*screen
= fd_screen(rsc
->base
.b
.screen
);
96 uint32_t flags
= DRM_FREEDRENO_GEM_CACHE_WCOMBINE
|
97 DRM_FREEDRENO_GEM_TYPE_KMEM
; /* TODO */
99 /* if we start using things other than write-combine,
100 * be sure to check for PIPE_RESOURCE_FLAG_MAP_COHERENT
106 rsc
->bo
= fd_bo_new(screen
->dev
, size
, flags
);
109 rsc
->pending_ctx
= NULL
;
110 list_delinit(&rsc
->list
);
111 util_range_set_empty(&rsc
->valid_buffer_range
);
114 /* Currently this is only used for flushing Z32_S8 texture transfers, but
115 * eventually it should handle everything.
118 fd_resource_flush(struct fd_transfer
*trans
, const struct pipe_box
*box
)
120 struct fd_resource
*rsc
= fd_resource(trans
->base
.resource
);
121 struct fd_resource_slice
*slice
= fd_resource_slice(rsc
, trans
->base
.level
);
122 struct fd_resource_slice
*sslice
= fd_resource_slice(rsc
->stencil
, trans
->base
.level
);
123 enum pipe_format format
= trans
->base
.resource
->format
;
125 float *depth
= fd_bo_map(rsc
->bo
) + slice
->offset
+
126 (trans
->base
.box
.y
+ box
->y
) * slice
->pitch
* 4 + (trans
->base
.box
.x
+ box
->x
) * 4;
127 uint8_t *stencil
= fd_bo_map(rsc
->stencil
->bo
) + sslice
->offset
+
128 (trans
->base
.box
.y
+ box
->y
) * sslice
->pitch
+ trans
->base
.box
.x
+ box
->x
;
130 assert(format
== PIPE_FORMAT_Z32_FLOAT_S8X24_UINT
||
131 format
== PIPE_FORMAT_X32_S8X24_UINT
);
133 if (format
!= PIPE_FORMAT_X32_S8X24_UINT
)
134 util_format_z32_float_s8x24_uint_unpack_z_float(
135 depth
, slice
->pitch
* 4,
136 trans
->staging
, trans
->base
.stride
,
137 box
->width
, box
->height
);
139 util_format_z32_float_s8x24_uint_unpack_s_8uint(
140 stencil
, sslice
->pitch
,
141 trans
->staging
, trans
->base
.stride
,
142 box
->width
, box
->height
);
145 static void fd_resource_transfer_flush_region(struct pipe_context
*pctx
,
146 struct pipe_transfer
*ptrans
,
147 const struct pipe_box
*box
)
149 struct fd_resource
*rsc
= fd_resource(ptrans
->resource
);
150 struct fd_transfer
*trans
= fd_transfer(ptrans
);
152 if (ptrans
->resource
->target
== PIPE_BUFFER
)
153 util_range_add(&rsc
->valid_buffer_range
,
154 ptrans
->box
.x
+ box
->x
,
155 ptrans
->box
.x
+ box
->x
+ box
->width
);
158 fd_resource_flush(trans
, box
);
162 fd_resource_transfer_unmap(struct pipe_context
*pctx
,
163 struct pipe_transfer
*ptrans
)
165 struct fd_context
*ctx
= fd_context(pctx
);
166 struct fd_resource
*rsc
= fd_resource(ptrans
->resource
);
167 struct fd_transfer
*trans
= fd_transfer(ptrans
);
169 if (trans
->staging
&& !(ptrans
->usage
& PIPE_TRANSFER_FLUSH_EXPLICIT
)) {
171 u_box_2d(0, 0, ptrans
->box
.width
, ptrans
->box
.height
, &box
);
172 fd_resource_flush(trans
, &box
);
175 if (!(ptrans
->usage
& PIPE_TRANSFER_UNSYNCHRONIZED
)) {
176 fd_bo_cpu_fini(rsc
->bo
);
178 fd_bo_cpu_fini(rsc
->stencil
->bo
);
181 util_range_add(&rsc
->valid_buffer_range
,
183 ptrans
->box
.x
+ ptrans
->box
.width
);
185 pipe_resource_reference(&ptrans
->resource
, NULL
);
186 util_slab_free(&ctx
->transfer_pool
, ptrans
);
189 free(trans
->staging
);
193 fd_resource_transfer_map(struct pipe_context
*pctx
,
194 struct pipe_resource
*prsc
,
195 unsigned level
, unsigned usage
,
196 const struct pipe_box
*box
,
197 struct pipe_transfer
**pptrans
)
199 struct fd_context
*ctx
= fd_context(pctx
);
200 struct fd_resource
*rsc
= fd_resource(prsc
);
201 struct fd_resource_slice
*slice
= fd_resource_slice(rsc
, level
);
202 struct fd_transfer
*trans
;
203 struct pipe_transfer
*ptrans
;
204 enum pipe_format format
= prsc
->format
;
210 DBG("prsc=%p, level=%u, usage=%x, box=%dx%d+%d,%d", prsc
, level
, usage
,
211 box
->width
, box
->height
, box
->x
, box
->y
);
213 ptrans
= util_slab_alloc(&ctx
->transfer_pool
);
217 /* util_slab_alloc() doesn't zero: */
218 trans
= fd_transfer(ptrans
);
219 memset(trans
, 0, sizeof(*trans
));
221 pipe_resource_reference(&ptrans
->resource
, prsc
);
222 ptrans
->level
= level
;
223 ptrans
->usage
= usage
;
225 ptrans
->stride
= slice
->pitch
* rsc
->cpp
;
226 ptrans
->layer_stride
= slice
->size0
;
228 if (usage
& PIPE_TRANSFER_READ
)
229 op
|= DRM_FREEDRENO_PREP_READ
;
231 if (usage
& PIPE_TRANSFER_WRITE
)
232 op
|= DRM_FREEDRENO_PREP_WRITE
;
234 if (usage
& PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE
) {
235 realloc_bo(rsc
, fd_bo_size(rsc
->bo
));
237 realloc_bo(rsc
->stencil
, fd_bo_size(rsc
->stencil
->bo
));
238 fd_invalidate_resource(ctx
, prsc
);
239 } else if ((usage
& PIPE_TRANSFER_WRITE
) &&
240 prsc
->target
== PIPE_BUFFER
&&
241 !util_ranges_intersect(&rsc
->valid_buffer_range
,
242 box
->x
, box
->x
+ box
->width
)) {
243 /* We are trying to write to a previously uninitialized range. No need
246 } else if (!(usage
& PIPE_TRANSFER_UNSYNCHRONIZED
)) {
247 /* If the GPU is writing to the resource, or if it is reading from the
248 * resource and we're trying to write to it, flush the renders.
250 if (((ptrans
->usage
& PIPE_TRANSFER_WRITE
) &&
251 pending(rsc
, FD_PENDING_READ
| FD_PENDING_WRITE
)) ||
252 pending(rsc
, FD_PENDING_WRITE
))
253 fd_context_render(pctx
);
255 /* The GPU keeps track of how the various bo's are being used, and
256 * will wait if necessary for the proper operation to have
259 ret
= fd_bo_cpu_prep(rsc
->bo
, ctx
->screen
->pipe
, op
);
264 buf
= fd_bo_map(rsc
->bo
);
266 fd_resource_transfer_unmap(pctx
, ptrans
);
270 if (rsc
->layer_first
) {
271 offset
= slice
->offset
+
272 box
->y
/ util_format_get_blockheight(format
) * ptrans
->stride
+
273 box
->x
/ util_format_get_blockwidth(format
) * rsc
->cpp
+
274 box
->z
* rsc
->layer_size
;
276 offset
= slice
->offset
+
277 box
->y
/ util_format_get_blockheight(format
) * ptrans
->stride
+
278 box
->x
/ util_format_get_blockwidth(format
) * rsc
->cpp
+
279 box
->z
* slice
->size0
;
282 if (prsc
->format
== PIPE_FORMAT_Z32_FLOAT_S8X24_UINT
||
283 prsc
->format
== PIPE_FORMAT_X32_S8X24_UINT
) {
284 trans
->base
.stride
= trans
->base
.box
.width
* rsc
->cpp
* 2;
285 trans
->staging
= malloc(trans
->base
.stride
* trans
->base
.box
.height
);
289 /* if we're not discarding the whole range (or resource), we must copy
292 if (!(usage
& (PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE
|
293 PIPE_TRANSFER_DISCARD_RANGE
))) {
294 struct fd_resource_slice
*sslice
=
295 fd_resource_slice(rsc
->stencil
, level
);
296 void *sbuf
= fd_bo_map(rsc
->stencil
->bo
);
300 float *depth
= (float *)(buf
+ slice
->offset
+
301 box
->y
* slice
->pitch
* 4 + box
->x
* 4);
302 uint8_t *stencil
= sbuf
+ sslice
->offset
+
303 box
->y
* sslice
->pitch
+ box
->x
;
305 if (format
!= PIPE_FORMAT_X32_S8X24_UINT
)
306 util_format_z32_float_s8x24_uint_pack_z_float(
307 trans
->staging
, trans
->base
.stride
,
308 depth
, slice
->pitch
* 4,
309 box
->width
, box
->height
);
311 util_format_z32_float_s8x24_uint_pack_s_8uint(
312 trans
->staging
, trans
->base
.stride
,
313 stencil
, sslice
->pitch
,
314 box
->width
, box
->height
);
317 buf
= trans
->staging
;
326 fd_resource_transfer_unmap(pctx
, ptrans
);
331 fd_resource_destroy(struct pipe_screen
*pscreen
,
332 struct pipe_resource
*prsc
)
334 struct fd_resource
*rsc
= fd_resource(prsc
);
337 list_delinit(&rsc
->list
);
338 util_range_destroy(&rsc
->valid_buffer_range
);
343 fd_resource_get_handle(struct pipe_screen
*pscreen
,
344 struct pipe_resource
*prsc
,
345 struct winsys_handle
*handle
)
347 struct fd_resource
*rsc
= fd_resource(prsc
);
349 return fd_screen_bo_get_handle(pscreen
, rsc
->bo
,
350 rsc
->slices
[0].pitch
* rsc
->cpp
, handle
);
354 static const struct u_resource_vtbl fd_resource_vtbl
= {
355 .resource_get_handle
= fd_resource_get_handle
,
356 .resource_destroy
= fd_resource_destroy
,
357 .transfer_map
= fd_resource_transfer_map
,
358 .transfer_flush_region
= fd_resource_transfer_flush_region
,
359 .transfer_unmap
= fd_resource_transfer_unmap
,
360 .transfer_inline_write
= u_default_transfer_inline_write
,
364 setup_slices(struct fd_resource
*rsc
, uint32_t alignment
)
366 struct pipe_resource
*prsc
= &rsc
->base
.b
;
367 uint32_t level
, size
= 0;
368 uint32_t width
= prsc
->width0
;
369 uint32_t height
= prsc
->height0
;
370 uint32_t depth
= prsc
->depth0
;
371 /* in layer_first layout, the level (slice) contains just one
372 * layer (since in fact the layer contains the slices)
374 uint32_t layers_in_level
= rsc
->layer_first
? 1 : prsc
->array_size
;
376 for (level
= 0; level
<= prsc
->last_level
; level
++) {
377 struct fd_resource_slice
*slice
= fd_resource_slice(rsc
, level
);
379 slice
->pitch
= width
= align(width
, 32);
380 slice
->offset
= size
;
381 /* 1d array and 2d array textures must all have the same layer size
382 * for each miplevel on a3xx. 3d textures can have different layer
383 * sizes for high levels, but the hw auto-sizer is buggy (or at least
384 * different than what this code does), so as soon as the layer size
385 * range gets into range, we stop reducing it.
387 if (prsc
->target
== PIPE_TEXTURE_3D
&& (
389 (level
> 1 && rsc
->slices
[level
- 1].size0
> 0xf000)))
390 slice
->size0
= align(slice
->pitch
* height
* rsc
->cpp
, alignment
);
391 else if (level
== 0 || rsc
->layer_first
|| alignment
== 1)
392 slice
->size0
= align(slice
->pitch
* height
* rsc
->cpp
, alignment
);
394 slice
->size0
= rsc
->slices
[level
- 1].size0
;
396 size
+= slice
->size0
* depth
* layers_in_level
;
398 width
= u_minify(width
, 1);
399 height
= u_minify(height
, 1);
400 depth
= u_minify(depth
, 1);
407 slice_alignment(struct pipe_screen
*pscreen
, const struct pipe_resource
*tmpl
)
409 /* on a3xx, 2d array and 3d textures seem to want their
410 * layers aligned to page boundaries:
412 switch (tmpl
->target
) {
413 case PIPE_TEXTURE_3D
:
414 case PIPE_TEXTURE_1D_ARRAY
:
415 case PIPE_TEXTURE_2D_ARRAY
:
423 * Create a new texture object, using the given template info.
425 static struct pipe_resource
*
426 fd_resource_create(struct pipe_screen
*pscreen
,
427 const struct pipe_resource
*tmpl
)
429 struct fd_resource
*rsc
= CALLOC_STRUCT(fd_resource
);
430 struct pipe_resource
*prsc
= &rsc
->base
.b
;
433 DBG("target=%d, format=%s, %ux%ux%u, array_size=%u, last_level=%u, "
434 "nr_samples=%u, usage=%u, bind=%x, flags=%x",
435 tmpl
->target
, util_format_name(tmpl
->format
),
436 tmpl
->width0
, tmpl
->height0
, tmpl
->depth0
,
437 tmpl
->array_size
, tmpl
->last_level
, tmpl
->nr_samples
,
438 tmpl
->usage
, tmpl
->bind
, tmpl
->flags
);
445 pipe_reference_init(&prsc
->reference
, 1);
446 list_inithead(&rsc
->list
);
447 prsc
->screen
= pscreen
;
449 util_range_init(&rsc
->valid_buffer_range
);
451 rsc
->base
.vtbl
= &fd_resource_vtbl
;
452 if (tmpl
->format
== PIPE_FORMAT_Z32_FLOAT_S8X24_UINT
)
453 rsc
->cpp
= util_format_get_blocksize(PIPE_FORMAT_Z32_FLOAT
);
455 rsc
->cpp
= util_format_get_blocksize(tmpl
->format
);
459 if (is_a4xx(fd_screen(pscreen
))) {
460 switch (tmpl
->target
) {
461 case PIPE_TEXTURE_3D
:
462 rsc
->layer_first
= false;
465 rsc
->layer_first
= true;
470 size
= setup_slices(rsc
, slice_alignment(pscreen
, tmpl
));
472 if (rsc
->layer_first
) {
473 rsc
->layer_size
= align(size
, 4096);
474 size
= rsc
->layer_size
* prsc
->array_size
;
477 realloc_bo(rsc
, size
);
481 /* There is no native Z32F_S8 sampling or rendering format, so this must
482 * be emulated via two separate textures. The depth texture still keeps
483 * its Z32F_S8 format though, and we also keep a reference to a separate
486 if (tmpl
->format
== PIPE_FORMAT_Z32_FLOAT_S8X24_UINT
) {
487 struct pipe_resource stencil
= *tmpl
;
488 stencil
.format
= PIPE_FORMAT_S8_UINT
;
489 rsc
->stencil
= fd_resource(fd_resource_create(pscreen
, &stencil
));
496 fd_resource_destroy(pscreen
, prsc
);
501 * Create a texture from a winsys_handle. The handle is often created in
502 * another process by first creating a pipe texture and then calling
503 * resource_get_handle.
505 static struct pipe_resource
*
506 fd_resource_from_handle(struct pipe_screen
*pscreen
,
507 const struct pipe_resource
*tmpl
,
508 struct winsys_handle
*handle
)
510 struct fd_resource
*rsc
= CALLOC_STRUCT(fd_resource
);
511 struct fd_resource_slice
*slice
= &rsc
->slices
[0];
512 struct pipe_resource
*prsc
= &rsc
->base
.b
;
514 DBG("target=%d, format=%s, %ux%ux%u, array_size=%u, last_level=%u, "
515 "nr_samples=%u, usage=%u, bind=%x, flags=%x",
516 tmpl
->target
, util_format_name(tmpl
->format
),
517 tmpl
->width0
, tmpl
->height0
, tmpl
->depth0
,
518 tmpl
->array_size
, tmpl
->last_level
, tmpl
->nr_samples
,
519 tmpl
->usage
, tmpl
->bind
, tmpl
->flags
);
526 pipe_reference_init(&prsc
->reference
, 1);
527 list_inithead(&rsc
->list
);
528 prsc
->screen
= pscreen
;
530 util_range_init(&rsc
->valid_buffer_range
);
532 rsc
->bo
= fd_screen_bo_from_handle(pscreen
, handle
, &slice
->pitch
);
536 rsc
->base
.vtbl
= &fd_resource_vtbl
;
537 rsc
->cpp
= util_format_get_blocksize(tmpl
->format
);
538 slice
->pitch
/= rsc
->cpp
;
545 fd_resource_destroy(pscreen
, prsc
);
549 static void fd_blitter_pipe_begin(struct fd_context
*ctx
);
550 static void fd_blitter_pipe_end(struct fd_context
*ctx
);
553 * _copy_region using pipe (3d engine)
556 fd_blitter_pipe_copy_region(struct fd_context
*ctx
,
557 struct pipe_resource
*dst
,
559 unsigned dstx
, unsigned dsty
, unsigned dstz
,
560 struct pipe_resource
*src
,
562 const struct pipe_box
*src_box
)
564 /* not until we allow rendertargets to be buffers */
565 if (dst
->target
== PIPE_BUFFER
|| src
->target
== PIPE_BUFFER
)
568 if (!util_blitter_is_copy_supported(ctx
->blitter
, dst
, src
))
571 fd_blitter_pipe_begin(ctx
);
572 util_blitter_copy_texture(ctx
->blitter
,
573 dst
, dst_level
, dstx
, dsty
, dstz
,
574 src
, src_level
, src_box
);
575 fd_blitter_pipe_end(ctx
);
581 * Copy a block of pixels from one resource to another.
582 * The resource must be of the same format.
583 * Resources with nr_samples > 1 are not allowed.
586 fd_resource_copy_region(struct pipe_context
*pctx
,
587 struct pipe_resource
*dst
,
589 unsigned dstx
, unsigned dsty
, unsigned dstz
,
590 struct pipe_resource
*src
,
592 const struct pipe_box
*src_box
)
594 struct fd_context
*ctx
= fd_context(pctx
);
596 /* TODO if we have 2d core, or other DMA engine that could be used
597 * for simple copies and reasonably easily synchronized with the 3d
598 * core, this is where we'd plug it in..
601 /* try blit on 3d pipe: */
602 if (fd_blitter_pipe_copy_region(ctx
,
603 dst
, dst_level
, dstx
, dsty
, dstz
,
604 src
, src_level
, src_box
))
607 /* else fallback to pure sw: */
608 util_resource_copy_region(pctx
,
609 dst
, dst_level
, dstx
, dsty
, dstz
,
610 src
, src_level
, src_box
);
614 * Optimal hardware path for blitting pixels.
615 * Scaling, format conversion, up- and downsampling (resolve) are allowed.
618 fd_blit(struct pipe_context
*pctx
, const struct pipe_blit_info
*blit_info
)
620 struct fd_context
*ctx
= fd_context(pctx
);
621 struct pipe_blit_info info
= *blit_info
;
623 if (info
.src
.resource
->nr_samples
> 1 &&
624 info
.dst
.resource
->nr_samples
<= 1 &&
625 !util_format_is_depth_or_stencil(info
.src
.resource
->format
) &&
626 !util_format_is_pure_integer(info
.src
.resource
->format
)) {
627 DBG("color resolve unimplemented");
631 if (util_try_blit_via_copy_region(pctx
, &info
)) {
635 if (info
.mask
& PIPE_MASK_S
) {
636 DBG("cannot blit stencil, skipping");
637 info
.mask
&= ~PIPE_MASK_S
;
640 if (!util_blitter_is_blit_supported(ctx
->blitter
, &info
)) {
641 DBG("blit unsupported %s -> %s",
642 util_format_short_name(info
.src
.resource
->format
),
643 util_format_short_name(info
.dst
.resource
->format
));
647 fd_blitter_pipe_begin(ctx
);
648 util_blitter_blit(ctx
->blitter
, &info
);
649 fd_blitter_pipe_end(ctx
);
653 fd_blitter_pipe_begin(struct fd_context
*ctx
)
655 util_blitter_save_vertex_buffer_slot(ctx
->blitter
, ctx
->vtx
.vertexbuf
.vb
);
656 util_blitter_save_vertex_elements(ctx
->blitter
, ctx
->vtx
.vtx
);
657 util_blitter_save_vertex_shader(ctx
->blitter
, ctx
->prog
.vp
);
658 util_blitter_save_so_targets(ctx
->blitter
, ctx
->streamout
.num_targets
,
659 ctx
->streamout
.targets
);
660 util_blitter_save_rasterizer(ctx
->blitter
, ctx
->rasterizer
);
661 util_blitter_save_viewport(ctx
->blitter
, &ctx
->viewport
);
662 util_blitter_save_scissor(ctx
->blitter
, &ctx
->scissor
);
663 util_blitter_save_fragment_shader(ctx
->blitter
, ctx
->prog
.fp
);
664 util_blitter_save_blend(ctx
->blitter
, ctx
->blend
);
665 util_blitter_save_depth_stencil_alpha(ctx
->blitter
, ctx
->zsa
);
666 util_blitter_save_stencil_ref(ctx
->blitter
, &ctx
->stencil_ref
);
667 util_blitter_save_sample_mask(ctx
->blitter
, ctx
->sample_mask
);
668 util_blitter_save_framebuffer(ctx
->blitter
, &ctx
->framebuffer
);
669 util_blitter_save_fragment_sampler_states(ctx
->blitter
,
670 ctx
->fragtex
.num_samplers
,
671 (void **)ctx
->fragtex
.samplers
);
672 util_blitter_save_fragment_sampler_views(ctx
->blitter
,
673 ctx
->fragtex
.num_textures
, ctx
->fragtex
.textures
);
675 fd_hw_query_set_stage(ctx
, ctx
->ring
, FD_STAGE_BLIT
);
679 fd_blitter_pipe_end(struct fd_context
*ctx
)
681 fd_hw_query_set_stage(ctx
, ctx
->ring
, FD_STAGE_NULL
);
685 fd_flush_resource(struct pipe_context
*pctx
, struct pipe_resource
*prsc
)
687 struct fd_resource
*rsc
= fd_resource(prsc
);
689 if (pending(rsc
, FD_PENDING_WRITE
| FD_PENDING_READ
))
690 fd_context_render(pctx
);
694 fd_resource_screen_init(struct pipe_screen
*pscreen
)
696 pscreen
->resource_create
= fd_resource_create
;
697 pscreen
->resource_from_handle
= fd_resource_from_handle
;
698 pscreen
->resource_get_handle
= u_resource_get_handle_vtbl
;
699 pscreen
->resource_destroy
= u_resource_destroy_vtbl
;
703 fd_resource_context_init(struct pipe_context
*pctx
)
705 pctx
->transfer_map
= u_transfer_map_vtbl
;
706 pctx
->transfer_flush_region
= u_transfer_flush_region_vtbl
;
707 pctx
->transfer_unmap
= u_transfer_unmap_vtbl
;
708 pctx
->transfer_inline_write
= u_transfer_inline_write_vtbl
;
709 pctx
->create_surface
= fd_create_surface
;
710 pctx
->surface_destroy
= fd_surface_destroy
;
711 pctx
->resource_copy_region
= fd_resource_copy_region
;
712 pctx
->blit
= fd_blit
;
713 pctx
->flush_resource
= fd_flush_resource
;