virgl: rename virgl.h to virgl_screen.h
[mesa.git] / src / gallium / drivers / virgl / virgl_context.h
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 "virgl_protocol.h"
29
30 #include "virgl_screen.h"
31 #include "util/u_slab.h"
32 #include "util/list.h"
33 #include "indices/u_primconvert.h"
34
35 struct virgl_resource;
36 struct virgl_buffer;
37
38 struct virgl_sampler_view {
39 struct pipe_sampler_view base;
40 uint32_t handle;
41 };
42
43 struct virgl_so_target {
44 struct pipe_stream_output_target base;
45 uint32_t handle;
46 };
47
48 struct virgl_textures_info {
49 struct virgl_sampler_view *views[16];
50 uint32_t enabled_mask;
51 };
52
53 struct virgl_context {
54 struct pipe_context base;
55 struct virgl_cmd_buf *cbuf;
56
57 struct virgl_textures_info samplers[PIPE_SHADER_TYPES];
58
59 struct pipe_framebuffer_state framebuffer;
60
61 struct util_slab_mempool texture_transfer_pool;
62
63 struct pipe_index_buffer index_buffer;
64 struct u_upload_mgr *uploader;
65
66 struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
67 unsigned num_vertex_buffers;
68 boolean vertex_array_dirty;
69
70 struct virgl_so_target so_targets[PIPE_MAX_SO_BUFFERS];
71 unsigned num_so_targets;
72
73 struct pipe_resource *ubos[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS];
74 int num_transfers;
75 int num_draws;
76 struct list_head to_flush_bufs;
77
78 struct primconvert_context *primconvert;
79 uint32_t hw_sub_ctx_id;
80 };
81
82 struct pipe_context *virgl_context_create(struct pipe_screen *pscreen,
83 void *priv, unsigned flags);
84
85 void virgl_init_blit_functions(struct virgl_context *vctx);
86 void virgl_init_query_functions(struct virgl_context *vctx);
87 void virgl_init_so_functions(struct virgl_context *vctx);
88
89 void virgl_transfer_inline_write(struct pipe_context *ctx,
90 struct pipe_resource *res,
91 unsigned level,
92 unsigned usage,
93 const struct pipe_box *box,
94 const void *data,
95 unsigned stride,
96 unsigned layer_stride);
97
98 struct tgsi_token *virgl_tgsi_transform(const struct tgsi_token *tokens_in);
99
100 #endif