Path: blob/21.2-virgl/src/gallium/auxiliary/draw/draw_context.h
4565 views
1/**************************************************************************2*3* Copyright 2007 VMware, Inc.4* All Rights Reserved.5*6* Permission is hereby granted, free of charge, to any person obtaining a7* copy of this software and associated documentation files (the8* "Software"), to deal in the Software without restriction, including9* without limitation the rights to use, copy, modify, merge, publish,10* distribute, sub license, and/or sell copies of the Software, and to11* permit persons to whom the Software is furnished to do so, subject to12* the following conditions:13*14* The above copyright notice and this permission notice (including the15* next paragraph) shall be included in all copies or substantial portions16* of the Software.17*18* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS19* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF20* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.21* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR22* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,23* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE24* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.25*26**************************************************************************/2728/**29* \brief Public interface into the drawing module.30*/3132/* Authors: Keith Whitwell <[email protected]>33*/343536#ifndef DRAW_CONTEXT_H37#define DRAW_CONTEXT_H383940#include "pipe/p_state.h"4142struct pipe_context;43struct draw_context;44struct draw_stage;45struct draw_vertex_shader;46struct draw_geometry_shader;47struct draw_tess_ctrl_shader;48struct draw_tess_eval_shader;49struct draw_fragment_shader;50struct tgsi_sampler;51struct tgsi_image;52struct tgsi_buffer;5354/*55* structure to contain driver internal information56* for stream out support. mapping stores the pointer57* to the buffer contents, and internal offset stores58* an internal counter to how much of the stream59* out buffer is used (in bytes).60*/61struct draw_so_target {62struct pipe_stream_output_target target;63void *mapping;64int internal_offset;65};6667bool draw_has_llvm(void);6869struct draw_context *draw_create( struct pipe_context *pipe );7071#ifdef DRAW_LLVM_AVAILABLE72struct draw_context *draw_create_with_llvm_context(struct pipe_context *pipe,73void *context);74#endif7576struct draw_context *draw_create_no_llvm(struct pipe_context *pipe);7778void draw_destroy( struct draw_context *draw );7980void draw_flush(struct draw_context *draw);8182void draw_set_viewport_states( struct draw_context *draw,83unsigned start_slot,84unsigned num_viewports,85const struct pipe_viewport_state *viewports );8687void draw_set_clip_state( struct draw_context *pipe,88const struct pipe_clip_state *clip );8990/**91* Sets the rasterization state used by the draw module.92* The rast_handle is used to pass the driver specific representation93* of the rasterization state. It's going to be used when the94* draw module sets the state back on the driver itself using the95* pipe::bind_rasterizer_state method.96*97* NOTE: if you're calling this function from within the pipe's98* bind_rasterizer_state you should always call it before binding99* the actual state - that's because the draw module can try to100* bind its own rasterizer state which would reset your newly101* set state. i.e. always do102* draw_set_rasterizer_state(driver->draw, state->pipe_state, state);103* driver->state.raster = state;104*/105void draw_set_rasterizer_state( struct draw_context *draw,106const struct pipe_rasterizer_state *raster,107void *rast_handle );108109void draw_set_rasterize_stage( struct draw_context *draw,110struct draw_stage *stage );111112void draw_wide_point_threshold(struct draw_context *draw, float threshold);113114void draw_wide_point_sprites(struct draw_context *draw, boolean draw_sprite);115116void draw_wide_line_threshold(struct draw_context *draw, float threshold);117118void draw_enable_line_stipple(struct draw_context *draw, boolean enable);119120void draw_enable_point_sprites(struct draw_context *draw, boolean enable);121122void draw_set_zs_format(struct draw_context *draw, enum pipe_format format);123124/* for TGSI constants are 4 * sizeof(float), but for NIR they need to be sizeof(float); */125void draw_set_constant_buffer_stride(struct draw_context *draw, unsigned num_bytes);126127boolean128draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe);129130boolean131draw_install_aapoint_stage(struct draw_context *draw, struct pipe_context *pipe);132133boolean134draw_install_pstipple_stage(struct draw_context *draw, struct pipe_context *pipe);135136137struct tgsi_shader_info *138draw_get_shader_info(const struct draw_context *draw);139140void141draw_prepare_shader_outputs(struct draw_context *draw);142143int144draw_find_shader_output(const struct draw_context *draw,145uint semantic_name, uint semantic_index);146147boolean148draw_will_inject_frontface(const struct draw_context *draw);149150uint151draw_num_shader_outputs(const struct draw_context *draw);152153uint154draw_total_vs_outputs(const struct draw_context *draw);155156uint157draw_total_gs_outputs(const struct draw_context *draw);158159uint160draw_total_tcs_outputs(const struct draw_context *draw);161162uint163draw_total_tes_outputs(const struct draw_context *draw);164165void166draw_texture_sampler(struct draw_context *draw,167enum pipe_shader_type shader_type,168struct tgsi_sampler *sampler);169170void171draw_image(struct draw_context *draw,172enum pipe_shader_type shader_type,173struct tgsi_image *image);174175void176draw_buffer(struct draw_context *draw,177enum pipe_shader_type shader_type,178struct tgsi_buffer *buffer);179180void181draw_set_sampler_views(struct draw_context *draw,182enum pipe_shader_type shader_stage,183struct pipe_sampler_view **views,184unsigned num);185void186draw_set_samplers(struct draw_context *draw,187enum pipe_shader_type shader_stage,188struct pipe_sampler_state **samplers,189unsigned num);190191void192draw_set_images(struct draw_context *draw,193enum pipe_shader_type shader_stage,194struct pipe_image_view *images,195unsigned num);196197void198draw_set_mapped_texture(struct draw_context *draw,199enum pipe_shader_type shader_stage,200unsigned sview_idx,201uint32_t width, uint32_t height, uint32_t depth,202uint32_t first_level, uint32_t last_level,203uint32_t num_samples,204uint32_t sample_stride,205const void *base,206uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS],207uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS],208uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS]);209210void211draw_set_mapped_image(struct draw_context *draw,212enum pipe_shader_type shader_stage,213unsigned idx,214uint32_t width, uint32_t height, uint32_t depth,215const void *base_ptr,216uint32_t row_stride,217uint32_t img_stride,218uint32_t num_samples,219uint32_t sample_stride);220221/*222* Vertex shader functions223*/224225struct draw_vertex_shader *226draw_create_vertex_shader(struct draw_context *draw,227const struct pipe_shader_state *shader);228void draw_bind_vertex_shader(struct draw_context *draw,229struct draw_vertex_shader *dvs);230void draw_delete_vertex_shader(struct draw_context *draw,231struct draw_vertex_shader *dvs);232void draw_vs_attach_so(struct draw_vertex_shader *dvs,233const struct pipe_stream_output_info *info);234void draw_vs_reset_so(struct draw_vertex_shader *dvs);235236237/*238* Fragment shader functions239*/240struct draw_fragment_shader *241draw_create_fragment_shader(struct draw_context *draw,242const struct pipe_shader_state *shader);243void draw_bind_fragment_shader(struct draw_context *draw,244struct draw_fragment_shader *dvs);245void draw_delete_fragment_shader(struct draw_context *draw,246struct draw_fragment_shader *dvs);247248/*249* Geometry shader functions250*/251struct draw_geometry_shader *252draw_create_geometry_shader(struct draw_context *draw,253const struct pipe_shader_state *shader);254void draw_bind_geometry_shader(struct draw_context *draw,255struct draw_geometry_shader *dvs);256void draw_delete_geometry_shader(struct draw_context *draw,257struct draw_geometry_shader *dvs);258259/*260* Tess shader functions261*/262struct draw_tess_ctrl_shader *263draw_create_tess_ctrl_shader(struct draw_context *draw,264const struct pipe_shader_state *shader);265void draw_bind_tess_ctrl_shader(struct draw_context *draw,266struct draw_tess_ctrl_shader *dvs);267void draw_delete_tess_ctrl_shader(struct draw_context *draw,268struct draw_tess_ctrl_shader *dvs);269struct draw_tess_eval_shader *270draw_create_tess_eval_shader(struct draw_context *draw,271const struct pipe_shader_state *shader);272void draw_bind_tess_eval_shader(struct draw_context *draw,273struct draw_tess_eval_shader *dvs);274void draw_delete_tess_eval_shader(struct draw_context *draw,275struct draw_tess_eval_shader *dvs);276void draw_set_tess_state(struct draw_context *draw,277const float default_outer_level[4],278const float default_inner_level[2]);279280/*281* Vertex data functions282*/283284void draw_set_vertex_buffers(struct draw_context *draw,285unsigned start_slot, unsigned count,286unsigned unbind_num_trailing_slots,287const struct pipe_vertex_buffer *buffers);288289void draw_set_vertex_elements(struct draw_context *draw,290unsigned count,291const struct pipe_vertex_element *elements);292293void draw_set_indexes(struct draw_context *draw,294const void *elements, unsigned elem_size,295unsigned available_space);296297void draw_set_mapped_vertex_buffer(struct draw_context *draw,298unsigned attr, const void *buffer,299size_t size);300301void302draw_set_mapped_constant_buffer(struct draw_context *draw,303enum pipe_shader_type shader_type,304unsigned slot,305const void *buffer,306unsigned size);307308void309draw_set_mapped_shader_buffer(struct draw_context *draw,310enum pipe_shader_type shader_type,311unsigned slot,312const void *buffer,313unsigned size);314315void316draw_set_mapped_so_targets(struct draw_context *draw,317int num_targets,318struct draw_so_target *targets[PIPE_MAX_SO_BUFFERS]);319320321/***********************************************************************322* draw_pt.c323*/324325void draw_vbo(struct draw_context *draw,326const struct pipe_draw_info *info,327unsigned drawid_offset,328const struct pipe_draw_indirect_info *indirect,329const struct pipe_draw_start_count_bias *draws,330unsigned num_draws);331332333/*******************************************************************************334* Driver backend interface335*/336struct vbuf_render;337void draw_set_render( struct draw_context *draw,338struct vbuf_render *render );339340void draw_set_driver_clipping( struct draw_context *draw,341boolean bypass_clip_xy,342boolean bypass_clip_z,343boolean guard_band_xy,344boolean bypass_clip_points);345346/*******************************************************************************347* Draw statistics348*/349void draw_collect_pipeline_statistics(struct draw_context *draw,350boolean enable);351352void draw_collect_primitives_generated(struct draw_context *draw,353bool eanble);354355/*******************************************************************************356* Draw pipeline357*/358boolean draw_need_pipeline(const struct draw_context *draw,359const struct pipe_rasterizer_state *rasterizer,360unsigned prim );361362int363draw_get_shader_param(enum pipe_shader_type shader, enum pipe_shader_cap param);364365int366draw_get_shader_param_no_llvm(enum pipe_shader_type shader,367enum pipe_shader_cap param);368369boolean370draw_get_option_use_llvm(void);371372struct lp_cached_code;373void374draw_set_disk_cache_callbacks(struct draw_context *draw,375void *data_cookie,376void (*find_shader)(void *cookie,377struct lp_cached_code *cache,378unsigned char ir_sha1_cache_key[20]),379void (*insert_shader)(void *cookie,380struct lp_cached_code *cache,381unsigned char ir_sha1_cache_key[20]));382#endif /* DRAW_CONTEXT_H */383384385