revert 213 commits (to 56092) from the last month. 10 still need work to resolve...
[AROS.git] / workbench / libs / mesa / src / gallium / auxiliary / draw / draw_vs.h
blobe6d187e97742bfe0ee8d18f6c3bd58b98e3cbb33
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"
36 #include "draw_vertex.h"
39 struct draw_context;
40 struct pipe_shader_state;
42 struct draw_variant_input
44 enum pipe_format format;
45 unsigned buffer;
46 unsigned offset;
47 unsigned instance_divisor;
50 struct draw_variant_output
52 enum attrib_emit format; /* output format */
53 unsigned vs_output:8; /* which vertex shader output is this? */
54 unsigned offset:24; /* offset into output vertex */
57 struct draw_variant_element {
58 struct draw_variant_input in;
59 struct draw_variant_output out;
62 struct draw_vs_variant_key {
63 unsigned output_stride;
64 unsigned nr_elements:8; /* max2(nr_inputs, nr_outputs) */
65 unsigned nr_inputs:8;
66 unsigned nr_outputs:8;
67 unsigned viewport:1;
68 unsigned clip:1;
69 unsigned const_vbuffers:5;
70 struct draw_variant_element element[PIPE_MAX_ATTRIBS];
73 struct draw_vs_variant;
76 struct draw_vs_variant {
77 struct draw_vs_variant_key key;
79 struct draw_vertex_shader *vs;
81 void (*set_buffer)( struct draw_vs_variant *,
82 unsigned i,
83 const void *ptr,
84 unsigned stride,
85 unsigned max_stride );
87 void (PIPE_CDECL *run_linear)( struct draw_vs_variant *shader,
88 unsigned start,
89 unsigned count,
90 void *output_buffer );
92 void (PIPE_CDECL *run_elts)( struct draw_vs_variant *shader,
93 const unsigned *elts,
94 unsigned count,
95 void *output_buffer );
97 void (*destroy)( struct draw_vs_variant * );
102 * Private version of the compiled vertex_shader
104 struct draw_vertex_shader {
105 struct draw_context *draw;
107 /* This member will disappear shortly:
109 struct pipe_shader_state state;
111 struct tgsi_shader_info info;
112 unsigned position_output;
113 unsigned edgeflag_output;
115 /* Extracted from shader:
117 const float (*immediates)[4];
121 struct draw_vs_variant *variant[16];
122 unsigned nr_variants;
123 unsigned last_variant;
124 struct draw_vs_variant *(*create_variant)( struct draw_vertex_shader *shader,
125 const struct draw_vs_variant_key *key );
128 void (*prepare)( struct draw_vertex_shader *shader,
129 struct draw_context *draw );
131 /* Run the shader - this interface will get cleaned up in the
132 * future:
134 void (*run_linear)( struct draw_vertex_shader *shader,
135 const float (*input)[4],
136 float (*output)[4],
137 const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
138 const unsigned const_size[PIPE_MAX_CONSTANT_BUFFERS],
139 unsigned count,
140 unsigned input_stride,
141 unsigned output_stride );
144 void (*delete)( struct draw_vertex_shader * );
148 struct draw_vs_variant *
149 draw_vs_lookup_variant( struct draw_vertex_shader *base,
150 const struct draw_vs_variant_key *key );
153 /********************************************************************************
154 * Internal functions:
157 struct draw_vertex_shader *
158 draw_create_vs_exec(struct draw_context *draw,
159 const struct pipe_shader_state *templ);
161 struct draw_vertex_shader *
162 draw_create_vs_sse(struct draw_context *draw,
163 const struct pipe_shader_state *templ);
165 struct draw_vertex_shader *
166 draw_create_vs_ppc(struct draw_context *draw,
167 const struct pipe_shader_state *templ);
170 struct draw_vs_variant_key;
171 struct draw_vertex_shader;
173 struct draw_vs_variant *
174 draw_vs_create_variant_aos_sse( struct draw_vertex_shader *vs,
175 const struct draw_vs_variant_key *key );
177 #if HAVE_LLVM
178 struct draw_vertex_shader *
179 draw_create_vs_llvm(struct draw_context *draw,
180 const struct pipe_shader_state *state);
181 #endif
184 /********************************************************************************
185 * Helpers for vs implementations that don't do their own fetch/emit variants.
186 * Means these can be shared between shaders.
188 struct translate;
189 struct translate_key;
191 struct translate *draw_vs_get_fetch( struct draw_context *draw,
192 struct translate_key *key );
195 struct translate *draw_vs_get_emit( struct draw_context *draw,
196 struct translate_key *key );
198 struct draw_vs_variant *
199 draw_vs_create_variant_generic( struct draw_vertex_shader *vs,
200 const struct draw_vs_variant_key *key );
204 static INLINE int draw_vs_variant_keysize( const struct draw_vs_variant_key *key )
206 return 2 * sizeof(int) + key->nr_elements * sizeof(struct draw_variant_element);
209 static INLINE int draw_vs_variant_key_compare( const struct draw_vs_variant_key *a,
210 const struct draw_vs_variant_key *b )
212 int keysize = draw_vs_variant_keysize(a);
213 return memcmp(a, b, keysize);
217 struct aos_machine *draw_vs_aos_machine( void );
218 void draw_vs_aos_machine_destroy( struct aos_machine *machine );
220 void
221 draw_vs_aos_machine_constants(struct aos_machine *machine,
222 unsigned slot,
223 const void *constants);
225 void draw_vs_aos_machine_viewport( struct aos_machine *machine,
226 const struct pipe_viewport_state *viewport );
229 #define MAX_TGSI_VERTICES 4
233 #endif