14a49301eSmrg/************************************************************************** 24a49301eSmrg * 3af69d88dSmrg * Copyright 2007 VMware, Inc. 44a49301eSmrg * All Rights Reserved. 54a49301eSmrg * 64a49301eSmrg * Permission is hereby granted, free of charge, to any person obtaining a 74a49301eSmrg * copy of this software and associated documentation files (the 84a49301eSmrg * "Software"), to deal in the Software without restriction, including 94a49301eSmrg * without limitation the rights to use, copy, modify, merge, publish, 104a49301eSmrg * distribute, sub license, and/or sell copies of the Software, and to 114a49301eSmrg * permit persons to whom the Software is furnished to do so, subject to 124a49301eSmrg * the following conditions: 134a49301eSmrg * 144a49301eSmrg * The above copyright notice and this permission notice (including the 154a49301eSmrg * next paragraph) shall be included in all copies or substantial portions 164a49301eSmrg * of the Software. 174a49301eSmrg * 184a49301eSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 194a49301eSmrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 204a49301eSmrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21af69d88dSmrg * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 224a49301eSmrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 234a49301eSmrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 244a49301eSmrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 254a49301eSmrg * 264a49301eSmrg **************************************************************************/ 274a49301eSmrg 284a49301eSmrg#ifndef TGSI_PARSE_H 294a49301eSmrg#define TGSI_PARSE_H 304a49301eSmrg 313464ebd5Sriastradh#include "pipe/p_compiler.h" 324a49301eSmrg#include "pipe/p_shader_tokens.h" 334a49301eSmrg 344a49301eSmrg#if defined __cplusplus 354a49301eSmrgextern "C" { 364a49301eSmrg#endif 374a49301eSmrg 384a49301eSmrgstruct tgsi_full_header 394a49301eSmrg{ 404a49301eSmrg struct tgsi_header Header; 414a49301eSmrg struct tgsi_processor Processor; 424a49301eSmrg}; 434a49301eSmrg 444a49301eSmrgstruct tgsi_full_dst_register 454a49301eSmrg{ 46cdc920a0Smrg struct tgsi_dst_register Register; 47af69d88dSmrg struct tgsi_ind_register Indirect; 483464ebd5Sriastradh struct tgsi_dimension Dimension; 49af69d88dSmrg struct tgsi_ind_register DimIndirect; 504a49301eSmrg}; 514a49301eSmrg 524a49301eSmrgstruct tgsi_full_src_register 534a49301eSmrg{ 54cdc920a0Smrg struct tgsi_src_register Register; 55af69d88dSmrg struct tgsi_ind_register Indirect; 56cdc920a0Smrg struct tgsi_dimension Dimension; 57af69d88dSmrg struct tgsi_ind_register DimIndirect; 583464ebd5Sriastradh}; 593464ebd5Sriastradh 604a49301eSmrgstruct tgsi_full_declaration 614a49301eSmrg{ 624a49301eSmrg struct tgsi_declaration Declaration; 63cdc920a0Smrg struct tgsi_declaration_range Range; 64cdc920a0Smrg struct tgsi_declaration_dimension Dim; 65af69d88dSmrg struct tgsi_declaration_interp Interp; 664a49301eSmrg struct tgsi_declaration_semantic Semantic; 6701e04c3fSmrg struct tgsi_declaration_image Image; 68af69d88dSmrg struct tgsi_declaration_sampler_view SamplerView; 69af69d88dSmrg struct tgsi_declaration_array Array; 704a49301eSmrg}; 714a49301eSmrg 724a49301eSmrgstruct tgsi_full_immediate 734a49301eSmrg{ 744a49301eSmrg struct tgsi_immediate Immediate; 754a49301eSmrg union tgsi_immediate_data u[4]; 764a49301eSmrg}; 774a49301eSmrg 78cdc920a0Smrgstruct tgsi_full_property 79cdc920a0Smrg{ 80cdc920a0Smrg struct tgsi_property Property; 81cdc920a0Smrg struct tgsi_property_data u[8]; 82cdc920a0Smrg}; 83cdc920a0Smrg 844a49301eSmrg#define TGSI_FULL_MAX_DST_REGISTERS 2 853464ebd5Sriastradh#define TGSI_FULL_MAX_SRC_REGISTERS 5 /* SAMPLE_D has 5 */ 86af69d88dSmrg#define TGSI_FULL_MAX_TEX_OFFSETS 4 874a49301eSmrg 884a49301eSmrgstruct tgsi_full_instruction 894a49301eSmrg{ 904a49301eSmrg struct tgsi_instruction Instruction; 91cdc920a0Smrg struct tgsi_instruction_label Label; 92cdc920a0Smrg struct tgsi_instruction_texture Texture; 9301e04c3fSmrg struct tgsi_instruction_memory Memory; 94cdc920a0Smrg struct tgsi_full_dst_register Dst[TGSI_FULL_MAX_DST_REGISTERS]; 95cdc920a0Smrg struct tgsi_full_src_register Src[TGSI_FULL_MAX_SRC_REGISTERS]; 96af69d88dSmrg struct tgsi_texture_offset TexOffsets[TGSI_FULL_MAX_TEX_OFFSETS]; 974a49301eSmrg}; 984a49301eSmrg 994a49301eSmrgunion tgsi_full_token 1004a49301eSmrg{ 1014a49301eSmrg struct tgsi_token Token; 1024a49301eSmrg struct tgsi_full_declaration FullDeclaration; 1034a49301eSmrg struct tgsi_full_immediate FullImmediate; 1044a49301eSmrg struct tgsi_full_instruction FullInstruction; 105cdc920a0Smrg struct tgsi_full_property FullProperty; 1064a49301eSmrg}; 1074a49301eSmrg 1084a49301eSmrgstruct tgsi_parse_context 1094a49301eSmrg{ 1104a49301eSmrg const struct tgsi_token *Tokens; 1114a49301eSmrg unsigned Position; 1124a49301eSmrg struct tgsi_full_header FullHeader; 1134a49301eSmrg union tgsi_full_token FullToken; 1144a49301eSmrg}; 1154a49301eSmrg 1164a49301eSmrg#define TGSI_PARSE_OK 0 1174a49301eSmrg#define TGSI_PARSE_ERROR 1 1184a49301eSmrg 1194a49301eSmrgunsigned 1204a49301eSmrgtgsi_parse_init( 1214a49301eSmrg struct tgsi_parse_context *ctx, 1224a49301eSmrg const struct tgsi_token *tokens ); 1234a49301eSmrg 1244a49301eSmrgvoid 1254a49301eSmrgtgsi_parse_free( 1264a49301eSmrg struct tgsi_parse_context *ctx ); 1274a49301eSmrg 1284a49301eSmrgboolean 1294a49301eSmrgtgsi_parse_end_of_tokens( 1304a49301eSmrg struct tgsi_parse_context *ctx ); 1314a49301eSmrg 1324a49301eSmrgvoid 1334a49301eSmrgtgsi_parse_token( 1344a49301eSmrg struct tgsi_parse_context *ctx ); 1354a49301eSmrg 13601e04c3fSmrgstatic inline unsigned 1373464ebd5Sriastradhtgsi_num_tokens(const struct tgsi_token *tokens) 1383464ebd5Sriastradh{ 1393464ebd5Sriastradh struct tgsi_header header; 1403464ebd5Sriastradh memcpy(&header, tokens, sizeof(header)); 1413464ebd5Sriastradh return header.HeaderSize + header.BodySize; 1423464ebd5Sriastradh} 1433464ebd5Sriastradh 1443464ebd5Sriastradhvoid 1453464ebd5Sriastradhtgsi_dump_tokens(const struct tgsi_token *tokens); 1464a49301eSmrg 1474a49301eSmrgstruct tgsi_token * 1484a49301eSmrgtgsi_dup_tokens(const struct tgsi_token *tokens); 1494a49301eSmrg 150cdc920a0Smrgstruct tgsi_token * 151cdc920a0Smrgtgsi_alloc_tokens(unsigned num_tokens); 152cdc920a0Smrg 15301e04c3fSmrgvoid 15401e04c3fSmrgtgsi_free_tokens(const struct tgsi_token *tokens); 15501e04c3fSmrg 15601e04c3fSmrgunsigned 15701e04c3fSmrgtgsi_get_processor_type(const struct tgsi_token *tokens); 158cdc920a0Smrg 1594a49301eSmrg#if defined __cplusplus 1604a49301eSmrg} 1614a49301eSmrg#endif 1624a49301eSmrg 1634a49301eSmrg#endif /* TGSI_PARSE_H */ 1644a49301eSmrg 165