xref: /aosp_15_r20/external/mesa3d/src/gallium/auxiliary/util/u_surface.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /**************************************************************************
2  *
3  * Copyright 2009 VMware, Inc.  All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sub license, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice (including the
14  * next paragraph) shall be included in all copies or substantial portions
15  * of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
21  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  *
25  **************************************************************************/
26 
27 
28 #ifndef U_SURFACE_H
29 #define U_SURFACE_H
30 
31 
32 #include "util/compiler.h"
33 #include "pipe/p_state.h"
34 
35 #include "util/u_pack_color.h"
36 
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 
43 extern void
44 u_surface_default_template(struct pipe_surface *view,
45                            const struct pipe_resource *texture);
46 
47 extern void
48 util_copy_box(uint8_t * dst,
49               enum pipe_format format,
50               unsigned dst_stride, uint64_t dst_slice_stride,
51               unsigned dst_x, unsigned dst_y, unsigned dst_z,
52               unsigned width, unsigned height, unsigned depth,
53               const uint8_t * src,
54               int src_stride, uint64_t src_slice_stride,
55               unsigned src_x, unsigned src_y, unsigned src_z);
56 
57 extern void
58 util_fill_rect(uint8_t * dst, enum pipe_format format,
59                unsigned dst_stride, unsigned dst_x, unsigned dst_y,
60                unsigned width, unsigned height, union util_color *uc);
61 
62 extern void
63 util_fill_box(uint8_t * dst, enum pipe_format format,
64               unsigned stride, uintptr_t layer_stride,
65               unsigned x, unsigned y, unsigned z,
66               unsigned width, unsigned height, unsigned depth,
67               union util_color *uc);
68 
69 extern void
70 util_fill_zs_box(uint8_t *dst, enum pipe_format format,
71                  bool need_rmw, unsigned clear_flags, unsigned stride,
72                  unsigned layer_stride, unsigned width,
73                  unsigned height, unsigned depth,
74                  uint64_t zstencil);
75 
76 extern void
77 util_resource_copy_region(struct pipe_context *pipe,
78                           struct pipe_resource *dst,
79                           unsigned dst_level,
80                           unsigned dst_x, unsigned dst_y, unsigned dst_z,
81                           struct pipe_resource *src,
82                           unsigned src_level,
83                           const struct pipe_box *src_box);
84 
85 extern void
86 u_default_clear_texture(struct pipe_context *pipe,
87                         struct pipe_resource *tex,
88                         unsigned level,
89                         const struct pipe_box *box,
90                         const void *data);
91 
92 extern void
93 util_clear_texture_sw(struct pipe_context *pipe,
94                       struct pipe_resource *tex,
95                       unsigned level,
96                       const struct pipe_box *box,
97                       const void *data);
98 
99 extern void
100 util_clear_render_target(struct pipe_context *pipe,
101                          struct pipe_surface *dst,
102                          const union pipe_color_union *color,
103                          unsigned dstx, unsigned dsty,
104                          unsigned width, unsigned height);
105 
106 extern void
107 util_clear_depth_stencil(struct pipe_context *pipe,
108                          struct pipe_surface *dst,
109                          unsigned clear_flags,
110                          double depth,
111                          unsigned stencil,
112                          unsigned dstx, unsigned dsty,
113                          unsigned width, unsigned height);
114 
115 bool
116 util_can_blit_via_copy_region(const struct pipe_blit_info *blit,
117                               bool tight_format_check,
118                               bool render_condition_bound);
119 
120 extern bool
121 util_try_blit_via_copy_region(struct pipe_context *ctx,
122                               const struct pipe_blit_info *blit,
123                               bool render_condition_bound);
124 
125 
126 #ifdef __cplusplus
127 }
128 #endif
129 
130 
131 #endif /* U_SURFACE_H */
132