• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 Collabora Ltd.
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  * on the rights to use, copy, modify, merge, publish, distribute, sub
8  * license, and/or sell copies of the Software, and to permit persons to whom
9  * the 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 NON-INFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21  * USE OR OTHER DEALINGS IN THE SOFTWARE.
22  */
23 
24 #ifndef ZINK_BATCH_H
25 #define ZINK_BATCH_H
26 
27 #include <vulkan/vulkan_core.h>
28 #include "zink_types.h"
29 
30 #include "util/list.h"
31 #include "util/set.h"
32 #include "util/u_dynarray.h"
33 
34 #include "zink_fence.h"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 
41 void
42 zink_reset_batch_state(struct zink_context *ctx, struct zink_batch_state *bs);
43 
44 void
45 zink_clear_batch_state(struct zink_context *ctx, struct zink_batch_state *bs);
46 
47 void
48 zink_batch_reset_all(struct zink_context *ctx);
49 
50 void
51 zink_batch_state_destroy(struct zink_screen *screen, struct zink_batch_state *bs);
52 
53 void
54 zink_batch_state_clear_resources(struct zink_screen *screen, struct zink_batch_state *bs);
55 
56 void
57 zink_reset_batch(struct zink_context *ctx, struct zink_batch *batch);
58 void
59 zink_start_batch(struct zink_context *ctx, struct zink_batch *batch);
60 
61 void
62 zink_end_batch(struct zink_context *ctx, struct zink_batch *batch);
63 
64 void
65 zink_batch_add_wait_semaphore(struct zink_batch *batch, VkSemaphore sem);
66 
67 void
68 zink_batch_reference_resource_rw(struct zink_batch *batch,
69                                  struct zink_resource *res,
70                                  bool write);
71 void
72 zink_batch_reference_resource(struct zink_batch *batch, struct zink_resource *res);
73 
74 bool
75 zink_batch_reference_resource_move(struct zink_batch *batch, struct zink_resource *res);
76 
77 void
78 zink_batch_reference_program(struct zink_batch *batch,
79                              struct zink_program *pg);
80 
81 void
82 zink_batch_bind_db(struct zink_context *ctx);
83 void
84 debug_describe_zink_batch_state(char *buf, const struct zink_batch_state *ptr);
85 
86 static ALWAYS_INLINE bool
zink_batch_usage_is_unflushed(const struct zink_batch_usage * u)87 zink_batch_usage_is_unflushed(const struct zink_batch_usage *u)
88 {
89    return u && u->unflushed;
90 }
91 
92 static ALWAYS_INLINE void
zink_batch_usage_unset(struct zink_batch_usage ** u,struct zink_batch_state * bs)93 zink_batch_usage_unset(struct zink_batch_usage **u, struct zink_batch_state *bs)
94 {
95    (void)p_atomic_cmpxchg((uintptr_t *)u, (uintptr_t)&bs->usage, (uintptr_t)NULL);
96 }
97 
98 static ALWAYS_INLINE void
zink_batch_usage_set(struct zink_batch_usage ** u,struct zink_batch_state * bs)99 zink_batch_usage_set(struct zink_batch_usage **u, struct zink_batch_state *bs)
100 {
101    *u = &bs->usage;
102 }
103 
104 static ALWAYS_INLINE bool
zink_batch_usage_matches(const struct zink_batch_usage * u,const struct zink_batch_state * bs)105 zink_batch_usage_matches(const struct zink_batch_usage *u, const struct zink_batch_state *bs)
106 {
107    return u == &bs->usage;
108 }
109 
110 static ALWAYS_INLINE bool
zink_batch_usage_exists(const struct zink_batch_usage * u)111 zink_batch_usage_exists(const struct zink_batch_usage *u)
112 {
113    return u && (u->usage || u->unflushed);
114 }
115 
116 bool
117 zink_screen_usage_check_completion(struct zink_screen *screen, const struct zink_batch_usage *u);
118 bool
119 zink_screen_usage_check_completion_fast(struct zink_screen *screen, const struct zink_batch_usage *u);
120 
121 bool
122 zink_batch_usage_check_completion(struct zink_context *ctx, const struct zink_batch_usage *u);
123 
124 void
125 zink_batch_usage_wait(struct zink_context *ctx, struct zink_batch_usage *u);
126 
127 void
128 zink_batch_usage_try_wait(struct zink_context *ctx, struct zink_batch_usage *u);
129 
130 #ifdef __cplusplus
131 }
132 #endif
133 
134 #endif
135