14a49301eSmrg/**************************************************************************
24a49301eSmrg *
3af69d88dSmrg * Copyright 2007 VMware, Inc.
44a49301eSmrg * All Rights Reserved.
54a49301eSmrg *
64a49301eSmrg * Permission is hereby granted, free of charge, to any person obtaining a
74a49301eSmrg * copy of this software and associated documentation files (the
84a49301eSmrg * "Software"), to deal in the Software without restriction, including
94a49301eSmrg * without limitation the rights to use, copy, modify, merge, publish,
104a49301eSmrg * distribute, sub license, and/or sell copies of the Software, and to
114a49301eSmrg * permit persons to whom the Software is furnished to do so, subject to
124a49301eSmrg * the following conditions:
134a49301eSmrg *
144a49301eSmrg * The above copyright notice and this permission notice (including the
154a49301eSmrg * next paragraph) shall be included in all copies or substantial portions
164a49301eSmrg * of the Software.
174a49301eSmrg *
184a49301eSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
194a49301eSmrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
204a49301eSmrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21af69d88dSmrg * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
224a49301eSmrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
234a49301eSmrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
244a49301eSmrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
254a49301eSmrg *
264a49301eSmrg **************************************************************************/
274a49301eSmrg
28af69d88dSmrg/* Authors:  Keith Whitwell <keithw@vmware.com>
294a49301eSmrg */
304a49301eSmrg
314a49301eSmrg#ifndef SP_STATE_H
324a49301eSmrg#define SP_STATE_H
334a49301eSmrg
344a49301eSmrg#include "pipe/p_state.h"
354a49301eSmrg#include "tgsi/tgsi_scan.h"
364a49301eSmrg
374a49301eSmrg
384a49301eSmrg#define SP_NEW_VIEWPORT      0x1
394a49301eSmrg#define SP_NEW_RASTERIZER    0x2
404a49301eSmrg#define SP_NEW_FS            0x4
414a49301eSmrg#define SP_NEW_BLEND         0x8
424a49301eSmrg#define SP_NEW_CLIP          0x10
434a49301eSmrg#define SP_NEW_SCISSOR       0x20
444a49301eSmrg#define SP_NEW_STIPPLE       0x40
454a49301eSmrg#define SP_NEW_FRAMEBUFFER   0x80
464a49301eSmrg#define SP_NEW_DEPTH_STENCIL_ALPHA 0x100
474a49301eSmrg#define SP_NEW_CONSTANTS     0x200
484a49301eSmrg#define SP_NEW_SAMPLER       0x400
494a49301eSmrg#define SP_NEW_TEXTURE       0x800
504a49301eSmrg#define SP_NEW_VERTEX        0x1000
514a49301eSmrg#define SP_NEW_VS            0x2000
524a49301eSmrg#define SP_NEW_QUERY         0x4000
53cdc920a0Smrg#define SP_NEW_GS            0x8000
543464ebd5Sriastradh#define SP_NEW_SO            0x10000
553464ebd5Sriastradh#define SP_NEW_SO_BUFFERS    0x20000
564a49301eSmrg
574a49301eSmrg
584a49301eSmrgstruct tgsi_sampler;
5901e04c3fSmrgstruct tgsi_image;
6001e04c3fSmrgstruct tgsi_buffer;
614a49301eSmrgstruct tgsi_exec_machine;
624a49301eSmrgstruct vertex_info;
634a49301eSmrg
644a49301eSmrg
65af69d88dSmrgstruct sp_fragment_shader_variant_key
66af69d88dSmrg{
67af69d88dSmrg   boolean polygon_stipple;
68af69d88dSmrg};
69af69d88dSmrg
704a49301eSmrg
71af69d88dSmrgstruct sp_fragment_shader_variant
72af69d88dSmrg{
73af69d88dSmrg   const struct tgsi_token *tokens;
74af69d88dSmrg   struct sp_fragment_shader_variant_key key;
754a49301eSmrg   struct tgsi_shader_info info;
764a49301eSmrg
77af69d88dSmrg   unsigned stipple_sampler_unit;
78af69d88dSmrg
79af69d88dSmrg   /* See comments about this elsewhere */
80af69d88dSmrg#if 0
813464ebd5Sriastradh   struct draw_fragment_shader *draw_shader;
82af69d88dSmrg#endif
83af69d88dSmrg
84af69d88dSmrg   void (*prepare)(const struct sp_fragment_shader_variant *shader,
85af69d88dSmrg		   struct tgsi_exec_machine *machine,
8601e04c3fSmrg		   struct tgsi_sampler *sampler,
8701e04c3fSmrg		   struct tgsi_image *image,
8801e04c3fSmrg		   struct tgsi_buffer *buffer);
89af69d88dSmrg
90af69d88dSmrg   unsigned (*run)(const struct sp_fragment_shader_variant *shader,
91af69d88dSmrg		   struct tgsi_exec_machine *machine,
9201e04c3fSmrg		   struct quad_header *quad,
9301e04c3fSmrg		   bool early_depth_test);
943464ebd5Sriastradh
95af69d88dSmrg   /* Deletes this instance of the object */
96af69d88dSmrg   void (*delete)(struct sp_fragment_shader_variant *shader,
97af69d88dSmrg                  struct tgsi_exec_machine *machine);
984a49301eSmrg
99af69d88dSmrg   struct sp_fragment_shader_variant *next;
100af69d88dSmrg};
1014a49301eSmrg
1024a49301eSmrg
103af69d88dSmrg/** Subclass of pipe_shader_state */
104af69d88dSmrgstruct sp_fragment_shader {
105af69d88dSmrg   struct pipe_shader_state shader;
106af69d88dSmrg   struct sp_fragment_shader_variant *variants;
107af69d88dSmrg   struct draw_fragment_shader *draw_shader;
1084a49301eSmrg};
1094a49301eSmrg
1104a49301eSmrg
1114a49301eSmrg/** Subclass of pipe_shader_state */
1124a49301eSmrgstruct sp_vertex_shader {
1134a49301eSmrg   struct pipe_shader_state shader;
1144a49301eSmrg   struct draw_vertex_shader *draw_data;
1154a49301eSmrg   int max_sampler;             /* -1 if no samplers */
1164a49301eSmrg};
1174a49301eSmrg
118cdc920a0Smrg/** Subclass of pipe_shader_state */
119cdc920a0Smrgstruct sp_geometry_shader {
120cdc920a0Smrg   struct pipe_shader_state shader;
121cdc920a0Smrg   struct draw_geometry_shader *draw_data;
1223464ebd5Sriastradh   int max_sampler;
1233464ebd5Sriastradh};
1243464ebd5Sriastradh
1253464ebd5Sriastradhstruct sp_velems_state {
1263464ebd5Sriastradh   unsigned count;
1273464ebd5Sriastradh   struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS];
128cdc920a0Smrg};
1294a49301eSmrg
1303464ebd5Sriastradhstruct sp_so_state {
131af69d88dSmrg   struct pipe_stream_output_info base;
1323464ebd5Sriastradh};
1334a49301eSmrg
13401e04c3fSmrg/** Subclass of pipe_compute_state */
13501e04c3fSmrgstruct sp_compute_shader {
13601e04c3fSmrg   struct pipe_compute_state shader;
13701e04c3fSmrg   struct tgsi_token *tokens;
13801e04c3fSmrg   struct tgsi_shader_info info;
13901e04c3fSmrg   int max_sampler;             /* -1 if no samplers */
14001e04c3fSmrg};
1414a49301eSmrg
142cdc920a0Smrgvoid
1433464ebd5Sriastradhsoftpipe_init_blend_funcs(struct pipe_context *pipe);
1444a49301eSmrg
145cdc920a0Smrgvoid
1463464ebd5Sriastradhsoftpipe_init_clip_funcs(struct pipe_context *pipe);
1474a49301eSmrg
1483464ebd5Sriastradhvoid
1493464ebd5Sriastradhsoftpipe_init_sampler_funcs(struct pipe_context *pipe);
1504a49301eSmrg
1513464ebd5Sriastradhvoid
1523464ebd5Sriastradhsoftpipe_init_rasterizer_funcs(struct pipe_context *pipe);
1534a49301eSmrg
1543464ebd5Sriastradhvoid
1553464ebd5Sriastradhsoftpipe_init_shader_funcs(struct pipe_context *pipe);
1564a49301eSmrg
1573464ebd5Sriastradhvoid
1583464ebd5Sriastradhsoftpipe_init_streamout_funcs(struct pipe_context *pipe);
1594a49301eSmrg
1603464ebd5Sriastradhvoid
1613464ebd5Sriastradhsoftpipe_init_vertex_funcs(struct pipe_context *pipe);
1624a49301eSmrg
16301e04c3fSmrgvoid
16401e04c3fSmrgsoftpipe_init_image_funcs(struct pipe_context *pipe);
16501e04c3fSmrg
1663464ebd5Sriastradhvoid
1673464ebd5Sriastradhsoftpipe_set_framebuffer_state(struct pipe_context *,
1683464ebd5Sriastradh                               const struct pipe_framebuffer_state *);
1694a49301eSmrg
170cdc920a0Smrgvoid
171af69d88dSmrgsoftpipe_update_derived(struct softpipe_context *softpipe, unsigned prim);
1724a49301eSmrg
1734a49301eSmrgvoid
174af69d88dSmrgsoftpipe_set_sampler_views(struct pipe_context *pipe,
17501e04c3fSmrg                           enum pipe_shader_type shader,
176af69d88dSmrg                           unsigned start,
177af69d88dSmrg                           unsigned num,
1787ec681f3Smrg                           unsigned unbind_num_trailing_slots,
1797ec681f3Smrg                           bool take_ownership,
180af69d88dSmrg                           struct pipe_sampler_view **views);
1814a49301eSmrg
1824a49301eSmrg
1834a49301eSmrgvoid
184af69d88dSmrgsoftpipe_draw_vbo(struct pipe_context *pipe,
1857ec681f3Smrg                  const struct pipe_draw_info *info,
1867ec681f3Smrg                  unsigned drawid_offset,
1877ec681f3Smrg                  const struct pipe_draw_indirect_info *indirect,
1887ec681f3Smrg                  const struct pipe_draw_start_count_bias *draws,
1897ec681f3Smrg                  unsigned num_draws);
1904a49301eSmrg
1914a49301eSmrgvoid
1924a49301eSmrgsoftpipe_map_texture_surfaces(struct softpipe_context *sp);
1934a49301eSmrg
1944a49301eSmrgvoid
1954a49301eSmrgsoftpipe_unmap_texture_surfaces(struct softpipe_context *sp);
1964a49301eSmrg
1974a49301eSmrg
1984a49301eSmrgstruct vertex_info *
1994a49301eSmrgsoftpipe_get_vbuf_vertex_info(struct softpipe_context *softpipe);
2004a49301eSmrg
2014a49301eSmrg
202af69d88dSmrgstruct sp_fragment_shader_variant *
203af69d88dSmrgsoftpipe_find_fs_variant(struct softpipe_context *softpipe,
204af69d88dSmrg                         struct sp_fragment_shader *fs,
205af69d88dSmrg                         const struct sp_fragment_shader_variant_key *key);
206af69d88dSmrg
207af69d88dSmrg
208af69d88dSmrgstruct sp_fragment_shader_variant *
209af69d88dSmrgsoftpipe_find_fs_variant(struct softpipe_context *softpipe,
210af69d88dSmrg                         struct sp_fragment_shader *fs,
211af69d88dSmrg                         const struct sp_fragment_shader_variant_key *key);
212af69d88dSmrg
21301e04c3fSmrgvoid
21401e04c3fSmrgsoftpipe_prepare_vertex_sampling(struct softpipe_context *ctx,
21501e04c3fSmrg                                 unsigned num,
21601e04c3fSmrg                                 struct pipe_sampler_view **views);
21701e04c3fSmrgvoid
21801e04c3fSmrgsoftpipe_cleanup_vertex_sampling(struct softpipe_context *ctx);
219af69d88dSmrg
22001e04c3fSmrg
22101e04c3fSmrgvoid
22201e04c3fSmrgsoftpipe_prepare_geometry_sampling(struct softpipe_context *ctx,
22301e04c3fSmrg                                   unsigned num,
22401e04c3fSmrg                                   struct pipe_sampler_view **views);
22501e04c3fSmrgvoid
22601e04c3fSmrgsoftpipe_cleanup_geometry_sampling(struct softpipe_context *ctx);
22701e04c3fSmrg
22801e04c3fSmrg
22901e04c3fSmrgvoid
23001e04c3fSmrgsoftpipe_launch_grid(struct pipe_context *context,
23101e04c3fSmrg                     const struct pipe_grid_info *info);
23201e04c3fSmrg
23301e04c3fSmrgvoid
23401e04c3fSmrgsoftpipe_update_compute_samplers(struct softpipe_context *softpipe);
2354a49301eSmrg#endif
236