Path: blob/21.2-virgl/src/gallium/auxiliary/tgsi/tgsi_parse.h
4565 views
/**************************************************************************1*2* Copyright 2007 VMware, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627#ifndef TGSI_PARSE_H28#define TGSI_PARSE_H2930#include "pipe/p_compiler.h"31#include "pipe/p_shader_tokens.h"3233#if defined __cplusplus34extern "C" {35#endif3637struct tgsi_full_header38{39struct tgsi_header Header;40struct tgsi_processor Processor;41};4243struct tgsi_full_dst_register44{45struct tgsi_dst_register Register;46struct tgsi_ind_register Indirect;47struct tgsi_dimension Dimension;48struct tgsi_ind_register DimIndirect;49};5051struct tgsi_full_src_register52{53struct tgsi_src_register Register;54struct tgsi_ind_register Indirect;55struct tgsi_dimension Dimension;56struct tgsi_ind_register DimIndirect;57};5859struct tgsi_full_declaration60{61struct tgsi_declaration Declaration;62struct tgsi_declaration_range Range;63struct tgsi_declaration_dimension Dim;64struct tgsi_declaration_interp Interp;65struct tgsi_declaration_semantic Semantic;66struct tgsi_declaration_image Image;67struct tgsi_declaration_sampler_view SamplerView;68struct tgsi_declaration_array Array;69};7071struct tgsi_full_immediate72{73struct tgsi_immediate Immediate;74union tgsi_immediate_data u[4];75};7677struct tgsi_full_property78{79struct tgsi_property Property;80struct tgsi_property_data u[8];81};8283#define TGSI_FULL_MAX_DST_REGISTERS 284#define TGSI_FULL_MAX_SRC_REGISTERS 5 /* SAMPLE_D has 5 */85#define TGSI_FULL_MAX_TEX_OFFSETS 48687struct tgsi_full_instruction88{89struct tgsi_instruction Instruction;90struct tgsi_instruction_label Label;91struct tgsi_instruction_texture Texture;92struct tgsi_instruction_memory Memory;93struct tgsi_full_dst_register Dst[TGSI_FULL_MAX_DST_REGISTERS];94struct tgsi_full_src_register Src[TGSI_FULL_MAX_SRC_REGISTERS];95struct tgsi_texture_offset TexOffsets[TGSI_FULL_MAX_TEX_OFFSETS];96};9798union tgsi_full_token99{100struct tgsi_token Token;101struct tgsi_full_declaration FullDeclaration;102struct tgsi_full_immediate FullImmediate;103struct tgsi_full_instruction FullInstruction;104struct tgsi_full_property FullProperty;105};106107struct tgsi_parse_context108{109const struct tgsi_token *Tokens;110unsigned Position;111struct tgsi_full_header FullHeader;112union tgsi_full_token FullToken;113};114115#define TGSI_PARSE_OK 0116#define TGSI_PARSE_ERROR 1117118unsigned119tgsi_parse_init(120struct tgsi_parse_context *ctx,121const struct tgsi_token *tokens );122123void124tgsi_parse_free(125struct tgsi_parse_context *ctx );126127boolean128tgsi_parse_end_of_tokens(129struct tgsi_parse_context *ctx );130131void132tgsi_parse_token(133struct tgsi_parse_context *ctx );134135static inline unsigned136tgsi_num_tokens(const struct tgsi_token *tokens)137{138struct tgsi_header header;139memcpy(&header, tokens, sizeof(header));140return header.HeaderSize + header.BodySize;141}142143void144tgsi_dump_tokens(const struct tgsi_token *tokens);145146struct tgsi_token *147tgsi_dup_tokens(const struct tgsi_token *tokens);148149struct tgsi_token *150tgsi_alloc_tokens(unsigned num_tokens);151152void153tgsi_free_tokens(const struct tgsi_token *tokens);154155unsigned156tgsi_get_processor_type(const struct tgsi_token *tokens);157158#if defined __cplusplus159}160#endif161162#endif /* TGSI_PARSE_H */163164165166