~mmach/netext73/mesa-haswell

« back to all changes in this revision

Viewing changes to src/gallium/drivers/virgl/virgl_context.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 2014, 2015 Red Hat.
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
 
#ifndef VIRGL_CONTEXT_H
24
 
#define VIRGL_CONTEXT_H
25
 
 
26
 
#include "pipe/p_state.h"
27
 
#include "pipe/p_context.h"
28
 
#include "util/slab.h"
29
 
#include "util/list.h"
30
 
 
31
 
#include "virgl_staging_mgr.h"
32
 
#include "virgl_transfer_queue.h"
33
 
 
34
 
struct pipe_screen;
35
 
struct tgsi_token;
36
 
struct u_upload_mgr;
37
 
struct virgl_cmd_buf;
38
 
struct virgl_vertex_elements_state;
39
 
 
40
 
struct virgl_sampler_view {
41
 
   struct pipe_sampler_view base;
42
 
   uint32_t handle;
43
 
};
44
 
 
45
 
struct virgl_so_target {
46
 
   struct pipe_stream_output_target base;
47
 
   uint32_t handle;
48
 
};
49
 
 
50
 
struct virgl_rasterizer_state {
51
 
   struct pipe_rasterizer_state rs;
52
 
   uint32_t handle;
53
 
};
54
 
 
55
 
struct virgl_shader_binding_state {
56
 
   struct pipe_sampler_view *views[PIPE_MAX_SHADER_SAMPLER_VIEWS];
57
 
 
58
 
   struct pipe_constant_buffer ubos[PIPE_MAX_CONSTANT_BUFFERS];
59
 
   uint32_t ubo_enabled_mask;
60
 
 
61
 
   struct pipe_shader_buffer ssbos[PIPE_MAX_SHADER_BUFFERS];
62
 
   uint32_t ssbo_enabled_mask;
63
 
 
64
 
   struct pipe_image_view images[PIPE_MAX_SHADER_IMAGES];
65
 
   uint32_t image_enabled_mask;
66
 
};
67
 
 
68
 
struct virgl_context {
69
 
   struct pipe_context base;
70
 
   struct virgl_cmd_buf *cbuf;
71
 
   unsigned cbuf_initial_cdw;
72
 
 
73
 
   struct virgl_shader_binding_state shader_bindings[PIPE_SHADER_TYPES];
74
 
   struct pipe_shader_buffer atomic_buffers[PIPE_MAX_HW_ATOMIC_BUFFERS];
75
 
   uint32_t atomic_buffer_enabled_mask;
76
 
 
77
 
   struct virgl_vertex_elements_state *vertex_elements;
78
 
 
79
 
   struct pipe_framebuffer_state framebuffer;
80
 
 
81
 
   struct slab_child_pool transfer_pool;
82
 
   struct virgl_transfer_queue queue;
83
 
   struct u_upload_mgr *uploader;
84
 
   struct virgl_staging_mgr staging;
85
 
   bool encoded_transfers;
86
 
   bool supports_staging;
87
 
   uint8_t patch_vertices;
88
 
 
89
 
   struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
90
 
   unsigned num_vertex_buffers;
91
 
   boolean vertex_array_dirty;
92
 
 
93
 
   struct virgl_rasterizer_state rs_state;
94
 
   struct virgl_so_target so_targets[PIPE_MAX_SO_BUFFERS];
95
 
   unsigned num_so_targets;
96
 
 
97
 
   uint32_t num_draws, num_compute;
98
 
 
99
 
   struct primconvert_context *primconvert;
100
 
   uint32_t hw_sub_ctx_id;
101
 
 
102
 
   /* The total size of staging resources used in queued copy transfers. */
103
 
   uint64_t queued_staging_res_size;
104
 
};
105
 
 
106
 
static inline struct virgl_sampler_view *
107
 
virgl_sampler_view(struct pipe_sampler_view *view)
108
 
{
109
 
   return (struct virgl_sampler_view *)view;
110
 
};
111
 
 
112
 
static inline struct virgl_so_target *
113
 
virgl_so_target(struct pipe_stream_output_target *target)
114
 
{
115
 
   return (struct virgl_so_target *)target;
116
 
}
117
 
 
118
 
static inline struct virgl_context *virgl_context(struct pipe_context *ctx)
119
 
{
120
 
   return (struct virgl_context *)ctx;
121
 
}
122
 
 
123
 
struct pipe_context *virgl_context_create(struct pipe_screen *pscreen,
124
 
                                          void *priv, unsigned flags);
125
 
 
126
 
void virgl_init_blit_functions(struct virgl_context *vctx);
127
 
void virgl_init_query_functions(struct virgl_context *vctx);
128
 
void virgl_init_so_functions(struct virgl_context *vctx);
129
 
 
130
 
struct tgsi_token *virgl_tgsi_transform(struct virgl_screen *vscreen, const struct tgsi_token *tokens_in);
131
 
 
132
 
bool
133
 
virgl_can_rebind_resource(struct virgl_context *vctx,
134
 
                          struct pipe_resource *res);
135
 
 
136
 
void
137
 
virgl_rebind_resource(struct virgl_context *vctx,
138
 
                      struct pipe_resource *res);
139
 
 
140
 
void virgl_flush_eq(struct virgl_context *ctx, void *closure, struct pipe_fence_handle **fence);
141
 
 
142
 
#endif