Path: blob/21.2-virgl/src/gallium/drivers/virgl/virgl_context.h
4570 views
/*1* Copyright 2014, 2015 Red Hat.2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* on the rights to use, copy, modify, merge, publish, distribute, sub7* license, and/or sell copies of the Software, and to permit persons to whom8* the Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL17* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,18* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR19* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE20* USE OR OTHER DEALINGS IN THE SOFTWARE.21*/22#ifndef VIRGL_CONTEXT_H23#define VIRGL_CONTEXT_H2425#include "pipe/p_state.h"26#include "pipe/p_context.h"27#include "util/slab.h"28#include "util/list.h"2930#include "virgl_staging_mgr.h"31#include "virgl_transfer_queue.h"3233struct pipe_screen;34struct tgsi_token;35struct u_upload_mgr;36struct virgl_cmd_buf;37struct virgl_vertex_elements_state;3839struct virgl_sampler_view {40struct pipe_sampler_view base;41uint32_t handle;42};4344struct virgl_so_target {45struct pipe_stream_output_target base;46uint32_t handle;47};4849struct virgl_rasterizer_state {50struct pipe_rasterizer_state rs;51uint32_t handle;52};5354struct virgl_shader_binding_state {55struct pipe_sampler_view *views[16];56uint32_t view_enabled_mask;5758struct pipe_constant_buffer ubos[PIPE_MAX_CONSTANT_BUFFERS];59uint32_t ubo_enabled_mask;6061struct pipe_shader_buffer ssbos[PIPE_MAX_SHADER_BUFFERS];62uint32_t ssbo_enabled_mask;6364struct pipe_image_view images[PIPE_MAX_SHADER_IMAGES];65uint32_t image_enabled_mask;66};6768struct virgl_context {69struct pipe_context base;70struct virgl_cmd_buf *cbuf;71unsigned cbuf_initial_cdw;7273struct virgl_shader_binding_state shader_bindings[PIPE_SHADER_TYPES];74struct pipe_shader_buffer atomic_buffers[PIPE_MAX_HW_ATOMIC_BUFFERS];75uint32_t atomic_buffer_enabled_mask;7677struct virgl_vertex_elements_state *vertex_elements;7879struct pipe_framebuffer_state framebuffer;8081struct slab_child_pool transfer_pool;82struct virgl_transfer_queue queue;83struct u_upload_mgr *uploader;84struct virgl_staging_mgr staging;85bool encoded_transfers;86bool supports_staging;8788struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];89unsigned num_vertex_buffers;90boolean vertex_array_dirty;9192struct virgl_rasterizer_state rs_state;93struct virgl_so_target so_targets[PIPE_MAX_SO_BUFFERS];94unsigned num_so_targets;9596uint32_t num_draws, num_compute;9798struct primconvert_context *primconvert;99uint32_t hw_sub_ctx_id;100101/* The total size of staging resources used in queued copy transfers. */102uint64_t queued_staging_res_size;103};104105static inline struct virgl_sampler_view *106virgl_sampler_view(struct pipe_sampler_view *view)107{108return (struct virgl_sampler_view *)view;109};110111static inline struct virgl_so_target *112virgl_so_target(struct pipe_stream_output_target *target)113{114return (struct virgl_so_target *)target;115}116117static inline struct virgl_context *virgl_context(struct pipe_context *ctx)118{119return (struct virgl_context *)ctx;120}121122struct pipe_context *virgl_context_create(struct pipe_screen *pscreen,123void *priv, unsigned flags);124125void virgl_init_blit_functions(struct virgl_context *vctx);126void virgl_init_query_functions(struct virgl_context *vctx);127void virgl_init_so_functions(struct virgl_context *vctx);128129struct tgsi_token *virgl_tgsi_transform(struct virgl_screen *vscreen, const struct tgsi_token *tokens_in);130131bool132virgl_can_rebind_resource(struct virgl_context *vctx,133struct pipe_resource *res);134135void136virgl_rebind_resource(struct virgl_context *vctx,137struct pipe_resource *res);138139#endif140141142