diff options
author | José Fonseca <[email protected]> | 2013-03-11 10:13:47 +0000 |
---|---|---|
committer | José Fonseca <[email protected]> | 2013-03-12 00:35:06 +0000 |
commit | 44a8e5135470fa51ae36b304f3c5286bf9cca259 (patch) | |
tree | deb5f35c1c5a855a441377e9dd4d004085620693 /src/gallium/state_trackers/d3d1x/d3d1xshader | |
parent | 7db60f049f05f013cd1ababdc6acfc1f9ab27884 (diff) |
d3d1x: Remove.
Unused/unmaintained.
Reviewed-by: Christoph Bumiller <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/d3d1x/d3d1xshader')
25 files changed, 0 insertions, 2077 deletions
diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/Makefile b/src/gallium/state_trackers/d3d1x/d3d1xshader/Makefile deleted file mode 100644 index f132518ccc7..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -LIBNAME=d3d1xshader -CPP_SOURCES=$(wildcard src/*.cpp) src/sm4_text.cpp -LIBRARY_INCLUDES=-Iinclude -I../d3dapi -I../w32api -PROGS=tools/fxdis -PROGS_DEPS=libd3d1xshader.a -LIBS=$(PROGS_DEPS) - -include ../Makefile.inc - -include/sm4.h: include/sm4_defs.h - -include/sm4_defs.h: $(wildcard defs/*.txt) - ./gen-header.sh $^ > $@ - -src/sm4_text.cpp: $(wildcard defs/*.txt) - ./gen-text.sh $^ > $@ diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/files.txt b/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/files.txt deleted file mode 100644 index c44a46beed5..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/files.txt +++ /dev/null @@ -1,41 +0,0 @@ -temp -input -output -indexable_temp -immediate32 -immediate64 -sampler -resource -constant_buffer -immediate_constant_buffer -label -input_primitiveid -output_depth -null -rasterizer -output_coverage_mask -stream -function_body -function_table -interface -function_input -function_output -output_control_point_id -input_fork_instance_id -input_join_instance_id -input_control_point -output_control_point -input_patch_constant -input_domain_point -this_pointer -unordered_access_view -thread_group_shared_memory -input_thread_id -input_thread_group_id -input_thread_id_in_group -input_coverage_mask -input_thread_id_in_group_flattened -input_gs_instance_id -output_depth_greater_equal -output_depth_less_equal -cycle_counter diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/interpolations.txt b/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/interpolations.txt deleted file mode 100644 index 4e52eec34f4..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/interpolations.txt +++ /dev/null @@ -1,8 +0,0 @@ -undefined -constant -linear -linear centroid -linear noperspective -linear noperspective centroid -linear sample -linear noperspective sample diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/opcodes.txt b/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/opcodes.txt deleted file mode 100644 index 46ff28d6f9c..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/opcodes.txt +++ /dev/null @@ -1,207 +0,0 @@ -add -and -break -breakc -call -callc -case -continue -continuec -cut -default -deriv_rtx -deriv_rty -discard -div -dp2 -dp3 -dp4 -else -emit -emitthencut -endif -endloop -endswitch -eq -exp -frc -ftoi -ftou -ge -iadd -if -ieq -ige -ilt -imad -imax -imin -imul -ine -ineg -ishl -ishr -itof -label -ld -ld_ms -log -loop -lt -mad -min -max -customdata -mov -movc -mul -ne -nop -not -or -resinfo -ret -retc -round_ne -round_ni -round_pi -round_z -rsq -sample -sample_c -sample_c_lz -sample_l -sample_d -sample_b -sqrt -switch -sincos -udiv -ult -uge -umul -umad -umax -umin -ushr -utof -xor -dcl_resource -dcl_constant_buffer -dcl_sampler -dcl_index_range -dcl_gs_output_primitive_topology -dcl_gs_input_primitive -dcl_max_output_vertex_count -dcl_input -dcl_input_sgv -dcl_input_siv -dcl_input_ps -dcl_input_ps_sgv -dcl_input_ps_siv -dcl_output -dcl_output_sgv -dcl_output_siv -dcl_temps -dcl_indexable_temp -dcl_global_flags -d3d10_count -lod -gather4 -sample_pos -sample_info -d3d10_1_count -hs_decls -hs_control_point_phase -hs_fork_phase -hs_join_phase -emit_stream -cut_stream -emitthencut_stream -interface_call -bufinfo -deriv_rtx_coarse -deriv_rtx_fine -deriv_rty_coarse -deriv_rty_fine -gather4_c -gather4_po -gather4_po_c -rcp -f32tof16 -f16tof32 -uaddc -usubb -countbits -firstbit_hi -firstbit_lo -firstbit_shi -ubfe -ibfe -bfi -bfrev -swapc -dcl_stream -dcl_function_body -dcl_function_table -dcl_interface -dcl_input_control_point_count -dcl_output_control_point_count -dcl_tess_domain -dcl_tess_partitioning -dcl_tess_output_primitive -dcl_hs_max_tessfactor -dcl_hs_fork_phase_instance_count -dcl_hs_join_phase_instance_count -dcl_thread_group -dcl_unordered_access_view_typed -dcl_unordered_access_view_raw -dcl_unordered_access_view_structured -dcl_thread_group_shared_memory_raw -dcl_thread_group_shared_memory_structured -dcl_resource_raw -dcl_resource_structured -ld_uav_typed -store_uav_typed -ld_raw -store_raw -ld_structured -store_structured -atomic_and -atomic_or -atomic_xor -atomic_cmp_store -atomic_iadd -atomic_imax -atomic_imin -atomic_umax -atomic_umin -imm_atomic_alloc -imm_atomic_consume -imm_atomic_iadd -imm_atomic_and -imm_atomic_or -imm_atomic_xor -imm_atomic_exch -imm_atomic_cmp_exch -imm_atomic_imax -imm_atomic_imin -imm_atomic_umax -imm_atomic_umin -sync -dadd -dmax -dmin -dmul -deq -dge -dlt -dne -dmov -dmovc -dtof -ftod -eval_snapped -eval_sample_index -eval_centroid -dcl_gs_instance_count diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/operand_compnums.txt b/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/operand_compnums.txt deleted file mode 100644 index 887df2b141a..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/operand_compnums.txt +++ /dev/null @@ -1,5 +0,0 @@ -0 -1 -4 -n - diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/operand_index_reprs.txt b/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/operand_index_reprs.txt deleted file mode 100644 index f1ce172aaf1..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/operand_index_reprs.txt +++ /dev/null @@ -1,5 +0,0 @@ -imm32 -imm64 -reg -reg_imm32 -reg_imm64 diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/operand_modes.txt b/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/operand_modes.txt deleted file mode 100644 index 4088957e989..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/operand_modes.txt +++ /dev/null @@ -1,4 +0,0 @@ -mask -swizzle -scalar - diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/shortfiles.txt b/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/shortfiles.txt deleted file mode 100644 index 9e2d303ccd9..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/shortfiles.txt +++ /dev/null @@ -1,41 +0,0 @@ -r -v -o -x -l -d -sampler -resource -cb -icb -label -vPrim -oDepth -null -rasterizer -oMask -stream -function_body -function_table -interface -function_input -function_output -vOutputControlPointID -vForkInstanceID -vJoinInstanceID -vicp -vocp -input_patch_constant -vDomain -this -u -g -vThreadID -vThreadGrouID -vThreadIDInGroup -vCoverage -vThreadIDInGroupFlattened -vGSInstanceID -oDepthGE -oDepthLE -vCycleCounter diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/svs.txt b/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/svs.txt deleted file mode 100644 index c7148ec301a..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/svs.txt +++ /dev/null @@ -1,23 +0,0 @@ -undefined -position -clip_distance -cull_distance -render_target_array_index -viewport_array_index -vertex_id -primitive_id -instance_id -is_front_face -sample_index -final_quad_u_eq_0_edge_tessfactor -final_quad_v_eq_0_edge_tessfactor -final_quad_u_eq_1_edge_tessfactor -final_quad_v_eq_1_edge_tessfactor -final_quad_u_inside_tessfactor -final_quad_v_inside_tessfactor -final_tri_u_eq_0_edge_tessfactor -final_tri_v_eq_0_edge_tessfactor -final_tri_w_eq_0_edge_tessfactor -final_tri_inside_tessfactor -final_line_detail_tessfactor -final_line_density_tessfactor diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/targets.txt b/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/targets.txt deleted file mode 100644 index d3bc186c54d..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/targets.txt +++ /dev/null @@ -1,13 +0,0 @@ -unknown -buffer -texture1d -texture2d -texture2dms -texture3d -texturecube -texture1darray -texture2darray -texture2dmsarray -texturecubearray -raw_buffer -structured_buffer diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/token_instruction_extended_types.txt b/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/token_instruction_extended_types.txt deleted file mode 100644 index e8fd70c4808..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/token_instruction_extended_types.txt +++ /dev/null @@ -1,4 +0,0 @@ -empty -sample_controls -resource_dim -resource_return_type diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/token_operand_extended_types.txt b/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/token_operand_extended_types.txt deleted file mode 100644 index 891fcafa67a..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/token_operand_extended_types.txt +++ /dev/null @@ -1,2 +0,0 @@ -empty -modifier diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/gen-header.sh b/src/gallium/state_trackers/d3d1x/d3d1xshader/gen-header.sh deleted file mode 100755 index fcda13f9076..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/gen-header.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -for i in "$@"; do - n=$(basename "$i" .txt|sed -e 's/s$//') - if test "$n" == "shortfile"; then continue; fi - echo "enum sm4_$n" - echo "{" - while read j; do - echo $'\t'"SM4_${n}_$j", - done < "$i" |tr '[a-z]' '[A-Z]'|tr ' ' '_' - 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 deleted file mode 100755 index 4663f635d43..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/gen-text.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -for i in "$@"; do - n=$(basename "$i" .txt|sed -e 's/s$//') - echo "const char* sm4_${n}_names[] =" - echo "{" - while read j; do - echo $'\t'"\"$j\"", - done < "$i" - echo "};" - echo -done diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/include/dxbc.h b/src/gallium/state_trackers/d3d1x/d3d1xshader/include/dxbc.h deleted file mode 100644 index 0343a67f863..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/include/dxbc.h +++ /dev/null @@ -1,125 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Luca Barbieri - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#ifndef DXBC_H_ -#define DXBC_H_ - -#include <stdint.h> -#include <vector> -#include <map> -#include <iostream> -#include "le32.h" - -#define FOURCC(a, b, c, d) ((uint32_t)(uint8_t)(a) | ((uint32_t)(uint8_t)(b) << 8) | ((uint32_t)(uint8_t)(c) << 16) | ((uint32_t)(uint8_t)(d) << 24 )) -#define FOURCC_DXBC FOURCC('D', 'X', 'B', 'C') -#define FOURCC_RDEF FOURCC('R', 'D', 'E', 'F') -#define FOURCC_ISGN FOURCC('I', 'S', 'G', 'N') -#define FOURCC_OSGN FOURCC('O', 'S', 'G', 'N') -#define FOURCC_SHDR FOURCC('S', 'H', 'D', 'R') -#define FOURCC_SHEX FOURCC('S', 'H', 'E', 'X') -#define FOURCC_STAT FOURCC('S', 'T', 'A', 'T') -#define FOURCC_PCSG FOURCC('P', 'C', 'S', 'G') - -/* this is always little-endian! */ -struct dxbc_chunk_header -{ - unsigned fourcc; - unsigned size; -}; - -/* this is always little-endian! */ -struct dxbc_chunk_signature : public dxbc_chunk_header -{ - uint32_t count; - uint32_t unk; - struct - { - uint32_t name_offset; - uint32_t semantic_index; - uint32_t system_value_type; - uint32_t component_type; - uint32_t register_num; - uint8_t mask; - uint8_t read_write_mask; - uint8_t stream; /* TODO: guess! */ - uint8_t unused; - } elements[]; -}; - -struct dxbc_container -{ - const void* data; - std::vector<dxbc_chunk_header*> chunks; - std::map<unsigned, unsigned> chunk_map; -}; - -struct dxbc_container_header -{ - unsigned fourcc; - uint32_t unk[4]; - uint32_t one; - uint32_t total_size; - uint32_t chunk_count; -}; - -dxbc_container* dxbc_parse(const void* data, int size); -std::ostream& operator <<(std::ostream& out, const dxbc_container& container); - -dxbc_chunk_header* dxbc_find_chunk(const void* data, int size, unsigned fourcc); - -static inline dxbc_chunk_header* dxbc_find_shader_bytecode(const void* data, int size) -{ - dxbc_chunk_header* chunk; - chunk = dxbc_find_chunk(data, size, FOURCC_SHDR); - if(!chunk) - chunk = dxbc_find_chunk(data, size, FOURCC_SHEX); - return chunk; -} - -#define DXBC_FIND_INPUT_SIGNATURE 0 -#define DXBC_FIND_OUTPUT_SIGNATURE 1 -#define DXBC_FIND_PATCH_SIGNATURE 2 - -static inline dxbc_chunk_signature* dxbc_find_signature(const void* data, int size, unsigned kind) -{ - unsigned fourcc; - switch(kind) { - case DXBC_FIND_INPUT_SIGNATURE: fourcc = FOURCC_ISGN; break; - case DXBC_FIND_OUTPUT_SIGNATURE: fourcc = FOURCC_OSGN; break; - case DXBC_FIND_PATCH_SIGNATURE: fourcc = FOURCC_PCSG; break; - default: - return NULL; - } - return (dxbc_chunk_signature*)dxbc_find_chunk(data, size, fourcc); -} - -struct _D3D11_SIGNATURE_PARAMETER_DESC; -typedef struct _D3D11_SIGNATURE_PARAMETER_DESC D3D11_SIGNATURE_PARAMETER_DESC; -int dxbc_parse_signature(dxbc_chunk_signature* sig, D3D11_SIGNATURE_PARAMETER_DESC** params); - -std::pair<void*, size_t> dxbc_assemble(struct dxbc_chunk_header** chunks, unsigned num_chunks); - -#endif /* DXBC_H_ */ diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/include/le32.h b/src/gallium/state_trackers/d3d1x/d3d1xshader/include/le32.h deleted file mode 100644 index 923942a7786..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/include/le32.h +++ /dev/null @@ -1,45 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Luca Barbieri - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#ifndef LE32_H_ -#define LE32_H_ - -#include <stdint.h> -#include <assert.h> - -#ifdef WORDS_BIGENDIAN -static inline uint32_t bswap_le32(uint32_t v) -{ - return ((v & 0xff) << 24) | ((v & 0xff00) << 8) | ((v & 0xff0000) >> 8) | ((v & 0xff000000) >> 24); -} -#else -static inline uint32_t bswap_le32(uint32_t v) -{ - return v; -} -#endif - -#endif /* LE32_H_ */ diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/include/sm4.h b/src/gallium/state_trackers/d3d1x/d3d1xshader/include/sm4.h deleted file mode 100644 index 43627f7c0ba..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/include/sm4.h +++ /dev/null @@ -1,416 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Luca Barbieri - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -/* Header for Shader Model 4.0, 4.1 and 5.0 */ - -#ifndef SM4_H_ -#define SM4_H_ - -#include <stdint.h> -#include <string.h> -#include <stdlib.h> -#include <memory> -#include <vector> -#include <map> -#include <iostream> -#include "le32.h" - -#include "sm4_defs.h" - -extern const char* sm4_opcode_names[]; -extern const char* sm4_file_names[]; -extern const char* sm4_shortfile_names[]; -extern const char* sm4_target_names[]; -extern const char* sm4_interpolation_names[]; -extern const char* sm4_sv_names[]; - -struct sm4_token_version -{ - unsigned minor : 4; - unsigned major : 4; - unsigned format : 8; - unsigned type : 16; -}; - -struct sm4_token_instruction -{ - // we don't make it an union directly because unions can't be inherited from - union - { - // length and extended are always present, but they are only here to reduce duplication - struct - { - unsigned opcode : 11; - unsigned _11_23 : 13; - unsigned length : 7; - unsigned extended : 1; - }; - struct - { - unsigned opcode : 11; - unsigned resinfo_return_type : 2; - unsigned sat : 1; - unsigned _14_17 : 4; - unsigned test_nz : 1; // bit 18 - unsigned precise_mask : 4; - unsigned _23 : 1; - unsigned length : 7; - unsigned extended : 1; - } insn; - struct - { - unsigned opcode : 11; - unsigned threads_in_group : 1; - unsigned shared_memory : 1; - unsigned uav_group : 1; - unsigned uav_global : 1; - unsigned _15_17 : 3; - } sync; - struct - { - unsigned opcode : 11; - unsigned allow_refactoring : 1; - unsigned fp64 : 1; - unsigned early_depth_stencil : 1; - unsigned enable_raw_and_structured_in_non_cs : 1; - } dcl_global_flags; - struct - { - unsigned opcode : 11; - unsigned target : 5; - unsigned nr_samples : 7; - } dcl_resource; - struct - { - unsigned opcode : 11; - unsigned shadow : 1; - unsigned mono : 1; - } dcl_sampler; - struct - { - unsigned opcode : 11; - unsigned interpolation : 5; - } dcl_input_ps; - struct - { - unsigned opcode : 11; - unsigned dynamic : 1; - } dcl_constant_buffer; - struct - { - unsigned opcode : 11; - unsigned primitive : 6; - } dcl_gs_input_primitive; - struct - { - unsigned opcode : 11; - unsigned primitive_topology : 7; - } dcl_gs_output_primitive_topology; - struct - { - unsigned opcode : 11; - unsigned control_points : 6; - } dcl_input_control_point_count; - struct - { - unsigned opcode : 11; - unsigned control_points : 6; - } dcl_output_control_point_count; - struct - { - unsigned opcode : 11; - unsigned domain : 3; /* D3D_TESSELLATOR_DOMAIN */ - } dcl_tess_domain; - struct - { - unsigned opcode : 11; - unsigned partitioning : 3; /* D3D_TESSELLATOR_PARTITIONING */ - } dcl_tess_partitioning; - struct - { - unsigned opcode : 11; - unsigned primitive : 3; /* D3D_TESSELLATOR_OUTPUT_PRIMITIVE */ - } dcl_tess_output_primitive; - }; -}; - -union sm4_token_instruction_extended -{ - struct - { - unsigned type : 6; - unsigned _6_30 : 25; - unsigned extended :1; - }; - struct - { - unsigned type : 6; - unsigned _6_8 : 3; - int offset_u : 4; - int offset_v : 4; - int offset_w : 4; - } sample_controls; - struct - { - unsigned type : 6; - unsigned target : 5; - } resource_target; - struct - { - unsigned type : 6; - unsigned x : 4; - unsigned y : 4; - unsigned z : 4; - unsigned w : 4; - } resource_return_type; -}; - -struct sm4_token_resource_return_type -{ - unsigned x : 4; - unsigned y : 4; - unsigned z : 4; - unsigned w : 4; -}; - -struct sm4_token_operand -{ - unsigned comps_enum : 2; /* sm4_operands_comps */ - unsigned mode : 2; /* sm4_operand_mode */ - unsigned sel : 8; - unsigned file : 8; /* sm4_file */ - unsigned num_indices : 2; - 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 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 sm4_token_operand_extended -{ - unsigned type : 6; - unsigned neg : 1; - unsigned abs : 1; -}; - -union sm4_any -{ - double f64; - float f32; - int64_t i64; - int32_t i32; - uint64_t u64; - int64_t u32; -}; - -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 sm4_op -{ - uint8_t mode; - uint8_t comps; - uint8_t mask; - uint8_t num_indices; - uint8_t swizzle[4]; - sm4_file file; - sm4_any imm_values[4]; - bool neg; - bool abs; - struct - { - int64_t disp; - std::auto_ptr<sm4_op> reg; - } indices[3]; - - bool is_index_simple(unsigned i) const - { - return !indices[i].reg.get() && indices[i].disp >= 0 && (int64_t)(int32_t)indices[i].disp == indices[i].disp; - } - - bool has_simple_index() const - { - return num_indices == 1 && is_index_simple(0); - } - - sm4_op() - { - memset(this, 0, sizeof(*this)); - } - - void dump(); - -private: - sm4_op(const sm4_op& op) - {} -}; - -/* for sample_d */ -#define SM4_MAX_OPS 6 - -struct sm4_insn : public sm4_token_instruction -{ - int8_t sample_offset[3]; - uint8_t resource_target; - uint8_t resource_return_type[4]; - - unsigned num; - unsigned num_ops; - std::auto_ptr<sm4_op> ops[SM4_MAX_OPS]; - - sm4_insn() - { - memset(this, 0, sizeof(*this)); - } - - void dump(); - -private: - sm4_insn(const sm4_insn& op) - {} -}; - -struct sm4_dcl : public sm4_token_instruction -{ - std::auto_ptr<sm4_op> op; - union - { - unsigned num; - float f32; - sm4_sv sv; - struct - { - unsigned id; - unsigned expected_function_table_length; - unsigned table_length; - unsigned array_length; - } intf; - unsigned thread_group_size[3]; - sm4_token_resource_return_type rrt; - struct - { - unsigned num; - unsigned comps; - } indexable_temp; - struct - { - unsigned stride; - unsigned count; - } structured; - }; - - void* data; - - sm4_dcl() - { - memset(this, 0, sizeof(*this)); - } - - ~sm4_dcl() - { - free(data); - } - - void dump(); - -private: - sm4_dcl(const sm4_dcl& op) - {} -}; - -struct _D3D11_SIGNATURE_PARAMETER_DESC; - -struct sm4_program -{ - sm4_token_version version; - std::vector<sm4_dcl*> dcls; - std::vector<sm4_insn*> insns; - - _D3D11_SIGNATURE_PARAMETER_DESC* params_in; - _D3D11_SIGNATURE_PARAMETER_DESC* params_out; - _D3D11_SIGNATURE_PARAMETER_DESC* params_patch; - unsigned num_params_in; - unsigned num_params_out; - unsigned num_params_patch; - - /* for ifs, the insn number of the else or endif if there is no else - * for elses, the insn number of the endif - * for endifs, the insn number of the if - * for loops, the insn number of the endloop - * for endloops, the insn number of the loop - * for all others, -1 - */ - std::vector<int> cf_insn_linked; - - bool labels_found; - std::vector<int> label_to_insn_num; - - sm4_program() - { - memset(&version, 0, sizeof(version)); - labels_found = false; - num_params_in = num_params_out = num_params_patch = 0; - } - - ~sm4_program() - { - for(std::vector<sm4_dcl*>::iterator i = dcls.begin(), e = dcls.end(); i != e; ++i) - delete *i; - for(std::vector<sm4_insn*>::iterator i = insns.begin(), e = insns.end(); i != e; ++i) - delete *i; - - if(num_params_in) - free(params_in); - if(num_params_out) - free(params_out); - if(num_params_patch) - free(params_patch); - } - - void dump(); - -private: - sm4_program(const sm4_dcl& op) - {} -}; - -sm4_program* sm4_parse(void* tokens, int size); - -bool sm4_link_cf_insns(sm4_program& program); -bool sm4_find_labels(sm4_program& program); - -#endif /* SM4_H_ */ - diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/src/dxbc_assemble.cpp b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/dxbc_assemble.cpp deleted file mode 100644 index 1021a8a1bd5..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/src/dxbc_assemble.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Luca Barbieri - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include <stdlib.h> -#include <string.h> -#include "dxbc.h" - -std::pair<void*, size_t> dxbc_assemble(struct dxbc_chunk_header** chunks, unsigned num_chunks) -{ - size_t data_size = 0; - for(unsigned i = 0; i < num_chunks; ++i) - data_size += sizeof(uint32_t) + sizeof(dxbc_chunk_header) + bswap_le32(chunks[i]->size); - - size_t total_size = sizeof(dxbc_container_header) + data_size; - dxbc_container_header* header = (dxbc_container_header*)malloc(total_size); - if(!header) - return std::make_pair((void*)0, 0); - - header->fourcc = bswap_le32(FOURCC_DXBC); - memset(header->unk, 0, sizeof(header->unk)); - header->one = bswap_le32(1); - header->total_size = bswap_le32(total_size); - header->chunk_count = num_chunks; - - uint32_t* chunk_offsets = (uint32_t*)(header + 1); - uint32_t off = sizeof(struct dxbc_container_header) + num_chunks * sizeof(uint32_t); - for(unsigned i = 0; i < num_chunks; ++i) - { - chunk_offsets[i] = bswap_le32(off); - unsigned chunk_full_size = sizeof(dxbc_chunk_header) + bswap_le32(chunks[i]->size); - memcpy((char*)header + off, chunks[i], chunk_full_size); - off += chunk_full_size; - } - - return std::make_pair((void*)header, total_size); -} diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/src/dxbc_dump.cpp b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/dxbc_dump.cpp deleted file mode 100644 index a3feec74463..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/src/dxbc_dump.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Luca Barbieri - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include <memory> -#include <string.h> -#include <iomanip> -#include "dxbc.h" - -std::ostream& operator <<(std::ostream& out, const dxbc_container& container) -{ - for(unsigned i = 0; i < container.chunks.size(); ++i) - { - struct dxbc_chunk_header* chunk = container.chunks[i]; - char fourcc_str[5]; - memcpy(fourcc_str, &chunk->fourcc, 4); - fourcc_str[4] = 0; - out << "# DXBC chunk " << std::setw(2) << i << ": " << fourcc_str << " offset " << ((char*)chunk - (char*)container.data) << " size " << bswap_le32(chunk->size) << "\n"; - } - return out; -} diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/src/dxbc_parse.cpp b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/dxbc_parse.cpp deleted file mode 100644 index 05d10c19543..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/src/dxbc_parse.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Luca Barbieri - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include <memory> -#include "dxbc.h" -#include <d3d11shader.h> -#include <d3dcommon.h> - -dxbc_container* dxbc_parse(const void* data, int size) -{ - std::auto_ptr<dxbc_container> container(new dxbc_container()); - container->data = data; - dxbc_container_header* header = (dxbc_container_header*)data; - uint32_t* chunk_offsets = (uint32_t*)(header + 1); - if(bswap_le32(header->fourcc) != FOURCC_DXBC) - return 0; - unsigned num_chunks = bswap_le32(header->chunk_count); - for(unsigned i = 0; i < num_chunks; ++i) - { - unsigned offset = bswap_le32(chunk_offsets[i]); - dxbc_chunk_header* chunk = (dxbc_chunk_header*)((char*)data + offset); - unsigned fourcc = bswap_le32(chunk->fourcc); - container->chunk_map[fourcc] = i; - container->chunks.push_back(chunk); - } - return container.release(); -} - -dxbc_chunk_header* dxbc_find_chunk(const void* data, int size, unsigned fourcc) -{ - dxbc_container_header* header = (dxbc_container_header*)data; - uint32_t* chunk_offsets = (uint32_t*)(header + 1); - if(bswap_le32(header->fourcc) != FOURCC_DXBC) - return 0; - unsigned num_chunks = bswap_le32(header->chunk_count); - for(unsigned i = 0; i < num_chunks; ++i) - { - unsigned offset = bswap_le32(chunk_offsets[i]); - dxbc_chunk_header* chunk = (dxbc_chunk_header*)((char*)data + offset); - if(bswap_le32(chunk->fourcc) == fourcc) - return chunk; - } - return 0; -} - -int dxbc_parse_signature(dxbc_chunk_signature* sig, D3D11_SIGNATURE_PARAMETER_DESC** params) -{ - unsigned count = bswap_le32(sig->count); - *params = (D3D11_SIGNATURE_PARAMETER_DESC*)malloc(sizeof(D3D11_SIGNATURE_PARAMETER_DESC) * count); - - for (unsigned i = 0; i < count; ++i) - { - D3D11_SIGNATURE_PARAMETER_DESC& param = (*params)[i]; - param.SemanticName = (char*)&sig->count + bswap_le32(sig->elements[i].name_offset); - param.SemanticIndex = bswap_le32(sig->elements[i].semantic_index); - param.SystemValueType = (D3D_NAME)bswap_le32(sig->elements[i].system_value_type); - param.ComponentType = (D3D_REGISTER_COMPONENT_TYPE)bswap_le32(sig->elements[i].component_type); - param.Register = bswap_le32(sig->elements[i].register_num); - param.Mask = sig->elements[i].mask; - param.ReadWriteMask = sig->elements[i].read_write_mask; - param.Stream = sig->elements[i].stream; - } - return count; -} diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/src/sm4_analyze.cpp b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/sm4_analyze.cpp deleted file mode 100644 index ac7bfdc21a4..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/src/sm4_analyze.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Luca Barbieri - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include <vector> -#include <set> -#include "sm4.h" - -#define check(x) do {if(!(x)) return false;} while(0) - -bool sm4_link_cf_insns(sm4_program& program) -{ - if(program.cf_insn_linked.size()) - return true; - - std::vector<int> cf_insn_linked; - cf_insn_linked.resize(program.insns.size()); - memset(&cf_insn_linked[0], 0xff, cf_insn_linked.size() * sizeof(int)); - std::vector<unsigned> cf_stack; - for(unsigned insn_num = 0; insn_num < program.insns.size(); ++insn_num) - { - unsigned v; - switch(program.insns[insn_num]->opcode) - { - case SM4_OPCODE_LOOP: - cf_stack.push_back(insn_num); - break; - case SM4_OPCODE_ENDLOOP: - check(!cf_stack.empty()); - v = cf_stack.back(); - 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 SM4_OPCODE_IF: - case SM4_OPCODE_SWITCH: - cf_insn_linked[insn_num] = insn_num; // later changed - cf_stack.push_back(insn_num); - break; - case SM4_OPCODE_ELSE: - case SM4_OPCODE_CASE: - check(!cf_stack.empty()); - v = cf_stack.back(); - if(program.insns[insn_num]->opcode == SM4_OPCODE_ELSE) - check(program.insns[v]->opcode == SM4_OPCODE_IF); - else - 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 SM4_OPCODE_ENDSWITCH: - case SM4_OPCODE_ENDIF: - check(!cf_stack.empty()); - v = cf_stack.back(); - 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 == 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(); - break; - } - } - check(cf_stack.empty()); - program.cf_insn_linked.swap(cf_insn_linked); - return true; -} - -bool sm4_find_labels(sm4_program& program) -{ - if(program.labels_found) - return true; - - std::vector<int> labels; - for(unsigned insn_num = 0; insn_num < program.insns.size(); ++insn_num) - { - switch(program.insns[insn_num]->opcode) - { - case SM4_OPCODE_LABEL: - if(program.insns[insn_num]->num_ops > 0) - { - 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()) - labels.resize(idx + 1); - labels[idx] = insn_num; - } - } - break; - } - } - program.label_to_insn_num.swap(labels); - program.labels_found = true; - return true; -} diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/src/sm4_dump.cpp b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/sm4_dump.cpp deleted file mode 100644 index 746d7c8927f..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/src/sm4_dump.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Luca Barbieri - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include "sm4.h" - -// TODO: we should fix this to output the same syntax as fxc, if sm4_dump_short_syntax is set - -bool sm4_dump_short_syntax = true; - -std::ostream& operator <<(std::ostream& out, const sm4_op& op) -{ - if(op.neg) - out << '-'; - if(op.abs) - out << '|'; - if(op.file == SM4_FILE_IMMEDIATE32) - { - out << "l("; - for(unsigned i = 0; i < op.comps; ++i) - { - if(i) - out << ", "; - out << op.imm_values[i].f32; - } - out << ")"; - } - else if(op.file == SM4_FILE_IMMEDIATE64) - { - out << "d("; - for(unsigned i = 0; i < op.comps; ++i) - { - if(i) - out << ", "; - out << op.imm_values[i].f64; - } - out << ")"; - return out; - } - else - { - bool naked = false; - if(sm4_dump_short_syntax) - { - switch(op.file) - { - 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: - naked = false; - break; - } - } - - out << (sm4_dump_short_syntax ? sm4_shortfile_names : sm4_file_names)[op.file]; - - if(op.indices[0].reg.get()) - naked = false; - - for(unsigned i = 0; i < op.num_indices; ++i) - { - if(!naked || i) - out << '['; - if(op.indices[i].reg.get()) - { - out << *op.indices[i].reg; - if(op.indices[i].disp) - out << '+' << op.indices[i].disp; - } - else - out << op.indices[i].disp; - if(!naked || i) - out << ']'; - } - if(op.comps) - { - switch(op.mode) - { - 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 SM4_OPERAND_MODE_SWIZZLE: - out << '.'; - for(unsigned i = 0; i < op.comps; ++i) - out << "xyzw"[op.swizzle[i]]; - break; - case SM4_OPERAND_MODE_SCALAR: - out << (sm4_dump_short_syntax ? '.' : ':'); - out << "xyzw"[op.swizzle[0]]; - break; - } - } - } - if(op.abs) - out << '|'; - return out; -} - -std::ostream& operator <<(std::ostream& out, const sm4_dcl& dcl) -{ - out << sm4_opcode_names[dcl.opcode]; - switch(dcl.opcode) - { - case SM4_OPCODE_DCL_GLOBAL_FLAGS: - if(dcl.dcl_global_flags.allow_refactoring) - out << " refactoringAllowed"; - if(dcl.dcl_global_flags.early_depth_stencil) - out << " forceEarlyDepthStencil"; - if(dcl.dcl_global_flags.fp64) - out << " enableDoublePrecisionFloatOps"; - if(dcl.dcl_global_flags.enable_raw_and_structured_in_non_cs) - out << " enableRawAndStructuredBuffers"; - break; - 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 SM4_OPCODE_DCL_TEMPS: - out << ' ' << dcl.num; - break; - default: - break; - } - if(dcl.op.get()) - out << ' ' << *dcl.op; - switch(dcl.opcode) - { - case SM4_OPCODE_DCL_CONSTANT_BUFFER: - out << ", " << (dcl.dcl_constant_buffer.dynamic ? "dynamicIndexed" : "immediateIndexed"); - break; - 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 sm4_insn& insn) -{ - out << sm4_opcode_names[insn.opcode]; - if(insn.insn.sat) - out << "_sat"; - for(unsigned i = 0; i < insn.num_ops; ++i) - { - if(i) - out << ','; - out << ' ' << *insn.ops[i]; - } - return out; -} - -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) - out << *program.dcls[i] << "\n"; - - for(unsigned i = 0; i < program.insns.size(); ++i) - out << *program.insns[i] << "\n"; - return out; -} - -void sm4_op::dump() -{ - std::cout << *this; -} - -void sm4_insn::dump() -{ - std::cout << *this; -} - -void sm4_dcl::dump() -{ - std::cout << *this; -} - -void sm4_program::dump() -{ - std::cout << *this; -} diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/src/sm4_parse.cpp b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/sm4_parse.cpp deleted file mode 100644 index e35f8f2be9b..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/src/sm4_parse.cpp +++ /dev/null @@ -1,445 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Luca Barbieri - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include "sm4.h" -#include "utils.h" - -#if 1 -#define check(x) assert(x) -#define fail(x) assert(0 && (x)) -#else -#define check(x) do {if(!(x)) throw(#x);} while(0) -#define fail(x) throw(x) -#endif - -struct sm4_parser -{ - unsigned* tokens; - unsigned* tokens_end; - sm4_program& program; - - sm4_parser(sm4_program& program, void* p_tokens, unsigned size) - : program(program) - { - tokens = (unsigned*)p_tokens; - tokens_end = (unsigned*)((char*)p_tokens + size); - } - - /* TODO: byteswap if machine is big endian */ - uint32_t read32() - { - check(tokens < tokens_end); - return bswap_le32(*tokens++); - } - - template<typename T> - void read_token(T* tok) - { - *(unsigned*)tok = read32(); - } - - uint64_t read64() - { - unsigned a = read32(); - unsigned b = read32(); - return (uint64_t)a | ((uint64_t)b << 32); - } - - void skip(unsigned toskip) - { - tokens += toskip; - } - - void read_op(sm4_op* pop) - { - sm4_op& op = *pop; - sm4_token_operand optok; - read_token(&optok); - assert(optok.file < SM4_FILE_COUNT); - op.swizzle[0] = 0; - op.swizzle[1] = 1; - op.swizzle[2] = 2; - op.swizzle[3] = 3; - op.mask = 0xf; - switch(optok.comps_enum) - { - case SM4_OPERAND_COMPNUM_0: - op.comps = 0; - break; - case SM4_OPERAND_COMPNUM_1: - op.comps = 1; - op.swizzle[1] = op.swizzle[2] = op.swizzle[3] = 0; - break; - case SM4_OPERAND_COMPNUM_4: - op.comps = 4; - op.mode = optok.mode; - switch(optok.mode) - { - case SM4_OPERAND_MODE_MASK: - op.mask = SM4_OPERAND_SEL_MASK(optok.sel); - break; - 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 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 SM4_OPERAND_COMPNUM_N: - fail("Unhandled operand component type"); - } - op.file = (sm4_file)optok.file; - op.num_indices = optok.num_indices; - - if(optok.extended) - { - sm4_token_operand_extended optokext; - read_token(&optokext); - if(optokext.type == 0) - {} - else if(optokext.type == 1) - { - op.neg = optokext.neg; - op.abs= optokext.abs; - } - else - fail("Unhandled extended operand token type"); - } - - for(unsigned i = 0; i < op.num_indices; ++i) - { - unsigned repr; - if(i == 0) - repr = optok.index0_repr; - else if(i == 1) - repr = optok.index1_repr; - else if(i == 2) - repr = optok.index2_repr; - else - fail("Unhandled operand index representation"); - op.indices[i].disp = 0; - // TODO: is disp supposed to be signed here?? - switch(repr) - { - case SM4_OPERAND_INDEX_REPR_IMM32: - op.indices[i].disp = (int32_t)read32(); - break; - case SM4_OPERAND_INDEX_REPR_IMM64: - op.indices[i].disp = read64(); - break; - case SM4_OPERAND_INDEX_REPR_REG: -relative: - op.indices[i].reg.reset(new sm4_op()); - read_op(&*op.indices[i].reg); - break; - case SM4_OPERAND_INDEX_REPR_REG_IMM32: - op.indices[i].disp = (int32_t)read32(); - goto relative; - case SM4_OPERAND_INDEX_REPR_REG_IMM64: - op.indices[i].disp = read64(); - goto relative; - } - } - - if(op.file == SM4_FILE_IMMEDIATE32) - { - for(unsigned i = 0; i < op.comps; ++i) - op.imm_values[i].i32 = read32(); - } - else if(op.file == SM4_FILE_IMMEDIATE64) - { - for(unsigned i = 0; i < op.comps; ++i) - op.imm_values[i].i64 = read64(); - } - } - - void do_parse() - { - read_token(&program.version); - - unsigned lentok = read32(); - tokens_end = tokens - 2 + lentok; - - while(tokens != tokens_end) - { - sm4_token_instruction insntok; - read_token(&insntok); - unsigned* insn_end = tokens - 1 + insntok.length; - sm4_opcode opcode = (sm4_opcode)insntok.opcode; - check(opcode < SM4_OPCODE_COUNT); - - if(opcode == SM4_OPCODE_CUSTOMDATA) - { - // immediate constant buffer data - unsigned customlen = read32() - 2; - - sm4_dcl& dcl = *new sm4_dcl; - program.dcls.push_back(&dcl); - - dcl.opcode = SM4_OPCODE_CUSTOMDATA; - dcl.num = customlen; - dcl.data = malloc(customlen * sizeof(tokens[0])); - - memcpy(dcl.data, &tokens[0], customlen * sizeof(tokens[0])); - - skip(customlen); - continue; - } - - if(opcode == SM4_OPCODE_HS_FORK_PHASE || opcode == SM4_OPCODE_HS_JOIN_PHASE) - { - // need to interleave these with the declarations or we cannot - // assign fork/join phase instance counts to phases - sm4_dcl& dcl = *new sm4_dcl; - program.dcls.push_back(&dcl); - dcl.opcode = opcode; - } - - if((opcode >= SM4_OPCODE_DCL_RESOURCE && opcode <= SM4_OPCODE_DCL_GLOBAL_FLAGS) - || (opcode >= SM4_OPCODE_DCL_STREAM && opcode <= SM4_OPCODE_DCL_RESOURCE_STRUCTURED)) - { - sm4_dcl& dcl = *new sm4_dcl; - program.dcls.push_back(&dcl); - (sm4_token_instruction&)dcl = insntok; - - sm4_token_instruction_extended exttok; - memcpy(&exttok, &insntok, sizeof(exttok)); - while(exttok.extended) - { - read_token(&exttok); - } - -#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 == SM4_FILE_##FILE); - - switch(opcode) - { - case SM4_OPCODE_DCL_GLOBAL_FLAGS: - break; - case SM4_OPCODE_DCL_RESOURCE: - READ_OP(RESOURCE); - read_token(&dcl.rrt); - break; - case SM4_OPCODE_DCL_SAMPLER: - READ_OP(SAMPLER); - break; - case SM4_OPCODE_DCL_INPUT: - case SM4_OPCODE_DCL_INPUT_PS: - READ_OP(INPUT); - break; - 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 = (sm4_sv)(uint16_t)read32(); - break; - case SM4_OPCODE_DCL_OUTPUT: - READ_OP(OUTPUT); - break; - case SM4_OPCODE_DCL_OUTPUT_SIV: - case SM4_OPCODE_DCL_OUTPUT_SGV: - READ_OP(OUTPUT); - dcl.sv = (sm4_sv)(uint16_t)read32(); - break; - case SM4_OPCODE_DCL_INDEX_RANGE: - READ_OP_ANY; - check(dcl.op->file == SM4_FILE_INPUT || dcl.op->file == SM4_FILE_OUTPUT); - dcl.num = read32(); - break; - case SM4_OPCODE_DCL_TEMPS: - dcl.num = read32(); - break; - case SM4_OPCODE_DCL_INDEXABLE_TEMP: - READ_OP(INDEXABLE_TEMP); - dcl.indexable_temp.num = read32(); - dcl.indexable_temp.comps = read32(); - break; - case SM4_OPCODE_DCL_CONSTANT_BUFFER: - READ_OP(CONSTANT_BUFFER); - break; - case SM4_OPCODE_DCL_GS_INPUT_PRIMITIVE: - case SM4_OPCODE_DCL_GS_OUTPUT_PRIMITIVE_TOPOLOGY: - break; - case SM4_OPCODE_DCL_MAX_OUTPUT_VERTEX_COUNT: - dcl.num = read32(); - break; - case SM4_OPCODE_DCL_GS_INSTANCE_COUNT: - dcl.num = read32(); - break; - 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 SM4_OPCODE_DCL_HS_MAX_TESSFACTOR: - dcl.f32 = read32(); - break; - case SM4_OPCODE_DCL_HS_FORK_PHASE_INSTANCE_COUNT: - dcl.num = read32(); - break; - case SM4_OPCODE_DCL_FUNCTION_BODY: - dcl.num = read32(); - break; - 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 SM4_OPCODE_DCL_INTERFACE: - dcl.intf.id = read32(); - dcl.intf.expected_function_table_length = read32(); - { - uint32_t v = read32(); - dcl.intf.table_length = v & 0xffff; - dcl.intf.array_length = v >> 16; - } - dcl.data = malloc(dcl.intf.table_length * sizeof(uint32_t)); - for(unsigned i = 0; i < dcl.intf.table_length; ++i) - ((uint32_t*)dcl.data)[i] = read32(); - break; - 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 SM4_OPCODE_DCL_UNORDERED_ACCESS_VIEW_TYPED: - READ_OP(UNORDERED_ACCESS_VIEW); - read_token(&dcl.rrt); - break; - case SM4_OPCODE_DCL_UNORDERED_ACCESS_VIEW_RAW: - READ_OP(UNORDERED_ACCESS_VIEW); - break; - case SM4_OPCODE_DCL_UNORDERED_ACCESS_VIEW_STRUCTURED: - READ_OP(UNORDERED_ACCESS_VIEW); - dcl.structured.stride = read32(); - break; - case SM4_OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_RAW: - READ_OP(THREAD_GROUP_SHARED_MEMORY); - dcl.num = read32(); - break; - 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 SM4_OPCODE_DCL_RESOURCE_RAW: - READ_OP(RESOURCE); - break; - case SM4_OPCODE_DCL_RESOURCE_STRUCTURED: - READ_OP(RESOURCE); - dcl.structured.stride = read32(); - break; - case SM4_OPCODE_DCL_STREAM: - /* TODO: dcl_stream is undocumented: what is it? */ - fail("Unhandled dcl_stream since it's undocumented"); - default: - fail("Unhandled declaration"); - } - - check(tokens == insn_end); - } - else - { - sm4_insn& insn = *new sm4_insn; - program.insns.push_back(&insn); - (sm4_token_instruction&)insn = insntok; - - sm4_token_instruction_extended exttok; - memcpy(&exttok, &insntok, sizeof(exttok)); - while(exttok.extended) - { - read_token(&exttok); - 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 == SM4_TOKEN_INSTRUCTION_EXTENDED_TYPE_RESOURCE_DIM) - insn.resource_target = exttok.resource_target.target; - 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; - insn.resource_return_type[2] = exttok.resource_return_type.z; - insn.resource_return_type[3] = exttok.resource_return_type.w; - } - } - - switch(opcode) - { - case SM4_OPCODE_INTERFACE_CALL: - insn.num = read32(); - break; - default: - break; - } - - unsigned op_num = 0; - while(tokens != insn_end) - { - check(tokens < insn_end); - check(op_num < SM4_MAX_OPS); - insn.ops[op_num].reset(new sm4_op); - read_op(&*insn.ops[op_num]); - ++op_num; - } - insn.num_ops = op_num; - } - } - } - - const char* parse() - { - try - { - do_parse(); - return 0; - } - catch(const char* error) - { - return error; - } - } -}; - -sm4_program* sm4_parse(void* tokens, int size) -{ - sm4_program* program = new sm4_program; - sm4_parser parser(*program, tokens, size); - if(!parser.parse()) - return program; - delete program; - return 0; -} diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/src/utils.h b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/utils.h deleted file mode 100644 index 6e77b51175d..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/src/utils.h +++ /dev/null @@ -1,45 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Luca Barbieri - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#ifndef BYTESWAP_H_ -#define BYTESWAP_H_ - -#include <stdint.h> -#include <assert.h> - -#ifdef WORDS_BIGENDIAN -static inline uint32_t le32_to_cpu(uint32_t v) -{ - return ((v & 0xff) << 24) | ((v & 0xff00) << 8) | ((v & 0xff0000) >> 8) | ((v & 0xff000000) >> 24); -} -#else -static inline uint32_t le32_to_cpu(uint32_t v) -{ - return v; -} -#endif - -#endif /* BYTESWAP_H_ */ diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/tools/fxdis.cpp b/src/gallium/state_trackers/d3d1x/d3d1xshader/tools/fxdis.cpp deleted file mode 100644 index 20a7cbd1c38..00000000000 --- a/src/gallium/state_trackers/d3d1x/d3d1xshader/tools/fxdis.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Luca Barbieri - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include "dxbc.h" -#include "sm4.h" -#include <iostream> -#include <fstream> - -void usage() -{ - std::cerr << "Gallium Direct3D10/11 Shader Disassembler\n"; - std::cerr << "This program is free software, released under a MIT-like license\n"; - std::cerr << "Not affiliated with or endorsed by Microsoft in any way\n"; - std::cerr << "Latest version available from http://cgit.freedesktop.org/mesa/mesa/\n"; - std::cerr << "\n"; - std::cerr << "Usage: fxdis FILE\n"; - std::cerr << std::endl; -} - -int main(int argc, char** argv) -{ - if(argc < 2) - { - usage(); - return 1; - } - - std::vector<char> data; - std::ifstream in(argv[1]); - char c; - in >> std::noskipws; - while(in >> c) - data.push_back(c); - in.close(); - - dxbc_container* dxbc = dxbc_parse(&data[0], data.size()); - if(dxbc) - { - std::cout << *dxbc; - dxbc_chunk_header* sm4_chunk = dxbc_find_shader_bytecode(&data[0], data.size()); - if(sm4_chunk) - { - sm4_program* sm4 = sm4_parse(sm4_chunk + 1, bswap_le32(sm4_chunk->size)); - if(sm4) - { - std::cout << *sm4; - delete sm4; - } - } - delete dxbc; - } -} |