st_program.h revision fa7a5898761fc106c9dbef6f640ce4654eae5136
18e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell/**************************************************************************
28e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell *
38e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
48e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * All Rights Reserved.
58e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell *
68e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a
78e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * copy of this software and associated documentation files (the
88e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * "Software"), to deal in the Software without restriction, including
98e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * without limitation the rights to use, copy, modify, merge, publish,
108e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * distribute, sub license, and/or sell copies of the Software, and to
118e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * permit persons to whom the Software is furnished to do so, subject to
128e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * the following conditions:
138e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell *
148e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * The above copyright notice and this permission notice (including the
158e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * next paragraph) shall be included in all copies or substantial portions
168e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * of the Software.
178e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell *
188e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
198e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
208e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
218e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
228e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
238e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
248e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
258e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell *
268e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell **************************************************************************/
278e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
288e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell /*
298e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell  * Authors:
308e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell  *   Keith Whitwell <keith@tungstengraphics.com>
318e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell  */
328e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
338e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
348e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell#ifndef ST_PROGRAM_H
358e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell#define ST_PROGRAM_H
368e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
374824c342c864e870251a7d343c95e51274e50d23Keith Whitwell#include "mtypes.h"
38c89502bb4e6d80182e4977ab084639850e1eba68Keith Whitwell#include "pipe/tgsi/exec/tgsi_token.h"
394fd7bc00f06a98e1db2ad886a13566f19895e3c0michal#include "x86/rtasm/x86sse.h"
404824c342c864e870251a7d343c95e51274e50d23Keith Whitwell
41636480cc9c7836daf879cb45644900922cf31f47Brian
42636480cc9c7836daf879cb45644900922cf31f47Brian#define ST_MAX_SHADER_TOKENS 1024
43636480cc9c7836daf879cb45644900922cf31f47Brian
444824c342c864e870251a7d343c95e51274e50d23Keith Whitwell
45daf5b0f41baa50951e7c2f9ea5cd90b119085a7fZack Rusinstruct cso_fragment_shader;
46daf5b0f41baa50951e7c2f9ea5cd90b119085a7fZack Rusinstruct cso_vertex_shader;
47636480cc9c7836daf879cb45644900922cf31f47Brianstruct translated_vertex_program;
484824c342c864e870251a7d343c95e51274e50d23Keith Whitwell
49636480cc9c7836daf879cb45644900922cf31f47Brian
50636480cc9c7836daf879cb45644900922cf31f47Brian/**
51636480cc9c7836daf879cb45644900922cf31f47Brian * Derived from Mesa gl_fragment_program:
52636480cc9c7836daf879cb45644900922cf31f47Brian */
538e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwellstruct st_fragment_program
548e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell{
558e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell   struct gl_fragment_program Base;
5640c543eb71368c646259afb87d5c76551f6b45b7Brian   GLuint serialNo;
578e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
58636480cc9c7836daf879cb45644900922cf31f47Brian   GLuint input_to_slot[FRAG_ATTRIB_MAX];  /**< Maps FRAG_ATTRIB_x to slot */
59636480cc9c7836daf879cb45644900922cf31f47Brian   GLuint num_input_slots;
60636480cc9c7836daf879cb45644900922cf31f47Brian
61c0dd02219d47f45ce469abbef8044431f6d85d0amichal   /** The program in TGSI format */
62636480cc9c7836daf879cb45644900922cf31f47Brian   struct tgsi_token tokens[ST_MAX_SHADER_TOKENS];
63ccd63b54cfbb6bb241d55f7ac95afcd14819f469Zack Rusin
6437cf13ed9a429c755f121daa1776b1b30a985ab3Brian   /** Pointer to the corresponding cached shader */
65daf5b0f41baa50951e7c2f9ea5cd90b119085a7fZack Rusin   const struct cso_fragment_shader *fs;
6637cf13ed9a429c755f121daa1776b1b30a985ab3Brian
678e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell   GLuint param_state;
68636480cc9c7836daf879cb45644900922cf31f47Brian
69636480cc9c7836daf879cb45644900922cf31f47Brian   /** List of vertex programs which have been translated such that their
70636480cc9c7836daf879cb45644900922cf31f47Brian    * outputs match this fragment program's inputs.
71636480cc9c7836daf879cb45644900922cf31f47Brian    */
72636480cc9c7836daf879cb45644900922cf31f47Brian   struct translated_vertex_program *vertex_programs;
738e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell};
748e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
758e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
76636480cc9c7836daf879cb45644900922cf31f47Brian/**
77636480cc9c7836daf879cb45644900922cf31f47Brian * Derived from Mesa gl_fragment_program:
78636480cc9c7836daf879cb45644900922cf31f47Brian */
794824c342c864e870251a7d343c95e51274e50d23Keith Whitwellstruct st_vertex_program
804824c342c864e870251a7d343c95e51274e50d23Keith Whitwell{
81bb611c5f1f6aec7ac51d4fa3301422b47f6de795Brian   struct gl_vertex_program Base;  /**< The Mesa vertex program */
8240c543eb71368c646259afb87d5c76551f6b45b7Brian   GLuint serialNo;
83bb611c5f1f6aec7ac51d4fa3301422b47f6de795Brian
84bb611c5f1f6aec7ac51d4fa3301422b47f6de795Brian   /** maps a Mesa VERT_ATTRIB_x to a packed TGSI input index */
85fa7a5898761fc106c9dbef6f640ce4654eae5136Brian   GLuint input_to_index[VERT_ATTRIB_MAX];
86bb611c5f1f6aec7ac51d4fa3301422b47f6de795Brian   /** maps a TGSI input index back to a Mesa VERT_ATTRIB_x */
87636480cc9c7836daf879cb45644900922cf31f47Brian   GLuint index_to_input[PIPE_MAX_SHADER_INPUTS];
88bb611c5f1f6aec7ac51d4fa3301422b47f6de795Brian
89bb611c5f1f6aec7ac51d4fa3301422b47f6de795Brian   /** The program in TGSI format */
90636480cc9c7836daf879cb45644900922cf31f47Brian   struct tgsi_token tokens[ST_MAX_SHADER_TOKENS];
914fd7bc00f06a98e1db2ad886a13566f19895e3c0michal
9237cf13ed9a429c755f121daa1776b1b30a985ab3Brian   /** Pointer to the corresponding cached shader */
93daf5b0f41baa50951e7c2f9ea5cd90b119085a7fZack Rusin   const struct cso_vertex_shader *vs;
9437cf13ed9a429c755f121daa1776b1b30a985ab3Brian
954824c342c864e870251a7d343c95e51274e50d23Keith Whitwell   GLuint param_state;
964824c342c864e870251a7d343c95e51274e50d23Keith Whitwell};
974824c342c864e870251a7d343c95e51274e50d23Keith Whitwell
986da9234fd437f97267e7831f034c78b31156d939Brian
9940c543eb71368c646259afb87d5c76551f6b45b7Brianextern void
10040c543eb71368c646259afb87d5c76551f6b45b7Brianst_init_program_functions(struct dd_function_table *functions);
1016da9234fd437f97267e7831f034c78b31156d939Brian
1028e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell
1034824c342c864e870251a7d343c95e51274e50d23Keith Whitwellstatic inline struct st_fragment_program *
1044824c342c864e870251a7d343c95e51274e50d23Keith Whitwellst_fragment_program( struct gl_fragment_program *fp )
1054824c342c864e870251a7d343c95e51274e50d23Keith Whitwell{
1064824c342c864e870251a7d343c95e51274e50d23Keith Whitwell   return (struct st_fragment_program *)fp;
1074824c342c864e870251a7d343c95e51274e50d23Keith Whitwell}
1084824c342c864e870251a7d343c95e51274e50d23Keith Whitwell
10940c543eb71368c646259afb87d5c76551f6b45b7Brian
1104824c342c864e870251a7d343c95e51274e50d23Keith Whitwellstatic inline struct st_vertex_program *
1114824c342c864e870251a7d343c95e51274e50d23Keith Whitwellst_vertex_program( struct gl_vertex_program *vp )
1124824c342c864e870251a7d343c95e51274e50d23Keith Whitwell{
1134824c342c864e870251a7d343c95e51274e50d23Keith Whitwell   return (struct st_vertex_program *)vp;
1144824c342c864e870251a7d343c95e51274e50d23Keith Whitwell}
1154824c342c864e870251a7d343c95e51274e50d23Keith Whitwell
11637cf13ed9a429c755f121daa1776b1b30a985ab3Brian
117daf5b0f41baa50951e7c2f9ea5cd90b119085a7fZack Rusinextern const struct cso_fragment_shader *
11840c543eb71368c646259afb87d5c76551f6b45b7Brianst_translate_fragment_program(struct st_context *st,
11940c543eb71368c646259afb87d5c76551f6b45b7Brian                              struct st_fragment_program *fp,
12040c543eb71368c646259afb87d5c76551f6b45b7Brian                              const GLuint inputMapping[],
12140c543eb71368c646259afb87d5c76551f6b45b7Brian                              struct tgsi_token *tokens,
12240c543eb71368c646259afb87d5c76551f6b45b7Brian                              GLuint maxTokens);
12337cf13ed9a429c755f121daa1776b1b30a985ab3Brian
12437cf13ed9a429c755f121daa1776b1b30a985ab3Brian
125daf5b0f41baa50951e7c2f9ea5cd90b119085a7fZack Rusinextern const struct cso_vertex_shader *
12640c543eb71368c646259afb87d5c76551f6b45b7Brianst_translate_vertex_program(struct st_context *st,
12740c543eb71368c646259afb87d5c76551f6b45b7Brian                            struct st_vertex_program *vp,
12840c543eb71368c646259afb87d5c76551f6b45b7Brian                            const GLuint vert_output_to_slot[],
12940c543eb71368c646259afb87d5c76551f6b45b7Brian                            struct tgsi_token *tokens,
13040c543eb71368c646259afb87d5c76551f6b45b7Brian                            GLuint maxTokens);
13137cf13ed9a429c755f121daa1776b1b30a985ab3Brian
1328e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell#endif
133