Path: blob/21.2-virgl/src/gallium/drivers/virgl/virgl_encode.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_ENCODE_H23#define VIRGL_ENCODE_H2425#include "pipe/p_defines.h"26#include "pipe/p_state.h"2728#include "virgl_winsys.h"29#include "virtio-gpu/virgl_protocol.h"3031struct tgsi_token;3233struct virgl_context;34struct virgl_resource;35struct virgl_screen;36struct virgl_transfer;37struct virgl_sampler_view;3839struct virgl_surface {40struct pipe_surface base;41uint32_t handle;42};4344struct virgl_indexbuf {45unsigned offset;46unsigned index_size; /**< size of an index, in bytes */47struct pipe_resource *buffer; /**< the actual buffer */48const void *user_buffer; /**< pointer to a user buffer if buffer == NULL */49};5051static inline struct virgl_surface *virgl_surface(struct pipe_surface *surf)52{53return (struct virgl_surface *)surf;54}5556static inline void virgl_encoder_write_dword(struct virgl_cmd_buf *state,57uint32_t dword)58{59state->buf[state->cdw++] = dword;60}6162static inline void virgl_encoder_write_qword(struct virgl_cmd_buf *state,63uint64_t qword)64{65memcpy(state->buf + state->cdw, &qword, sizeof(uint64_t));66state->cdw += 2;67}6869static inline void virgl_encoder_write_block(struct virgl_cmd_buf *state,70const uint8_t *ptr, uint32_t len)71{72int x;73memcpy(state->buf + state->cdw, ptr, len);74x = (len % 4);75if (x) {76uint8_t *mp = (uint8_t *)(state->buf + state->cdw);77mp += len;78memset(mp, 0, x);79}80state->cdw += (len + 3) / 4;81}8283extern int virgl_encode_blend_state(struct virgl_context *ctx,84uint32_t handle,85const struct pipe_blend_state *blend_state);86extern int virgl_encode_rasterizer_state(struct virgl_context *ctx,87uint32_t handle,88const struct pipe_rasterizer_state *state);8990extern int virgl_encode_shader_state(struct virgl_context *ctx,91uint32_t handle,92uint32_t type,93const struct pipe_stream_output_info *so_info,94uint32_t cs_req_local_mem,95const struct tgsi_token *tokens);9697int virgl_encode_stream_output_info(struct virgl_context *ctx,98uint32_t handle,99uint32_t type,100const struct pipe_shader_state *shader);101102int virgl_encoder_set_so_targets(struct virgl_context *ctx,103unsigned num_targets,104struct pipe_stream_output_target **targets,105unsigned append_bitmask);106107int virgl_encoder_create_so_target(struct virgl_context *ctx,108uint32_t handle,109struct virgl_resource *res,110unsigned buffer_offset,111unsigned buffer_size);112113int virgl_encode_clear(struct virgl_context *ctx,114unsigned buffers,115const union pipe_color_union *color,116double depth, unsigned stencil);117118int virgl_encode_clear_texture(struct virgl_context *ctx,119struct virgl_resource *res,120unsigned int level,121const struct pipe_box *box,122const void *data);123124int virgl_encode_bind_object(struct virgl_context *ctx,125uint32_t handle, uint32_t object);126int virgl_encode_delete_object(struct virgl_context *ctx,127uint32_t handle, uint32_t object);128129int virgl_encoder_set_framebuffer_state(struct virgl_context *ctx,130const struct pipe_framebuffer_state *state);131int virgl_encoder_set_viewport_states(struct virgl_context *ctx,132int start_slot,133int num_viewports,134const struct pipe_viewport_state *states);135136int virgl_encoder_draw_vbo(struct virgl_context *ctx,137const struct pipe_draw_info *info,138unsigned drawid_offset,139const struct pipe_draw_indirect_info *indirect,140const struct pipe_draw_start_count_bias *draw);141142143int virgl_encoder_create_surface(struct virgl_context *ctx,144uint32_t handle,145struct virgl_resource *res,146const struct pipe_surface *templat);147148int virgl_encoder_flush_frontbuffer(struct virgl_context *ctx,149struct virgl_resource *res);150151int virgl_encoder_create_vertex_elements(struct virgl_context *ctx,152uint32_t handle,153unsigned num_elements,154const struct pipe_vertex_element *element);155156int virgl_encoder_set_vertex_buffers(struct virgl_context *ctx,157unsigned num_buffers,158const struct pipe_vertex_buffer *buffers);159160161int virgl_encoder_inline_write(struct virgl_context *ctx,162struct virgl_resource *res,163unsigned level, unsigned usage,164const struct pipe_box *box,165const void *data, unsigned stride,166unsigned layer_stride);167int virgl_encode_sampler_state(struct virgl_context *ctx,168uint32_t handle,169const struct pipe_sampler_state *state);170int virgl_encode_sampler_view(struct virgl_context *ctx,171uint32_t handle,172struct virgl_resource *res,173const struct pipe_sampler_view *state);174175int virgl_encode_set_sampler_views(struct virgl_context *ctx,176uint32_t shader_type,177uint32_t start_slot,178uint32_t num_views,179struct virgl_sampler_view **views);180181int virgl_encode_bind_sampler_states(struct virgl_context *ctx,182uint32_t shader_type,183uint32_t start_slot,184uint32_t num_handles,185uint32_t *handles);186187int virgl_encoder_set_index_buffer(struct virgl_context *ctx,188const struct virgl_indexbuf *ib);189190uint32_t virgl_object_assign_handle(void);191192int virgl_encoder_write_constant_buffer(struct virgl_context *ctx,193uint32_t shader,194uint32_t index,195uint32_t size,196const void *data);197198int virgl_encoder_set_uniform_buffer(struct virgl_context *ctx,199uint32_t shader,200uint32_t index,201uint32_t offset,202uint32_t length,203struct virgl_resource *res);204int virgl_encode_dsa_state(struct virgl_context *ctx,205uint32_t handle,206const struct pipe_depth_stencil_alpha_state *dsa_state);207208int virgl_encoder_set_stencil_ref(struct virgl_context *ctx,209const struct pipe_stencil_ref *ref);210211int virgl_encoder_set_blend_color(struct virgl_context *ctx,212const struct pipe_blend_color *color);213214int virgl_encoder_set_scissor_state(struct virgl_context *ctx,215unsigned start_slot,216int num_scissors,217const struct pipe_scissor_state *ss);218219void virgl_encoder_set_polygon_stipple(struct virgl_context *ctx,220const struct pipe_poly_stipple *ps);221222void virgl_encoder_set_sample_mask(struct virgl_context *ctx,223unsigned sample_mask);224225void virgl_encoder_set_min_samples(struct virgl_context *ctx,226unsigned min_samples);227228void virgl_encoder_set_clip_state(struct virgl_context *ctx,229const struct pipe_clip_state *clip);230231int virgl_encode_resource_copy_region(struct virgl_context *ctx,232struct virgl_resource *dst_res,233unsigned dst_level,234unsigned dstx, unsigned dsty, unsigned dstz,235struct virgl_resource *src_res,236unsigned src_level,237const struct pipe_box *src_box);238239int virgl_encode_blit(struct virgl_context *ctx,240struct virgl_resource *dst_res,241struct virgl_resource *src_res,242const struct pipe_blit_info *blit);243244int virgl_encoder_create_query(struct virgl_context *ctx,245uint32_t handle,246uint query_type,247uint query_index,248struct virgl_resource *res,249uint32_t offset);250251int virgl_encoder_begin_query(struct virgl_context *ctx,252uint32_t handle);253int virgl_encoder_end_query(struct virgl_context *ctx,254uint32_t handle);255int virgl_encoder_get_query_result(struct virgl_context *ctx,256uint32_t handle, boolean wait);257258int virgl_encoder_render_condition(struct virgl_context *ctx,259uint32_t handle, boolean condition,260enum pipe_render_cond_flag mode);261262int virgl_encoder_set_sub_ctx(struct virgl_context *ctx, uint32_t sub_ctx_id);263int virgl_encoder_create_sub_ctx(struct virgl_context *ctx, uint32_t sub_ctx_id);264int virgl_encoder_destroy_sub_ctx(struct virgl_context *ctx, uint32_t sub_ctx_id);265266int virgl_encode_bind_shader(struct virgl_context *ctx,267uint32_t handle, uint32_t type);268269int virgl_encode_set_tess_state(struct virgl_context *ctx,270const float outer[4],271const float inner[2]);272273int virgl_encode_set_shader_buffers(struct virgl_context *ctx,274enum pipe_shader_type shader,275unsigned start_slot, unsigned count,276const struct pipe_shader_buffer *buffers);277int virgl_encode_set_shader_images(struct virgl_context *ctx,278enum pipe_shader_type shader,279unsigned start_slot, unsigned count,280const struct pipe_image_view *images);281int virgl_encode_set_hw_atomic_buffers(struct virgl_context *ctx,282unsigned start_slot, unsigned count,283const struct pipe_shader_buffer *buffers);284int virgl_encode_memory_barrier(struct virgl_context *ctx,285unsigned flags);286int virgl_encode_launch_grid(struct virgl_context *ctx,287const struct pipe_grid_info *grid_info);288int virgl_encode_texture_barrier(struct virgl_context *ctx,289unsigned flags);290291int virgl_encode_host_debug_flagstring(struct virgl_context *ctx,292const char *envname);293294int virgl_encode_get_query_result_qbo(struct virgl_context *ctx,295uint32_t handle,296struct virgl_resource *res, boolean wait,297uint32_t result_type,298uint32_t offset,299uint32_t index);300301void virgl_encode_transfer(struct virgl_screen *vs, struct virgl_cmd_buf *buf,302struct virgl_transfer *trans, uint32_t direction);303304void virgl_encode_copy_transfer(struct virgl_context *ctx,305struct virgl_transfer *trans);306307void virgl_encode_end_transfers(struct virgl_cmd_buf *buf);308309int virgl_encode_tweak(struct virgl_context *ctx, enum vrend_tweak_type tweak, uint32_t value);310311void virgl_encode_get_memory_info(struct virgl_context *ctx, struct virgl_resource *res);312313void virgl_encode_emit_string_marker(struct virgl_context *ctx, const char *message,314int len);315316enum virgl_formats pipe_to_virgl_format(enum pipe_format format);317#endif318319320