diff options
Diffstat (limited to 'src/gallium/state_trackers/d3d1x/d3d1xshader')
-rw-r--r-- | src/gallium/state_trackers/d3d1x/d3d1xshader/Makefile | 4 | ||||
-rwxr-xr-x | src/gallium/state_trackers/d3d1x/d3d1xshader/gen-header.sh | 6 | ||||
-rwxr-xr-x | src/gallium/state_trackers/d3d1x/d3d1xshader/gen-text.sh | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/d3d1x/d3d1xshader/include/sm4.h (renamed from src/gallium/state_trackers/d3d1x/d3d1xshader/include/tpf.h) | 132 | ||||
-rw-r--r-- | src/gallium/state_trackers/d3d1x/d3d1xshader/src/sm4_analyze.cpp (renamed from src/gallium/state_trackers/d3d1x/d3d1xshader/src/tpf_analyze.cpp) | 54 | ||||
-rw-r--r-- | src/gallium/state_trackers/d3d1x/d3d1xshader/src/sm4_dump.cpp (renamed from src/gallium/state_trackers/d3d1x/d3d1xshader/src/tpf_dump.cpp) | 86 | ||||
-rw-r--r-- | src/gallium/state_trackers/d3d1x/d3d1xshader/src/sm4_parse.cpp (renamed from src/gallium/state_trackers/d3d1x/d3d1xshader/src/tpf_parse.cpp) | 192 | ||||
-rw-r--r-- | src/gallium/state_trackers/d3d1x/d3d1xshader/tools/fxdis.cpp | 14 |
8 files changed, 246 insertions, 244 deletions
diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/Makefile b/src/gallium/state_trackers/d3d1x/d3d1xshader/Makefile index 866762e1bb4..4f67145b6fa 100644 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/Makefile +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/Makefile @@ -6,8 +6,8 @@ LIBS=libd3d1xshader.a include ../Makefile.inc -include/tpf_defs.h: $(wildcard defs/*.txt) +include/sm4_defs.h: $(wildcard defs/*.txt) ./gen-header.sh $^ > $@ -src/tpf_text.cpp: $(wildcard defs/*.txt) +src/sm4_text.cpp: $(wildcard defs/*.txt) ./gen-text.sh $^ > $@ diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/gen-header.sh b/src/gallium/state_trackers/d3d1x/d3d1xshader/gen-header.sh index 558794f1d25..fcda13f9076 100755 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/gen-header.sh +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/gen-header.sh @@ -2,12 +2,12 @@ for i in "$@"; do n=$(basename "$i" .txt|sed -e 's/s$//') if test "$n" == "shortfile"; then continue; fi - echo "enum tpf_$n" + echo "enum sm4_$n" echo "{" while read j; do - echo $'\t'"TPF_${n}_$j", + echo $'\t'"SM4_${n}_$j", done < "$i" |tr '[a-z]' '[A-Z]'|tr ' ' '_' - echo $'\t'"TPF_${n}_COUNT"|tr '[a-z]' '[A-Z]' + echo $'\t'"SM4_${n}_COUNT"|tr '[a-z]' '[A-Z]' echo "};" echo done diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/gen-text.sh b/src/gallium/state_trackers/d3d1x/d3d1xshader/gen-text.sh index b31e16e19c9..4663f635d43 100755 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/gen-text.sh +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/gen-text.sh @@ -1,7 +1,7 @@ #!/bin/bash for i in "$@"; do n=$(basename "$i" .txt|sed -e 's/s$//') - echo "const char* tpf_${n}_names[] =" + echo "const char* sm4_${n}_names[] =" echo "{" while read j; do echo $'\t'"\"$j\"", diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/include/tpf.h b/src/gallium/state_trackers/d3d1x/d3d1xshader/include/sm4.h index 6ab9b820e8f..07f84f0c73f 100644 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/include/tpf.h +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/include/sm4.h @@ -24,8 +24,10 @@ * **************************************************************************/ -#ifndef TPF_H_ -#define TPF_H_ +/* Header for Shader Model 4.0, 4.1 and 5.0 */ + +#ifndef SM4_H_ +#define SM4_H_ #include <stdint.h> #include <string.h> @@ -36,16 +38,16 @@ #include <iostream> #include "le32.h" -#include "tpf_defs.h" +#include "sm4_defs.h" -extern const char* tpf_opcode_names[]; -extern const char* tpf_file_names[]; -extern const char* tpf_file_ms_names[]; -extern const char* tpf_target_names[]; -extern const char* tpf_interpolation_names[]; -extern const char* tpf_sv_names[]; +extern const char* sm4_opcode_names[]; +extern const char* sm4_file_names[]; +extern const char* sm4_file_ms_names[]; +extern const char* sm4_target_names[]; +extern const char* sm4_interpolation_names[]; +extern const char* sm4_sv_names[]; -struct tpf_token_version +struct sm4_token_version { unsigned minor : 4; unsigned major : 4; @@ -53,7 +55,7 @@ struct tpf_token_version unsigned type : 16; }; -struct tpf_token_instruction +struct sm4_token_instruction { // we don't make it an union directly because unions can't be inherited from union @@ -155,7 +157,7 @@ struct tpf_token_instruction }; }; -union tpf_token_instruction_extended +union sm4_token_instruction_extended { struct { @@ -186,7 +188,7 @@ union tpf_token_instruction_extended } resource_return_type; }; -struct tpf_token_resource_return_type +struct sm4_token_resource_return_type { unsigned x : 4; unsigned y : 4; @@ -194,31 +196,31 @@ struct tpf_token_resource_return_type unsigned w : 4; }; -struct tpf_token_operand +struct sm4_token_operand { - unsigned comps_enum : 2; /* tpf_operands_comps */ - unsigned mode : 2; /* tpf_operand_mode */ + unsigned comps_enum : 2; /* sm4_operands_comps */ + unsigned mode : 2; /* sm4_operand_mode */ unsigned sel : 8; - unsigned file : 8; /* tpf_file */ + unsigned file : 8; /* sm4_file */ unsigned num_indices : 2; - unsigned index0_repr : 3; /* tpf_operand_index_repr */ - unsigned index1_repr : 3; /* tpf_operand_index_repr */ - unsigned index2_repr : 3; /* tpf_operand_index_repr */ + unsigned index0_repr : 3; /* sm4_operand_index_repr */ + unsigned index1_repr : 3; /* sm4_operand_index_repr */ + unsigned index2_repr : 3; /* sm4_operand_index_repr */ unsigned extended : 1; }; -#define TPF_OPERAND_SEL_MASK(sel) ((sel) & 0xf) -#define TPF_OPERAND_SEL_SWZ(sel, i) (((sel) >> ((i) * 2)) & 3) -#define TPF_OPERAND_SEL_SCALAR(sel) ((sel) & 3) +#define SM4_OPERAND_SEL_MASK(sel) ((sel) & 0xf) +#define SM4_OPERAND_SEL_SWZ(sel, i) (((sel) >> ((i) * 2)) & 3) +#define SM4_OPERAND_SEL_SCALAR(sel) ((sel) & 3) -struct tpf_token_operand_extended +struct sm4_token_operand_extended { unsigned type : 6; unsigned neg : 1; unsigned abs : 1; }; -union tpf_any +union sm4_any { double f64; float f32; @@ -228,30 +230,30 @@ union tpf_any int64_t u32; }; -struct tpf_op; -struct tpf_insn; -struct tpf_dcl; -struct tpf_program; -std::ostream& operator <<(std::ostream& out, const tpf_op& op); -std::ostream& operator <<(std::ostream& out, const tpf_insn& op); -std::ostream& operator <<(std::ostream& out, const tpf_dcl& op); -std::ostream& operator <<(std::ostream& out, const tpf_program& op); +struct sm4_op; +struct sm4_insn; +struct sm4_dcl; +struct sm4_program; +std::ostream& operator <<(std::ostream& out, const sm4_op& op); +std::ostream& operator <<(std::ostream& out, const sm4_insn& op); +std::ostream& operator <<(std::ostream& out, const sm4_dcl& op); +std::ostream& operator <<(std::ostream& out, const sm4_program& op); -struct tpf_op +struct sm4_op { uint8_t mode; uint8_t comps; uint8_t mask; uint8_t num_indices; uint8_t swizzle[4]; - tpf_file file; - tpf_any imm_values[4]; + sm4_file file; + sm4_any imm_values[4]; bool neg; bool abs; struct { int64_t disp; - std::auto_ptr<tpf_op> reg; + std::auto_ptr<sm4_op> reg; } indices[3]; bool is_index_simple(unsigned i) const @@ -264,7 +266,7 @@ struct tpf_op return num_indices == 1 && is_index_simple(0); } - tpf_op() + sm4_op() { memset(this, 0, sizeof(*this)); } @@ -272,14 +274,14 @@ struct tpf_op void dump(); private: - tpf_op(const tpf_op& op) + sm4_op(const sm4_op& op) {} }; /* for sample_d */ -#define TPF_MAX_OPS 6 +#define SM4_MAX_OPS 6 -struct tpf_insn : public tpf_token_instruction +struct sm4_insn : public sm4_token_instruction { int8_t sample_offset[3]; uint8_t resource_target; @@ -287,9 +289,9 @@ struct tpf_insn : public tpf_token_instruction unsigned num; unsigned num_ops; - std::auto_ptr<tpf_op> ops[TPF_MAX_OPS]; + std::auto_ptr<sm4_op> ops[SM4_MAX_OPS]; - tpf_insn() + sm4_insn() { memset(this, 0, sizeof(*this)); } @@ -297,18 +299,18 @@ struct tpf_insn : public tpf_token_instruction void dump(); private: - tpf_insn(const tpf_insn& op) + sm4_insn(const sm4_insn& op) {} }; -struct tpf_dcl : public tpf_token_instruction +struct sm4_dcl : public sm4_token_instruction { - std::auto_ptr<tpf_op> op; + std::auto_ptr<sm4_op> op; union { unsigned num; float f32; - tpf_sv sv; + sm4_sv sv; struct { unsigned id; @@ -317,7 +319,7 @@ struct tpf_dcl : public tpf_token_instruction unsigned array_length; } intf; unsigned thread_group_size[3]; - tpf_token_resource_return_type rrt; + sm4_token_resource_return_type rrt; struct { unsigned num; @@ -332,12 +334,12 @@ struct tpf_dcl : public tpf_token_instruction void* data; - tpf_dcl() + sm4_dcl() { memset(this, 0, sizeof(*this)); } - ~tpf_dcl() + ~sm4_dcl() { free(data); } @@ -345,15 +347,15 @@ struct tpf_dcl : public tpf_token_instruction void dump(); private: - tpf_dcl(const tpf_dcl& op) + sm4_dcl(const sm4_dcl& op) {} }; -struct tpf_program +struct sm4_program { - tpf_token_version version; - std::vector<tpf_dcl*> dcls; - std::vector<tpf_insn*> insns; + sm4_token_version version; + std::vector<sm4_dcl*> dcls; + std::vector<sm4_insn*> insns; /* for ifs, the insn number of the else or endif if there is no else * for elses, the insn number of the endif @@ -376,33 +378,33 @@ struct tpf_program bool labels_found; std::vector<int> label_to_insn_num; - tpf_program() + sm4_program() { memset(&version, 0, sizeof(version)); labels_found = false; resource_sampler_slots_assigned = false; } - ~tpf_program() + ~sm4_program() { - for(std::vector<tpf_dcl*>::iterator i = dcls.begin(), e = dcls.end(); i != e; ++i) + for(std::vector<sm4_dcl*>::iterator i = dcls.begin(), e = dcls.end(); i != e; ++i) delete *i; - for(std::vector<tpf_insn*>::iterator i = insns.begin(), e = insns.end(); i != e; ++i) + for(std::vector<sm4_insn*>::iterator i = insns.begin(), e = insns.end(); i != e; ++i) delete *i; } void dump(); private: - tpf_program(const tpf_dcl& op) + sm4_program(const sm4_dcl& op) {} }; -tpf_program* tpf_parse(void* tokens, int size); +sm4_program* sm4_parse(void* tokens, int size); -bool tpf_link_cf_insns(tpf_program& program); -bool tpf_find_labels(tpf_program& program); -bool tpf_allocate_resource_sampler_pairs(tpf_program& program); +bool sm4_link_cf_insns(sm4_program& program); +bool sm4_find_labels(sm4_program& program); +bool sm4_allocate_resource_sampler_pairs(sm4_program& program); -#endif /* TPF_H_ */ +#endif /* SM4_H_ */ diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/src/tpf_analyze.cpp b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/sm4_analyze.cpp index a381564ada1..848db1bdbbb 100644 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/src/tpf_analyze.cpp +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/sm4_analyze.cpp @@ -26,11 +26,11 @@ #include <vector> #include <set> -#include "tpf.h" +#include "sm4.h" #define check(x) do {if(!(x)) return false;} while(0) -bool tpf_link_cf_insns(tpf_program& program) +bool sm4_link_cf_insns(sm4_program& program) { if(program.cf_insn_linked.size()) return true; @@ -44,42 +44,42 @@ bool tpf_link_cf_insns(tpf_program& program) unsigned v; switch(program.insns[insn_num]->opcode) { - case TPF_OPCODE_LOOP: + case SM4_OPCODE_LOOP: cf_stack.push_back(insn_num); break; - case TPF_OPCODE_ENDLOOP: + case SM4_OPCODE_ENDLOOP: check(!cf_stack.empty()); v = cf_stack.back(); - check(program.insns[v]->opcode == TPF_OPCODE_LOOP); + check(program.insns[v]->opcode == SM4_OPCODE_LOOP); cf_insn_linked[v] = insn_num; cf_insn_linked[insn_num] = v; cf_stack.pop_back(); break; - case TPF_OPCODE_IF: - case TPF_OPCODE_SWITCH: + case SM4_OPCODE_IF: + case SM4_OPCODE_SWITCH: cf_insn_linked[insn_num] = insn_num; // later changed cf_stack.push_back(insn_num); break; - case TPF_OPCODE_ELSE: - case TPF_OPCODE_CASE: + case SM4_OPCODE_ELSE: + case SM4_OPCODE_CASE: check(!cf_stack.empty()); v = cf_stack.back(); - if(program.insns[insn_num]->opcode == TPF_OPCODE_ELSE) - check(program.insns[v]->opcode == TPF_OPCODE_IF); + if(program.insns[insn_num]->opcode == SM4_OPCODE_ELSE) + check(program.insns[v]->opcode == SM4_OPCODE_IF); else - check(program.insns[v]->opcode == TPF_OPCODE_SWITCH || program.insns[v]->opcode == TPF_OPCODE_CASE); + check(program.insns[v]->opcode == SM4_OPCODE_SWITCH || program.insns[v]->opcode == SM4_OPCODE_CASE); cf_insn_linked[insn_num] = cf_insn_linked[v]; // later changed cf_insn_linked[v] = insn_num; cf_stack.back() = insn_num; break; - case TPF_OPCODE_ENDSWITCH: - case TPF_OPCODE_ENDIF: + case SM4_OPCODE_ENDSWITCH: + case SM4_OPCODE_ENDIF: check(!cf_stack.empty()); v = cf_stack.back(); - if(program.insns[insn_num]->opcode == TPF_OPCODE_ENDIF) - check(program.insns[v]->opcode == TPF_OPCODE_IF || program.insns[v]->opcode == TPF_OPCODE_ELSE); + if(program.insns[insn_num]->opcode == SM4_OPCODE_ENDIF) + check(program.insns[v]->opcode == SM4_OPCODE_IF || program.insns[v]->opcode == SM4_OPCODE_ELSE); else - check(program.insns[v]->opcode == TPF_OPCODE_SWITCH || program.insns[v]->opcode == TPF_OPCODE_CASE); + check(program.insns[v]->opcode == SM4_OPCODE_SWITCH || program.insns[v]->opcode == SM4_OPCODE_CASE); cf_insn_linked[insn_num] = cf_insn_linked[v]; cf_insn_linked[v] = insn_num; cf_stack.pop_back(); @@ -91,7 +91,7 @@ bool tpf_link_cf_insns(tpf_program& program) return true; } -bool tpf_find_labels(tpf_program& program) +bool sm4_find_labels(sm4_program& program) { if(program.labels_found) return true; @@ -101,11 +101,11 @@ bool tpf_find_labels(tpf_program& program) { switch(program.insns[insn_num]->opcode) { - case TPF_OPCODE_LABEL: + case SM4_OPCODE_LABEL: if(program.insns[insn_num]->num_ops > 0) { - tpf_op& op = *program.insns[insn_num]->ops[0]; - if(op.file == TPF_FILE_LABEL && op.has_simple_index()) + sm4_op& op = *program.insns[insn_num]->ops[0]; + if(op.file == SM4_FILE_LABEL && op.has_simple_index()) { unsigned idx = (unsigned)op.indices[0].disp; if(idx >= labels.size()) @@ -121,7 +121,7 @@ bool tpf_find_labels(tpf_program& program) return true; } -bool tpf_allocate_resource_sampler_pairs(tpf_program& program) +bool sm4_allocate_resource_sampler_pairs(sm4_program& program) { if(program.resource_sampler_slots_assigned) return true; @@ -135,16 +135,16 @@ bool tpf_allocate_resource_sampler_pairs(tpf_program& program) int sampler = -2; for(unsigned i = 0; i < program.insns[insn_num]->num_ops; ++i) { - tpf_op* op = program.insns[insn_num]->ops[i].get(); + sm4_op* op = program.insns[insn_num]->ops[i].get(); if(op) { - if(op->file == TPF_FILE_RESOURCE) + if(op->file == SM4_FILE_RESOURCE) { if(!op->has_simple_index() || resource >= 0) return false; resource = (int)op->indices[0].disp; } - if(op->file == TPF_FILE_SAMPLER) + if(op->file == SM4_FILE_SAMPLER) { if(!op->has_simple_index() || sampler >= 0) return false; @@ -154,11 +154,11 @@ bool tpf_allocate_resource_sampler_pairs(tpf_program& program) } unsigned opcode = program.insns[insn_num]->opcode; - if(opcode == TPF_OPCODE_LD || opcode == TPF_OPCODE_LD_MS) + if(opcode == SM4_OPCODE_LD || opcode == SM4_OPCODE_LD_MS) sampler = -1; if(sampler >= -1 && resource >= 0) pairs.insert(std::make_pair(resource, sampler)); - if(opcode == TPF_OPCODE_RESINFO) + if(opcode == SM4_OPCODE_RESINFO) resinfos.insert(resource); } diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/src/tpf_dump.cpp b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/sm4_dump.cpp index 2e6e0949a8a..746d7c8927f 100644 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/src/tpf_dump.cpp +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/sm4_dump.cpp @@ -24,19 +24,19 @@ * **************************************************************************/ -#include "tpf.h" +#include "sm4.h" -// TODO: we should fix this to output the same syntax as fxc, if tpf_dump_ms_syntax is set +// TODO: we should fix this to output the same syntax as fxc, if sm4_dump_short_syntax is set -bool tpf_dump_ms_syntax = true; +bool sm4_dump_short_syntax = true; -std::ostream& operator <<(std::ostream& out, const tpf_op& op) +std::ostream& operator <<(std::ostream& out, const sm4_op& op) { if(op.neg) out << '-'; if(op.abs) out << '|'; - if(op.file == TPF_FILE_IMMEDIATE32) + if(op.file == SM4_FILE_IMMEDIATE32) { out << "l("; for(unsigned i = 0; i < op.comps; ++i) @@ -47,7 +47,7 @@ std::ostream& operator <<(std::ostream& out, const tpf_op& op) } out << ")"; } - else if(op.file == TPF_FILE_IMMEDIATE64) + else if(op.file == SM4_FILE_IMMEDIATE64) { out << "d("; for(unsigned i = 0; i < op.comps; ++i) @@ -62,17 +62,17 @@ std::ostream& operator <<(std::ostream& out, const tpf_op& op) else { bool naked = false; - if(tpf_dump_ms_syntax) + if(sm4_dump_short_syntax) { switch(op.file) { - case TPF_FILE_TEMP: - case TPF_FILE_INPUT: - case TPF_FILE_OUTPUT: - case TPF_FILE_CONSTANT_BUFFER: - case TPF_FILE_INDEXABLE_TEMP: - case TPF_FILE_UNORDERED_ACCESS_VIEW: - case TPF_FILE_THREAD_GROUP_SHARED_MEMORY: + case SM4_FILE_TEMP: + case SM4_FILE_INPUT: + case SM4_FILE_OUTPUT: + case SM4_FILE_CONSTANT_BUFFER: + case SM4_FILE_INDEXABLE_TEMP: + case SM4_FILE_UNORDERED_ACCESS_VIEW: + case SM4_FILE_THREAD_GROUP_SHARED_MEMORY: naked = true; break; default: @@ -81,7 +81,7 @@ std::ostream& operator <<(std::ostream& out, const tpf_op& op) } } - out << (tpf_dump_ms_syntax ? tpf_file_ms_names : tpf_file_names)[op.file]; + out << (sm4_dump_short_syntax ? sm4_shortfile_names : sm4_file_names)[op.file]; if(op.indices[0].reg.get()) naked = false; @@ -105,21 +105,21 @@ std::ostream& operator <<(std::ostream& out, const tpf_op& op) { switch(op.mode) { - case TPF_OPERAND_MODE_MASK: - out << (tpf_dump_ms_syntax ? '.' : '!'); + case SM4_OPERAND_MODE_MASK: + out << (sm4_dump_short_syntax ? '.' : '!'); for(unsigned i = 0; i < op.comps; ++i) { if(op.mask & (1 << i)) out << "xyzw"[i]; } break; - case TPF_OPERAND_MODE_SWIZZLE: + case SM4_OPERAND_MODE_SWIZZLE: out << '.'; for(unsigned i = 0; i < op.comps; ++i) out << "xyzw"[op.swizzle[i]]; break; - case TPF_OPERAND_MODE_SCALAR: - out << (tpf_dump_ms_syntax ? '.' : ':'); + case SM4_OPERAND_MODE_SCALAR: + out << (sm4_dump_short_syntax ? '.' : ':'); out << "xyzw"[op.swizzle[0]]; break; } @@ -130,12 +130,12 @@ std::ostream& operator <<(std::ostream& out, const tpf_op& op) return out; } -std::ostream& operator <<(std::ostream& out, const tpf_dcl& dcl) +std::ostream& operator <<(std::ostream& out, const sm4_dcl& dcl) { - out << tpf_opcode_names[dcl.opcode]; + out << sm4_opcode_names[dcl.opcode]; switch(dcl.opcode) { - case TPF_OPCODE_DCL_GLOBAL_FLAGS: + case SM4_OPCODE_DCL_GLOBAL_FLAGS: if(dcl.dcl_global_flags.allow_refactoring) out << " refactoringAllowed"; if(dcl.dcl_global_flags.early_depth_stencil) @@ -145,12 +145,12 @@ std::ostream& operator <<(std::ostream& out, const tpf_dcl& dcl) if(dcl.dcl_global_flags.enable_raw_and_structured_in_non_cs) out << " enableRawAndStructuredBuffers"; break; - case TPF_OPCODE_DCL_INPUT_PS: - case TPF_OPCODE_DCL_INPUT_PS_SIV: - case TPF_OPCODE_DCL_INPUT_PS_SGV: - out << ' ' << tpf_interpolation_names[dcl.dcl_input_ps.interpolation]; + case SM4_OPCODE_DCL_INPUT_PS: + case SM4_OPCODE_DCL_INPUT_PS_SIV: + case SM4_OPCODE_DCL_INPUT_PS_SGV: + out << ' ' << sm4_interpolation_names[dcl.dcl_input_ps.interpolation]; break; - case TPF_OPCODE_DCL_TEMPS: + case SM4_OPCODE_DCL_TEMPS: out << ' ' << dcl.num; break; default: @@ -160,25 +160,25 @@ std::ostream& operator <<(std::ostream& out, const tpf_dcl& dcl) out << ' ' << *dcl.op; switch(dcl.opcode) { - case TPF_OPCODE_DCL_CONSTANT_BUFFER: + case SM4_OPCODE_DCL_CONSTANT_BUFFER: out << ", " << (dcl.dcl_constant_buffer.dynamic ? "dynamicIndexed" : "immediateIndexed"); break; - case TPF_OPCODE_DCL_INPUT_SIV: - case TPF_OPCODE_DCL_INPUT_SGV: - case TPF_OPCODE_DCL_OUTPUT_SIV: - case TPF_OPCODE_DCL_OUTPUT_SGV: - case TPF_OPCODE_DCL_INPUT_PS_SIV: - case TPF_OPCODE_DCL_INPUT_PS_SGV: - out << ", " << tpf_sv_names[dcl.num]; + case SM4_OPCODE_DCL_INPUT_SIV: + case SM4_OPCODE_DCL_INPUT_SGV: + case SM4_OPCODE_DCL_OUTPUT_SIV: + case SM4_OPCODE_DCL_OUTPUT_SGV: + case SM4_OPCODE_DCL_INPUT_PS_SIV: + case SM4_OPCODE_DCL_INPUT_PS_SGV: + out << ", " << sm4_sv_names[dcl.num]; break; } return out; } -std::ostream& operator <<(std::ostream& out, const tpf_insn& insn) +std::ostream& operator <<(std::ostream& out, const sm4_insn& insn) { - out << tpf_opcode_names[insn.opcode]; + out << sm4_opcode_names[insn.opcode]; if(insn.insn.sat) out << "_sat"; for(unsigned i = 0; i < insn.num_ops; ++i) @@ -190,7 +190,7 @@ std::ostream& operator <<(std::ostream& out, const tpf_insn& insn) return out; } -std::ostream& operator <<(std::ostream& out, const tpf_program& program) +std::ostream& operator <<(std::ostream& out, const sm4_program& program) { out << "pvghdc"[program.version.type] << "s_" << program.version.major << "_" << program.version.minor << "\n"; for(unsigned i = 0; i < program.dcls.size(); ++i) @@ -201,22 +201,22 @@ std::ostream& operator <<(std::ostream& out, const tpf_program& program) return out; } -void tpf_op::dump() +void sm4_op::dump() { std::cout << *this; } -void tpf_insn::dump() +void sm4_insn::dump() { std::cout << *this; } -void tpf_dcl::dump() +void sm4_dcl::dump() { std::cout << *this; } -void tpf_program::dump() +void sm4_program::dump() { std::cout << *this; } diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/src/tpf_parse.cpp b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/sm4_parse.cpp index 2dfb88e5beb..2c0f8269af3 100644 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/src/tpf_parse.cpp +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/sm4_parse.cpp @@ -24,7 +24,7 @@ * **************************************************************************/ -#include "tpf.h" +#include "sm4.h" #include "utils.h" #if 1 @@ -35,13 +35,13 @@ #define fail(x) throw(x) #endif -struct tpf_parser +struct sm4_parser { unsigned* tokens; unsigned* tokens_end; - tpf_program& program; + sm4_program& program; - tpf_parser(tpf_program& program, void* p_tokens, unsigned size) + sm4_parser(sm4_program& program, void* p_tokens, unsigned size) : program(program) { tokens = (unsigned*)p_tokens; @@ -73,12 +73,12 @@ struct tpf_parser tokens += toskip; } - void read_op(tpf_op* pop) + void read_op(sm4_op* pop) { - tpf_op& op = *pop; - tpf_token_operand optok; + sm4_op& op = *pop; + sm4_token_operand optok; read_token(&optok); - assert(optok.file < TPF_FILE_COUNT); + assert(optok.file < SM4_FILE_COUNT); op.swizzle[0] = 0; op.swizzle[1] = 1; op.swizzle[2] = 2; @@ -86,40 +86,40 @@ struct tpf_parser op.mask = 0xf; switch(optok.comps_enum) { - case TPF_OPERAND_COMPNUM_0: + case SM4_OPERAND_COMPNUM_0: op.comps = 0; break; - case TPF_OPERAND_COMPNUM_1: + case SM4_OPERAND_COMPNUM_1: op.comps = 1; break; - case TPF_OPERAND_COMPNUM_4: + case SM4_OPERAND_COMPNUM_4: op.comps = 4; op.mode = optok.mode; switch(optok.mode) { - case TPF_OPERAND_MODE_MASK: - op.mask = TPF_OPERAND_SEL_MASK(optok.sel); + case SM4_OPERAND_MODE_MASK: + op.mask = SM4_OPERAND_SEL_MASK(optok.sel); break; - case TPF_OPERAND_MODE_SWIZZLE: - op.swizzle[0] = TPF_OPERAND_SEL_SWZ(optok.sel, 0); - op.swizzle[1] = TPF_OPERAND_SEL_SWZ(optok.sel, 1); - op.swizzle[2] = TPF_OPERAND_SEL_SWZ(optok.sel, 2); - op.swizzle[3] = TPF_OPERAND_SEL_SWZ(optok.sel, 3); + case SM4_OPERAND_MODE_SWIZZLE: + op.swizzle[0] = SM4_OPERAND_SEL_SWZ(optok.sel, 0); + op.swizzle[1] = SM4_OPERAND_SEL_SWZ(optok.sel, 1); + op.swizzle[2] = SM4_OPERAND_SEL_SWZ(optok.sel, 2); + op.swizzle[3] = SM4_OPERAND_SEL_SWZ(optok.sel, 3); break; - case TPF_OPERAND_MODE_SCALAR: - op.swizzle[0] = op.swizzle[1] = op.swizzle[2] = op.swizzle[3] = TPF_OPERAND_SEL_SCALAR(optok.sel); + case SM4_OPERAND_MODE_SCALAR: + op.swizzle[0] = op.swizzle[1] = op.swizzle[2] = op.swizzle[3] = SM4_OPERAND_SEL_SCALAR(optok.sel); break; } break; - case TPF_OPERAND_COMPNUM_N: + case SM4_OPERAND_COMPNUM_N: fail("Unhandled operand component type"); } - op.file = (tpf_file)optok.file; + op.file = (sm4_file)optok.file; op.num_indices = optok.num_indices; if(optok.extended) { - tpf_token_operand_extended optokext; + sm4_token_operand_extended optokext; read_token(&optokext); if(optokext.type == 0) {} @@ -147,32 +147,32 @@ struct tpf_parser // TODO: is disp supposed to be signed here?? switch(repr) { - case TPF_OPERAND_INDEX_REPR_IMM32: + case SM4_OPERAND_INDEX_REPR_IMM32: op.indices[i].disp = (int32_t)read32(); break; - case TPF_OPERAND_INDEX_REPR_IMM64: + case SM4_OPERAND_INDEX_REPR_IMM64: op.indices[i].disp = read64(); break; - case TPF_OPERAND_INDEX_REPR_REG: + case SM4_OPERAND_INDEX_REPR_REG: relative: - op.indices[i].reg.reset(new tpf_op()); + op.indices[i].reg.reset(new sm4_op()); read_op(&*op.indices[0].reg); break; - case TPF_OPERAND_INDEX_REPR_REG_IMM32: + case SM4_OPERAND_INDEX_REPR_REG_IMM32: op.indices[i].disp = (int32_t)read32(); goto relative; - case TPF_OPERAND_INDEX_REPR_REG_IMM64: + case SM4_OPERAND_INDEX_REPR_REG_IMM64: op.indices[i].disp = read64(); goto relative; } } - if(op.file == TPF_FILE_IMMEDIATE32) + if(op.file == SM4_FILE_IMMEDIATE32) { for(unsigned i = 0; i < op.comps; ++i) op.imm_values[i].i32 = read32(); } - else if(op.file == TPF_FILE_IMMEDIATE64) + else if(op.file == SM4_FILE_IMMEDIATE64) { for(unsigned i = 0; i < op.comps; ++i) op.imm_values[i].i64 = read64(); @@ -188,114 +188,114 @@ relative: while(tokens != tokens_end) { - tpf_token_instruction insntok; + sm4_token_instruction insntok; read_token(&insntok); unsigned* insn_end = tokens - 1 + insntok.length; - tpf_opcode opcode = (tpf_opcode)insntok.opcode; - check(opcode < TPF_OPCODE_COUNT); + sm4_opcode opcode = (sm4_opcode)insntok.opcode; + check(opcode < SM4_OPCODE_COUNT); - if(opcode == TPF_OPCODE_CUSTOMDATA) + if(opcode == SM4_OPCODE_CUSTOMDATA) { unsigned customlen = read32() - 2; skip(customlen); continue; } - if((opcode >= TPF_OPCODE_DCL_RESOURCE && opcode <= TPF_OPCODE_DCL_GLOBAL_FLAGS) - || (opcode >= TPF_OPCODE_DCL_STREAM && opcode <= TPF_OPCODE_DCL_RESOURCE_STRUCTURED)) + if((opcode >= SM4_OPCODE_DCL_RESOURCE && opcode <= SM4_OPCODE_DCL_GLOBAL_FLAGS) + || (opcode >= SM4_OPCODE_DCL_STREAM && opcode <= SM4_OPCODE_DCL_RESOURCE_STRUCTURED)) { - tpf_dcl& dcl = *new tpf_dcl; + sm4_dcl& dcl = *new sm4_dcl; program.dcls.push_back(&dcl); - (tpf_token_instruction&)dcl = insntok; + (sm4_token_instruction&)dcl = insntok; - tpf_token_instruction_extended exttok; + sm4_token_instruction_extended exttok; memcpy(&exttok, &insntok, sizeof(exttok)); while(exttok.extended) { read_token(&exttok); } -#define READ_OP_ANY dcl.op.reset(new tpf_op()); read_op(&*dcl.op); +#define READ_OP_ANY dcl.op.reset(new sm4_op()); read_op(&*dcl.op); #define READ_OP(FILE) READ_OP_ANY - //check(dcl.op->file == TPF_FILE_##FILE); + //check(dcl.op->file == SM4_FILE_##FILE); switch(opcode) { - case TPF_OPCODE_DCL_GLOBAL_FLAGS: + case SM4_OPCODE_DCL_GLOBAL_FLAGS: break; - case TPF_OPCODE_DCL_RESOURCE: + case SM4_OPCODE_DCL_RESOURCE: READ_OP(RESOURCE); read_token(&dcl.rrt); break; - case TPF_OPCODE_DCL_SAMPLER: + case SM4_OPCODE_DCL_SAMPLER: READ_OP(SAMPLER); break; - case TPF_OPCODE_DCL_INPUT: - case TPF_OPCODE_DCL_INPUT_PS: + case SM4_OPCODE_DCL_INPUT: + case SM4_OPCODE_DCL_INPUT_PS: READ_OP(INPUT); break; - case TPF_OPCODE_DCL_INPUT_SIV: - case TPF_OPCODE_DCL_INPUT_SGV: - case TPF_OPCODE_DCL_INPUT_PS_SIV: - case TPF_OPCODE_DCL_INPUT_PS_SGV: + case SM4_OPCODE_DCL_INPUT_SIV: + case SM4_OPCODE_DCL_INPUT_SGV: + case SM4_OPCODE_DCL_INPUT_PS_SIV: + case SM4_OPCODE_DCL_INPUT_PS_SGV: READ_OP(INPUT); - dcl.sv = (tpf_sv)(uint16_t)read32(); + dcl.sv = (sm4_sv)(uint16_t)read32(); break; - case TPF_OPCODE_DCL_OUTPUT: + case SM4_OPCODE_DCL_OUTPUT: READ_OP(OUTPUT); break; - case TPF_OPCODE_DCL_OUTPUT_SIV: - case TPF_OPCODE_DCL_OUTPUT_SGV: + case SM4_OPCODE_DCL_OUTPUT_SIV: + case SM4_OPCODE_DCL_OUTPUT_SGV: READ_OP(OUTPUT); - dcl.sv = (tpf_sv)(uint16_t)read32(); + dcl.sv = (sm4_sv)(uint16_t)read32(); break; - case TPF_OPCODE_DCL_INDEX_RANGE: + case SM4_OPCODE_DCL_INDEX_RANGE: READ_OP_ANY; - check(dcl.op->file == TPF_FILE_INPUT || dcl.op->file == TPF_FILE_OUTPUT); + check(dcl.op->file == SM4_FILE_INPUT || dcl.op->file == SM4_FILE_OUTPUT); dcl.num = read32(); break; - case TPF_OPCODE_DCL_TEMPS: + case SM4_OPCODE_DCL_TEMPS: dcl.num = read32(); break; - case TPF_OPCODE_DCL_INDEXABLE_TEMP: + case SM4_OPCODE_DCL_INDEXABLE_TEMP: READ_OP(INDEXABLE_TEMP); dcl.indexable_temp.num = read32(); dcl.indexable_temp.comps = read32(); break; - case TPF_OPCODE_DCL_CONSTANT_BUFFER: + case SM4_OPCODE_DCL_CONSTANT_BUFFER: READ_OP(CONSTANT_BUFFER); break; - case TPF_OPCODE_DCL_GS_INPUT_PRIMITIVE: - case TPF_OPCODE_DCL_GS_OUTPUT_PRIMITIVE_TOPOLOGY: + case SM4_OPCODE_DCL_GS_INPUT_PRIMITIVE: + case SM4_OPCODE_DCL_GS_OUTPUT_PRIMITIVE_TOPOLOGY: break; - case TPF_OPCODE_DCL_MAX_OUTPUT_VERTEX_COUNT: + case SM4_OPCODE_DCL_MAX_OUTPUT_VERTEX_COUNT: dcl.num = read32(); break; - case TPF_OPCODE_DCL_GS_INSTANCE_COUNT: + case SM4_OPCODE_DCL_GS_INSTANCE_COUNT: dcl.num = read32(); break; - case TPF_OPCODE_DCL_INPUT_CONTROL_POINT_COUNT: - case TPF_OPCODE_DCL_OUTPUT_CONTROL_POINT_COUNT: - case TPF_OPCODE_DCL_TESS_DOMAIN: - case TPF_OPCODE_DCL_TESS_PARTITIONING: - case TPF_OPCODE_DCL_TESS_OUTPUT_PRIMITIVE: + case SM4_OPCODE_DCL_INPUT_CONTROL_POINT_COUNT: + case SM4_OPCODE_DCL_OUTPUT_CONTROL_POINT_COUNT: + case SM4_OPCODE_DCL_TESS_DOMAIN: + case SM4_OPCODE_DCL_TESS_PARTITIONING: + case SM4_OPCODE_DCL_TESS_OUTPUT_PRIMITIVE: break; - case TPF_OPCODE_DCL_HS_MAX_TESSFACTOR: + case SM4_OPCODE_DCL_HS_MAX_TESSFACTOR: dcl.f32 = read32(); break; - case TPF_OPCODE_DCL_HS_FORK_PHASE_INSTANCE_COUNT: + case SM4_OPCODE_DCL_HS_FORK_PHASE_INSTANCE_COUNT: dcl.num = read32(); break; - case TPF_OPCODE_DCL_FUNCTION_BODY: + case SM4_OPCODE_DCL_FUNCTION_BODY: dcl.num = read32(); break; - case TPF_OPCODE_DCL_FUNCTION_TABLE: + case SM4_OPCODE_DCL_FUNCTION_TABLE: dcl.num = read32(); dcl.data = malloc(dcl.num * sizeof(uint32_t)); for(unsigned i = 0; i < dcl.num; ++i) ((uint32_t*)dcl.data)[i] = read32(); break; - case TPF_OPCODE_DCL_INTERFACE: + case SM4_OPCODE_DCL_INTERFACE: dcl.intf.id = read32(); dcl.intf.expected_function_table_length = read32(); { @@ -307,39 +307,39 @@ relative: for(unsigned i = 0; i < dcl.intf.table_length; ++i) ((uint32_t*)dcl.data)[i] = read32(); break; - case TPF_OPCODE_DCL_THREAD_GROUP: + case SM4_OPCODE_DCL_THREAD_GROUP: dcl.thread_group_size[0] = read32(); dcl.thread_group_size[1] = read32(); dcl.thread_group_size[2] = read32(); break; - case TPF_OPCODE_DCL_UNORDERED_ACCESS_VIEW_TYPED: + case SM4_OPCODE_DCL_UNORDERED_ACCESS_VIEW_TYPED: READ_OP(UNORDERED_ACCESS_VIEW); read_token(&dcl.rrt); break; - case TPF_OPCODE_DCL_UNORDERED_ACCESS_VIEW_RAW: + case SM4_OPCODE_DCL_UNORDERED_ACCESS_VIEW_RAW: READ_OP(UNORDERED_ACCESS_VIEW); break; - case TPF_OPCODE_DCL_UNORDERED_ACCESS_VIEW_STRUCTURED: + case SM4_OPCODE_DCL_UNORDERED_ACCESS_VIEW_STRUCTURED: READ_OP(UNORDERED_ACCESS_VIEW); dcl.structured.stride = read32(); break; - case TPF_OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_RAW: + case SM4_OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_RAW: READ_OP(THREAD_GROUP_SHARED_MEMORY); dcl.num = read32(); break; - case TPF_OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_STRUCTURED: + case SM4_OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_STRUCTURED: READ_OP(THREAD_GROUP_SHARED_MEMORY); dcl.structured.stride = read32(); dcl.structured.count = read32(); break; - case TPF_OPCODE_DCL_RESOURCE_RAW: + case SM4_OPCODE_DCL_RESOURCE_RAW: READ_OP(RESOURCE); break; - case TPF_OPCODE_DCL_RESOURCE_STRUCTURED: + case SM4_OPCODE_DCL_RESOURCE_STRUCTURED: READ_OP(RESOURCE); dcl.structured.stride = read32(); break; - case TPF_OPCODE_DCL_STREAM: + case SM4_OPCODE_DCL_STREAM: /* TODO: dcl_stream is undocumented: what is it? */ fail("Unhandled dcl_stream since it's undocumented"); default: @@ -350,24 +350,24 @@ relative: } else { - tpf_insn& insn = *new tpf_insn; + sm4_insn& insn = *new sm4_insn; program.insns.push_back(&insn); - (tpf_token_instruction&)insn = insntok; + (sm4_token_instruction&)insn = insntok; - tpf_token_instruction_extended exttok; + sm4_token_instruction_extended exttok; memcpy(&exttok, &insntok, sizeof(exttok)); while(exttok.extended) { read_token(&exttok); - if(exttok.type == TPF_TOKEN_INSTRUCTION_EXTENDED_TYPE_SAMPLE_CONTROLS) + if(exttok.type == SM4_TOKEN_INSTRUCTION_EXTENDED_TYPE_SAMPLE_CONTROLS) { insn.sample_offset[0] = exttok.sample_controls.offset_u; insn.sample_offset[1] = exttok.sample_controls.offset_v; insn.sample_offset[2] = exttok.sample_controls.offset_w; } - else if(exttok.type == TPF_TOKEN_INSTRUCTION_EXTENDED_TYPE_RESOURCE_DIM) + else if(exttok.type == SM4_TOKEN_INSTRUCTION_EXTENDED_TYPE_RESOURCE_DIM) insn.resource_target = exttok.resource_target.target; - else if(exttok.type == TPF_TOKEN_INSTRUCTION_EXTENDED_TYPE_RESOURCE_RETURN_TYPE) + else if(exttok.type == SM4_TOKEN_INSTRUCTION_EXTENDED_TYPE_RESOURCE_RETURN_TYPE) { insn.resource_return_type[0] = exttok.resource_return_type.x; insn.resource_return_type[1] = exttok.resource_return_type.y; @@ -378,7 +378,7 @@ relative: switch(opcode) { - case TPF_OPCODE_INTERFACE_CALL: + case SM4_OPCODE_INTERFACE_CALL: insn.num = read32(); break; default: @@ -389,8 +389,8 @@ relative: while(tokens != insn_end) { check(tokens < insn_end); - check(op_num < TPF_MAX_OPS); - insn.ops[op_num].reset(new tpf_op); + check(op_num < SM4_MAX_OPS); + insn.ops[op_num].reset(new sm4_op); read_op(&*insn.ops[op_num]); ++op_num; } @@ -413,10 +413,10 @@ relative: } }; -tpf_program* tpf_parse(void* tokens, int size) +sm4_program* sm4_parse(void* tokens, int size) { - tpf_program* program = new tpf_program; - tpf_parser parser(*program, tokens, size); + sm4_program* program = new sm4_program; + sm4_parser parser(*program, tokens, size); if(!parser.parse()) return program; delete program; diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/tools/fxdis.cpp b/src/gallium/state_trackers/d3d1x/d3d1xshader/tools/fxdis.cpp index 721f95fc8ac..20a7cbd1c38 100644 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/tools/fxdis.cpp +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/tools/fxdis.cpp @@ -25,7 +25,7 @@ **************************************************************************/ #include "dxbc.h" -#include "tpf.h" +#include "sm4.h" #include <iostream> #include <fstream> @@ -60,14 +60,14 @@ int main(int argc, char** argv) if(dxbc) { std::cout << *dxbc; - dxbc_chunk_header* tpf_chunk = dxbc_find_shader_bytecode(&data[0], data.size()); - if(tpf_chunk) + dxbc_chunk_header* sm4_chunk = dxbc_find_shader_bytecode(&data[0], data.size()); + if(sm4_chunk) { - tpf_program* tpf = tpf_parse(tpf_chunk + 1, bswap_le32(tpf_chunk->size)); - if(tpf) + sm4_program* sm4 = sm4_parse(sm4_chunk + 1, bswap_le32(sm4_chunk->size)); + if(sm4) { - std::cout << *tpf; - delete tpf; + std::cout << *sm4; + delete sm4; } } delete dxbc; |