1 /**************************************************************************
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
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
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 **************************************************************************/
30 * Simple vertex/fragment shader generators.
36 #include "pipe/p_context.h"
37 #include "pipe/p_shader_tokens.h"
38 #include "util/u_simple_shaders.h"
39 #include "tgsi/tgsi_ureg.h"
44 * Make simple vertex pass-through shader.
47 util_make_vertex_passthrough_shader(struct pipe_context
*pipe
,
49 const uint
*semantic_names
,
50 const uint
*semantic_indexes
)
53 struct ureg_program
*ureg
;
56 ureg
= ureg_create( TGSI_PROCESSOR_VERTEX
);
60 for (i
= 0; i
< num_attribs
; i
++) {
64 src
= ureg_DECL_vs_input( ureg
, i
);
66 dst
= ureg_DECL_output( ureg
,
70 ureg_MOV( ureg
, dst
, src
);
75 return ureg_create_shader_and_destroy( ureg
, pipe
);
82 * Make simple fragment texture shader:
83 * IMM {0,0,0,1} // (if writemask != 0xf)
84 * MOV OUT[0], IMM[0] // (if writemask != 0xf)
85 * TEX OUT[0].writemask, IN[0], SAMP[0], 2D;
89 util_make_fragment_tex_shader_writemask(struct pipe_context
*pipe
,
92 struct ureg_program
*ureg
;
93 struct ureg_src sampler
;
97 ureg
= ureg_create( TGSI_PROCESSOR_FRAGMENT
);
101 sampler
= ureg_DECL_sampler( ureg
, 0 );
103 tex
= ureg_DECL_fs_input( ureg
,
104 TGSI_SEMANTIC_GENERIC
, 0,
105 TGSI_INTERPOLATE_PERSPECTIVE
);
107 out
= ureg_DECL_output( ureg
,
111 ureg_TEX( ureg
, out
, TGSI_TEXTURE_2D
, tex
, sampler
);
114 return ureg_create_shader_and_destroy( ureg
, pipe
);
118 util_make_fragment_tex_shader(struct pipe_context
*pipe
)
120 return util_make_fragment_tex_shader_writemask( pipe
,
121 TGSI_WRITEMASK_XYZW
);
127 * Make simple fragment color pass-through shader.
130 util_make_fragment_passthrough_shader(struct pipe_context
*pipe
)
132 struct ureg_program
*ureg
;
136 ureg
= ureg_create( TGSI_PROCESSOR_FRAGMENT
);
140 src
= ureg_DECL_fs_input( ureg
, TGSI_SEMANTIC_COLOR
, 0,
141 TGSI_INTERPOLATE_PERSPECTIVE
);
143 dst
= ureg_DECL_output( ureg
, TGSI_SEMANTIC_COLOR
, 0 );
145 ureg_MOV( ureg
, dst
, src
);
148 return ureg_create_shader_and_destroy( ureg
, pipe
);