1bf215546Sopenharmony_ci/************************************************************************** 2bf215546Sopenharmony_ci * 3bf215546Sopenharmony_ci * Copyright 2007 VMware, Inc. 4bf215546Sopenharmony_ci * All Rights Reserved. 5bf215546Sopenharmony_ci * 6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the 8bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including 9bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish, 10bf215546Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to 11bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to 12bf215546Sopenharmony_ci * the following conditions: 13bf215546Sopenharmony_ci * 14bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the 15bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions 16bf215546Sopenharmony_ci * of the Software. 17bf215546Sopenharmony_ci * 18bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21bf215546Sopenharmony_ci * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 22bf215546Sopenharmony_ci * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23bf215546Sopenharmony_ci * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24bf215546Sopenharmony_ci * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25bf215546Sopenharmony_ci * 26bf215546Sopenharmony_ci **************************************************************************/ 27bf215546Sopenharmony_ci 28bf215546Sopenharmony_ci/* Authors: Keith Whitwell <keithw@vmware.com> 29bf215546Sopenharmony_ci */ 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_ci#ifndef SP_STATE_H 32bf215546Sopenharmony_ci#define SP_STATE_H 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_ci#include "pipe/p_state.h" 35bf215546Sopenharmony_ci#include "tgsi/tgsi_scan.h" 36bf215546Sopenharmony_ci 37bf215546Sopenharmony_ci 38bf215546Sopenharmony_ci#define SP_NEW_VIEWPORT 0x1 39bf215546Sopenharmony_ci#define SP_NEW_RASTERIZER 0x2 40bf215546Sopenharmony_ci#define SP_NEW_FS 0x4 41bf215546Sopenharmony_ci#define SP_NEW_BLEND 0x8 42bf215546Sopenharmony_ci#define SP_NEW_CLIP 0x10 43bf215546Sopenharmony_ci#define SP_NEW_SCISSOR 0x20 44bf215546Sopenharmony_ci 45bf215546Sopenharmony_ci#define SP_NEW_FRAMEBUFFER 0x80 46bf215546Sopenharmony_ci#define SP_NEW_DEPTH_STENCIL_ALPHA 0x100 47bf215546Sopenharmony_ci#define SP_NEW_CONSTANTS 0x200 48bf215546Sopenharmony_ci#define SP_NEW_SAMPLER 0x400 49bf215546Sopenharmony_ci#define SP_NEW_TEXTURE 0x800 50bf215546Sopenharmony_ci#define SP_NEW_VERTEX 0x1000 51bf215546Sopenharmony_ci#define SP_NEW_VS 0x2000 52bf215546Sopenharmony_ci#define SP_NEW_QUERY 0x4000 53bf215546Sopenharmony_ci#define SP_NEW_GS 0x8000 54bf215546Sopenharmony_ci#define SP_NEW_SO 0x10000 55bf215546Sopenharmony_ci#define SP_NEW_SO_BUFFERS 0x20000 56bf215546Sopenharmony_ci 57bf215546Sopenharmony_ci 58bf215546Sopenharmony_cistruct tgsi_sampler; 59bf215546Sopenharmony_cistruct tgsi_image; 60bf215546Sopenharmony_cistruct tgsi_buffer; 61bf215546Sopenharmony_cistruct tgsi_exec_machine; 62bf215546Sopenharmony_cistruct vertex_info; 63bf215546Sopenharmony_ci 64bf215546Sopenharmony_ci 65bf215546Sopenharmony_cistruct sp_fragment_shader_variant_key 66bf215546Sopenharmony_ci{ 67bf215546Sopenharmony_ci /* Standard C doesn't allow 0-size structs */ 68bf215546Sopenharmony_ci int dummy; 69bf215546Sopenharmony_ci}; 70bf215546Sopenharmony_ci 71bf215546Sopenharmony_ci 72bf215546Sopenharmony_cistruct sp_fragment_shader_variant 73bf215546Sopenharmony_ci{ 74bf215546Sopenharmony_ci const struct tgsi_token *tokens; 75bf215546Sopenharmony_ci struct sp_fragment_shader_variant_key key; 76bf215546Sopenharmony_ci struct tgsi_shader_info info; 77bf215546Sopenharmony_ci 78bf215546Sopenharmony_ci /* See comments about this elsewhere */ 79bf215546Sopenharmony_ci#if 0 80bf215546Sopenharmony_ci struct draw_fragment_shader *draw_shader; 81bf215546Sopenharmony_ci#endif 82bf215546Sopenharmony_ci 83bf215546Sopenharmony_ci void (*prepare)(const struct sp_fragment_shader_variant *shader, 84bf215546Sopenharmony_ci struct tgsi_exec_machine *machine, 85bf215546Sopenharmony_ci struct tgsi_sampler *sampler, 86bf215546Sopenharmony_ci struct tgsi_image *image, 87bf215546Sopenharmony_ci struct tgsi_buffer *buffer); 88bf215546Sopenharmony_ci 89bf215546Sopenharmony_ci unsigned (*run)(const struct sp_fragment_shader_variant *shader, 90bf215546Sopenharmony_ci struct tgsi_exec_machine *machine, 91bf215546Sopenharmony_ci struct quad_header *quad, 92bf215546Sopenharmony_ci bool early_depth_test); 93bf215546Sopenharmony_ci 94bf215546Sopenharmony_ci /* Deletes this instance of the object */ 95bf215546Sopenharmony_ci void (*delete)(struct sp_fragment_shader_variant *shader, 96bf215546Sopenharmony_ci struct tgsi_exec_machine *machine); 97bf215546Sopenharmony_ci 98bf215546Sopenharmony_ci struct sp_fragment_shader_variant *next; 99bf215546Sopenharmony_ci}; 100bf215546Sopenharmony_ci 101bf215546Sopenharmony_ci 102bf215546Sopenharmony_ci/** Subclass of pipe_shader_state */ 103bf215546Sopenharmony_cistruct sp_fragment_shader { 104bf215546Sopenharmony_ci struct pipe_shader_state shader; 105bf215546Sopenharmony_ci struct sp_fragment_shader_variant *variants; 106bf215546Sopenharmony_ci struct draw_fragment_shader *draw_shader; 107bf215546Sopenharmony_ci}; 108bf215546Sopenharmony_ci 109bf215546Sopenharmony_ci 110bf215546Sopenharmony_ci/** Subclass of pipe_shader_state */ 111bf215546Sopenharmony_cistruct sp_vertex_shader { 112bf215546Sopenharmony_ci struct pipe_shader_state shader; 113bf215546Sopenharmony_ci struct draw_vertex_shader *draw_data; 114bf215546Sopenharmony_ci int max_sampler; /* -1 if no samplers */ 115bf215546Sopenharmony_ci}; 116bf215546Sopenharmony_ci 117bf215546Sopenharmony_ci/** Subclass of pipe_shader_state */ 118bf215546Sopenharmony_cistruct sp_geometry_shader { 119bf215546Sopenharmony_ci struct pipe_shader_state shader; 120bf215546Sopenharmony_ci struct draw_geometry_shader *draw_data; 121bf215546Sopenharmony_ci int max_sampler; 122bf215546Sopenharmony_ci}; 123bf215546Sopenharmony_ci 124bf215546Sopenharmony_cistruct sp_velems_state { 125bf215546Sopenharmony_ci unsigned count; 126bf215546Sopenharmony_ci struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS]; 127bf215546Sopenharmony_ci}; 128bf215546Sopenharmony_ci 129bf215546Sopenharmony_cistruct sp_so_state { 130bf215546Sopenharmony_ci struct pipe_stream_output_info base; 131bf215546Sopenharmony_ci}; 132bf215546Sopenharmony_ci 133bf215546Sopenharmony_ci/** Subclass of pipe_compute_state */ 134bf215546Sopenharmony_cistruct sp_compute_shader { 135bf215546Sopenharmony_ci struct pipe_compute_state shader; 136bf215546Sopenharmony_ci struct tgsi_token *tokens; 137bf215546Sopenharmony_ci struct tgsi_shader_info info; 138bf215546Sopenharmony_ci int max_sampler; /* -1 if no samplers */ 139bf215546Sopenharmony_ci}; 140bf215546Sopenharmony_ci 141bf215546Sopenharmony_civoid 142bf215546Sopenharmony_cisoftpipe_init_blend_funcs(struct pipe_context *pipe); 143bf215546Sopenharmony_ci 144bf215546Sopenharmony_civoid 145bf215546Sopenharmony_cisoftpipe_init_clip_funcs(struct pipe_context *pipe); 146bf215546Sopenharmony_ci 147bf215546Sopenharmony_civoid 148bf215546Sopenharmony_cisoftpipe_init_sampler_funcs(struct pipe_context *pipe); 149bf215546Sopenharmony_ci 150bf215546Sopenharmony_civoid 151bf215546Sopenharmony_cisoftpipe_init_rasterizer_funcs(struct pipe_context *pipe); 152bf215546Sopenharmony_ci 153bf215546Sopenharmony_civoid 154bf215546Sopenharmony_cisoftpipe_init_shader_funcs(struct pipe_context *pipe); 155bf215546Sopenharmony_ci 156bf215546Sopenharmony_civoid 157bf215546Sopenharmony_cisoftpipe_init_streamout_funcs(struct pipe_context *pipe); 158bf215546Sopenharmony_ci 159bf215546Sopenharmony_civoid 160bf215546Sopenharmony_cisoftpipe_init_vertex_funcs(struct pipe_context *pipe); 161bf215546Sopenharmony_ci 162bf215546Sopenharmony_civoid 163bf215546Sopenharmony_cisoftpipe_init_image_funcs(struct pipe_context *pipe); 164bf215546Sopenharmony_ci 165bf215546Sopenharmony_civoid 166bf215546Sopenharmony_cisoftpipe_set_framebuffer_state(struct pipe_context *, 167bf215546Sopenharmony_ci const struct pipe_framebuffer_state *); 168bf215546Sopenharmony_ci 169bf215546Sopenharmony_civoid 170bf215546Sopenharmony_cisoftpipe_update_derived(struct softpipe_context *softpipe, unsigned prim); 171bf215546Sopenharmony_ci 172bf215546Sopenharmony_civoid 173bf215546Sopenharmony_cisoftpipe_set_sampler_views(struct pipe_context *pipe, 174bf215546Sopenharmony_ci enum pipe_shader_type shader, 175bf215546Sopenharmony_ci unsigned start, 176bf215546Sopenharmony_ci unsigned num, 177bf215546Sopenharmony_ci unsigned unbind_num_trailing_slots, 178bf215546Sopenharmony_ci bool take_ownership, 179bf215546Sopenharmony_ci struct pipe_sampler_view **views); 180bf215546Sopenharmony_ci 181bf215546Sopenharmony_ci 182bf215546Sopenharmony_civoid 183bf215546Sopenharmony_cisoftpipe_draw_vbo(struct pipe_context *pipe, 184bf215546Sopenharmony_ci const struct pipe_draw_info *info, 185bf215546Sopenharmony_ci unsigned drawid_offset, 186bf215546Sopenharmony_ci const struct pipe_draw_indirect_info *indirect, 187bf215546Sopenharmony_ci const struct pipe_draw_start_count_bias *draws, 188bf215546Sopenharmony_ci unsigned num_draws); 189bf215546Sopenharmony_ci 190bf215546Sopenharmony_civoid 191bf215546Sopenharmony_cisoftpipe_map_texture_surfaces(struct softpipe_context *sp); 192bf215546Sopenharmony_ci 193bf215546Sopenharmony_civoid 194bf215546Sopenharmony_cisoftpipe_unmap_texture_surfaces(struct softpipe_context *sp); 195bf215546Sopenharmony_ci 196bf215546Sopenharmony_ci 197bf215546Sopenharmony_cistruct vertex_info * 198bf215546Sopenharmony_cisoftpipe_get_vbuf_vertex_info(struct softpipe_context *softpipe); 199bf215546Sopenharmony_ci 200bf215546Sopenharmony_ci 201bf215546Sopenharmony_cistruct sp_fragment_shader_variant * 202bf215546Sopenharmony_cisoftpipe_find_fs_variant(struct softpipe_context *softpipe, 203bf215546Sopenharmony_ci struct sp_fragment_shader *fs, 204bf215546Sopenharmony_ci const struct sp_fragment_shader_variant_key *key); 205bf215546Sopenharmony_ci 206bf215546Sopenharmony_civoid 207bf215546Sopenharmony_cisoftpipe_prepare_vertex_sampling(struct softpipe_context *ctx, 208bf215546Sopenharmony_ci unsigned num, 209bf215546Sopenharmony_ci struct pipe_sampler_view **views); 210bf215546Sopenharmony_civoid 211bf215546Sopenharmony_cisoftpipe_cleanup_vertex_sampling(struct softpipe_context *ctx); 212bf215546Sopenharmony_ci 213bf215546Sopenharmony_ci 214bf215546Sopenharmony_civoid 215bf215546Sopenharmony_cisoftpipe_prepare_geometry_sampling(struct softpipe_context *ctx, 216bf215546Sopenharmony_ci unsigned num, 217bf215546Sopenharmony_ci struct pipe_sampler_view **views); 218bf215546Sopenharmony_civoid 219bf215546Sopenharmony_cisoftpipe_cleanup_geometry_sampling(struct softpipe_context *ctx); 220bf215546Sopenharmony_ci 221bf215546Sopenharmony_ci 222bf215546Sopenharmony_civoid 223bf215546Sopenharmony_cisoftpipe_launch_grid(struct pipe_context *context, 224bf215546Sopenharmony_ci const struct pipe_grid_info *info); 225bf215546Sopenharmony_ci 226bf215546Sopenharmony_civoid 227bf215546Sopenharmony_cisoftpipe_update_compute_samplers(struct softpipe_context *softpipe); 228bf215546Sopenharmony_ci#endif 229