blob: 5f7a645f5d8496a8cc99868b64fdde4e93429560 [file] [log] [blame]
Keith Whitwellb29d8d22008-02-15 13:37:01 +00001/**************************************************************************
Zack Rusinaeae5762008-05-15 12:17:46 -04002 *
Keith Whitwellb29d8d22008-02-15 13:37:01 +00003 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
Zack Rusinaeae5762008-05-15 12:17:46 -04005 *
Keith Whitwellb29d8d22008-02-15 13:37:01 +00006 * 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:
Zack Rusinaeae5762008-05-15 12:17:46 -040013 *
Keith Whitwellb29d8d22008-02-15 13:37:01 +000014 * 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.
Zack Rusinaeae5762008-05-15 12:17:46 -040017 *
Keith Whitwellb29d8d22008-02-15 13:37:01 +000018 * 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.
Zack Rusinaeae5762008-05-15 12:17:46 -040025 *
Keith Whitwellb29d8d22008-02-15 13:37:01 +000026 **************************************************************************/
27
28 /*
29 * Authors:
30 * Zack Rusin
31 * Keith Whitwell <keith@tungstengraphics.com>
32 * Brian Paul
33 */
34
Stephane Marchesin3f477e12008-09-28 18:33:23 +020035#include "util/u_memory.h"
Keith Whitwellb29d8d22008-02-15 13:37:01 +000036#include "pipe/p_shader_tokens.h"
37#include "draw_private.h"
38#include "draw_context.h"
39#include "draw_vs.h"
40
José Fonsecac208a2c2008-07-28 12:42:13 +090041#include "tgsi/tgsi_parse.h"
Brianae146e42008-03-24 16:31:15 -060042
Keith Whitwellb29d8d22008-02-15 13:37:01 +000043#ifdef MESA_LLVM
44
Keith Whitwellb29d8d22008-02-15 13:37:01 +000045struct draw_llvm_vertex_shader {
46 struct draw_vertex_shader base;
Keith Whitwella773f062008-04-17 23:44:32 +010047 struct tgsi_exec_machine *machine;
Keith Whitwellb29d8d22008-02-15 13:37:01 +000048};
49
50
Keith Whitwellb29d8d22008-02-15 13:37:01 +000051static void
52vs_llvm_prepare( struct draw_vertex_shader *base,
53 struct draw_context *draw )
54{
Keith Whitwellb29d8d22008-02-15 13:37:01 +000055}
56
57
Keith Whitwell280bcff2008-04-17 14:20:00 +010058static void
59vs_llvm_run_linear( struct draw_vertex_shader *base,
60 const float (*input)[4],
61 float (*output)[4],
Michal Krol7c5f2552010-01-25 13:29:33 +010062 const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
Keith Whitwell280bcff2008-04-17 14:20:00 +010063 unsigned count,
64 unsigned input_stride,
65 unsigned output_stride )
66{
67 struct draw_llvm_vertex_shader *shader =
68 (struct draw_llvm_vertex_shader *)base;
Keith Whitwell280bcff2008-04-17 14:20:00 +010069}
70
71
72
Keith Whitwellb29d8d22008-02-15 13:37:01 +000073static void
74vs_llvm_delete( struct draw_vertex_shader *base )
75{
Zack Rusinaeae5762008-05-15 12:17:46 -040076 struct draw_llvm_vertex_shader *shader =
Keith Whitwellb29d8d22008-02-15 13:37:01 +000077 (struct draw_llvm_vertex_shader *)base;
78
79 /* Do something to free compiled shader:
80 */
81
Brianae146e42008-03-24 16:31:15 -060082 FREE( (void*) shader->base.state.tokens );
Keith Whitwellb29d8d22008-02-15 13:37:01 +000083 FREE( shader );
84}
85
86
87
88
89struct draw_vertex_shader *
90draw_create_vs_llvm(struct draw_context *draw,
91 const struct pipe_shader_state *templ)
92{
93 struct draw_llvm_vertex_shader *vs;
94
95 vs = CALLOC_STRUCT( draw_llvm_vertex_shader );
Zack Rusinaeae5762008-05-15 12:17:46 -040096 if (vs == NULL)
Keith Whitwellb29d8d22008-02-15 13:37:01 +000097 return NULL;
98
Brianae146e42008-03-24 16:31:15 -060099 /* we make a private copy of the tokens */
Brian Paul9671f7a2008-05-17 10:30:21 -0600100 vs->base.state.tokens = tgsi_dup_tokens(templ->tokens);
101 if (!vs->base.state.tokens) {
102 FREE(vs);
103 return NULL;
104 }
Keith Whitwell280bcff2008-04-17 14:20:00 +0100105
Zack Rusin201ac412008-04-21 00:10:39 -0400106 tgsi_scan_shader(vs->base.state.tokens, &vs->base.info);
Keith Whitwell280bcff2008-04-17 14:20:00 +0100107
Keith Whitwell7c99d7f2008-05-15 12:39:08 +0100108 vs->base.draw = draw;
Keith Whitwellb29d8d22008-02-15 13:37:01 +0000109 vs->base.prepare = vs_llvm_prepare;
Keith Whitwell7c99d7f2008-05-15 12:39:08 +0100110 vs->base.create_varient = draw_vs_varient_generic;
Keith Whitwell280bcff2008-04-17 14:20:00 +0100111 vs->base.run_linear = vs_llvm_run_linear;
Keith Whitwellb29d8d22008-02-15 13:37:01 +0000112 vs->base.delete = vs_llvm_delete;
Keith Whitwellaa99a762009-07-23 18:48:04 +0100113 vs->machine = draw->vs.machine;
Keith Whitwellb29d8d22008-02-15 13:37:01 +0000114
Keith Whitwellb29d8d22008-02-15 13:37:01 +0000115 return &vs->base;
116}
117
118
119
120
121
122#else
123
124struct draw_vertex_shader *
125draw_create_vs_llvm(struct draw_context *draw,
126 const struct pipe_shader_state *shader)
127{
128 return NULL;
129}
130
131#endif