st_program.h revision daf5b0f41baa50951e7c2f9ea5cd90b119085a7f
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 414824c342c864e870251a7d343c95e51274e50d23Keith Whitwell#define ST_FP_MAX_TOKENS 1024 424824c342c864e870251a7d343c95e51274e50d23Keith Whitwell 43daf5b0f41baa50951e7c2f9ea5cd90b119085a7fZack Rusinstruct cso_fragment_shader; 44daf5b0f41baa50951e7c2f9ea5cd90b119085a7fZack Rusinstruct cso_vertex_shader; 454824c342c864e870251a7d343c95e51274e50d23Keith Whitwell 468e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwellstruct st_fragment_program 478e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell{ 488e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell struct gl_fragment_program Base; 498e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell GLboolean error; /* If program is malformed for any reason. */ 5037cf13ed9a429c755f121daa1776b1b30a985ab3Brian GLuint id; /**< String id, for tracking ProgramStringNotify changes. */ 518e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 524824c342c864e870251a7d343c95e51274e50d23Keith Whitwell 534824c342c864e870251a7d343c95e51274e50d23Keith Whitwell struct tgsi_token tokens[ST_FP_MAX_TOKENS]; 544824c342c864e870251a7d343c95e51274e50d23Keith Whitwell GLboolean dirty; 55ccd63b54cfbb6bb241d55f7ac95afcd14819f469Zack Rusin 5637cf13ed9a429c755f121daa1776b1b30a985ab3Brian /** Pointer to the corresponding cached shader */ 57daf5b0f41baa50951e7c2f9ea5cd90b119085a7fZack Rusin const struct cso_fragment_shader *fs; 5837cf13ed9a429c755f121daa1776b1b30a985ab3Brian 598e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell GLuint param_state; 608e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell}; 618e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 628e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 634824c342c864e870251a7d343c95e51274e50d23Keith Whitwellstruct st_vertex_program 644824c342c864e870251a7d343c95e51274e50d23Keith Whitwell{ 65bb611c5f1f6aec7ac51d4fa3301422b47f6de795Brian struct gl_vertex_program Base; /**< The Mesa vertex program */ 66bb611c5f1f6aec7ac51d4fa3301422b47f6de795Brian GLboolean error; /**< Set if program is malformed for any reason. */ 6737cf13ed9a429c755f121daa1776b1b30a985ab3Brian GLuint id; /**< String id, for tracking ProgramStringNotify changes. */ 68bb611c5f1f6aec7ac51d4fa3301422b47f6de795Brian 69bb611c5f1f6aec7ac51d4fa3301422b47f6de795Brian /** maps a Mesa VERT_ATTRIB_x to a packed TGSI input index */ 70bb611c5f1f6aec7ac51d4fa3301422b47f6de795Brian GLuint input_to_index[MAX_VERTEX_PROGRAM_ATTRIBS]; 71bb611c5f1f6aec7ac51d4fa3301422b47f6de795Brian /** maps a TGSI input index back to a Mesa VERT_ATTRIB_x */ 72bb611c5f1f6aec7ac51d4fa3301422b47f6de795Brian GLuint index_to_input[MAX_VERTEX_PROGRAM_ATTRIBS]; 73bb611c5f1f6aec7ac51d4fa3301422b47f6de795Brian 7437cf13ed9a429c755f121daa1776b1b30a985ab3Brian#if 0 75bb611c5f1f6aec7ac51d4fa3301422b47f6de795Brian GLuint output_to_index[MAX_VERTEX_PROGRAM_ATTRIBS]; 76bb611c5f1f6aec7ac51d4fa3301422b47f6de795Brian GLuint index_to_output[MAX_VERTEX_PROGRAM_ATTRIBS]; 7737cf13ed9a429c755f121daa1776b1b30a985ab3Brian#endif 784824c342c864e870251a7d343c95e51274e50d23Keith Whitwell 79bb611c5f1f6aec7ac51d4fa3301422b47f6de795Brian /** The program in TGSI format */ 80de653b4c9bddcec46f3ddf411ec082dd178d7b38Brian struct tgsi_token tokens[ST_FP_MAX_TOKENS]; 814824c342c864e870251a7d343c95e51274e50d23Keith Whitwell GLboolean dirty; 824fd7bc00f06a98e1db2ad886a13566f19895e3c0michal 834fd7bc00f06a98e1db2ad886a13566f19895e3c0michal#if defined(USE_X86_ASM) || defined(SLANG_X86) 844fd7bc00f06a98e1db2ad886a13566f19895e3c0michal struct x86_function sse2_program; 854fd7bc00f06a98e1db2ad886a13566f19895e3c0michal#endif 864fd7bc00f06a98e1db2ad886a13566f19895e3c0michal 8737cf13ed9a429c755f121daa1776b1b30a985ab3Brian /** Pointer to the corresponding cached shader */ 88daf5b0f41baa50951e7c2f9ea5cd90b119085a7fZack Rusin const struct cso_vertex_shader *vs; 8937cf13ed9a429c755f121daa1776b1b30a985ab3Brian 904824c342c864e870251a7d343c95e51274e50d23Keith Whitwell GLuint param_state; 914824c342c864e870251a7d343c95e51274e50d23Keith Whitwell}; 924824c342c864e870251a7d343c95e51274e50d23Keith Whitwell 936da9234fd437f97267e7831f034c78b31156d939Brian 946da9234fd437f97267e7831f034c78b31156d939Brianextern void st_init_program_functions(struct dd_function_table *functions); 956da9234fd437f97267e7831f034c78b31156d939Brian 968e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 974824c342c864e870251a7d343c95e51274e50d23Keith Whitwellstatic inline struct st_fragment_program * 984824c342c864e870251a7d343c95e51274e50d23Keith Whitwellst_fragment_program( struct gl_fragment_program *fp ) 994824c342c864e870251a7d343c95e51274e50d23Keith Whitwell{ 1004824c342c864e870251a7d343c95e51274e50d23Keith Whitwell return (struct st_fragment_program *)fp; 1014824c342c864e870251a7d343c95e51274e50d23Keith Whitwell} 1024824c342c864e870251a7d343c95e51274e50d23Keith Whitwell 1034824c342c864e870251a7d343c95e51274e50d23Keith Whitwellstatic inline struct st_vertex_program * 1044824c342c864e870251a7d343c95e51274e50d23Keith Whitwellst_vertex_program( struct gl_vertex_program *vp ) 1054824c342c864e870251a7d343c95e51274e50d23Keith Whitwell{ 1064824c342c864e870251a7d343c95e51274e50d23Keith Whitwell return (struct st_vertex_program *)vp; 1074824c342c864e870251a7d343c95e51274e50d23Keith Whitwell} 1084824c342c864e870251a7d343c95e51274e50d23Keith Whitwell 10937cf13ed9a429c755f121daa1776b1b30a985ab3Brian 110daf5b0f41baa50951e7c2f9ea5cd90b119085a7fZack Rusinextern const struct cso_fragment_shader * 11137cf13ed9a429c755f121daa1776b1b30a985ab3Brianst_translate_fragment_shader(struct st_context *st, 11237cf13ed9a429c755f121daa1776b1b30a985ab3Brian struct st_fragment_program *fp); 11337cf13ed9a429c755f121daa1776b1b30a985ab3Brian 11437cf13ed9a429c755f121daa1776b1b30a985ab3Brian 115daf5b0f41baa50951e7c2f9ea5cd90b119085a7fZack Rusinextern const struct cso_vertex_shader * 11637cf13ed9a429c755f121daa1776b1b30a985ab3Brianst_translate_vertex_shader(struct st_context *st, 11737cf13ed9a429c755f121daa1776b1b30a985ab3Brian struct st_vertex_program *vp); 11837cf13ed9a429c755f121daa1776b1b30a985ab3Brian 11937cf13ed9a429c755f121daa1776b1b30a985ab3Brian 1208e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell#endif 121