Path: blob/21.2-virgl/src/gallium/auxiliary/cso_cache/cso_context.h
4565 views
/**************************************************************************1*2* Copyright 2007-2008 VMware, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/262728#ifndef CSO_CONTEXT_H29#define CSO_CONTEXT_H3031#include "pipe/p_context.h"32#include "pipe/p_state.h"33#include "pipe/p_defines.h"34#include "cso_cache.h"353637#ifdef __cplusplus38extern "C" {39#endif4041struct cso_context;42struct u_vbuf;4344#define CSO_NO_USER_VERTEX_BUFFERS (1 << 0)45#define CSO_NO_64B_VERTEX_BUFFERS (1 << 1)46#define CSO_NO_VBUF (1 << 2)4748struct cso_context *cso_create_context(struct pipe_context *pipe,49unsigned flags);50void cso_unbind_context(struct cso_context *ctx);51void cso_destroy_context( struct cso_context *cso );52struct pipe_context *cso_get_pipe_context(struct cso_context *cso);535455enum pipe_error cso_set_blend( struct cso_context *cso,56const struct pipe_blend_state *blend );575859enum pipe_error cso_set_depth_stencil_alpha( struct cso_context *cso,60const struct pipe_depth_stencil_alpha_state *dsa );61626364enum pipe_error cso_set_rasterizer( struct cso_context *cso,65const struct pipe_rasterizer_state *rasterizer );666768void69cso_set_samplers(struct cso_context *cso,70enum pipe_shader_type shader_stage,71unsigned count,72const struct pipe_sampler_state **states);737475/* Alternate interface to support gallium frontends that like to modify76* samplers one at a time:77*/78void79cso_single_sampler(struct cso_context *cso, enum pipe_shader_type shader_stage,80unsigned idx, const struct pipe_sampler_state *states);8182void83cso_single_sampler_done(struct cso_context *cso,84enum pipe_shader_type shader_stage);858687enum pipe_error cso_set_vertex_elements(struct cso_context *ctx,88const struct cso_velems_state *velems);8990void cso_set_vertex_buffers(struct cso_context *ctx,91unsigned start_slot, unsigned count,92const struct pipe_vertex_buffer *buffers);9394void cso_set_stream_outputs(struct cso_context *ctx,95unsigned num_targets,96struct pipe_stream_output_target **targets,97const unsigned *offsets);9899100/*101* We don't provide shader caching in CSO. Most of the time the api provides102* object semantics for shaders anyway, and the cases where it doesn't103* (eg mesa's internally-generated texenv programs), it will be up to104* gallium frontends to implement their own specialized caching.105*/106107void cso_set_fragment_shader_handle(struct cso_context *ctx, void *handle);108void cso_set_vertex_shader_handle(struct cso_context *ctx, void *handle);109void cso_set_geometry_shader_handle(struct cso_context *ctx, void *handle);110void cso_set_tessctrl_shader_handle(struct cso_context *ctx, void *handle);111void cso_set_tesseval_shader_handle(struct cso_context *ctx, void *handle);112void cso_set_compute_shader_handle(struct cso_context *ctx, void *handle);113114115void cso_set_framebuffer(struct cso_context *cso,116const struct pipe_framebuffer_state *fb);117118119void cso_set_viewport(struct cso_context *cso,120const struct pipe_viewport_state *vp);121void cso_set_viewport_dims(struct cso_context *ctx,122float width, float height, boolean invert);123124void cso_set_sample_mask(struct cso_context *cso, unsigned stencil_mask);125126void cso_set_min_samples(struct cso_context *cso, unsigned min_samples);127128void cso_set_stencil_ref(struct cso_context *cso,129const struct pipe_stencil_ref sr);130131void cso_set_render_condition(struct cso_context *cso,132struct pipe_query *query,133boolean condition,134enum pipe_render_cond_flag mode);135136/* gap */137#define CSO_BIT_BLEND 0x2138#define CSO_BIT_DEPTH_STENCIL_ALPHA 0x4139#define CSO_BIT_FRAGMENT_SAMPLERS 0x8140/* gap */141#define CSO_BIT_FRAGMENT_SHADER 0x20142#define CSO_BIT_FRAMEBUFFER 0x40143#define CSO_BIT_GEOMETRY_SHADER 0x80144#define CSO_BIT_MIN_SAMPLES 0x100145#define CSO_BIT_RASTERIZER 0x200146#define CSO_BIT_RENDER_CONDITION 0x400147#define CSO_BIT_SAMPLE_MASK 0x800148#define CSO_BIT_STENCIL_REF 0x1000149#define CSO_BIT_STREAM_OUTPUTS 0x2000150#define CSO_BIT_TESSCTRL_SHADER 0x4000151#define CSO_BIT_TESSEVAL_SHADER 0x8000152#define CSO_BIT_VERTEX_ELEMENTS 0x10000153#define CSO_BIT_VERTEX_SHADER 0x20000154#define CSO_BIT_VIEWPORT 0x40000155#define CSO_BIT_PAUSE_QUERIES 0x80000156157#define CSO_BITS_ALL_SHADERS (CSO_BIT_VERTEX_SHADER | \158CSO_BIT_FRAGMENT_SHADER | \159CSO_BIT_GEOMETRY_SHADER | \160CSO_BIT_TESSCTRL_SHADER | \161CSO_BIT_TESSEVAL_SHADER)162163#define CSO_BIT_COMPUTE_SHADER (1<<0)164#define CSO_BIT_COMPUTE_SAMPLERS (1<<1)165166void cso_save_state(struct cso_context *cso, unsigned state_mask);167void cso_restore_state(struct cso_context *cso);168169void cso_save_compute_state(struct cso_context *cso, unsigned state_mask);170void cso_restore_compute_state(struct cso_context *cso);171172/* Optimized version. */173void174cso_set_vertex_buffers_and_elements(struct cso_context *ctx,175const struct cso_velems_state *velems,176unsigned vb_count,177unsigned unbind_trailing_vb_count,178bool take_ownership,179bool uses_user_vertex_buffers,180const struct pipe_vertex_buffer *vbuffers);181182/* drawing */183184void185cso_draw_vbo(struct cso_context *cso,186const struct pipe_draw_info *info,187unsigned drawid_offset,188const struct pipe_draw_indirect_info *indirect,189const struct pipe_draw_start_count_bias draw);190191/* info->draw_id can be changed by the callee if increment_draw_id is true. */192void193cso_multi_draw(struct cso_context *cso,194struct pipe_draw_info *info,195unsigned drawid_offset,196const struct pipe_draw_start_count_bias *draws,197unsigned num_draws);198199void200cso_draw_arrays_instanced(struct cso_context *cso, uint mode,201uint start, uint count,202uint start_instance, uint instance_count);203204void205cso_draw_arrays(struct cso_context *cso, uint mode, uint start, uint count);206207#ifdef __cplusplus208}209#endif210211#endif212213214