i965g: Fix after context transfers
[mesa/mesa-lb.git] / src / gallium / auxiliary / draw / draw_vs.h
blobd095c9bad1d4b563c167b100bc0c6748f4b4ac7c
1 /**************************************************************************
2 *
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 /* Authors: Keith Whitwell <keith@tungstengraphics.com>
31 #ifndef DRAW_VS_H
32 #define DRAW_VS_H
34 #include "draw_context.h"
35 #include "draw_private.h"
38 struct draw_context;
39 struct pipe_shader_state;
41 struct draw_varient_input
43 enum pipe_format format;
44 unsigned buffer;
45 unsigned offset;
46 unsigned instance_divisor;
49 struct draw_varient_output
51 enum pipe_format format; /* output format */
52 unsigned vs_output:8; /* which vertex shader output is this? */
53 unsigned offset:24; /* offset into output vertex */
56 struct draw_varient_element {
57 struct draw_varient_input in;
58 struct draw_varient_output out;
61 struct draw_vs_varient_key {
62 unsigned output_stride;
63 unsigned nr_elements:8; /* max2(nr_inputs, nr_outputs) */
64 unsigned nr_inputs:8;
65 unsigned nr_outputs:8;
66 unsigned viewport:1;
67 unsigned clip:1;
68 unsigned const_vbuffers:5;
69 struct draw_varient_element element[PIPE_MAX_ATTRIBS];
72 struct draw_vs_varient;
75 struct draw_vs_varient {
76 struct draw_vs_varient_key key;
78 struct draw_vertex_shader *vs;
80 void (*set_buffer)( struct draw_vs_varient *,
81 unsigned i,
82 const void *ptr,
83 unsigned stride );
85 void (PIPE_CDECL *run_linear)( struct draw_vs_varient *shader,
86 unsigned start,
87 unsigned count,
88 void *output_buffer );
90 void (PIPE_CDECL *run_elts)( struct draw_vs_varient *shader,
91 const unsigned *elts,
92 unsigned count,
93 void *output_buffer );
95 void (*destroy)( struct draw_vs_varient * );
99 /**
100 * Private version of the compiled vertex_shader
102 struct draw_vertex_shader {
103 struct draw_context *draw;
105 /* This member will disappear shortly:
107 struct pipe_shader_state state;
109 struct tgsi_shader_info info;
110 unsigned position_output;
111 unsigned edgeflag_output;
113 /* Extracted from shader:
115 const float (*immediates)[4];
119 struct draw_vs_varient *varient[16];
120 unsigned nr_varients;
121 unsigned last_varient;
122 struct draw_vs_varient *(*create_varient)( struct draw_vertex_shader *shader,
123 const struct draw_vs_varient_key *key );
126 void (*prepare)( struct draw_vertex_shader *shader,
127 struct draw_context *draw );
129 /* Run the shader - this interface will get cleaned up in the
130 * future:
132 void (*run_linear)( struct draw_vertex_shader *shader,
133 const float (*input)[4],
134 float (*output)[4],
135 const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
136 unsigned count,
137 unsigned input_stride,
138 unsigned output_stride );
141 void (*delete)( struct draw_vertex_shader * );
145 struct draw_vs_varient *
146 draw_vs_lookup_varient( struct draw_vertex_shader *base,
147 const struct draw_vs_varient_key *key );
150 /********************************************************************************
151 * Internal functions:
154 struct draw_vertex_shader *
155 draw_create_vs_exec(struct draw_context *draw,
156 const struct pipe_shader_state *templ);
158 struct draw_vertex_shader *
159 draw_create_vs_sse(struct draw_context *draw,
160 const struct pipe_shader_state *templ);
162 struct draw_vertex_shader *
163 draw_create_vs_ppc(struct draw_context *draw,
164 const struct pipe_shader_state *templ);
166 struct draw_vertex_shader *
167 draw_create_vs_llvm(struct draw_context *draw,
168 const struct pipe_shader_state *templ);
172 struct draw_vs_varient_key;
173 struct draw_vertex_shader;
175 struct draw_vs_varient *draw_vs_varient_aos_sse( struct draw_vertex_shader *vs,
176 const struct draw_vs_varient_key *key );
180 /********************************************************************************
181 * Helpers for vs implementations that don't do their own fetch/emit varients.
182 * Means these can be shared between shaders.
184 struct translate;
185 struct translate_key;
187 struct translate *draw_vs_get_fetch( struct draw_context *draw,
188 struct translate_key *key );
191 struct translate *draw_vs_get_emit( struct draw_context *draw,
192 struct translate_key *key );
194 struct draw_vs_varient *draw_vs_varient_generic( struct draw_vertex_shader *vs,
195 const struct draw_vs_varient_key *key );
199 static INLINE int draw_vs_varient_keysize( const struct draw_vs_varient_key *key )
201 return 2 * sizeof(int) + key->nr_elements * sizeof(struct draw_varient_element);
204 static INLINE int draw_vs_varient_key_compare( const struct draw_vs_varient_key *a,
205 const struct draw_vs_varient_key *b )
207 int keysize = draw_vs_varient_keysize(a);
208 return memcmp(a, b, keysize);
212 struct aos_machine *draw_vs_aos_machine( void );
213 void draw_vs_aos_machine_destroy( struct aos_machine *machine );
215 void
216 draw_vs_aos_machine_constants(struct aos_machine *machine,
217 unsigned slot,
218 const void *constants);
220 void draw_vs_aos_machine_viewport( struct aos_machine *machine,
221 const struct pipe_viewport_state *viewport );
224 #define MAX_TGSI_VERTICES 4
228 #endif