~mmach/netext73/mesa-haswell

« back to all changes in this revision

Viewing changes to src/gallium/drivers/zink/zink_clear.h

  • Committer: mmach
  • Date: 2022-09-22 19:56:13 UTC
  • Revision ID: netbit73@gmail.com-20220922195613-wtik9mmy20tmor0i
2022-09-22 21:17:09

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright © 2020 Mike Blumenkrantz
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, sublicense,
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 next
12
 
 * paragraph) shall be included in all copies or substantial portions of the
13
 
 * 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 NONINFRINGEMENT.  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 DEALINGS
21
 
 * IN THE SOFTWARE.
22
 
 * 
23
 
 * Authors:
24
 
 *    Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
25
 
 */
26
 
 
27
 
#include "util/u_dynarray.h"
28
 
#include "pipe/p_state.h"
29
 
#include <vulkan/vulkan.h>
30
 
#include "util/u_rect.h"
31
 
 
32
 
struct zink_context;
33
 
struct zink_resource;
34
 
 
35
 
struct zink_framebuffer_clear_data {
36
 
   union {
37
 
      struct {
38
 
         union pipe_color_union color;
39
 
         bool srgb;
40
 
      } color;
41
 
      struct {
42
 
         float depth;
43
 
         unsigned stencil;
44
 
         uint8_t bits : 2; // PIPE_CLEAR_DEPTH, PIPE_CLEAR_STENCIL
45
 
      } zs;
46
 
   };
47
 
   struct pipe_scissor_state scissor;
48
 
   bool has_scissor;
49
 
   bool conditional;
50
 
};
51
 
 
52
 
struct zink_framebuffer_clear {
53
 
   struct util_dynarray clears;
54
 
};
55
 
 
56
 
void
57
 
zink_clear(struct pipe_context *pctx,
58
 
           unsigned buffers,
59
 
           const struct pipe_scissor_state *scissor_state,
60
 
           const union pipe_color_union *pcolor,
61
 
           double depth, unsigned stencil);
62
 
void
63
 
zink_clear_texture(struct pipe_context *ctx,
64
 
                   struct pipe_resource *p_res,
65
 
                   unsigned level,
66
 
                   const struct pipe_box *box,
67
 
                   const void *data);
68
 
void
69
 
zink_clear_buffer(struct pipe_context *pctx,
70
 
                  struct pipe_resource *pres,
71
 
                  unsigned offset,
72
 
                  unsigned size,
73
 
                  const void *clear_value,
74
 
                  int clear_value_size);
75
 
 
76
 
void
77
 
zink_clear_render_target(struct pipe_context *ctx, struct pipe_surface *dst,
78
 
                         const union pipe_color_union *color, unsigned dstx,
79
 
                         unsigned dsty, unsigned width, unsigned height,
80
 
                         bool render_condition_enabled);
81
 
 
82
 
void
83
 
zink_clear_depth_stencil(struct pipe_context *ctx, struct pipe_surface *dst,
84
 
                         unsigned clear_flags, double depth, unsigned stencil,
85
 
                         unsigned dstx, unsigned dsty, unsigned width, unsigned height,
86
 
                         bool render_condition_enabled);
87
 
 
88
 
bool
89
 
zink_fb_clear_needs_explicit(struct zink_framebuffer_clear *fb_clear);
90
 
 
91
 
bool
92
 
zink_fb_clear_first_needs_explicit(struct zink_framebuffer_clear *fb_clear);
93
 
 
94
 
void
95
 
zink_clear_framebuffer(struct zink_context *ctx, unsigned clear_buffers);
96
 
 
97
 
static inline struct zink_framebuffer_clear_data *
98
 
zink_fb_clear_element(struct zink_framebuffer_clear *fb_clear, int idx)
99
 
{
100
 
   return util_dynarray_element(&fb_clear->clears, struct zink_framebuffer_clear_data, idx);
101
 
}
102
 
 
103
 
static inline unsigned
104
 
zink_fb_clear_count(struct zink_framebuffer_clear *fb_clear)
105
 
{
106
 
   return fb_clear ? util_dynarray_num_elements(&fb_clear->clears, struct zink_framebuffer_clear_data) : 0;
107
 
}
108
 
 
109
 
void
110
 
zink_fb_clear_reset(struct zink_context *ctx, unsigned idx);
111
 
 
112
 
static inline bool
113
 
zink_fb_clear_element_needs_explicit(struct zink_framebuffer_clear_data *clear)
114
 
{
115
 
   return clear->has_scissor || clear->conditional;
116
 
}
117
 
 
118
 
void
119
 
zink_clear_apply_conditionals(struct zink_context *ctx);
120
 
 
121
 
void
122
 
zink_fb_clears_apply(struct zink_context *ctx, struct pipe_resource *pres);
123
 
 
124
 
void
125
 
zink_fb_clears_discard(struct zink_context *ctx, struct pipe_resource *pres);
126
 
 
127
 
void
128
 
zink_fb_clears_apply_or_discard(struct zink_context *ctx, struct pipe_resource *pres, struct u_rect region, bool discard_only);
129
 
 
130
 
void
131
 
zink_fb_clears_apply_region(struct zink_context *ctx, struct pipe_resource *pres, struct u_rect region);
132
 
 
133
 
void
134
 
zink_fb_clear_util_unpack_clear_color(struct zink_framebuffer_clear_data *clear, enum pipe_format format, union pipe_color_union *color);