1 /**************************************************************************
3 * Copyright 2003 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 **************************************************************************/
29 * Keith Whitwell <keith@tungstengraphics.com>
32 #include "shader/prog_parameter.h"
34 #include "pipe/p_context.h"
35 #include "pipe/p_defines.h"
36 #include "pipe/p_winsys.h"
37 #include "pipe/tgsi/mesa/mesa_to_tgsi.h"
38 #include "pipe/tgsi/exec/tgsi_dump.h"
40 #include "st_context.h"
42 #include "st_program.h"
46 static void compile_fs( struct st_context
*st
)
48 struct st_fragment_program
*fp
= st
->fp
;
50 /* XXX: fix static allocation of tokens:
52 tgsi_mesa_compile_fp_program( &fp
->Base
, fp
->tokens
, ST_FP_MAX_TOKENS
);
55 = tgsi_mesa_translate_vertex_input_mask(fp
->Base
.Base
.InputsRead
);
56 fp
->fs
.outputs_written
57 = tgsi_mesa_translate_vertex_output_mask(fp
->Base
.Base
.OutputsWritten
);
58 fp
->fs
.tokens
= &fp
->tokens
[0];
61 tgsi_dump( fp
->tokens
, TGSI_DUMP_VERBOSE
);
68 static void update_fs( struct st_context
*st
)
70 struct st_fragment_program
*fp
= NULL
;
72 /* find active shader and params. Changes to this Mesa state
73 * should be covered by ST_NEW_FRAGMENT_PROGRAM, thanks to the
74 * logic in st_cb_program.c
76 if (st
->ctx
->Shader
.CurrentProgram
&&
77 st
->ctx
->Shader
.CurrentProgram
->LinkStatus
&&
78 st
->ctx
->Shader
.CurrentProgram
->FragmentProgram
) {
79 struct gl_fragment_program
*f
80 = st
->ctx
->Shader
.CurrentProgram
->FragmentProgram
;
81 fp
= st_fragment_program(f
);
84 assert(st
->ctx
->FragmentProgram
._Current
);
85 fp
= st_fragment_program(st
->ctx
->FragmentProgram
._Current
);
88 /* translate shader to TGSI format */
89 if (st
->fp
!= fp
|| fp
->dirty
) {
95 st
->state
.fs
= fp
->fs
;
96 st
->pipe
->set_fs_state(st
->pipe
, &st
->state
.fs
);
101 const struct st_tracked_state st_update_fs
= {
104 .st
= ST_NEW_FRAGMENT_PROGRAM
,