Path: blob/21.2-virgl/src/gallium/frontends/d3d10umd/ShaderParse.h
4566 views
/**************************************************************************1*2* Copyright 2012-2021 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 SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL16* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,17* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR18* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE19* USE OR OTHER DEALINGS IN THE SOFTWARE.20*21* The above copyright notice and this permission notice (including the22* next paragraph) shall be included in all copies or substantial portions23* of the Software.24*25**************************************************************************/2627/*28* ShaderParse.h --29* Functions for parsing shader tokens.30*/3132#ifndef SHADER_PARSE_H33#define SHADER_PARSE_H3435#include "DriverIncludes.h"3637//#include "winddk/winddk_compat.h"38#include "winddk/d3d10tokenizedprogramformat.hpp"3940#ifdef __cplusplus41extern "C" {42#endif4344struct Shader_header {45D3D10_SB_TOKENIZED_PROGRAM_TYPE type;46unsigned major_version;47unsigned minor_version;48unsigned size;49};5051struct dx10_imm_const_buf {52unsigned count;53unsigned *data;54};5556struct dx10_customdata {57D3D10_SB_CUSTOMDATA_CLASS _class;58union {59struct dx10_imm_const_buf constbuf;60} u;61};6263struct dx10_indexable_temp {64unsigned index;65unsigned count;66unsigned components;67};6869struct dx10_global_flags {70unsigned refactoring_allowed:1;71};7273struct Shader_relative_index {74unsigned imm;75};7677struct Shader_relative_operand {78D3D10_SB_OPERAND_TYPE type;79struct Shader_relative_index index[2];80D3D10_SB_4_COMPONENT_NAME comp;81};8283struct Shader_index {84unsigned imm;85struct Shader_relative_operand rel;86D3D10_SB_OPERAND_INDEX_REPRESENTATION index_rep;87};8889struct Shader_operand {90D3D10_SB_OPERAND_TYPE type;91struct Shader_index index[2];92unsigned index_dim;93};9495struct Shader_dst_operand {96struct Shader_operand base;97unsigned mask;98};99100union Shader_immediate {101float f32;102int i32;103unsigned u32;104};105106struct Shader_src_operand {107struct Shader_operand base;108union Shader_immediate imm[4];109D3D10_SB_4_COMPONENT_NAME swizzle[4];110D3D10_SB_OPERAND_MODIFIER modifier;111};112113#define SHADER_MAX_DST_OPERANDS 2114#define SHADER_MAX_SRC_OPERANDS 5115116struct Shader_opcode {117D3D10_SB_OPCODE_TYPE type;118unsigned num_dst;119unsigned num_src;120struct Shader_dst_operand dst[SHADER_MAX_DST_OPERANDS];121struct Shader_src_operand src[SHADER_MAX_SRC_OPERANDS];122123/* Opcode specific data.124*/125union {126D3D10_SB_RESOURCE_DIMENSION dcl_resource_dimension;127D3D10_SB_SAMPLER_MODE dcl_sampler_mode;128D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN dcl_cb_access_pattern;129D3D10_SB_INTERPOLATION_MODE dcl_in_ps_interp;130D3D10_SB_PRIMITIVE_TOPOLOGY dcl_gs_output_primitive_topology;131D3D10_SB_PRIMITIVE dcl_gs_input_primitive;132D3D10_SB_INSTRUCTION_TEST_BOOLEAN test_boolean;133D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE resinfo_ret_type;134unsigned dcl_max_output_vertex_count;135unsigned dcl_num_temps;136struct dx10_indexable_temp dcl_indexable_temp;137unsigned index_range_count;138struct dx10_global_flags global_flags;139} specific;140D3D10_SB_NAME dcl_siv_name;141D3D10_SB_RESOURCE_RETURN_TYPE dcl_resource_ret_type[4];142143boolean saturate;144145struct {146int u:4;147int v:4;148int w:4;149} imm_texel_offset;150151struct dx10_customdata customdata;152};153154struct Shader_parser {155const unsigned *code;156const unsigned *curr;157158struct Shader_header header;159};160161void162Shader_parse_init(struct Shader_parser *parser,163const unsigned *code);164165boolean166Shader_parse_opcode(struct Shader_parser *parser,167struct Shader_opcode *opcode);168169void170Shader_opcode_free(struct Shader_opcode *opcode);171172173const struct tgsi_token *174Shader_tgsi_translate(const unsigned *code,175unsigned *output_mapping);176177178#ifdef __cplusplus179}180#endif181182#endif /* SHADER_PARSE_H */183184185