diff options
author | Keith Whitwell <[email protected]> | 2010-10-17 19:03:42 -0700 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2010-10-17 19:09:42 -0700 |
commit | 0072acd447dc6be652e63752e50215c3105322c8 (patch) | |
tree | 847d1763b54772d336a04e606f8248291c3092b7 /src/gallium/state_trackers/d3d1x | |
parent | 543fb77ddece7e1806e8eaa0d65bb2a945ef9a75 (diff) | |
parent | ca2b2ac131933b4171b519813df1aaa3a81621cd (diff) |
Merge remote branch 'origin/master' into lp-setup-llvm
Conflicts:
src/gallium/drivers/llvmpipe/lp_setup_coef.c
src/gallium/drivers/llvmpipe/lp_setup_coef.h
src/gallium/drivers/llvmpipe/lp_setup_coef_intrin.c
src/gallium/drivers/llvmpipe/lp_setup_point.c
src/gallium/drivers/llvmpipe/lp_setup_tri.c
src/gallium/drivers/llvmpipe/lp_state_derived.c
src/gallium/drivers/llvmpipe/lp_state_fs.h
Diffstat (limited to 'src/gallium/state_trackers/d3d1x')
140 files changed, 26958 insertions, 0 deletions
diff --git a/src/gallium/state_trackers/d3d1x/.gitignore b/src/gallium/state_trackers/d3d1x/.gitignore new file mode 100644 index 00000000000..f23bac71769 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/.gitignore @@ -0,0 +1,20 @@ +d3d1xshader/include/sm4_defs.h +d3d1xshader/src/sm4_text.cpp +d3d1xshader/tools/fxdis +d3dapi/*.h +docs/module_dependencies.svg +docs/module_dependencies.pdf +gd3d10/*.generated.* +gd3d1x/tools/dxbc2tgsi +gd3dapi/*.h +mstools/DXSDK +mstools/*.dll +mstools/*.exe +progs/bin/* +winedlls/*/version.res +winedlls/*/*.def +*.suo +*.vcxproj.filters +*.vcxproj.user +Debug +Release diff --git a/src/gallium/state_trackers/d3d1x/Makefile b/src/gallium/state_trackers/d3d1x/Makefile new file mode 100644 index 00000000000..75076eed723 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/Makefile @@ -0,0 +1,11 @@ +SUBDIRS=d3dapi gd3dapi docs d3d1xstutil d3d1xshader gd3d1x gd3d11 gd3d10 dxgi dxgid3d11 dxgid3d10 + +all: + @for dir in $(SUBDIRS) ; do $(MAKE) -C "$$dir" || exit $?; done + +clean: + rm -f `find . -name \*.[oa]` + rm -f `find . -name depend` + +install: + diff --git a/src/gallium/state_trackers/d3d1x/Makefile.inc b/src/gallium/state_trackers/d3d1x/Makefile.inc new file mode 100644 index 00000000000..303915d5bf5 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/Makefile.inc @@ -0,0 +1,19 @@ +TOP=../../../../.. +include $(TOP)/configs/current + +IDL=$(wildcard *.idl include/*.idl) +IDL_H=$(IDL:.idl=.h) +LD=$(CXX) $(CXXFLAGS) + +include ../../../Makefile.template + +idl: $(IDL_H) + +%.h: %.idl + widl -I../gd3dapi -I../d3dapi -I../w32api -U /dev/null -H $@ $^ + +%.svg: %.dot + dot -Tsvg -o $@ $< + +%.pdf: %.dot + dot -Tpdf -o $@ $< diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/Makefile b/src/gallium/state_trackers/d3d1x/d3d1xshader/Makefile new file mode 100644 index 00000000000..f132518ccc7 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/Makefile @@ -0,0 +1,16 @@ +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 new file mode 100644 index 00000000000..c44a46beed5 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/files.txt @@ -0,0 +1,41 @@ +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 new file mode 100644 index 00000000000..4e52eec34f4 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/interpolations.txt @@ -0,0 +1,8 @@ +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 new file mode 100644 index 00000000000..46ff28d6f9c --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/opcodes.txt @@ -0,0 +1,207 @@ +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 new file mode 100644 index 00000000000..887df2b141a --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/operand_compnums.txt @@ -0,0 +1,5 @@ +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 new file mode 100644 index 00000000000..f1ce172aaf1 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/operand_index_reprs.txt @@ -0,0 +1,5 @@ +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 new file mode 100644 index 00000000000..4088957e989 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/operand_modes.txt @@ -0,0 +1,4 @@ +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 new file mode 100644 index 00000000000..9e2d303ccd9 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/shortfiles.txt @@ -0,0 +1,41 @@ +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 new file mode 100644 index 00000000000..c7148ec301a --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/svs.txt @@ -0,0 +1,23 @@ +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 new file mode 100644 index 00000000000..d3bc186c54d --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/targets.txt @@ -0,0 +1,13 @@ +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 new file mode 100644 index 00000000000..e8fd70c4808 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/token_instruction_extended_types.txt @@ -0,0 +1,4 @@ +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 new file mode 100644 index 00000000000..891fcafa67a --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/token_operand_extended_types.txt @@ -0,0 +1,2 @@ +empty +modifier diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/gen-header.sh b/src/gallium/state_trackers/d3d1x/d3d1xshader/gen-header.sh new file mode 100755 index 00000000000..fcda13f9076 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/gen-header.sh @@ -0,0 +1,13 @@ +#!/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 new file mode 100755 index 00000000000..4663f635d43 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/gen-text.sh @@ -0,0 +1,11 @@ +#!/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 new file mode 100644 index 00000000000..5c7c87e5e8e --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/include/dxbc.h @@ -0,0 +1,112 @@ +/************************************************************************** + * + * 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') + +/* 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; +} + +static inline dxbc_chunk_signature* dxbc_find_signature(const void* data, int size, bool output) +{ + return (dxbc_chunk_signature*)dxbc_find_chunk(data, size, output ? FOURCC_OSGN : FOURCC_ISGN); +} + +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 new file mode 100644 index 00000000000..923942a7786 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/include/le32.h @@ -0,0 +1,45 @@ +/************************************************************************** + * + * 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 new file mode 100644 index 00000000000..d3ca2742a9e --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/include/sm4.h @@ -0,0 +1,410 @@ +/************************************************************************** + * + * 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 sm4_program +{ + 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 + * 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; + + /* NOTE: sampler 0 is the unnormalized nearest sampler for LD/LD_MS, while + * sampler 1 is user-specified sampler 0 + */ + bool resource_sampler_slots_assigned; + std::vector<int> slot_to_resource; + std::vector<int> slot_to_sampler; + std::map<std::pair<int, int>, int> resource_sampler_to_slot; + std::map<int, int> resource_to_slot; + + bool labels_found; + std::vector<int> label_to_insn_num; + + sm4_program() + { + memset(&version, 0, sizeof(version)); + labels_found = false; + resource_sampler_slots_assigned = false; + } + + ~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; + } + + 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); +bool sm4_allocate_resource_sampler_pairs(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 new file mode 100644 index 00000000000..1021a8a1bd5 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/dxbc_assemble.cpp @@ -0,0 +1,59 @@ +/************************************************************************** + * + * 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 new file mode 100644 index 00000000000..a3feec74463 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/dxbc_dump.cpp @@ -0,0 +1,43 @@ +/************************************************************************** + * + * 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 new file mode 100644 index 00000000000..4903e2c3b94 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/dxbc_parse.cpp @@ -0,0 +1,86 @@ +/************************************************************************** + * + * 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.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 new file mode 100644 index 00000000000..7903d547f14 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/sm4_analyze.cpp @@ -0,0 +1,186 @@ +/************************************************************************** + * + * 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; +} + +bool sm4_allocate_resource_sampler_pairs(sm4_program& program) +{ + if(program.resource_sampler_slots_assigned) + return true; + + std::set<std::pair<int, int> > pairs; + std::set<int> resinfos; + + for(unsigned insn_num = 0; insn_num < program.insns.size(); ++insn_num) + { + int resource = -1; + int sampler = -2; + for(unsigned i = 0; i < program.insns[insn_num]->num_ops; ++i) + { + sm4_op* op = program.insns[insn_num]->ops[i].get(); + if(op) + { + if(op->file == SM4_FILE_RESOURCE) + { + if(!op->has_simple_index() || resource >= 0) + return false; + resource = (int)op->indices[0].disp; + } + if(op->file == SM4_FILE_SAMPLER) + { + if(!op->has_simple_index() || sampler >= 0) + return false; + sampler = (int)op->indices[0].disp; + } + } + } + + unsigned opcode = program.insns[insn_num]->opcode; + 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 == SM4_OPCODE_RESINFO) + resinfos.insert(resource); + } + + for(std::set<std::pair<int, int> >::iterator i = pairs.begin(); i != pairs.end(); ++i) + { + program.resource_sampler_to_slot[*i] = program.slot_to_resource.size(); + if(!program.resource_to_slot.count(i->first)) + { + program.resource_to_slot[i->first] = program.slot_to_resource.size(); + resinfos.erase(i->first); + } + program.slot_to_resource.push_back(i->first); + program.slot_to_sampler.push_back(i->second); + } + + for(std::set<int>::iterator i = resinfos.begin(); i != resinfos.end(); ++i) + { + program.resource_sampler_to_slot[std::make_pair(*i, -1)] = program.slot_to_resource.size(); + program.resource_to_slot[*i] = program.slot_to_resource.size(); + program.slot_to_resource.push_back(*i); + program.slot_to_sampler.push_back(-1); + } + program.resource_sampler_slots_assigned = 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 new file mode 100644 index 00000000000..746d7c8927f --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/sm4_dump.cpp @@ -0,0 +1,222 @@ +/************************************************************************** + * + * 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 new file mode 100644 index 00000000000..2c0f8269af3 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/sm4_parse.cpp @@ -0,0 +1,424 @@ +/************************************************************************** + * + * 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; + 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[0].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[0].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) + { + unsigned customlen = read32() - 2; + skip(customlen); + continue; + } + + 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 new file mode 100644 index 00000000000..6e77b51175d --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/src/utils.h @@ -0,0 +1,45 @@ +/************************************************************************** + * + * 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 new file mode 100644 index 00000000000..20a7cbd1c38 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/tools/fxdis.cpp @@ -0,0 +1,75 @@ +/************************************************************************** + * + * 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; + } +} diff --git a/src/gallium/state_trackers/d3d1x/d3d1xstutil/Makefile b/src/gallium/state_trackers/d3d1x/d3d1xstutil/Makefile new file mode 100644 index 00000000000..f986f8e5f19 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xstutil/Makefile @@ -0,0 +1,5 @@ +LIBNAME=d3d1xstutil +CPP_SOURCES=$(wildcard src/*.cpp) +LIBRARY_INCLUDES=-Iinclude -I../gd3dapi -I../d3dapi -I../w32api -I../../../include -I../../../auxiliary + +include ../Makefile.inc diff --git a/src/gallium/state_trackers/d3d1x/d3d1xstutil/include/d3d1xstutil.h b/src/gallium/state_trackers/d3d1x/d3d1xstutil/include/d3d1xstutil.h new file mode 100644 index 00000000000..af355f02272 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xstutil/include/d3d1xstutil.h @@ -0,0 +1,1110 @@ +/************************************************************************** + * + * 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 D3D1XSTUTIL_H_ +#define D3D1XSTUTIL_H_ + +#ifdef _MSC_VER +#include <unordered_map> +#include <unordered_set> +#else +#include <tr1/unordered_map> +#include <tr1/unordered_set> +namespace std +{ + using namespace tr1; +} +#endif +#include <map> +#include <utility> + +#define WIN32_LEAN_AND_MEAN +#include <objbase.h> + +#include "galliumdxgi.h" +#include <d3dcommon.h> + +extern "C" +{ +#include <util/u_atomic.h> +#include <pipe/p_format.h> +#include <os/os_thread.h> +} + +#include <assert.h> +#ifdef min +#undef min +#endif +#ifdef max +#undef max +#endif + +#define D3D_PRIMITIVE_TOPOLOGY_COUNT 65 +extern unsigned d3d_to_pipe_prim[D3D_PRIMITIVE_TOPOLOGY_COUNT]; + +#define D3D_PRIMITIVE_COUNT 40 +extern unsigned d3d_to_pipe_prim_type[D3D_PRIMITIVE_COUNT]; + +/* NOTE: this _depends_ on the vtable layout of the C++ compiler to be + * binary compatible with Windows. + * Furthermore some absurd vtable layout likely won't work at all, since + * we perform some casts which are probably not safe by the C++ standard. + * + * In particular, the GNU/Linux/Itanium/clang ABI and Microsoft ABIs will work, + * but others may not. + * If in doubt, just switch to the latest version of a widely used C++ compiler. + * + * DESIGN of the Gallium COM implementation + * + * This state tracker uses somewhat unusual C++ coding patterns, + * to implement the COM interfaces required by Direct3D. + * + * While it may seem complicated, the effect is that the result + * generally behaves as intuitively as possible: in particular pointer + * casts very rarely change the pointer value (only for secondary + * DXGI/Gallium interfaces) + * + * Implementing COM is on first sight very easy: after all, it just + * consists of a reference count, and a dynamic_cast<> equivalent. + * + * However, implementing objects with multiple interfaces is actually + * quite tricky. + * The issue is that the interface pointers can't be equal, since this + * would place incompatible constraints on the vtable layout and thus + * multiple inheritance (and the subobjects the C++ compiler creates + * with it) must be correctly used. + * + * Furthermore, we must have a single reference count, which means + * that a naive implementation won't work, and it's necessary to either + * use virtual inheritance, or the "mixin inheritance" model we use. + * + * This solution aims to achieve the following object layout: + * 0: pointer to vtable for primary interface + * 1: reference count + * ... main class + * ... vtable pointers for secondary interfaces + * ... implementation of subclasses assuming secondary interfaces + * + * This allows us to cast pointers by just reinterpreting the value in + * almost all cases. + * + * To achieve this, *all* non-leaf classes must have their parent + * or the base COM interface as a template parameter, since derived + * classes may need to change that to support an interface derived + * from the one implemented by the superclass. + * + * Note however, that you can cast without regard to the template + * parameter, because only the vtable layout depends on it, since + * interfaces have no data members. + * + * For this to work, DON'T USE VIRTUAL FUNCTIONS except to implement + * interfaces, since the vtable layouts would otherwise be mismatched. + * An exception are virtual functions called only from other virtual functions, + * which is currently only used for the virtual destructor. + * + * The base class is GalliumComObject<IFoo>, which implements the + * IUnknown interface, and inherits IFoo. + * + * To support multiple inheritance, we insert GalliumMultiComObject, + * which redirects the secondary interfaces to the GalliumComObject + * superclass. + * + * Gallium(Multi)PrivateDataComObject is like ComObject but also + * implements the Get/SetPrivateData functions present on several + * D3D/DXGI interfaces. + * + * Example class hierarchy: + * + * IUnknown + * (pure interface) + * | + * V + * IAnimal + * (pure interface) + * | + * V + * IDuck + * (pure interface) + * | + * V + * GalliumComObject<IDuck> + * (non-instantiable, only implements IUnknown) + * | + * V + * GalliumAnimal<IDuck> + * (non-instantiable, only implements IAnimal) + * | + * V + * GalliumDuck + * (concrete) + * | + * V + * GalliumMultiComObject<GalliumDuck, IWheeledVehicle> <- IWheeledVehicle <- IVehicle <- IUnknown (second version) + * (non-instantiable, only implements IDuck and the IUnknown of IWheeledVehicle) + * | + * V + * GalliumDuckOnWheels + * (concrete) + * + * This will produce the desired layout. + * Note that GalliumAnimal<IFoo>* is safely castable to GalliumAnimal<IBar>* + * by reinterpreting, as long as non-interface virtual functions are not used, + * and that you only call interface functions for the superinterface of IBar + * that the object actually implements. + * + * Instead, if GalliumDuck where to inherit both from GalliumAnimal + * and IDuck, then (IDuck*)gallium_duck and (IAnimal*)gallium_duck would + * have different pointer values, which the "base class as template parameter" + * trick avoids. + * + * The price we pay is that you MUST NOT have virtual functions other than those + * implementing interfaces (except for leaf classes) since the position of these + * would depend on the base interface. + * As mentioned above, virtual functions only called from interface functions + * are an exception, currently used only for the virtual destructor. + * If you want virtual functions anyway , put them in a separate interface class, + * multiply inherit from that and cast the pointer to that interface. + * + * You CAN however have virtual functions on any class which does not specify + * his base as a template parameter, or where you don't need to change the + * template base interface parameter by casting. + * + * --- The magic QueryInterface "delete this" trick --- + * + * When the reference count drops to 0, we must delete the class. + * The problem is, that we must call the right virtual destructor (i.e. on the right class). + * However, we would like to be able to call release() and nonatomic_release() + * non-virtually for performance (also, the latter cannot be called virtually at all, since + * IUnknown does not offer it). + * + * The naive solution would be to just add a virtual destructor and rely on it. + * However, this doesn't work due to the fact that as described above we perform casets + * with are unsafe regarding vtable layout. + * In particular, consider the case where we try to delete GalliumComObject<ID3D11Texture2D> + * with a pointer to GalliumComObject<ID3D11Resource>. + * Since we think that this is a GalliumComObject<ID3D11Resource>, we'll look for the + * destructor in the vtable slot immediately after the ID3D11Resource vtable, but this is + * actually an ID3D11Texture2D function implemented by the object! + * + * So, we must put the destructor somewhere else. + * We could add it as a data member, but it would be awkward and it would bloat the + * class. + * Thus, we use this trick: we reuse the vtable slot for QueryInterface, which is always at the + * same position. + * To do so, we define a special value for the first pointer argument, that triggers a + * "delete this". + * In addition to that, we add a virtual destructor to GalliumComObject. + * That virtual destructor will be called by QueryInterface, and since that is a virtual + * function, it will know the correct place for the virtual destructor. + * + * QueryInterface is already slow due to the need to compare several GUIDs, so the + * additional pointer test should not be significant. + * + * Of course the ideal solution would be telling the C++ compiler to put the + * destructor it in a negative vtable slot, but unfortunately GCC doesn't support that + * yet, and this method is almost as good as that. + */ + +template<typename T> +struct com_traits; + +#define COM_INTERFACE(intf, base) \ +template<> \ +struct com_traits<intf> \ +{ \ + static REFIID iid() {return IID_##intf;} \ + static inline bool is_self_or_ancestor(REFIID riid) {return riid == iid() || com_traits<base>::is_self_or_ancestor(riid);} \ +}; + +template<> +struct com_traits<IUnknown> +{ + static REFIID iid() {return IID_IUnknown;} + static inline bool is_self_or_ancestor(REFIID riid) {return riid == iid();} +}; + +#ifndef _MSC_VER +#define __uuidof(T) (com_traits<T>::iid()) +#endif + +struct refcnt_t +{ + uint32_t refcnt; + + refcnt_t(unsigned v = 1) + : refcnt(v) + {} + + unsigned add_ref() + { + p_atomic_inc((int32_t*)&refcnt); + return refcnt; + } + + unsigned release() + { + if(p_atomic_dec_zero((int32_t*)&refcnt)) + return 0; + return refcnt; + } + + void nonatomic_add_ref() + { + p_atomic_inc((int32_t*)&refcnt); + } + + unsigned nonatomic_release() + { + if(p_atomic_dec_zero((int32_t*)&refcnt)) + return 0; + else + return 1; + } +}; + +#if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) +/* this should be safe because atomic ops are full memory barriers, and thus a sequence that does: + * ++one_refcnt; + * --other_refcnt; + * should never be reorderable (as seen from another CPU) to: + * --other_refcnt + * ++one_refcnt + * + * since one of the ops is atomic. + * If this weren't the case, a CPU could incorrectly destroy an object manipulated in that way by another one. + */ +struct dual_refcnt_t +{ + union + { + uint64_t refcnt; + struct + { + uint32_t atomic_refcnt; + uint32_t nonatomic_refcnt; + }; + }; + + dual_refcnt_t(unsigned v = 1) + { + atomic_refcnt = v; + nonatomic_refcnt = 0; + } + + bool is_zero() + { + if(sizeof(void*) == 8) + return *(volatile uint64_t*)&refcnt == 0ULL; + else + { + uint64_t v; + do + { + v = refcnt; + } + while(!__sync_bool_compare_and_swap(&refcnt, v, v)); + return v == 0ULL; + } + } + + unsigned add_ref() + { + //printf("%p add_ref at %u %u\n", this, atomic_refcnt, nonatomic_refcnt); + p_atomic_inc((int32_t*)&atomic_refcnt); + return atomic_refcnt + nonatomic_refcnt; + } + + unsigned release() + { + //printf("%p release at %u %u\n", this, atomic_refcnt, nonatomic_refcnt); + if(p_atomic_dec_zero((int32_t*)&atomic_refcnt) && !nonatomic_refcnt && is_zero()) + return 0; + unsigned v = atomic_refcnt + nonatomic_refcnt; + return v ? v : 1; + } + + void nonatomic_add_ref() + { + //printf("%p nonatomic_add_ref at %u %u\n", this, atomic_refcnt, nonatomic_refcnt); + ++nonatomic_refcnt; + } + + unsigned nonatomic_release() + { + //printf("%p nonatomic_release at %u %u\n", this, atomic_refcnt, nonatomic_refcnt); + if(!--nonatomic_refcnt) + { + __sync_synchronize(); + if(!atomic_refcnt && is_zero()) + return 0; + } + return 1; + } +}; +#else +// this will result in atomic operations being used while they could have been avoided +#ifdef __i386__ +#warning Compile for 586+ using GCC to improve the performance of the Direct3D 10/11 state tracker +#endif +typedef refcnt_t dual_refcnt_t; +#endif + +#define IID_MAGIC_DELETE_THIS (*(const IID*)((intptr_t)-(int)(sizeof(IID) - 1))) + +template<typename Base = IUnknown, typename RefCnt = refcnt_t> +struct GalliumComObject : public Base +{ + RefCnt refcnt; + + GalliumComObject() + {} + + /* DO NOT CALL this from externally called non-virtual functions in derived classes, since + * the vtable position depends on the COM interface being implemented + */ + virtual ~GalliumComObject() + {} + + inline ULONG add_ref() + { + return refcnt.add_ref(); + } + + inline ULONG release() + { + ULONG v = refcnt.release(); + if(!v) + { + /* this will call execute "delete this", using the correct vtable slot for the destructor */ + /* see the initial comment for an explaination of this magic trick */ + this->QueryInterface(IID_MAGIC_DELETE_THIS, 0); + return 0; + } + return v; + } + + inline void nonatomic_add_ref() + { + refcnt.nonatomic_add_ref(); + } + + inline void nonatomic_release() + { + if(!refcnt.nonatomic_release()) + { + /* this will execute "delete this", using the correct vtable slot for the destructor */ + /* see the initial comment for an explaination of this magic trick */ + this->QueryInterface(IID_MAGIC_DELETE_THIS, 0); + } + } + + inline HRESULT query_interface(REFIID riid, void **ppvObject) + { + if(com_traits<Base>::is_self_or_ancestor(riid)) + { + // must be the virtual AddRef, since it is overridden by some classes + this->AddRef(); + *ppvObject = this; + return S_OK; + } + else + return E_NOINTERFACE; + } + + virtual ULONG STDMETHODCALLTYPE AddRef() + { + return add_ref(); + } + + virtual ULONG STDMETHODCALLTYPE Release() + { + return release(); + } + + virtual HRESULT STDMETHODCALLTYPE QueryInterface( + REFIID riid, + void **ppvObject) + { + /* see the initial comment for an explaination of this magic trick */ + if(&riid == &IID_MAGIC_DELETE_THIS) + { + delete this; + return 0; + } + if(!this) + return E_INVALIDARG; + if(!ppvObject) + return E_POINTER; + return query_interface(riid, ppvObject); + } +}; + +template<typename BaseClass, typename SecondaryInterface> +struct GalliumMultiComObject : public BaseClass, SecondaryInterface +{ + // we could avoid this duplication, but the increased complexity to do so isn't worth it + virtual ULONG STDMETHODCALLTYPE AddRef() + { + return BaseClass::add_ref(); + } + + virtual ULONG STDMETHODCALLTYPE Release() + { + return BaseClass::release(); + } + + inline HRESULT query_interface(REFIID riid, void **ppvObject) + { + HRESULT hr = BaseClass::query_interface(riid, ppvObject); + if(SUCCEEDED(hr)) + return hr; + if(com_traits<SecondaryInterface>::is_self_or_ancestor(riid)) + { + // must be the virtual AddRef, since it is overridden by some classes + this->AddRef(); + *ppvObject = (SecondaryInterface*)this; + return S_OK; + } + else + return E_NOINTERFACE; + } + + virtual HRESULT STDMETHODCALLTYPE QueryInterface( + REFIID riid, + void **ppvObject) + { + /* see the initial comment for an explaination of this magic trick */ + if(&riid == &IID_MAGIC_DELETE_THIS) + { + delete this; + return 0; + } + if(!this) + return E_INVALIDARG; + if(!ppvObject) + return E_POINTER; + return query_interface(riid, ppvObject); + } +}; + +template<typename T, typename Traits> +struct refcnt_ptr +{ + T* p; + + refcnt_ptr() + : p(0) + {} + + void add_ref() {Traits::add_ref(p);} + void release() {Traits::release(p);} + + template<typename U, typename UTraits> + refcnt_ptr(const refcnt_ptr<U, UTraits>& c) + { + *this = static_cast<U*>(c.ref()); + } + + ~refcnt_ptr() + { + release(); + } + + void reset(T* q) + { + release(); + p = q; + } + + template<typename U, typename UTraits> + refcnt_ptr& operator =(const refcnt_ptr<U, UTraits>& q) + { + return *this = q.p; + } + + template<typename U> + refcnt_ptr& operator =(U* q) + { + release(); + p = static_cast<T*>(q); + add_ref(); + return *this; + } + + T* ref() + { + add_ref(); + return p; + } + + T* steal() + { + T* ret = p; + p = 0; + return ret; + } + + T* operator ->() + { + return p; + } + + const T* operator ->() const + { + return p; + } + + T** operator &() + { + assert(!p); + return &p; + } + + bool operator !() const + { + return !p; + } + + typedef T* refcnt_ptr::*unspecified_bool_type; + + operator unspecified_bool_type() const + { + return p ? &refcnt_ptr::p : 0; + } +}; + +struct simple_ptr_traits +{ + static void add_ref(void* p) {} + static void release(void* p) {} +}; + +struct com_ptr_traits +{ + static void add_ref(void* p) + { + if(p) + ((IUnknown*)p)->AddRef(); + } + + static void release(void* p) + { + if(p) + ((IUnknown*)p)->Release(); + } +}; + +template<typename T> +struct ComPtr : public refcnt_ptr<T, com_ptr_traits> +{ + template<typename U, typename UTraits> + ComPtr& operator =(const refcnt_ptr<U, UTraits>& q) + { + return *this = q.p; + } + + template<typename U> + ComPtr& operator =(U* q) + { + this->release(); + this->p = static_cast<T*>(q); + this->add_ref(); + return *this; + } +}; + +template<typename T, typename TTraits, typename U, typename UTraits> +bool operator ==(const refcnt_ptr<T, TTraits>& a, const refcnt_ptr<U, UTraits>& b) +{ + return a.p == b.p; +} + +template<typename T, typename TTraits, typename U> +bool operator ==(const refcnt_ptr<T, TTraits>& a, U* b) +{ + return a.p == b; +} + +template<typename T, typename TTraits, typename U> +bool operator ==(U* b, const refcnt_ptr<T, TTraits>& a) +{ + return a.p == b; +} + +template<typename T, typename TTraits, typename U, typename UTraits> +bool operator !=(const refcnt_ptr<T, TTraits>& a, const refcnt_ptr<U, UTraits>& b) +{ + return a.p != b.p; +} + +template<typename T, typename TTraits, typename U> +bool operator !=(const refcnt_ptr<T, TTraits>& a, U* b) +{ + return a.p != b; +} + +template<typename T, typename TTraits, typename U> +bool operator !=(U* b, const refcnt_ptr<T, TTraits>& a) +{ + return a.p != b; +} + +template<bool threadsafe> +struct maybe_mutex_t; + +template<> +struct maybe_mutex_t<true> +{ + pipe_mutex mutex; + + maybe_mutex_t() + { + pipe_mutex_init(mutex); + } + + void lock() + { + pipe_mutex_lock(mutex); + } + + void unlock() + { + pipe_mutex_unlock(mutex); + } +}; + +template<> +struct maybe_mutex_t<false> +{ + void lock() + { + } + + void unlock() + { + } +}; + +typedef maybe_mutex_t<true> mutex_t; + +template<typename T> +struct lock_t +{ + T& mutex; + lock_t(T& mutex) + : mutex(mutex) + { + mutex.lock(); + } + + ~lock_t() + { + mutex.unlock(); + } +}; + +struct c_string +{ + const char* p; + c_string(const char* p) + : p(p) + {} + + operator const char*() const + { + return p; + } +}; + +static inline bool operator ==(const c_string& a, const c_string& b) +{ + return !strcmp(a.p, b.p); +} + +static inline bool operator !=(const c_string& a, const c_string& b) +{ + return strcmp(a.p, b.p); +} + +static inline size_t raw_hash(const char* p, size_t size) +{ + size_t res; + if(sizeof(size_t) >= 8) + res = (size_t)14695981039346656037ULL; + else + res = (size_t)2166136261UL; + const char* end = p + size; + for(; p != end; ++p) + { + res ^= (size_t)*p; + if(sizeof(size_t) >= 8) + res *= (size_t)1099511628211ULL; + else + res *= (size_t)16777619UL; + } + return res; +}; + +template<typename T> +static inline size_t raw_hash(const T& t) +{ + return raw_hash((const char*)&t, sizeof(t)); +} + +// TODO: only tested with the gcc libstdc++, might not work elsewhere +namespace std +{ +#ifndef _MSC_VER + namespace tr1 + { +#endif + template<> + struct hash<GUID> : public std::unary_function<GUID, size_t> + { + inline size_t operator()(GUID __val) const; + }; + + inline size_t hash<GUID>::operator()(GUID __val) const + { + return raw_hash(__val); + } + + template<> + struct hash<c_string> : public std::unary_function<c_string, size_t> + { + inline size_t operator()(c_string __val) const; + }; + + inline size_t hash<c_string>::operator()(c_string __val) const + { + return raw_hash(__val.p, strlen(__val.p)); + } + + template<typename T, typename U> + struct hash<std::pair<T, U> > : public std::unary_function<std::pair<T, U>, size_t> + { + inline size_t operator()(std::pair<T, U> __val) const; + }; + + template<typename T, typename U> + inline size_t hash<std::pair<T, U> >::operator()(std::pair<T, U> __val) const + { + std::pair<size_t, size_t> p; + p.first = hash<T>()(__val.first); + p.second = hash<U>()(__val.second); + return raw_hash(p); + } +#ifndef _MSC_VER + } +#endif +} + +template<typename Base, typename RefCnt = refcnt_t> +struct GalliumPrivateDataComObject : public GalliumComObject<Base, RefCnt> +{ + typedef std::unordered_map<GUID, std::pair<void*, unsigned> > private_data_map_t; + private_data_map_t private_data_map; + mutex_t private_data_mutex; + + ~GalliumPrivateDataComObject() + { + for(private_data_map_t::iterator i = private_data_map.begin(), e = private_data_map.end(); i != e; ++i) + { + if(i->second.second == ~0u) + ((IUnknown*)i->second.first)->Release(); + else + free(i->second.first); + } + } + + HRESULT get_private_data( + REFGUID guid, + UINT *pDataSize, + void *pData) + { + lock_t<mutex_t> lock(private_data_mutex); + private_data_map_t::iterator i = private_data_map.find(guid); + *pDataSize = 0; + if(i == private_data_map.end()) + return DXGI_ERROR_NOT_FOUND; + if(i->second.second == ~0u) + { + /* TODO: is GetPrivateData on interface data supposed to do this? */ + if(*pDataSize < sizeof(void*)) + return E_INVALIDARG; + if(pData) + { + memcpy(pData, &i->second.first, sizeof(void*)); + ((IUnknown*)i->second.first)->AddRef(); + } + *pDataSize = sizeof(void*); + } + else + { + unsigned size = std::min(*pDataSize, i->second.second); + if(pData) + memcpy(pData, i->second.first, size); + *pDataSize = size; + } + return S_OK; + } + + HRESULT set_private_data( + REFGUID guid, + UINT DataSize, + const void *pData) + { + void* p = 0; + + if(DataSize && pData) + { + p = malloc(DataSize); + if(!p) + return E_OUTOFMEMORY; + } + + lock_t<mutex_t> lock(private_data_mutex); + std::pair<void*, unsigned>& v = private_data_map[guid]; + if(v.first) + { + if(v.second == ~0u) + ((IUnknown*)v.first)->Release(); + else + free(v.first); + } + if(DataSize && pData) + { + memcpy(p, pData, DataSize); + v.first = p; + v.second = DataSize; + } + else + private_data_map.erase(guid); + return S_OK; + } + + HRESULT set_private_data_interface( + REFGUID guid, + const IUnknown *pData) + { + lock_t<mutex_t> lock(private_data_mutex); + std::pair<void*, unsigned>& v = private_data_map[guid]; + if(v.first) + { + if(v.second == ~0u) + ((IUnknown*)v.first)->Release(); + else + free(v.first); + } + if(pData) + { + ((IUnknown*)pData)->AddRef(); + v.first = (void*)pData; + v.second = ~0; + } + else + private_data_map.erase(guid); + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE GetPrivateData( + REFGUID guid, + UINT *pDataSize, + void *pData) + { + return get_private_data(guid, pDataSize, pData); + } + + virtual HRESULT STDMETHODCALLTYPE SetPrivateData( + REFGUID guid, + UINT DataSize, + const void *pData) + { + return set_private_data(guid, DataSize, pData); + } + + virtual HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( + REFGUID guid, + const IUnknown *pData) + { + return set_private_data_interface(guid, pData); + } +}; + +template<typename BaseClass, typename SecondaryInterface> +struct GalliumMultiPrivateDataComObject : public GalliumMultiComObject<BaseClass, SecondaryInterface> +{ + // we could avoid this duplication, but the increased complexity to do so isn't worth it + virtual HRESULT STDMETHODCALLTYPE GetPrivateData( + REFGUID guid, + UINT *pDataSize, + void *pData) + { + return BaseClass::get_private_data(guid, pDataSize, pData); + } + + virtual HRESULT STDMETHODCALLTYPE SetPrivateData( + REFGUID guid, + UINT DataSize, + const void *pData) + { + return BaseClass::set_private_data(guid, DataSize, pData); + } + + virtual HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( + REFGUID guid, + const IUnknown *pData) + { + return BaseClass::set_private_data_interface(guid, pData); + } +}; + +#define DXGI_FORMAT_COUNT 100 +extern pipe_format dxgi_to_pipe_format[DXGI_FORMAT_COUNT]; +extern DXGI_FORMAT pipe_to_dxgi_format[PIPE_FORMAT_COUNT]; + +void init_pipe_to_dxgi_format(); + +COM_INTERFACE(IGalliumDevice, IUnknown); +COM_INTERFACE(IGalliumAdapter, IUnknown); +COM_INTERFACE(IGalliumResource, IUnknown); + +// used to make QueryInterface know the IIDs of the interface and its ancestors +COM_INTERFACE(IDXGIObject, IUnknown) +COM_INTERFACE(IDXGIDeviceSubObject, IDXGIObject) +COM_INTERFACE(IDXGISurface, IDXGIDeviceSubObject) +COM_INTERFACE(IDXGIOutput, IDXGIObject) +COM_INTERFACE(IDXGIAdapter, IDXGIObject) +COM_INTERFACE(IDXGISwapChain, IDXGIDeviceSubObject) +COM_INTERFACE(IDXGIFactory, IDXGIObject) +COM_INTERFACE(IDXGIDevice, IDXGIObject) +COM_INTERFACE(IDXGIResource, IDXGIDeviceSubObject) +COM_INTERFACE(IDXGISurface1, IDXGISurface) +COM_INTERFACE(IDXGIDevice1, IDXGIDevice) +COM_INTERFACE(IDXGIAdapter1, IDXGIAdapter) +COM_INTERFACE(IDXGIFactory1, IDXGIFactory) + +template<typename Base> +struct GalliumDXGIDevice : public GalliumMultiPrivateDataComObject<Base, IDXGIDevice1> +{ + ComPtr<IDXGIAdapter> adapter; + int priority; + unsigned max_latency; + + GalliumDXGIDevice(IDXGIAdapter* p_adapter) + { + adapter = p_adapter; + } + + virtual HRESULT STDMETHODCALLTYPE GetParent( + REFIID riid, + void **ppParent) + { + return adapter.p->QueryInterface(riid, ppParent); + } + + virtual HRESULT STDMETHODCALLTYPE GetAdapter( + IDXGIAdapter **pAdapter) + { + *pAdapter = adapter.ref(); + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE QueryResourceResidency( + IUnknown *const *ppResources, + DXGI_RESIDENCY *pResidencyStatus, + UINT NumResources) + { + for(unsigned i = 0; i < NumResources; ++i) + pResidencyStatus[i] = DXGI_RESIDENCY_FULLY_RESIDENT; + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE SetGPUThreadPriority( + INT Priority) + { + priority = Priority; + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE GetGPUThreadPriority( + INT *pPriority) + { + *pPriority = priority; + return S_OK; + } + + HRESULT STDMETHODCALLTYPE GetMaximumFrameLatency( + UINT *pMaxLatency + ) + { + *pMaxLatency = max_latency; + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE SetMaximumFrameLatency( + UINT MaxLatency) + { + max_latency = MaxLatency; + return S_OK; + } +}; + +COM_INTERFACE(ID3D10Blob, IUnknown); + +/* NOTE: ID3DBlob implementations may come from a Microsoft native DLL + * (e.g. d3dcompiler), or perhaps even from the application itself. + * + * Hence, never try to access the data/size members directly, which is why they are private. + * In internal code, use std::pair<void*, size_t> instead of this class. + */ +class GalliumD3DBlob : public GalliumComObject<ID3DBlob> +{ + void* data; + size_t size; + +public: + GalliumD3DBlob(void* data, size_t size) + : data(data), size(size) + {} + + ~GalliumD3DBlob() + { + free(data); + } + + virtual LPVOID STDMETHODCALLTYPE GetBufferPointer() + { + return data; + } + + virtual SIZE_T STDMETHODCALLTYPE GetBufferSize() + { + return size; + } +}; + +#endif /* D3D1XSTUTIL_H_ */ diff --git a/src/gallium/state_trackers/d3d1x/d3d1xstutil/src/d3d_sm4_enums.cpp b/src/gallium/state_trackers/d3d1x/d3d1xstutil/src/d3d_sm4_enums.cpp new file mode 100644 index 00000000000..410a56c2485 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xstutil/src/d3d_sm4_enums.cpp @@ -0,0 +1,42 @@ +#include "d3d1xstutil.h" + +unsigned d3d_to_pipe_prim[D3D_PRIMITIVE_TOPOLOGY_COUNT] = +{ + 0, + PIPE_PRIM_POINTS, + PIPE_PRIM_LINES, + PIPE_PRIM_LINE_STRIP, + PIPE_PRIM_TRIANGLES, + PIPE_PRIM_TRIANGLE_STRIP, + PIPE_PRIM_LINES_ADJACENCY, + PIPE_PRIM_LINE_STRIP_ADJACENCY, + PIPE_PRIM_TRIANGLES_ADJACENCY, + PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY, + /* gap */ + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, + /* patches */ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, +}; + +unsigned d3d_to_pipe_prim_type[D3D_PRIMITIVE_COUNT] = +{ + 0, + PIPE_PRIM_POINTS, + PIPE_PRIM_LINES, + PIPE_PRIM_TRIANGLES, + 0, + PIPE_PRIM_POINTS, + PIPE_PRIM_LINES_ADJACENCY, + PIPE_PRIM_TRIANGLES_ADJACENCY, + /* patches */ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, +}; diff --git a/src/gallium/state_trackers/d3d1x/d3d1xstutil/src/dxgi_enums.cpp b/src/gallium/state_trackers/d3d1x/d3d1xstutil/src/dxgi_enums.cpp new file mode 100644 index 00000000000..da28e643848 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xstutil/src/dxgi_enums.cpp @@ -0,0 +1,147 @@ +/************************************************************************** + * + * 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 <d3d1xstutil.h> + +/* D3D has to keep binary compatibility, so these tables will always work + * However, Gallium -> D3D conversion must use .[PIPE_xxx] = D3D11_xxx syntax */ + +pipe_format dxgi_to_pipe_format[DXGI_FORMAT_COUNT] = +{ + PIPE_FORMAT_NONE, + PIPE_FORMAT_R32G32B32A32_FLOAT, /* TYPELESS */ + PIPE_FORMAT_R32G32B32A32_FLOAT, + PIPE_FORMAT_R32G32B32A32_USCALED, + PIPE_FORMAT_R32G32B32A32_SSCALED, + PIPE_FORMAT_R32G32B32_FLOAT, /* TYPELESS */ + PIPE_FORMAT_R32G32B32_FLOAT, + PIPE_FORMAT_R32G32B32_USCALED, + PIPE_FORMAT_R32G32B32_SSCALED, + PIPE_FORMAT_R16G16B16A16_FLOAT, /* TYPELESS */ + PIPE_FORMAT_R16G16B16A16_FLOAT, + PIPE_FORMAT_R16G16B16A16_UNORM, + PIPE_FORMAT_R16G16B16A16_USCALED, + PIPE_FORMAT_R16G16B16A16_SNORM, + PIPE_FORMAT_R16G16B16A16_SSCALED, + PIPE_FORMAT_R32G32_FLOAT, /* TYPELESS */ + PIPE_FORMAT_R32G32_FLOAT, + PIPE_FORMAT_R32G32_USCALED, + PIPE_FORMAT_R32G32_SSCALED, + PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED, /* PIPE_FORMAT_R32G8X24_FLOAT_TYPELESS */ + PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED, + PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED, /* PIPE_FORMAT_R32_FLOAT_X8X24_TYPELESS */ + PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED, /* PIPE_FORMAT_X32_TYPELESS_G8X24_USCALED */ + PIPE_FORMAT_R10G10B10A2_UNORM, /* TYPELESS */ + PIPE_FORMAT_R10G10B10A2_UNORM, + PIPE_FORMAT_R10G10B10A2_USCALED, + PIPE_FORMAT_R11G11B10_FLOAT, + PIPE_FORMAT_R8G8B8A8_UNORM, /* TYPELESS */ + PIPE_FORMAT_R8G8B8A8_UNORM, + PIPE_FORMAT_R8G8B8A8_SRGB, + PIPE_FORMAT_R8G8B8A8_USCALED, + PIPE_FORMAT_R8G8B8A8_SNORM, + PIPE_FORMAT_R8G8B8A8_SSCALED, + PIPE_FORMAT_R16G16_FLOAT, /* TYPELESS */ + PIPE_FORMAT_R16G16_FLOAT, + PIPE_FORMAT_R16G16_UNORM, + PIPE_FORMAT_R16G16_USCALED, + PIPE_FORMAT_R16G16_SNORM, + PIPE_FORMAT_R16G16_SSCALED, + PIPE_FORMAT_R32_FLOAT, /* TYPELESS */ + PIPE_FORMAT_Z32_FLOAT, + PIPE_FORMAT_R32_FLOAT, + PIPE_FORMAT_R32_USCALED, + PIPE_FORMAT_R32_SSCALED, + PIPE_FORMAT_Z24_UNORM_S8_USCALED, /* PIPE_FORMAT_R24G8_TYPELESS */ + PIPE_FORMAT_Z24_UNORM_S8_USCALED, + PIPE_FORMAT_Z24X8_UNORM, /* PIPE_FORMAT_R24_UNORM_X8_TYPELESS */ + PIPE_FORMAT_Z24_UNORM_S8_USCALED, /* PIPE_FORMAT_X24_TYPELESS_G8_USCALED */ + PIPE_FORMAT_R8G8_UNORM, /* TYPELESS */ + PIPE_FORMAT_R8G8_UNORM, + PIPE_FORMAT_R8G8_USCALED, + PIPE_FORMAT_R8G8_SNORM, + PIPE_FORMAT_R8G8_SSCALED, + PIPE_FORMAT_R16_FLOAT, /* TYPELESS */ + PIPE_FORMAT_R16_FLOAT, + PIPE_FORMAT_Z16_UNORM, + PIPE_FORMAT_R16_UNORM, + PIPE_FORMAT_R16_USCALED, + PIPE_FORMAT_R16_SNORM, + PIPE_FORMAT_R16_SSCALED, + PIPE_FORMAT_R8_UNORM, /* TYPELESS */ + PIPE_FORMAT_R8_UNORM, + PIPE_FORMAT_R8_USCALED, + PIPE_FORMAT_R8_SNORM, + PIPE_FORMAT_R8_SSCALED, + PIPE_FORMAT_A8_UNORM, + PIPE_FORMAT_R1_UNORM, + PIPE_FORMAT_R9G9B9E5_FLOAT, + PIPE_FORMAT_R8G8_B8G8_UNORM, + PIPE_FORMAT_G8R8_G8B8_UNORM, + PIPE_FORMAT_DXT1_RGBA, /* TYPELESS */ + PIPE_FORMAT_DXT1_RGBA, + PIPE_FORMAT_DXT1_SRGBA, + PIPE_FORMAT_DXT3_RGBA, /* TYPELESS */ + PIPE_FORMAT_DXT3_RGBA, + PIPE_FORMAT_DXT3_SRGBA, + PIPE_FORMAT_DXT5_RGBA, /* TYPELESS */ + PIPE_FORMAT_DXT5_RGBA, + PIPE_FORMAT_DXT5_SRGBA, + PIPE_FORMAT_RGTC1_UNORM, /* TYPELESS */ + PIPE_FORMAT_RGTC1_UNORM, + PIPE_FORMAT_RGTC1_SNORM, + PIPE_FORMAT_RGTC2_UNORM, /* TYPELESS */ + PIPE_FORMAT_RGTC2_UNORM, + PIPE_FORMAT_RGTC2_SNORM, + PIPE_FORMAT_B5G6R5_UNORM, + PIPE_FORMAT_B5G5R5A1_UNORM, + PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_FORMAT_B8G8R8X8_UNORM, + PIPE_FORMAT_R10SG10SB10SA2U_NORM, + PIPE_FORMAT_B8G8R8A8_UNORM, /* TYPELESS */ + PIPE_FORMAT_B8G8R8A8_SRGB, + PIPE_FORMAT_B8G8R8X8_UNORM, /* TYPELESS */ + PIPE_FORMAT_B8G8R8X8_SRGB, + PIPE_FORMAT_NONE, /* PIPE_FORMAT_BC6H_TYPELESS */ + PIPE_FORMAT_NONE, /* PIPE_FORMAT_BC6H_UF16 */ + PIPE_FORMAT_NONE, /* PIPE_FORMAT_BC6H_SF16 */ + PIPE_FORMAT_NONE, /* PIPE_FORMAT_BC7_TYPELESS */ + PIPE_FORMAT_NONE, /* PIPE_FORMAT_BC7_UNORM */ + PIPE_FORMAT_NONE, /* PIPE_FORMAT_BC7_UNORM_SRGB */ +}; + +DXGI_FORMAT pipe_to_dxgi_format[PIPE_FORMAT_COUNT]; +static int pipe_to_dxgi_format_initialized; +void init_pipe_to_dxgi_format() +{ + if(!pipe_to_dxgi_format_initialized) + { + for(unsigned i = 0; i < DXGI_FORMAT_COUNT; ++i) + pipe_to_dxgi_format[dxgi_to_pipe_format[i]] = (DXGI_FORMAT)i; + pipe_to_dxgi_format[PIPE_FORMAT_NONE] = DXGI_FORMAT_UNKNOWN; + pipe_to_dxgi_format_initialized = 1; + } +} diff --git a/src/gallium/state_trackers/d3d1x/d3d1xstutil/src/guids.cpp b/src/gallium/state_trackers/d3d1x/d3d1xstutil/src/guids.cpp new file mode 100644 index 00000000000..ec45035b825 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3d1xstutil/src/guids.cpp @@ -0,0 +1,6 @@ +#define INITGUID +#include "d3d1xstutil.h" +#include <galliumd3d11.h> +#include <galliumd3d10_1.h> +#include <galliumdxgi.h> +#include <galliumcom.h> diff --git a/src/gallium/state_trackers/d3d1x/d3dapi/Makefile b/src/gallium/state_trackers/d3d1x/d3dapi/Makefile new file mode 100644 index 00000000000..8b16b1bcbcf --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3dapi/Makefile @@ -0,0 +1,4 @@ +all: idl + +include ../Makefile.inc + diff --git a/src/gallium/state_trackers/d3d1x/d3dapi/d3d10.idl b/src/gallium/state_trackers/d3d1x/d3dapi/d3d10.idl new file mode 100644 index 00000000000..91b1abc24ad --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3dapi/d3d10.idl @@ -0,0 +1,1554 @@ +/* + * Copyright 2007 Andras Kovacs + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* modified by Luca Barbieri on Sep 2010 to: + * - converted to using d3dcommon.idl + * - add missing D3D10_FORMAT_SUPPORT + * - add DXGI 1.1 D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX, D3D10_RESOURCE_MISC_GDI_COMPATIBLE +*/ +import "oaidl.idl"; +import "ocidl.idl"; +import "dxgi.idl"; +import "d3dcommon.idl"; + +cpp_quote("#ifndef _D3D10_CONSTANTS") +cpp_quote("#define _D3D10_CONSTANTS") +const float D3D10_DEFAULT_BLEND_FACTOR_ALPHA = 1.0; +const float D3D10_DEFAULT_BLEND_FACTOR_BLUE = 1.0; +const float D3D10_DEFAULT_BLEND_FACTOR_GREEN = 1.0; +const float D3D10_DEFAULT_BLEND_FACTOR_RED = 1.0; +const float D3D10_DEFAULT_BORDER_COLOR_COMPONENT = 0.0; +const float D3D10_DEFAULT_SLOPE_SCALED_DEPTH_BIAS = 0.0; +const float D3D10_DEFAULT_DEPTH_BIAS_CLAMP = 0.0; +const float D3D10_DEFAULT_MAX_ANISOTROPY = 16.0; +const float D3D10_DEFAULT_MIP_LOD_BIAS = 0.0; +const float D3D10_DEFAULT_VIEWPORT_MAX_DEPTH = 0.0; +const float D3D10_DEFAULT_VIEWPORT_MIN_DEPTH = 0.0; +const float D3D10_FLOAT16_FUSED_TOLERANCE_IN_ULP = 0.6; +const float D3D10_FLOAT32_MAX = 3.402823466e+38; +const float D3D10_FLOAT32_TO_INTEGER_TOLERANCE_IN_ULP = 0.6; +const float D3D10_FLOAT_TO_SRGB_EXPONENT_DENOMINATOR = 2.4; +const float D3D10_FLOAT_TO_SRGB_EXPONENT_NUMERATOR = 1.0; +const float D3D10_FLOAT_TO_SRGB_OFFSET = 0.055; +const float D3D10_FLOAT_TO_SRGB_SCALE_1 = 12.92; +const float D3D10_FLOAT_TO_SRGB_SCALE_2 = 1.055; +const float D3D10_FLOAT_TO_SRGB_THRESHOLD = 0.0031308; +const float D3D10_FTOI_INSTRUCTION_MAX_INPUT = 2147483647.999; +const float D3D10_FTOI_INSTRUCTION_MIN_INPUT = -2147483648.999; +const float D3D10_FTOU_INSTRUCTION_MAX_INPUT = 4294967295.999; +const float D3D10_FTOU_INSTRUCTION_MIN_INPUT = 0.0; +const float D3D10_LINEAR_GAMMA = 1.0; +const float D3D10_MAX_BORDER_COLOR_COMPONENT = 1.0; +const float D3D10_MAX_DEPTH = 1.0; +const float D3D10_MAX_POSITION_VALUE = 3.402823466e+34; +const float D3D10_MIN_BORDER_COLOR_COMPONENT = 0.0; +const float D3D10_MIN_DEPTH = 0.0; +const float D3D10_MIP_LOD_BIAS_MAX = 15.99; +const float D3D10_MIP_LOD_BIAS_MIN = -16.0; +const float D3D10_PS_PIXEL_CENTER_FRACTIONAL_COMPONENT = 0.5; +const float D3D10_MULTISAMPLE_ANTIALIAS_LINE_WIDTH = 1.4; +const float D3D10_SRGB_GAMMA = 2.2; +const float D3D10_SRGB_TO_FLOAT_DENOMINATOR_1 = 12.92; +const float D3D10_SRGB_TO_FLOAT_DENOMINATOR_2 = 1.055; +const float D3D10_SRGB_TO_FLOAT_EXPONENT = 2.4; +const float D3D10_SRGB_TO_FLOAT_OFFSET = 0.055; +const float D3D10_SRGB_TO_FLOAT_THRESHOLD = 0.04045; +const float D3D10_SRGB_TO_FLOAT_TOLERANCE_IN_ULP = 0.5; +const float D3D10_PS_LEGACY_PIXEL_CENTER_FRACTIONAL_COMPONENT = 0.0; +const float D3D_SPEC_VERSION = 1.050005; +const unsigned int D3D10_16BIT_INDEX_STRIP_CUT_VALUE = 0xffff; +const unsigned int D3D10_32BIT_INDEX_STRIP_CUT_VALUE = 0xffffffff; +const unsigned int D3D10_8BIT_INDEX_STRIP_CUT_VALUE = 0xff; +const unsigned int D3D10_ARRAY_AXIS_ADDRESS_RANGE_BIT_COUNT = 9; +const unsigned int D3D10_CLIP_OR_CULL_DISTANCE_COUNT = 8; +const unsigned int D3D10_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT = 2; +const unsigned int D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT = 14; +const unsigned int D3D10_COMMONSHADER_CONSTANT_BUFFER_COMPONENTS = 4; +const unsigned int D3D10_COMMONSHADER_CONSTANT_BUFFER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D10_COMMONSHADER_CONSTANT_BUFFER_HW_SLOT_COUNT = 15; +const unsigned int D3D10_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COMPONENTS = 4; +const unsigned int D3D10_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COUNT = 15; +const unsigned int D3D10_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READS_PER_INST = 1; +const unsigned int D3D10_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READ_PORTS = 1; +const unsigned int D3D10_COMMONSHADER_FLOWCONTROL_NESTING_LIMIT = 64; +const unsigned int D3D10_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COMPONENTS = 4; +const unsigned int D3D10_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COUNT = 1; +const unsigned int D3D10_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READS_PER_INST = 1; +const unsigned int D3D10_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READ_PORTS = 1; +const unsigned int D3D10_COMMONSHADER_IMMEDIATE_VALUE_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D10_COMMONSHADER_INPUT_RESOURCE_REGISTER_COMPONENTS = 1; +const unsigned int D3D10_COMMONSHADER_INPUT_RESOURCE_REGISTER_COUNT = 128; +const unsigned int D3D10_COMMONSHADER_INPUT_RESOURCE_REGISTER_READS_PER_INST = 1; +const unsigned int D3D10_COMMONSHADER_INPUT_RESOURCE_REGISTER_READ_PORTS = 1; +const unsigned int D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT = 128; +const unsigned int D3D10_COMMONSHADER_SAMPLER_REGISTER_COMPONENTS = 1; +const unsigned int D3D10_COMMONSHADER_SAMPLER_REGISTER_COUNT = 16; +const unsigned int D3D10_COMMONSHADER_SAMPLER_REGISTER_READS_PER_INST = 1; +const unsigned int D3D10_COMMONSHADER_SAMPLER_REGISTER_READ_PORTS = 1; +const unsigned int D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT = 16; +const unsigned int D3D10_COMMONSHADER_SUBROUTINE_NESTING_LIMIT = 32; +const unsigned int D3D10_COMMONSHADER_TEMP_REGISTER_COMPONENTS = 4; +const unsigned int D3D10_COMMONSHADER_TEMP_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D10_COMMONSHADER_TEMP_REGISTER_COUNT = 4096; +const unsigned int D3D10_COMMONSHADER_TEMP_REGISTER_READS_PER_INST = 3; +const unsigned int D3D10_COMMONSHADER_TEMP_REGISTER_READ_PORTS = 3; +const unsigned int D3D10_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MAX = 10; +const int D3D10_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MIN = -10; +const int D3D10_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE = -8; +const unsigned int D3D10_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE = 7; +const unsigned int D3D10_DEFAULT_DEPTH_BIAS = 0; +const unsigned int D3D10_DEFAULT_RENDER_TARGET_ARRAY_INDEX = 0; +const unsigned int D3D10_DEFAULT_SAMPLE_MASK = 0xffffffff; +const unsigned int D3D10_DEFAULT_SCISSOR_ENDX = 0; +const unsigned int D3D10_DEFAULT_SCISSOR_ENDY = 0; +const unsigned int D3D10_DEFAULT_SCISSOR_STARTX = 0; +const unsigned int D3D10_DEFAULT_SCISSOR_STARTY = 0; +const unsigned int D3D10_DEFAULT_STENCIL_READ_MASK = 0xff; +const unsigned int D3D10_DEFAULT_STENCIL_REFERENCE = 0; +const unsigned int D3D10_DEFAULT_STENCIL_WRITE_MASK = 0xff; +const unsigned int D3D10_DEFAULT_VIEWPORT_AND_SCISSORRECT_INDEX = 0; +const unsigned int D3D10_DEFAULT_VIEWPORT_HEIGHT = 0; +const unsigned int D3D10_DEFAULT_VIEWPORT_TOPLEFTX = 0; +const unsigned int D3D10_DEFAULT_VIEWPORT_TOPLEFTY = 0; +const unsigned int D3D10_DEFAULT_VIEWPORT_WIDTH = 0; +const unsigned int D3D10_GS_INPUT_PRIM_CONST_REGISTER_COMPONENTS = 1; +const unsigned int D3D10_GS_INPUT_PRIM_CONST_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D10_GS_INPUT_PRIM_CONST_REGISTER_COUNT = 1; +const unsigned int D3D10_GS_INPUT_PRIM_CONST_REGISTER_READS_PER_INST = 2; +const unsigned int D3D10_GS_INPUT_PRIM_CONST_REGISTER_READ_PORTS = 1; +const unsigned int D3D10_GS_INPUT_REGISTER_COMPONENTS = 4; +const unsigned int D3D10_GS_INPUT_REGISTER_COMPONENT_BIT_COUNT =32; +const unsigned int D3D10_GS_INPUT_REGISTER_COUNT = 16; +const unsigned int D3D10_GS_INPUT_REGISTER_READS_PER_INST = 2; +const unsigned int D3D10_GS_INPUT_REGISTER_READ_PORTS = 1; +const unsigned int D3D10_GS_INPUT_REGISTER_VERTICES = 6; +const unsigned int D3D10_GS_OUTPUT_ELEMENTS = 32; +const unsigned int D3D10_GS_OUTPUT_REGISTER_COMPONENTS = 4; +const unsigned int D3D10_GS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D10_GS_OUTPUT_REGISTER_COUNT = 32; +const unsigned int D3D10_IA_DEFAULT_INDEX_BUFFER_OFFSET_IN_BYTES = 0; +const unsigned int D3D10_IA_DEFAULT_PRIMITIVE_TOPOLOGY = 0; +const unsigned int D3D10_IA_DEFAULT_VERTEX_BUFFER_OFFSET_IN_BYTES = 0; +const unsigned int D3D10_IA_INDEX_INPUT_RESOURCE_SLOT_COUNT = 1; +const unsigned int D3D10_IA_INSTANCE_ID_BIT_COUNT = 32; +const unsigned int D3D10_IA_INTEGER_ARITHMETIC_BIT_COUNT = 32; +const unsigned int D3D10_IA_PRIMITIVE_ID_BIT_COUNT = 32; +const unsigned int D3D10_IA_VERTEX_ID_BIT_COUNT = 32; +const unsigned int D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT = 16; +const unsigned int D3D10_IA_VERTEX_INPUT_STRUCTURE_ELEMENTS_COMPONENTS = 64; +const unsigned int D3D10_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT = 16; +const unsigned int D3D10_INTEGER_DIVIDE_BY_ZERO_QUOTIENT = 0xffffffff; +const unsigned int D3D10_INTEGER_DIVIDE_BY_ZERO_REMAINDER = 0xffffffff; +const unsigned int D3D10_MAX_MAXANISOTROPY = 16; +const unsigned int D3D10_MAX_MULTISAMPLE_SAMPLE_COUNT = 32; +const unsigned int D3D10_MAX_TEXTURE_DIMENSION_2_TO_EXP = 17; +const unsigned int D3D10_MIN_MAXANISOTROPY = 0; +const unsigned int D3D10_MIP_LOD_FRACTIONAL_BIT_COUNT = 6; +const unsigned int D3D10_MIP_LOD_RANGE_BIT_COUNT = 8; +const unsigned int D3D10_NONSAMPLE_FETCH_OUT_OF_RANGE_ACCESS_RESULT = 0; +const unsigned int D3D10_PIXEL_ADDRESS_RANGE_BIT_COUNT = 13; +const unsigned int D3D10_PRE_SCISSOR_PIXEL_ADDRESS_RANGE_BIT_COUNT = 15; +const unsigned int D3D10_PS_FRONTFACING_DEFAULT_VALUE = 0xffffffff; +const unsigned int D3D10_PS_FRONTFACING_FALSE_VALUE = 0; +const unsigned int D3D10_PS_FRONTFACING_TRUE_VALUE = 0xffffffff; +const unsigned int D3D10_PS_INPUT_REGISTER_COMPONENTS = 4; +const unsigned int D3D10_PS_INPUT_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D10_PS_INPUT_REGISTER_COUNT = 32; +const unsigned int D3D10_PS_INPUT_REGISTER_READS_PER_INST = 2; +const unsigned int D3D10_PS_INPUT_REGISTER_READ_PORTS = 1; +const unsigned int D3D10_PS_OUTPUT_DEPTH_REGISTER_COMPONENTS = 1; +const unsigned int D3D10_PS_OUTPUT_DEPTH_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D10_PS_OUTPUT_DEPTH_REGISTER_COUNT = 1; +const unsigned int D3D10_PS_OUTPUT_REGISTER_COMPONENTS = 4; +const unsigned int D3D10_PS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D10_PS_OUTPUT_REGISTER_COUNT = 8; +const unsigned int D3D10_REQ_BLEND_OBJECT_COUNT_PER_CONTEXT = 4096; +const unsigned int D3D10_REQ_BUFFER_RESOURCE_TEXEL_COUNT_2_TO_EXP = 27; +const unsigned int D3D10_REQ_CONSTANT_BUFFER_ELEMENT_COUNT = 4096; +const unsigned int D3D10_REQ_DEPTH_STENCIL_OBJECT_COUNT_PER_CONTEXT = 4096; +const unsigned int D3D10_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP = 32; +const unsigned int D3D10_REQ_DRAW_VERTEX_COUNT_2_TO_EXP = 32; +const unsigned int D3D10_REQ_FILTERING_HW_ADDRESSABLE_RESOURCE_DIMENSION = 8192; +const unsigned int D3D10_REQ_GS_INVOCATION_32BIT_OUTPUT_COMPONENT_LIMIT = 1024; +const unsigned int D3D10_REQ_IMMEDIATE_CONSTANT_BUFFER_ELEMENT_COUNT = 4096; +const unsigned int D3D10_REQ_MAXANISOTROPY = 16; +const unsigned int D3D10_REQ_MIP_LEVELS = 14; +const unsigned int D3D10_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES = 2048; +const unsigned int D3D10_REQ_RASTERIZER_OBJECT_COUNT_PER_CONTEXT = 4096; +const unsigned int D3D10_REQ_RENDER_TO_BUFFER_WINDOW_WIDTH = 8192; +const unsigned int D3D10_REQ_RESOURCE_SIZE_IN_MEGABYTES = 128; +const unsigned int D3D10_REQ_RESOURCE_VIEW_COUNT_PER_CONTEXT_2_TO_EXP = 20; +const unsigned int D3D10_REQ_SAMPLER_OBJECT_COUNT_PER_CONTEXT = 4096; +const unsigned int D3D10_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION = 512; +const unsigned int D3D10_REQ_TEXTURE1D_U_DIMENSION = 8192; +const unsigned int D3D10_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION = 512; +const unsigned int D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION = 8192; +const unsigned int D3D10_REQ_TEXTURE3D_U_V_OR_W_DIMENSION = 2048; +const unsigned int D3D10_REQ_TEXTURECUBE_DIMENSION = 8192; +const unsigned int D3D10_RESINFO_INSTRUCTION_MISSING_COMPONENT_RETVAL = 0; +const unsigned int D3D10_SHADER_MAJOR_VERSION = 4; +const unsigned int D3D10_SHADER_MINOR_VERSION = 0; +const unsigned int D3D10_SHIFT_INSTRUCTION_PAD_VALUE = 0; +const unsigned int D3D10_SHIFT_INSTRUCTION_SHIFT_VALUE_BIT_COUNT = 5; +const unsigned int D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT = 8; +const unsigned int D3D10_SO_BUFFER_MAX_STRIDE_IN_BYTES = 2048; +const unsigned int D3D10_SO_BUFFER_MAX_WRITE_WINDOW_IN_BYTES = 256; +const unsigned int D3D10_SO_BUFFER_SLOT_COUNT = 4; +const unsigned int D3D10_SO_DDI_REGISTER_INDEX_DENOTING_GAP = 0xffffffff; +const unsigned int D3D10_SO_MULTIPLE_BUFFER_ELEMENTS_PER_BUFFER = 1; +const unsigned int D3D10_SO_SINGLE_BUFFER_COMPONENT_LIMIT = 64; +const unsigned int D3D10_STANDARD_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D10_STANDARD_COMPONENT_BIT_COUNT_DOUBLED = 64; +const unsigned int D3D10_STANDARD_MAXIMUM_ELEMENT_ALIGNMENT_BYTE_MULTIPLE = 4; +const unsigned int D3D10_STANDARD_PIXEL_COMPONENT_COUNT = 128; +const unsigned int D3D10_STANDARD_PIXEL_ELEMENT_COUNT = 32; +const unsigned int D3D10_STANDARD_VECTOR_SIZE = 4; +const unsigned int D3D10_STANDARD_VERTEX_ELEMENT_COUNT = 16; +const unsigned int D3D10_STANDARD_VERTEX_TOTAL_COMPONENT_COUNT = 64; +const unsigned int D3D10_SUBPIXEL_FRACTIONAL_BIT_COUNT = 8; +const unsigned int D3D10_SUBTEXEL_FRACTIONAL_BIT_COUNT = 6; +const unsigned int D3D10_TEXEL_ADDRESS_RANGE_BIT_COUNT = 18; +const unsigned int D3D10_UNBOUND_MEMORY_ACCESS_RESULT = 0; +const unsigned int D3D10_VIEWPORT_AND_SCISSORRECT_MAX_INDEX = 15; +const unsigned int D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE = 16; +const unsigned int D3D10_VIEWPORT_BOUNDS_MAX = 16383; +const int D3D10_VIEWPORT_BOUNDS_MIN = -16384; +const unsigned int D3D10_VS_INPUT_REGISTER_COMPONENTS = 4; +const unsigned int D3D10_VS_INPUT_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D10_VS_INPUT_REGISTER_COUNT = 16; +const unsigned int D3D10_VS_INPUT_REGISTER_READS_PER_INST = 2; +const unsigned int D3D10_VS_INPUT_REGISTER_READ_PORTS = 1; +const unsigned int D3D10_VS_OUTPUT_REGISTER_COMPONENTS = 4; +const unsigned int D3D10_VS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D10_VS_OUTPUT_REGISTER_COUNT = 16; +const unsigned int D3D10_WHQL_CONTEXT_COUNT_FOR_RESOURCE_LIMIT = 10; +const unsigned int D3D10_WHQL_DRAWINDEXED_INDEX_COUNT_2_TO_EXP = 25; +const unsigned int D3D10_WHQL_DRAW_VERTEX_COUNT_2_TO_EXP = 25; +const unsigned int D3D_MAJOR_VERSION = 10; +const unsigned int D3D_MINOR_VERSION = 0; +const unsigned int D3D_SPEC_DATE_DAY = 8; +const unsigned int D3D_SPEC_DATE_MONTH = 8; +const unsigned int D3D_SPEC_DATE_YEAR = 2006; +cpp_quote("#endif") + +const unsigned int D3D10_APPEND_ALIGNED_ELEMENT = 0xffffffff; +const unsigned int _FACD3D10 = 0x87; +const unsigned int _FACD3D10DEBUG = _FACD3D10 + 1; +const unsigned int D3D10_FILTER_TYPE_MASK = 0x3; +const unsigned int D3D10_SDK_VERSION = 29; + +cpp_quote("#define MAKE_D3D10_HRESULT(code) MAKE_HRESULT( 1, _FACD3D10, code)") +cpp_quote("#define MAKE_D3D10_STATUS(code) MAKE_HRESULT( 0, _FACD3D10, code)") +cpp_quote("#define D3D10_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS MAKE_D3D10_HRESULT(1)") +cpp_quote("#define D3D10_ERROR_FILE_NOT_FOUND MAKE_D3D10_HRESULT(2)") + +typedef enum D3D10_FORMAT_SUPPORT +{ + D3D10_FORMAT_SUPPORT_BUFFER = 0x1, + D3D10_FORMAT_SUPPORT_IA_VERTEX_BUFFER = 0x2, + D3D10_FORMAT_SUPPORT_IA_INDEX_BUFFER = 0x4, + D3D10_FORMAT_SUPPORT_SO_BUFFER = 0x8, + D3D10_FORMAT_SUPPORT_TEXTURE1D = 0x10, + D3D10_FORMAT_SUPPORT_TEXTURE2D = 0x20, + D3D10_FORMAT_SUPPORT_TEXTURE3D = 0x40, + D3D10_FORMAT_SUPPORT_TEXTURECUBE = 0x80, + D3D10_FORMAT_SUPPORT_SHADER_LOAD = 0x100, + D3D10_FORMAT_SUPPORT_SHADER_SAMPLE = 0x200, + D3D10_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON = 0x400, + D3D10_FORMAT_SUPPORT_SHADER_SAMPLE_MONO_TEXT = 0x800, + D3D10_FORMAT_SUPPORT_MIP = 0x1000, + D3D10_FORMAT_SUPPORT_MIP_AUTOGEN = 0x2000, + D3D10_FORMAT_SUPPORT_RENDER_TARGET = 0x4000, + D3D10_FORMAT_SUPPORT_BLENDABLE = 0x8000, + D3D10_FORMAT_SUPPORT_DEPTH_STENCIL = 0x10000, + D3D10_FORMAT_SUPPORT_CPU_LOCKABLE = 0x20000, + D3D10_FORMAT_SUPPORT_MULTISAMPLE_RESOLVE = 0x40000, + D3D10_FORMAT_SUPPORT_DISPLAY = 0x80000, + D3D10_FORMAT_SUPPORT_CAST_WITHIN_BIT_LAYOUT = 0x100000, + D3D10_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET = 0x200000, + D3D10_FORMAT_SUPPORT_MULTISAMPLE_LOAD = 0x400000, + D3D10_FORMAT_SUPPORT_SHADER_GATHER = 0x800000, +} D3D10_FORMAT_SUPPORT; + + +typedef enum D3D10_BLEND { + D3D10_BLEND_ZERO = 1, + D3D10_BLEND_ONE = 2, + D3D10_BLEND_SRC_COLOR = 3, + D3D10_BLEND_INV_SRC_COLOR = 4, + D3D10_BLEND_SRC_ALPHA = 5, + D3D10_BLEND_INV_SRC_ALPHA = 6, + D3D10_BLEND_DEST_ALPHA = 7, + D3D10_BLEND_INV_DEST_ALPHA = 8, + D3D10_BLEND_DEST_COLOR = 9, + D3D10_BLEND_INV_DEST_COLOR = 10, + D3D10_BLEND_SRC_ALPHA_SAT = 11, + D3D10_BLEND_BLEND_FACTOR = 14, + D3D10_BLEND_INV_BLEND_FACTOR = 15, + D3D10_BLEND_SRC1_COLOR = 16, + D3D10_BLEND_INV_SRC1_COLOR = 17, + D3D10_BLEND_SRC1_ALPHA = 18, + D3D10_BLEND_INV_SRC1_ALPHA = 19 +} D3D10_BLEND; + +typedef enum D3D10_BLEND_OP { + D3D10_BLEND_OP_ADD = 1, + D3D10_BLEND_OP_SUBTRACT, + D3D10_BLEND_OP_REV_SUBTRACT, + D3D10_BLEND_OP_MIN, + D3D10_BLEND_OP_MAX, +} D3D10_BLEND_OP; + +typedef struct D3D10_BLEND_DESC { + BOOL AlphaToCoverageEnable; + BOOL BlendEnable[8]; + D3D10_BLEND SrcBlend; + D3D10_BLEND DestBlend; + D3D10_BLEND_OP BlendOp; + D3D10_BLEND SrcBlendAlpha; + D3D10_BLEND DestBlendAlpha; + D3D10_BLEND_OP BlendOpAlpha; + UINT8 RenderTargetWriteMask[8]; +} D3D10_BLEND_DESC; + +typedef enum D3D10_DEPTH_WRITE_MASK { + D3D10_DEPTH_WRITE_MASK_ZERO, + D3D10_DEPTH_WRITE_MASK_ALL, +} D3D10_DEPTH_WRITE_MASK; + +typedef enum D3D10_COMPARISON_FUNC { + D3D10_COMPARISON_NEVER = 1, + D3D10_COMPARISON_LESS, + D3D10_COMPARISON_EQUAL, + D3D10_COMPARISON_LESS_EQUAL, + D3D10_COMPARISON_GREATER, + D3D10_COMPARISON_NOT_EQUAL, + D3D10_COMPARISON_GREATER_EQUAL, + D3D10_COMPARISON_ALWAYS, +} D3D10_COMPARISON_FUNC; + +typedef enum D3D10_STENCIL_OP { + D3D10_STENCIL_OP_KEEP = 1, + D3D10_STENCIL_OP_ZERO, + D3D10_STENCIL_OP_REPLACE, + D3D10_STENCIL_OP_INCR_SAT, + D3D10_STENCIL_OP_DECR_SAT, + D3D10_STENCIL_OP_INVERT, + D3D10_STENCIL_OP_INCR, + D3D10_STENCIL_OP_DECR, +} D3D10_STENCIL_OP; + +typedef struct D3D10_DEPTH_STENCILOP_DESC { + D3D10_STENCIL_OP StencilFailOp; + D3D10_STENCIL_OP StencilDepthFailOp; + D3D10_STENCIL_OP StencilPassOp; + D3D10_COMPARISON_FUNC StencilFunc; +} D3D10_DEPTH_STENCILOP_DESC; + +typedef struct D3D10_DEPTH_STENCIL_DESC { + BOOL DepthEnable; + D3D10_DEPTH_WRITE_MASK DepthWriteMask; + D3D10_COMPARISON_FUNC DepthFunc; + BOOL StencilEnable; + UINT8 StencilReadMask; + UINT8 StencilWriteMask; + D3D10_DEPTH_STENCILOP_DESC FrontFace; + D3D10_DEPTH_STENCILOP_DESC BackFace; +} D3D10_DEPTH_STENCIL_DESC; + +typedef enum D3D10_FILL_MODE { + D3D10_FILL_WIREFRAME = 2, + D3D10_FILL_SOLID, +} D3D10_FILL_MODE; + +typedef enum D3D10_CULL_MODE { + D3D10_CULL_NONE = 1, + D3D10_CULL_FRONT, + D3D10_CULL_BACK, +} D3D10_CULL_MODE; + +typedef struct D3D10_RASTERIZER_DESC { + D3D10_FILL_MODE FillMode; + D3D10_CULL_MODE CullMode; + BOOL FrontCounterClockwise; + INT DepthBias; + FLOAT DepthBiasClamp; + FLOAT SlopeScaledDepthBias; + BOOL DepthClipEnable; + BOOL ScissorEnable; + BOOL MultisampleEnable; + BOOL AntialiasedLineEnable; +} D3D10_RASTERIZER_DESC; + +typedef enum D3D10_FILTER { + D3D10_FILTER_MIN_MAG_MIP_POINT = 0, + D3D10_FILTER_MIN_MAG_POINT_MIP_LINEAR = 0x1, + D3D10_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x4, + D3D10_FILTER_MIN_POINT_MAG_MIP_LINEAR = 0x5, + D3D10_FILTER_MIN_LINEAR_MAG_MIP_POINT = 0x10, + D3D10_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x11, + D3D10_FILTER_MIN_MAG_LINEAR_MIP_POINT = 0x14, + D3D10_FILTER_MIN_MAG_MIP_LINEAR = 0x15, + D3D10_FILTER_ANISOTROPIC = 0x55, + D3D10_FILTER_COMPARISON_MIN_MAG_MIP_POINT = 0x80, + D3D10_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR = 0x81, + D3D10_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x84, + D3D10_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR = 0x85, + D3D10_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT = 0x90, + D3D10_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x91, + D3D10_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT = 0x94, + D3D10_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR = 0x95, + D3D10_FILTER_COMPARISON_ANISOTROPIC = 0xd5, + D3D10_FILTER_TEXT_1BIT = 0x80000000 +} D3D10_FILTER; + +typedef enum D3D10_TEXTURE_ADDRESS_MODE { + D3D10_TEXTURE_ADDRESS_WRAP = 1, + D3D10_TEXTURE_ADDRESS_MIRROR, + D3D10_TEXTURE_ADDRESS_CLAMP, + D3D10_TEXTURE_ADDRESS_BORDER, + D3D10_TEXTURE_ADDRESS_MIRROR_ONCE, +} D3D10_TEXTURE_ADDRESS_MODE; + +typedef struct D3D10_SAMPLER_DESC { + D3D10_FILTER Filter; + D3D10_TEXTURE_ADDRESS_MODE AddressU; + D3D10_TEXTURE_ADDRESS_MODE AddressV; + D3D10_TEXTURE_ADDRESS_MODE AddressW; + FLOAT MipLODBias; + UINT MaxAnisotropy; + D3D10_COMPARISON_FUNC ComparisonFunc; + FLOAT BorderColor[4]; + FLOAT MinLOD; + FLOAT MaxLOD; +} D3D10_SAMPLER_DESC; + +typedef enum D3D10_COUNTER { + D3D10_COUNTER_GPU_IDLE, + D3D10_COUNTER_VERTEX_PROCESSING, + D3D10_COUNTER_GEOMETRY_PROCESSING, + D3D10_COUNTER_PIXEL_PROCESSING, + D3D10_COUNTER_OTHER_GPU_PROCESSING, + D3D10_COUNTER_HOST_ADAPTER_BANDWIDTH_UTILIZATION, + D3D10_COUNTER_LOCAL_VIDMEM_BANDWIDTH_UTILIZATION, + D3D10_COUNTER_VERTEX_THROUGHPUT_UTILIZATION, + D3D10_COUNTER_TRIANGLE_SETUP_THROUGHPUT_UTILIZATION, + D3D10_COUNTER_FILLRATE_THROUGHPUT_UTILIZATION, + D3D10_COUNTER_VS_MEMORY_LIMITED, + D3D10_COUNTER_VS_COMPUTATION_LIMITED, + D3D10_COUNTER_GS_MEMORY_LIMITED, + D3D10_COUNTER_GS_COMPUTATION_LIMITED, + D3D10_COUNTER_PS_MEMORY_LIMITED, + D3D10_COUNTER_PS_COMPUTATION_LIMITED, + D3D10_COUNTER_POST_TRANSFORM_CACHE_HIT_RATE, + D3D10_COUNTER_TEXTURE_CACHE_HIT_RATE, + D3D10_COUNTER_DEVICE_DEPENDENT_0 = 0x40000000 +} D3D10_COUNTER; + +typedef struct D3D10_COUNTER_DESC { + D3D10_COUNTER Counter; + UINT MiscFlags; +} D3D10_COUNTER_DESC; + +typedef enum D3D10_COUNTER_TYPE { + D3D10_COUNTER_TYPE_FLOAT32, + D3D10_COUNTER_TYPE_UINT16, + D3D10_COUNTER_TYPE_UINT32, + D3D10_COUNTER_TYPE_UINT64, +} D3D10_COUNTER_TYPE; + +typedef struct D3D10_COUNTER_INFO { + D3D10_COUNTER LastDeviceDependentCounter; + UINT NumSimultaneousCounters; + UINT8 NumDetectableParallelUnits; +} D3D10_COUNTER_INFO; + +typedef enum D3D10_RESOURCE_DIMENSION { + D3D10_RESOURCE_DIMENSION_UNKNOWN, + D3D10_RESOURCE_DIMENSION_BUFFER, + D3D10_RESOURCE_DIMENSION_TEXTURE1D, + D3D10_RESOURCE_DIMENSION_TEXTURE2D, + D3D10_RESOURCE_DIMENSION_TEXTURE3D, +} D3D10_RESOURCE_DIMENSION; + +typedef enum D3D10_USAGE { + D3D10_USAGE_DEFAULT, + D3D10_USAGE_IMMUTABLE, + D3D10_USAGE_DYNAMIC, + D3D10_USAGE_STAGING, +} D3D10_USAGE; + +typedef struct D3D10_BUFFER_DESC { + UINT ByteWidth; + D3D10_USAGE Usage; + UINT BindFlags; + UINT CPUAccessFlags; + UINT MiscFlags; +} D3D10_BUFFER_DESC; + +typedef enum D3D10_MAP { + D3D10_MAP_READ = 1, + D3D10_MAP_WRITE, + D3D10_MAP_READ_WRITE, + D3D10_MAP_WRITE_DISCARD, + D3D10_MAP_WRITE_NO_OVERWRITE, +} D3D10_MAP; + +typedef struct D3D10_TEXTURE1D_DESC { + UINT Width; + UINT MipLevels; + UINT ArraySize; + DXGI_FORMAT Format; + D3D10_USAGE Usage; + UINT BindFlags; + UINT CPUAccessFlags; + UINT MiscFlags; +} D3D10_TEXTURE1D_DESC; + +typedef struct D3D10_TEXTURE2D_DESC { + UINT Width; + UINT Height; + UINT MipLevels; + UINT ArraySize; + DXGI_FORMAT Format; + DXGI_SAMPLE_DESC SampleDesc; + D3D10_USAGE Usage; + UINT BindFlags; + UINT CPUAccessFlags; + UINT MiscFlags; +} D3D10_TEXTURE2D_DESC; + +typedef struct D3D10_TEXTURE3D_DESC { + UINT Width; + UINT Height; + UINT Depth; + UINT MipLevels; + DXGI_FORMAT Format; + D3D10_USAGE Usage; + UINT BindFlags; + UINT CPUAccessFlags; + UINT MiscFlags; +} D3D10_TEXTURE3D_DESC; + +typedef enum D3D10_DSV_DIMENSION +{ + D3D10_DSV_DIMENSION_UNKNOWN, + D3D10_DSV_DIMENSION_TEXTURE1D, + D3D10_DSV_DIMENSION_TEXTURE1DARRAY, + D3D10_DSV_DIMENSION_TEXTURE2D, + D3D10_DSV_DIMENSION_TEXTURE2DARRAY, + D3D10_DSV_DIMENSION_TEXTURE2DMS, + D3D10_DSV_DIMENSION_TEXTURE2DMSARRAY, +} D3D10_DSV_DIMENSION; + +typedef struct D3D10_TEX1D_DSV { + UINT MipSlice; +} D3D10_TEX1D_DSV; + +typedef struct D3D10_TEX1D_ARRAY_DSV { + UINT MipSlice; + UINT FirstArraySlice; + UINT ArraySize; +} D3D10_TEX1D_ARRAY_DSV; + +typedef struct D3D10_TEX2D_DSV { + UINT MipSlice; +} D3D10_TEX2D_DSV; + +typedef struct D3D10_TEX2D_ARRAY_DSV { + UINT MipSlice; + UINT FirstArraySlice; + UINT ArraySize; +} D3D10_TEX2D_ARRAY_DSV; + +typedef struct D3D10_TEX2DMS_DSV { + UINT UnusedField_NothingToDefine; +} D3D10_TEX2DMS_DSV; + +typedef struct D3D10_TEX2DMS_ARRAY_DSV { + UINT FirstArraySlice; + UINT ArraySize; +} D3D10_TEX2DMS_ARRAY_DSV; + +typedef struct D3D10_DEPTH_STENCIL_VIEW_DESC { + DXGI_FORMAT Format; + D3D10_DSV_DIMENSION ViewDimension; + union { + D3D10_TEX1D_DSV Texture1D; + D3D10_TEX1D_ARRAY_DSV Texture1DArray; + D3D10_TEX2D_DSV Texture2D; + D3D10_TEX2D_ARRAY_DSV Texture2DArray; + D3D10_TEX2DMS_DSV Texture2DMS; + D3D10_TEX2DMS_ARRAY_DSV Texture2DMSArray; + } DUMMYUNIONNAME; +} D3D10_DEPTH_STENCIL_VIEW_DESC; + +typedef enum D3D10_RTV_DIMENSION { + D3D10_RTV_DIMENSION_UNKNOWN, + D3D10_RTV_DIMENSION_BUFFER, + D3D10_RTV_DIMENSION_TEXTURE1D, + D3D10_RTV_DIMENSION_TEXTURE1DARRAY, + D3D10_RTV_DIMENSION_TEXTURE2D, + D3D10_RTV_DIMENSION_TEXTURE2DARRAY, + D3D10_RTV_DIMENSION_TEXTURE2DMS, + D3D10_RTV_DIMENSION_TEXTURE2DMSARRAY, + D3D10_RTV_DIMENSION_TEXTURE3D, +} D3D10_RTV_DIMENSION; + +typedef struct D3D10_BUFFER_RTV { + UINT ElementOffset; + UINT ElementWidth; +} D3D10_BUFFER_RTV; + +typedef struct D3D10_TEX1D_RTV { + UINT MipSlice; +} D3D10_TEX1D_RTV; + +typedef struct D3D10_TEX1D_ARRAY_RTV { + UINT MipSlice; + UINT FirstArraySlice; + UINT ArraySize; +} D3D10_TEX1D_ARRAY_RTV; + +typedef struct D3D10_TEX2D_RTV { + UINT MipSlice; +} D3D10_TEX2D_RTV; + +typedef struct D3D10_TEX2D_ARRAY_RTV { + UINT MipSlice; + UINT FirstArraySlice; + UINT ArraySize; +} D3D10_TEX2D_ARRAY_RTV; + +typedef struct D3D10_TEX2DMS_RTV { + UINT UnusedField_NothingToDefine; +} D3D10_TEX2DMS_RTV; + +typedef struct D3D10_TEX2DMS_ARRAY_RTV { + UINT FirstArraySlice; + UINT ArraySize; +} D3D10_TEX2DMS_ARRAY_RTV; + +typedef struct D3D10_TEX3D_RTV { + UINT MipSlice; + UINT FirstWSlice; + UINT WSize; +} D3D10_TEX3D_RTV; + +typedef struct D3D10_RENDER_TARGET_VIEW_DESC { + DXGI_FORMAT Format; + D3D10_RTV_DIMENSION ViewDimension; + union { + D3D10_BUFFER_RTV Buffer; + D3D10_TEX1D_RTV Texture1D; + D3D10_TEX1D_ARRAY_RTV Texture1DArray; + D3D10_TEX2D_RTV Texture2D; + D3D10_TEX2D_ARRAY_RTV Texture2DArray; + D3D10_TEX2DMS_RTV Texture2DMS; + D3D10_TEX2DMS_ARRAY_RTV Texture2DMSArray; + D3D10_TEX3D_RTV Texture3D; + } DUMMYUNIONNAME; +} D3D10_RENDER_TARGET_VIEW_DESC; + +typedef D3D_SRV_DIMENSION D3D10_SRV_DIMENSION; + +typedef struct D3D10_BUFFER_SRV { + UINT ElementOffset; + UINT ElementWidth; +} D3D10_BUFFER_SRV; + +typedef struct D3D10_TEX1D_SRV { + UINT MostDetailedMip; + UINT MipLevels; +} D3D10_TEX1D_SRV; + +typedef struct D3D10_TEX1D_ARRAY_SRV { + UINT MostDetailedMip; + UINT MipLevels; + UINT FirstArraySlice; + UINT ArraySize; +} D3D10_TEX1D_ARRAY_SRV; + +typedef struct D3D10_TEX2D_SRV { + UINT MostDetailedMip; + UINT MipLevels; +} D3D10_TEX2D_SRV; + +typedef struct D3D10_TEX2D_ARRAY_SRV { + UINT MostDetailedMip; + UINT MipLevels; + UINT FirstArraySlice; + UINT ArraySize; +} D3D10_TEX2D_ARRAY_SRV; + +typedef struct D3D10_TEX2DMS_SRV { + UINT UnusedField_NothingToDefine; +} D3D10_TEX2DMS_SRV; + +typedef struct D3D10_TEX2DMS_ARRAY_SRV { + UINT FirstArraySlice; + UINT ArraySize; +} D3D10_TEX2DMS_ARRAY_SRV; + +typedef struct D3D10_TEX3D_SRV { + UINT MostDetailedMip; + UINT MipLevels; +} D3D10_TEX3D_SRV; + +typedef struct D3D10_TEXCUBE_SRV { + UINT MostDetailedMip; + UINT MipLevels; +} D3D10_TEXCUBE_SRV; + +typedef struct D3D10_SHADER_RESOURCE_VIEW_DESC { + DXGI_FORMAT Format; + D3D10_SRV_DIMENSION ViewDimension; + union { + D3D10_BUFFER_SRV Buffer; + D3D10_TEX1D_SRV Texture1D; + D3D10_TEX1D_ARRAY_SRV Texture1DArray; + D3D10_TEX2D_SRV Texture2D; + D3D10_TEX2D_ARRAY_SRV Texture2DArray; + D3D10_TEX2DMS_SRV Texture2DMS; + D3D10_TEX2DMS_ARRAY_SRV Texture2DMSArray; + D3D10_TEX3D_SRV Texture3D; + D3D10_TEXCUBE_SRV TextureCube; + } DUMMYUNIONNAME; +} D3D10_SHADER_RESOURCE_VIEW_DESC; + +typedef struct D3D10_BOX { + UINT left; + UINT top; + UINT front; + UINT right; + UINT bottom; + UINT back; +} D3D10_BOX; + +typedef struct D3D10_SUBRESOURCE_DATA { + const void *pSysMem; + UINT SysMemPitch; + UINT SysMemSlicePitch; +} D3D10_SUBRESOURCE_DATA; + +typedef struct D3D10_SO_DECLARATION_ENTRY { + LPCSTR SemanticName; + UINT SemanticIndex; + BYTE StartComponent; + BYTE ComponentCount; + BYTE OutputSlot; +} D3D10_SO_DECLARATION_ENTRY; + +typedef enum D3D10_INPUT_CLASSIFICATION { + D3D10_INPUT_PER_VERTEX_DATA, + D3D10_INPUT_PER_INSTANCE_DATA, +} D3D10_INPUT_CLASSIFICATION; + +typedef struct D3D10_INPUT_ELEMENT_DESC { + LPCSTR SemanticName; + UINT SemanticIndex; + DXGI_FORMAT Format; + UINT InputSlot; + UINT AlignedByteOffset; + D3D10_INPUT_CLASSIFICATION InputSlotClass; + UINT InstanceDataStepRate; +} D3D10_INPUT_ELEMENT_DESC; + +typedef enum D3D10_QUERY { + D3D10_QUERY_EVENT, + D3D10_QUERY_OCCLUSION, + D3D10_QUERY_TIMESTAMP, + D3D10_QUERY_TIMESTAMP_DISJOINT, + D3D10_QUERY_PIPELINE_STATISTICS, + D3D10_QUERY_OCCLUSION_PREDICATE, + D3D10_QUERY_SO_STATISTICS, + D3D10_QUERY_SO_OVERFLOW_PREDICATE, +} D3D10_QUERY; + +typedef struct D3D10_QUERY_DESC { + D3D10_QUERY Query; + UINT MiscFlags; +} D3D10_QUERY_DESC; + +typedef D3D_PRIMITIVE_TOPOLOGY D3D10_PRIMITIVE_TOPOLOGY; + +typedef RECT D3D10_RECT; + +typedef struct D3D10_VIEWPORT { + INT TopLeftX; + INT TopLeftY; + UINT Width; + UINT Height; + FLOAT MinDepth; + FLOAT MaxDepth; +} D3D10_VIEWPORT; + +typedef struct D3D10_MAPPED_TEXTURE2D { + void *pData; + UINT RowPitch; +} D3D10_MAPPED_TEXTURE2D; + +typedef struct D3D10_MAPPED_TEXTURE3D { + void *pData; + UINT RowPitch; + UINT DepthPitch; +} D3D10_MAPPED_TEXTURE3D; + +typedef enum D3D10_BIND_FLAG { + D3D10_BIND_VERTEX_BUFFER = 0x1, + D3D10_BIND_INDEX_BUFFER = 0x2, + D3D10_BIND_CONSTANT_BUFFER = 0x4, + D3D10_BIND_SHADER_RESOURCE = 0x8, + D3D10_BIND_STREAM_OUTPUT = 0x10, + D3D10_BIND_RENDER_TARGET = 0x20, + D3D10_BIND_DEPTH_STENCIL = 0x40 +} D3D10_BIND_FLAG; + +typedef enum D3D10_CPU_ACCESS_FLAG { + D3D10_CPU_ACCESS_WRITE = 0x10000, + D3D10_CPU_ACCESS_READ = 0x20000 +} D3D10_CPU_ACCESS_FLAG; + +typedef enum D3D10_RESOURCE_MISC_FLAG { + D3D10_RESOURCE_MISC_GENERATE_MIPS = 0x1, + D3D10_RESOURCE_MISC_SHARED = 0x2, + D3D10_RESOURCE_MISC_TEXTURECUBE = 0x4, + D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX = 0x10L, + D3D10_RESOURCE_MISC_GDI_COMPATIBLE = 0x20L +} D3D10_RESOURCE_MISC_FLAG; + +typedef enum D3D10_MAP_FLAG { + D3D10_MAP_FLAG_DO_NOT_WAIT = 0x100000, +} D3D10_MAP_FLAG; + +typedef enum D3D10_CLEAR_FLAG { + D3D10_CLEAR_DEPTH = 0x1, + D3D10_CLEAR_STENCIL = 0x2 +} D3D10_CLEAR_FLAG; + +typedef enum D3D10_COLOR_WRITE_ENABLE { + D3D10_COLOR_WRITE_ENABLE_RED = 0x1, + D3D10_COLOR_WRITE_ENABLE_GREEN = 0x2, + D3D10_COLOR_WRITE_ENABLE_BLUE = 0x4, + D3D10_COLOR_WRITE_ENABLE_ALPHA = 0x8, + D3D10_COLOR_WRITE_ENABLE_ALL = (D3D10_COLOR_WRITE_ENABLE_RED | D3D10_COLOR_WRITE_ENABLE_GREEN | + D3D10_COLOR_WRITE_ENABLE_BLUE | D3D10_COLOR_WRITE_ENABLE_ALPHA) +} D3D10_COLOR_WRITE_ENABLE; + +typedef enum D3D10_TEXTURECUBE_FACE { + D3D10_TEXTURECUBE_FACE_POSITIVE_X, + D3D10_TEXTURECUBE_FACE_NEGATIVE_X, + D3D10_TEXTURECUBE_FACE_POSITIVE_Y, + D3D10_TEXTURECUBE_FACE_NEGATIVE_Y, + D3D10_TEXTURECUBE_FACE_POSITIVE_Z, + D3D10_TEXTURECUBE_FACE_NEGATIVE_Z, +} D3D10_TEXTURECUBE_FACE; + +typedef enum D3D10_ASYNC_GETDATA_FLAG { + D3D10_ASYNC_GETDATA_DONOTFLUSH = 0x1, +} D3D10_ASYNC_GETDATA_FLAG; + +typedef enum D3D10_FILTER_TYPE { + D3D10_FILTER_TYPE_POINT, + D3D10_FILTER_TYPE_LINEAR +} D3D10_FILTER_TYPE; + +typedef enum D3D10_QUERY_MISC_FLAG { + D3D10_QUERY_MISC_PREDICATEHINT = 0x1 +} D3D10_QUERY_MISC_FLAG; + +typedef struct D3D10_QUERY_DATA_TIMESTAMP_DISJOINT { + UINT64 Frequency; + BOOL Disjoint; +} D3D10_QUERY_DATA_TIMESTAMP_DISJOINT; + +typedef struct D3D10_QUERY_DATA_PIPELINE_STATISTICS { + UINT64 IAVertices; + UINT64 IAPrimitives; + UINT64 VSInvocations; + UINT64 GSInvocations; + UINT64 GSPrimitives; + UINT64 CInvocations; + UINT64 CPrimitives; + UINT64 PSInvocations; +} D3D10_QUERY_DATA_PIPELINE_STATISTICS; + +typedef struct D3D10_QUERY_DATA_SO_STATISTICS { + UINT64 NumPrimitivesWritten; + UINT64 PrimitivesStorageNeeded; +} D3D10_QUERY_DATA_SO_STATISTICS; + +typedef enum D3D10_CREATE_DEVICE_FLAG { + D3D10_CREATE_DEVICE_SINGLETHREADED = 0x1, + D3D10_CREATE_DEVICE_DEBUG = 0x2, + D3D10_CREATE_DEVICE_SWITCH_TO_REF = 0x4, + D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS = 0x8 +} D3D10_CREATE_DEVICE_FLAG; + +/* Core */ + +interface ID3D10Device; + +[ + object, + local, + uuid(9b7e4c00-342c-4106-a19f-4f2704f689f0) +] +interface ID3D10DeviceChild : IUnknown +{ + void GetDevice( + [out] ID3D10Device **a); + HRESULT GetPrivateData( + [in] REFGUID a, + [in, out] UINT *b, + [out] void *c); + HRESULT SetPrivateData( + [in] REFGUID a, + [in] UINT b, + [in] const void *c); + HRESULT SetPrivateDataInterface( + [in] REFGUID a, + [in] const IUnknown *b); +} + +/* Resource */ + +[ + object, + local, + uuid(9b7e4c01-342c-4106-a19f-4f2704f689f0) +] +interface ID3D10Resource : ID3D10DeviceChild +{ + void GetType( + [out] D3D10_RESOURCE_DIMENSION *a); + void SetEvictionPriority( + [in] UINT a); + UINT GetEvictionPriority(); +} + +[ + object, + local, + uuid(9b7e4c02-342c-4106-a19f-4f2704f689f0) +] +interface ID3D10Buffer : ID3D10Resource +{ + HRESULT Map( + [in] D3D10_MAP a, + [in] UINT b, + [out] void **c); + void Unmap(); + void GetDesc( + [out] D3D10_BUFFER_DESC *a); +} + +[ + object, + local, + uuid(9b7e4c03-342c-4106-a19f-4f2704f689F0) +] +interface ID3D10Texture1D : ID3D10Resource +{ + HRESULT Map( + [in] UINT a, + [in] D3D10_MAP b, + [in] UINT c, + [out] void **d); + void Unmap( + [in] UINT a); + void GetDesc( + [out] D3D10_TEXTURE1D_DESC *a); +} + +[ + object, + local, + uuid(9b7e4c04-342c-4106-a19f-4f2704f689F0) +] +interface ID3D10Texture2D : ID3D10Resource +{ + HRESULT Map( + [in] UINT a, + [in] D3D10_MAP b, + [in] UINT c, + [out] D3D10_MAPPED_TEXTURE2D *d); + void Unmap( + [in] UINT a); + void GetDesc( + [out] D3D10_TEXTURE2D_DESC *a); +} + +[ + object, + local, + uuid(9b7e4c05-342c-4106-a19f-4f2704f689F0) +] +interface ID3D10Texture3D : ID3D10Resource +{ + HRESULT Map( + [in] UINT a, + [in] D3D10_MAP b, + [in] UINT c, + [out] D3D10_MAPPED_TEXTURE3D *d); + void Unmap( + [in] UINT a); + void GetDesc( + [out] D3D10_TEXTURE3D_DESC *a); +} + +[ + object, + local, + uuid(c902b03f-60a7-49ba-9936-2a3ab37a7e33) +] +interface ID3D10View : ID3D10DeviceChild +{ + void GetResource( + [out] ID3D10Resource **a); +} + +[ + object, + local, + uuid(9b7e4c09-342c-4106-a19f-4f2704f689f0) +] +interface ID3D10DepthStencilView : ID3D10View +{ + void GetDesc( + [out] D3D10_DEPTH_STENCIL_VIEW_DESC *a); +} + + +[ + object, + local, + uuid(9b7e4c08-342c-4106-a19f-4f2704f689f0) +] +interface ID3D10RenderTargetView : ID3D10View +{ + void GetDesc( + [out] D3D10_RENDER_TARGET_VIEW_DESC *a); +} + +[ + object, + local, + uuid(9b7e4c07-342c-4106-a19f-4f2704f689f0) +] +interface ID3D10ShaderResourceView : ID3D10View +{ + void GetDesc( + [out] D3D10_SHADER_RESOURCE_VIEW_DESC *a); +} + +/* Resource End */ + +[ + object, + local, + uuid(edad8d19-8a35-4d6d-8566-2ea276cde161) +] +interface ID3D10BlendState : ID3D10DeviceChild +{ + void GetDesc( + [out] D3D10_BLEND_DESC *a); +} + +[ + object, + local, + uuid(2b4b1cc8-a4ad-41f8-8322-ca86fc3ec675) +] +interface ID3D10DepthStencilState : ID3D10DeviceChild +{ + void GetDesc( + [out] D3D10_DEPTH_STENCIL_DESC *a); +} + +[ + object, + local, + uuid(6316be88-54cd-4040-ab44-20461bc81f68) +] +interface ID3D10GeometryShader : ID3D10DeviceChild +{ +} + +[ + object, + local, + uuid(9b7e4c0b-342c-4106-a19f-4f2704f689f0) +] +interface ID3D10InputLayout : ID3D10DeviceChild +{ +} + +[ + object, + local, + uuid(4968b601-9d00-4cde-8346-8e7f675819b6) +] +interface ID3D10PixelShader : ID3D10DeviceChild +{ +} + +[ + object, + local, + uuid(a2a07292-89af-4345-be2e-c53d9fbb6e9f) +] +interface ID3D10RasterizerState : ID3D10DeviceChild +{ + void GetDesc( + [out] D3D10_RASTERIZER_DESC *a); +} + +[ + object, + local, + uuid(9b7e4c0c-342c-4106-a19f-4f2704f689f0) +] +interface ID3D10SamplerState : ID3D10DeviceChild +{ + void GetDesc( + [out] D3D10_SAMPLER_DESC *a); +} + +[ + object, + local, + uuid(9b7e4c0a-342c-4106-a19f-4f2704f689f0) +] +interface ID3D10VertexShader : ID3D10DeviceChild +{ +} + +[ + object, + local, + uuid(9b7e4c0d-342c-4106-a19f-4f2704f689f0) +] +interface ID3D10Asynchronous : ID3D10DeviceChild +{ + void Begin(); + void End(); + HRESULT GetData( + [out] void *a, + [in] UINT b, + [in] UINT c); + UINT GetDataSize(); +} + +[ + object, + local, + uuid(9b7e4c11-342c-4106-a19f-4f2704f689f0) +] +interface ID3D10Counter : ID3D10Asynchronous +{ + void GetDesc( + [out] D3D10_COUNTER_DESC *a); +} + +[ + object, + local, + uuid(9b7e4C0e-342C-4106-a19f-4f2704f689f0) +] +interface ID3D10Query : ID3D10Asynchronous +{ + void GetDesc( + [out] D3D10_QUERY_DESC *a); +} + +[ + object, + local, + uuid(9b7e4c10-342c-4106-a19f-4f2704f689f0) +] +interface ID3D10Predicate : ID3D10Query +{ +} + +[ + object, + local, + uuid(9b7e4c0f-342c-4106-a19f-4f2704f689f0) +] +interface ID3D10Device : IUnknown +{ + void VSSetConstantBuffers( + [in] UINT a, + [in] UINT b, + [in] ID3D10Buffer *const *c); + void PSSetShaderResources( + [in] UINT a, + [in] UINT b, + [in] ID3D10ShaderResourceView *const *c); + void PSSetShader( + [in] ID3D10PixelShader *a); + void PSSetSamplers( + [in] UINT a, + [in] UINT b, + [in]ID3D10SamplerState *const *c); + void VSSetShader( + [in] ID3D10VertexShader *a); + void DrawIndexed( + [in] UINT a, + [in] UINT b, + [in] INT c); + void Draw( + [in] UINT a, + [in] UINT b); + void PSSetConstantBuffers( + [in] UINT a, + [in] UINT b, + [in] ID3D10Buffer *const *c); + void IASetInputLayout( + [in] ID3D10InputLayout *a); + void IASetVertexBuffers( + [in] UINT a, + [in] UINT b, + [in] ID3D10Buffer *const *c, + [in] const UINT *d, + [in] const UINT *e); + void IASetIndexBuffer( + [in] ID3D10Buffer *a, + [in] DXGI_FORMAT b, + [in] UINT c); + void DrawIndexedInstanced( + [in] UINT a, + [in] UINT b, + [in] UINT c, + [in] INT d, + [in] UINT e); + void DrawInstanced( + [in] UINT a, + [in] UINT b, + [in] UINT c, + [in] UINT d); + void GSSetConstantBuffers( + [in] UINT a, + [in] UINT b, + [in] ID3D10Buffer *const *c); + void GSSetShader( + [in] ID3D10GeometryShader *a); + void IASetPrimitiveTopology( + [in] D3D10_PRIMITIVE_TOPOLOGY a); + void VSSetShaderResources( + [in] UINT a, + [in] UINT b, + [in] ID3D10ShaderResourceView *const *c); + void VSSetSamplers( + [in] UINT a, + [in] UINT b, + [in] ID3D10SamplerState *const *c); + void SetPredication( + [in] ID3D10Predicate *a, + [in] BOOL b); + void GSSetShaderResources( + [in] UINT a, + [in] UINT b, + [in] ID3D10ShaderResourceView * const *c); + void GSSetSamplers( + [in] UINT a, + [in] UINT b, + [in] ID3D10SamplerState *const *c); + void OMSetRenderTargets( + [in] UINT a, + [in] ID3D10RenderTargetView *const *b, + [in] ID3D10DepthStencilView *c); + void OMSetBlendState( + [in] ID3D10BlendState *a, + [in] const FLOAT b[4], + [in] UINT c); + void OMSetDepthStencilState( + [in] ID3D10DepthStencilState *a, + [in] UINT b); + void SOSetTargets( + [in] UINT a, + [in] ID3D10Buffer *const *b, + [in] const UINT *c); + void DrawAuto(); + void RSSetState( + [in] ID3D10RasterizerState *a); + void RSSetViewports( + [in] UINT a, + [in] const D3D10_VIEWPORT *b); + void RSSetScissorRects( + [in] UINT a, + [in] const D3D10_RECT *b); + void CopySubresourceRegion( + [in] ID3D10Resource *a, + [in] UINT b, + [in] UINT c, + [in] UINT d, + [in] UINT e, + [in] ID3D10Resource *f, + [in] UINT g, + [in] const D3D10_BOX *h); + void CopyResource( + [in] ID3D10Resource *a, + [in] ID3D10Resource *b); + void UpdateSubresource( + [in] ID3D10Resource *a, + [in] UINT b, + [in] const D3D10_BOX *c, + [in] const void *d, + [in] UINT e, + [in] UINT f); + void ClearRenderTargetView( + [in] ID3D10RenderTargetView *a, + [in] const FLOAT b[4]); + void ClearDepthStencilView( + [in] ID3D10DepthStencilView *a, + [in] UINT b, + [in] FLOAT c, + [in] UINT8 d); + void GenerateMips( + [in] ID3D10ShaderResourceView *a); + void ResolveSubresource( + [in] ID3D10Resource *a, + [in] UINT b, + [in] ID3D10Resource *c, + [in] UINT d, + [in] DXGI_FORMAT e); + void VSGetConstantBuffers( + [in] UINT a, + [in] UINT b, + [out] ID3D10Buffer **c); + void PSGetShaderResources( + [in] UINT a, + [in] UINT b, + [out] ID3D10ShaderResourceView **c); + void PSGetShader( + [out] ID3D10PixelShader **a); + void PSGetSamplers( + [in] UINT a, + [in] UINT b, + [out] ID3D10SamplerState **c); + void VSGetShader( + [out] ID3D10VertexShader **a); + void PSGetConstantBuffers( + [in] UINT a, + [in] UINT b, + [out] ID3D10Buffer **c); + void IAGetInputLayout( + [out] ID3D10InputLayout **a); + void IAGetVertexBuffers( + [in] UINT a, + [in] UINT b, + [out] ID3D10Buffer **c, + [out] UINT *d, + [out] UINT *e); + void IAGetIndexBuffer( + [out] ID3D10Buffer **a, + [out] DXGI_FORMAT *b, + [out] UINT *c); + void GSGetConstantBuffers( + [in] UINT a, + [in] UINT b, + [out] ID3D10Buffer **c); + void GSGetShader( + [out] ID3D10GeometryShader **a); + void IAGetPrimitiveTopology( + [out] D3D10_PRIMITIVE_TOPOLOGY *a); + void VSGetShaderResources( + [in] UINT a, + [in] UINT b, + [out] ID3D10ShaderResourceView **c); + void VSGetSamplers( + [in] UINT a, + [in] UINT b, + [out] ID3D10SamplerState **c); + void GetPredication( + [out] ID3D10Predicate **a, + [out] BOOL *b); + void GSGetShaderResources( + [in] UINT a, + [in] UINT b, + [out] ID3D10ShaderResourceView **c); + void GSGetSamplers( + [in] UINT a, + [in] UINT b, + [out] ID3D10SamplerState **c); + void OMGetRenderTargets( + [in] UINT a, + [out] ID3D10RenderTargetView **b, + [out] ID3D10DepthStencilView **c); + void OMGetBlendState( + [out] ID3D10BlendState **a, + [out] FLOAT b[4], + [out] UINT *c); + void OMGetDepthStencilState( + [out] ID3D10DepthStencilState **a, + [out] UINT *b); + void SOGetTargets( + [in] UINT a, + [out] ID3D10Buffer **b, + [out] UINT *c); + void RSGetState( + [out] ID3D10RasterizerState **a); + void RSGetViewports( + [in, out] UINT *a, + [out] D3D10_VIEWPORT *b); + void RSGetScissorRects( + [in, out] UINT *a, + [out] D3D10_RECT *b); + HRESULT GetDeviceRemovedReason(); + HRESULT SetExceptionMode( + [in] UINT a); + UINT GetExceptionMode(); + HRESULT GetPrivateData( + [in] REFGUID a, + [in, out] UINT *b, + [out] void *c); + HRESULT SetPrivateData( + [in] REFGUID a, + [in] UINT b, + [in] const void *c); + HRESULT SetPrivateDataInterface( + [in] REFGUID a, + [in] const IUnknown *b); + void ClearState(); + void Flush(); + HRESULT CreateBuffer( + [in] const D3D10_BUFFER_DESC *a, + [in] const D3D10_SUBRESOURCE_DATA *b, + [out] ID3D10Buffer **c); + HRESULT CreateTexture1D( + [in] const D3D10_TEXTURE1D_DESC *a, + [in] const D3D10_SUBRESOURCE_DATA *b, + [out] ID3D10Texture1D **c); + HRESULT CreateTexture2D( + [in] const D3D10_TEXTURE2D_DESC *a, + [in] const D3D10_SUBRESOURCE_DATA *b, + [out] ID3D10Texture2D **c); + HRESULT CreateTexture3D( + [in] const D3D10_TEXTURE3D_DESC *a, + [in] const D3D10_SUBRESOURCE_DATA *b, + [out] ID3D10Texture3D **c); + HRESULT CreateShaderResourceView( + [in] ID3D10Resource *a, + [in] const D3D10_SHADER_RESOURCE_VIEW_DESC *b, + [out] ID3D10ShaderResourceView **c); + HRESULT CreateRenderTargetView( + [in] ID3D10Resource *a, + [in] const D3D10_RENDER_TARGET_VIEW_DESC *b, + [out] ID3D10RenderTargetView **c); + HRESULT CreateDepthStencilView( + [in] ID3D10Resource *a, + [in] const D3D10_DEPTH_STENCIL_VIEW_DESC *b, + [out] ID3D10DepthStencilView **c); + HRESULT CreateInputLayout( + [in] const D3D10_INPUT_ELEMENT_DESC *a, + [in] UINT b, + [in] const void *c, + [in] SIZE_T d, + [out] ID3D10InputLayout **e); + HRESULT CreateVertexShader( + [in] const void *a, + [in] SIZE_T b, + [out] ID3D10VertexShader **c); + HRESULT CreateGeometryShader( + [in] const void *a, + [in] SIZE_T b, + [out] ID3D10GeometryShader **c); + HRESULT CreateGeometryShaderWithStreamOutput( + [in] const void *a, + [in] SIZE_T b, + [in] const D3D10_SO_DECLARATION_ENTRY *c, + [in] UINT d, + [in] UINT e, + [out] ID3D10GeometryShader **f); + HRESULT CreatePixelShader( + [in] const void *a, + [in] SIZE_T b, + [out] ID3D10PixelShader **c); + HRESULT CreateBlendState( + [in] const D3D10_BLEND_DESC *a, + [out] ID3D10BlendState **b); + HRESULT CreateDepthStencilState( + [in] const D3D10_DEPTH_STENCIL_DESC *a, + [out] ID3D10DepthStencilState **b); + HRESULT CreateRasterizerState( + [in] const D3D10_RASTERIZER_DESC *a, + [out] ID3D10RasterizerState **b); + HRESULT CreateSamplerState( + [in] const D3D10_SAMPLER_DESC *a, + [out] ID3D10SamplerState **b); + HRESULT CreateQuery( + [in] const D3D10_QUERY_DESC *a, + [out] ID3D10Query **b); + HRESULT CreatePredicate( + [in] const D3D10_QUERY_DESC *a, + [out] ID3D10Predicate **b); + HRESULT CreateCounter( + [in] const D3D10_COUNTER_DESC *a, + [out] ID3D10Counter **b); + HRESULT CheckFormatSupport( + [in] DXGI_FORMAT a, + [out] UINT *b); + HRESULT CheckMultisampleQualityLevels( + [in] DXGI_FORMAT a, + [in] UINT b, + [out] UINT *c); + void CheckCounterInfo( + [out] D3D10_COUNTER_INFO *a); + HRESULT CheckCounter( + [in] const D3D10_COUNTER_DESC *a, + [out] D3D10_COUNTER_TYPE *b, + [out] UINT *c, + [out] LPSTR d, + [in, out] UINT *e, + [out] LPSTR f, + [in, out] UINT *g, + [out] LPSTR h, + [in, out] UINT *i); + UINT GetCreationFlags(); + HRESULT OpenSharedResource( + [in] HANDLE a, + [in] REFIID b, + [out] void **c); + void SetTextFilterSize( + [in] UINT a, + [in] UINT b); + void GetTextFilterSize( + [out] UINT *a, + [out] UINT *b); +} + +[ + object, + local, + uuid(9b7e4e00-342c-4106-a19f-4f2704f689f0) +] +interface ID3D10Multithread : IUnknown +{ + void Enter(); + void Leave(); + BOOL SetMultithreadProtected( + [in] BOOL a); + BOOL GetMultithreadProtected(); +} + +cpp_quote("#include \"d3d10misc.h\"") +cpp_quote("#include \"d3d10shader.h\"") +cpp_quote("#include \"d3d10effect.h\"") +/* TODO: Include "d310sdklayers.h" as soon as it exists */ diff --git a/src/gallium/state_trackers/d3d1x/d3dapi/d3d10_1.idl b/src/gallium/state_trackers/d3d1x/d3dapi/d3d10_1.idl new file mode 100644 index 00000000000..7edeff94f79 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3dapi/d3d10_1.idl @@ -0,0 +1,191 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + +import "oaidl.idl"; +import "ocidl.idl"; +import "d3d10.idl"; +import "d3dcommon.idl"; + +const unsigned int D3D10_1_SDK_VERSION = 0x20; + +cpp_quote("#ifndef _D3D10_1_CONSTANTS") +cpp_quote("#define _D3D10_1_CONSTANTS") +const unsigned int D3D10_1_DEFAULT_SAMPLE_MASK = 0xffffffff; +const float D3D10_1_FLOAT16_FUSED_TOLERANCE_IN_ULP = 0.6; +const float D3D10_1_FLOAT32_TO_INTEGER_TOLERANCE_IN_ULP = 0.6; +const unsigned int D3D10_1_GS_INPUT_REGISTER_COUNT = 32; +const unsigned int D3D10_1_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT = 32; +const unsigned int D3D10_1_IA_VERTEX_INPUT_STRUCTURE_ELEMENTS_COMPONENTS = 128; +const unsigned int D3D10_1_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT = 32; +const unsigned int D3D10_1_PS_OUTPUT_MASK_REGISTER_COMPONENTS = 1; +const unsigned int D3D10_1_PS_OUTPUT_MASK_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D10_1_PS_OUTPUT_MASK_REGISTER_COUNT = 1; +const unsigned int D3D10_1_SHADER_MAJOR_VERSION = 4; +const unsigned int D3D10_1_SHADER_MINOR_VERSION = 1; +const unsigned int D3D10_1_SO_BUFFER_MAX_STRIDE_IN_BYTES = 2048; +const unsigned int D3D10_1_SO_BUFFER_MAX_WRITE_WINDOW_IN_BYTES = 256; +const unsigned int D3D10_1_SO_BUFFER_SLOT_COUNT = 4; +const unsigned int D3D10_1_SO_MULTIPLE_BUFFER_ELEMENTS_PER_BUFFER = 1; +const unsigned int D3D10_1_SO_SINGLE_BUFFER_COMPONENT_LIMIT = 64; +const unsigned int D3D10_1_STANDARD_VERTEX_ELEMENT_COUNT = 32; +const unsigned int D3D10_1_SUBPIXEL_FRACTIONAL_BIT_COUNT = 8; +const unsigned int D3D10_1_VS_INPUT_REGISTER_COUNT = 32; +const unsigned int D3D10_1_VS_OUTPUT_REGISTER_COUNT = 32; +cpp_quote("#endif") + +typedef enum D3D10_FEATURE_LEVEL1 +{ + D3D10_FEATURE_LEVEL_10_0 = 0xa000, + D3D10_FEATURE_LEVEL_10_1 = 0xa100, + D3D10_FEATURE_LEVEL_9_1 = 0x9100, + D3D10_FEATURE_LEVEL_9_2 = 0x9200, + D3D10_FEATURE_LEVEL_9_3 = 0x9300 +} D3D10_FEATURE_LEVEL1; + +typedef struct D3D10_RENDER_TARGET_BLEND_DESC1 +{ + BOOL BlendEnable; + D3D10_BLEND SrcBlend; + D3D10_BLEND DestBlend; + D3D10_BLEND_OP BlendOp; + D3D10_BLEND SrcBlendAlpha; + D3D10_BLEND DestBlendAlpha; + D3D10_BLEND_OP BlendOpAlpha; + UINT8 RenderTargetWriteMask; +} D3D10_RENDER_TARGET_BLEND_DESC1; + +typedef struct D3D10_BLEND_DESC1 +{ + BOOL AlphaToCoverageEnable; + BOOL IndependentBlendEnable; + D3D10_RENDER_TARGET_BLEND_DESC1 RenderTarget[8]; +} D3D10_BLEND_DESC1; + +typedef struct D3D10_TEXCUBE_ARRAY_SRV1 +{ + UINT MostDetailedMip; + UINT MipLevels; + UINT First2DArrayFace; + UINT NumCubes; +} D3D10_TEXCUBE_ARRAY_SRV1; + +typedef D3D_SRV_DIMENSION D3D10_SRV_DIMENSION1; + +typedef struct D3D10_SHADER_RESOURCE_VIEW_DESC1 +{ + DXGI_FORMAT Format; + D3D10_SRV_DIMENSION1 ViewDimension; + union + { + D3D10_BUFFER_SRV Buffer; + D3D10_TEX1D_SRV Texture1D; + D3D10_TEX1D_ARRAY_SRV Texture1DArray; + D3D10_TEX2D_SRV Texture2D; + D3D10_TEX2D_ARRAY_SRV Texture2DArray; + D3D10_TEX2DMS_SRV Texture2DMS; + D3D10_TEX2DMS_ARRAY_SRV Texture2DMSArray; + D3D10_TEX3D_SRV Texture3D; + D3D10_TEXCUBE_SRV TextureCube; + D3D10_TEXCUBE_ARRAY_SRV1 TextureCubeArray; + } ; +} D3D10_SHADER_RESOURCE_VIEW_DESC1; + +typedef enum D3D10_STANDARD_MULTISAMPLE_QUALITY_LEVELS +{ + D3D10_STANDARD_MULTISAMPLE_PATTERN = 0xffffffff, + D3D10_CENTER_MULTISAMPLE_PATTERN = 0xfffffffe +} D3D10_STANDARD_MULTISAMPLE_QUALITY_LEVELS; + +[object, local, uuid("EDAD8D99-8A35-4d6d-8566-2EA276CDE161")] +interface ID3D10BlendState1 : ID3D10BlendState +{ + void GetDesc1( + [out] D3D10_BLEND_DESC1 *a + ); +}; + +[object, local, uuid("9B7E4C87-342C-4106-A19F-4F2704F689F0")] +interface ID3D10ShaderResourceView1 : ID3D10ShaderResourceView +{ + void GetDesc1( + [out] D3D10_SHADER_RESOURCE_VIEW_DESC1 *a + ); +}; + +[object, local, uuid("9B7E4C8F-342C-4106-A19F-4F2704F689F0")] +interface ID3D10Device1 : ID3D10Device +{ + HRESULT CreateShaderResourceView1( + [in] ID3D10Resource *a, + [in] const D3D10_SHADER_RESOURCE_VIEW_DESC1 *b, + [out,optional] ID3D10ShaderResourceView1 **c + ); + + HRESULT CreateBlendState1( + [in] const D3D10_BLEND_DESC1 *a, + [out, optional] ID3D10BlendState1 **b + ); + + D3D10_FEATURE_LEVEL1 GetFeatureLevel(); +}; + +//cpp_quote("#include \"d3d10_1shader.h\"") + +typedef enum D3D10_DRIVER_TYPE D3D10_DRIVER_TYPE; + +HRESULT D3D10CreateDevice1( + [in,optional] IDXGIAdapter* a, + [in] D3D10_DRIVER_TYPE b, + [in] HMODULE c, + [in] UINT d, + [in] D3D10_FEATURE_LEVEL1 e, + [in] UINT f, + [out,optional] ID3D10Device1** g +); + +typedef HRESULT (* PFN_D3D10_CREATE_DEVICE_AND_SWAP_CHAIN1)( + [in,optional] IDXGIAdapter*, + D3D10_DRIVER_TYPE, + HMODULE, + UINT, + D3D10_FEATURE_LEVEL1, + UINT, + [in, optional] DXGI_SWAP_CHAIN_DESC*, + [out,optional] IDXGISwapChain**, + [out,optional] ID3D10Device1** +); + +HRESULT D3D10CreateDeviceAndSwapChain1( + [in,optional] IDXGIAdapter* a, + [in] D3D10_DRIVER_TYPE b, + [in] HMODULE c, + [in] UINT d, + [in] D3D10_FEATURE_LEVEL1 e, + [in] UINT f, + [in,optional] DXGI_SWAP_CHAIN_DESC* g, + [out,optional] IDXGISwapChain** h, + [out,optional] ID3D10Device1** i +); diff --git a/src/gallium/state_trackers/d3d1x/d3dapi/d3d10misc.h b/src/gallium/state_trackers/d3d1x/d3dapi/d3d10misc.h new file mode 100644 index 00000000000..4f866ff4153 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3dapi/d3d10misc.h @@ -0,0 +1,47 @@ +/* + * Copyright 2008 Henri Verbeet for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef __D3D10MISC_H__ +#define __D3D10MISC_H__ + +#include "d3d10.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum D3D10_DRIVER_TYPE { + D3D10_DRIVER_TYPE_HARDWARE = 0, + D3D10_DRIVER_TYPE_REFERENCE = 1, + D3D10_DRIVER_TYPE_NULL = 2, + D3D10_DRIVER_TYPE_SOFTWARE = 3, + D3D10_DRIVER_TYPE_WARP = 5, // added by Luca Barbieri in Sep 2010 +} D3D10_DRIVER_TYPE; + +HRESULT WINAPI D3D10CreateDevice(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver_type, + HMODULE swrast, UINT flags, UINT sdk_version, ID3D10Device **device); + +HRESULT WINAPI D3D10CreateDeviceAndSwapChain(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver_type, + HMODULE swrast, UINT flags, UINT sdk_version, DXGI_SWAP_CHAIN_DESC *swapchain_desc, + IDXGISwapChain **swapchain, ID3D10Device **device); + +#ifdef __cplusplus +} +#endif + +#endif /* __D3D10MISC_H__ */ diff --git a/src/gallium/state_trackers/d3d1x/d3dapi/d3d10shader.idl b/src/gallium/state_trackers/d3d1x/d3dapi/d3d10shader.idl new file mode 100644 index 00000000000..6088a8894a2 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3dapi/d3d10shader.idl @@ -0,0 +1,269 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + +import "d3d10.idl"; + +cpp_quote("#define D3D10_TX_VERSION(a, b) (('T' << 24) | ('X' << 16) | ((a) << 8) | (b)))") + +const unsigned int D3D10_SHADER_DEBUG = (1 << 0); +const unsigned int D3D10_SHADER_SKIP_VALIDATION = (1 << 1); +const unsigned int D3D10_SHADER_SKIP_OPTIMIZATION = (1 << 2); +const unsigned int D3D10_SHADER_PACK_MATRIX_ROW_MAJOR = (1 << 3); +const unsigned int D3D10_SHADER_PACK_MATRIX_COLUMN_MAJOR = (1 << 4); +const unsigned int D3D10_SHADER_PARTIAL_PRECISION = (1 << 5); +const unsigned int D3D10_SHADER_FORCE_VS_SOFTWARE_NO_OPT = (1 << 6); +const unsigned int D3D10_SHADER_FORCE_PS_SOFTWARE_NO_OPT = (1 << 7); +const unsigned int D3D10_SHADER_NO_PRESHADER = (1 << 8); +const unsigned int D3D10_SHADER_AVOID_FLOW_CONTROL = (1 << 9); +const unsigned int D3D10_SHADER_PREFER_FLOW_CONTROL = (1 << 10); +const unsigned int D3D10_SHADER_ENABLE_STRICTNESS = (1 << 11); +const unsigned int D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY = (1 << 12); +const unsigned int D3D10_SHADER_IEEE_STRICTNESS = (1 << 13); +const unsigned int D3D10_SHADER_WARNINGS_ARE_ERRORS = (1 << 18); + + +const unsigned int D3D10_SHADER_OPTIMIZATION_LEVEL0 = (1 << 14); +const unsigned int D3D10_SHADER_OPTIMIZATION_LEVEL1 = 0; +const unsigned int D3D10_SHADER_OPTIMIZATION_LEVEL2 = ((1 << 14) | (1 << 15)); +const unsigned int D3D10_SHADER_OPTIMIZATION_LEVEL3 = (1 << 15); + +typedef D3D_SHADER_MACRO D3D10_SHADER_MACRO; +typedef D3D10_SHADER_MACRO* LPD3D10_SHADER_MACRO; + + +typedef D3D_SHADER_VARIABLE_CLASS D3D10_SHADER_VARIABLE_CLASS; +typedef D3D10_SHADER_VARIABLE_CLASS* LPD3D10_SHADER_VARIABLE_CLASS; +typedef D3D_SHADER_VARIABLE_FLAGS D3D10_SHADER_VARIABLE_FLAGS; +typedef D3D10_SHADER_VARIABLE_FLAGS* LPD3D10_SHADER_VARIABLE_FLAGS; +typedef D3D_SHADER_VARIABLE_TYPE D3D10_SHADER_VARIABLE_TYPE; +typedef D3D10_SHADER_VARIABLE_TYPE* LPD3D10_SHADER_VARIABLE_TYPE; +typedef D3D_SHADER_INPUT_FLAGS D3D10_SHADER_INPUT_FLAGS; +typedef D3D10_SHADER_INPUT_FLAGS* LPD3D10_SHADER_INPUT_FLAGS; +typedef D3D_SHADER_INPUT_TYPE D3D10_SHADER_INPUT_TYPE; +typedef D3D10_SHADER_INPUT_TYPE* LPD3D10_SHADER_INPUT_TYPE; +typedef D3D_SHADER_CBUFFER_FLAGS D3D10_SHADER_CBUFFER_FLAGS; +typedef D3D10_SHADER_CBUFFER_FLAGS* LPD3D10_SHADER_CBUFFER_FLAGS; +typedef D3D_CBUFFER_TYPE D3D10_CBUFFER_TYPE; +typedef D3D10_CBUFFER_TYPE* LPD3D10_CBUFFER_TYPE; +typedef D3D_NAME D3D10_NAME; +typedef D3D_RESOURCE_RETURN_TYPE D3D10_RESOURCE_RETURN_TYPE; +typedef D3D_REGISTER_COMPONENT_TYPE D3D10_REGISTER_COMPONENT_TYPE; +typedef D3D_INCLUDE_TYPE D3D10_INCLUDE_TYPE; +typedef ID3DInclude* LPD3D10INCLUDE; + +cpp_quote("#define D3D10_SHVER_GET_TYPE(v) (((v) >> 16) & 0xffff)") +cpp_quote("#define D3D10_SHVER_GET_MAJOR(v) (((v) >> 4) & 0xf)") +cpp_quote("#define D3D10_SHVER_GET_MINOR(v) (((v) >> 0) & 0xf)") + +typedef struct _D3D10_SIGNATURE_PARAMETER_DESC +{ + LPCSTR SemanticName; + UINT SemanticIndex; + UINT Register; + D3D_NAME SystemValueType; + D3D_REGISTER_COMPONENT_TYPE ComponentType; + BYTE Mask; + BYTE ReadWriteMask; +} D3D10_SIGNATURE_PARAMETER_DESC; + +typedef struct _D3D10_SHADER_BUFFER_DESC +{ + LPCSTR Name; + D3D_CBUFFER_TYPE Type; + UINT Variables; + UINT Size; + UINT uFlags; +} D3D10_SHADER_BUFFER_DESC; + +typedef struct _D3D10_SHADER_VARIABLE_DESC +{ + LPCSTR Name; + UINT StartOffset; + UINT Size; + UINT uFlags; + LPVOID DefaultValue; + UINT StartTexture; + UINT TextureSize; + UINT StartSampler; + UINT SamplerSize; +} D3D10_SHADER_VARIABLE_DESC; + +typedef struct _D3D10_SHADER_TYPE_DESC +{ + D3D_SHADER_VARIABLE_CLASS Class; + D3D_SHADER_VARIABLE_TYPE Type; + UINT Rows; + UINT Columns; + UINT Elements; + UINT Members; + UINT Offset; + LPCSTR Name; +} D3D10_SHADER_TYPE_DESC; + +typedef D3D_TESSELLATOR_DOMAIN D3D10_TESSELLATOR_DOMAIN; +typedef D3D_TESSELLATOR_PARTITIONING D3D10_TESSELLATOR_PARTITIONING; +typedef D3D_TESSELLATOR_OUTPUT_PRIMITIVE D3D10_TESSELLATOR_OUTPUT_PRIMITIVE; + +typedef struct _D3D10_SHADER_DESC +{ + UINT Version; + LPCSTR Creator; + UINT Flags; + + UINT ConstantBuffers; + UINT BoundResources; + UINT InputParameters; + UINT OutputParameters; + + UINT InstructionCount; + UINT TempRegisterCount; + UINT TempArrayCount; + UINT DefCount; + UINT DclCount; + UINT TextureNormalInstructions; + UINT TextureLoadInstructions; + UINT TextureCompInstructions; + UINT TextureBiasInstructions; + UINT TextureGradientInstructions; + UINT FloatInstructionCount; + UINT IntInstructionCount; + UINT UintInstructionCount; + UINT StaticFlowControlCount; + UINT DynamicFlowControlCount; + UINT MacroInstructionCount; + UINT ArrayInstructionCount; + UINT CutInstructionCount; + UINT EmitInstructionCount; + D3D_PRIMITIVE_TOPOLOGY GSOutputTopology; + UINT GSMaxOutputVertexCount; +} D3D10_SHADER_DESC; + +typedef struct _D3D10_SHADER_INPUT_BIND_DESC +{ + LPCSTR Name; + D3D_SHADER_INPUT_TYPE Type; + UINT BindPoint; + UINT BindCount; + + UINT uFlags; + D3D_RESOURCE_RETURN_TYPE ReturnType; + D3D_SRV_DIMENSION Dimension; + UINT NumSamples; +} D3D10_SHADER_INPUT_BIND_DESC; + +[local, object, uuid("C530AD7D-9B16-4395-A979-BA2ECFF83ADD")] +interface ID3D10ShaderReflectionType +{ + HRESULT GetDesc( + [out] D3D10_SHADER_TYPE_DESC *a + ); + + ID3D10ShaderReflectionType* GetMemberTypeByIndex( + [in] UINT a + ); + + ID3D10ShaderReflectionType* GetMemberTypeByName( + [in] LPCSTR a + ); + + LPCSTR GetMemberTypeName( + [in] UINT a + ); +}; + +interface ID3D10ShaderReflectionConstantBuffer; + +[object, local, uuid("1BF63C95-2650-405d-99C1-3636BD1DA0A1")] +interface ID3D10ShaderReflectionVariable +{ + HRESULT GetDesc( + [out] D3D10_SHADER_VARIABLE_DESC *a + ); + + ID3D10ShaderReflectionType* GetType(); +}; + +[object, local, uuid("66C66A94-DDDD-4b62-A66A-F0DA33C2B4D0")] +interface ID3D10ShaderReflectionConstantBuffer +{ + HRESULT GetDesc( + [out] D3D10_SHADER_BUFFER_DESC *a + ); + + ID3D10ShaderReflectionVariable* GetVariableByIndex( + [in] UINT a + ); + + ID3D10ShaderReflectionVariable* GetVariableByName( + [in] LPCSTR a + ); +}; + +[object,local,uuid("D40E20B6-F8F7-42ad-AB20-4BAF8F15DFAA")] +interface ID3D10ShaderReflection : IUnknown +{ + HRESULT GetDesc( + [out] D3D10_SHADER_DESC *a + ); + + ID3D10ShaderReflectionConstantBuffer* GetConstantBufferByIndex( + [in] UINT a + ); + + ID3D10ShaderReflectionConstantBuffer* GetConstantBufferByName( + [in] LPCSTR a + ); + + HRESULT GetResourceBindingDesc( + [in] UINT a, + [out] D3D10_SHADER_INPUT_BIND_DESC *b + ); + + HRESULT GetInputParameterDesc( + [in] UINT a, + [out] D3D10_SIGNATURE_PARAMETER_DESC *b + ); + + HRESULT GetOutputParameterDesc + ( + [in] UINT a, + [out] D3D10_SIGNATURE_PARAMETER_DESC *b + ); +}; + +HRESULT D3D10CompileShader(LPCSTR pSrcData, SIZE_T SrcDataLen, LPCSTR pFileName, const D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, + LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs); +HRESULT D3D10DisassembleShader(const void *pShader, SIZE_T BytecodeLength, BOOL EnableColorCode, LPCSTR pComments, ID3D10Blob** ppDisassembly); +LPCSTR D3D10GetPixelShaderProfile(ID3D10Device *pDevice); +LPCSTR D3D10GetVertexShaderProfile(ID3D10Device *pDevice); +LPCSTR D3D10GetGeometryShaderProfile(ID3D10Device *pDevice); +HRESULT D3D10ReflectShader(const void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10ShaderReflection **ppReflector); +HRESULT D3D10PreprocessShader(LPCSTR pSrcData, SIZE_T SrcDataSize, LPCSTR pFileName, const D3D10_SHADER_MACRO* pDefines, + LPD3D10INCLUDE pInclude, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs); +HRESULT D3D10GetInputSignatureBlob(const void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10Blob **ppSignatureBlob); +HRESULT D3D10GetOutputSignatureBlob(const void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10Blob **ppSignatureBlob); +HRESULT D3D10GetInputAndOutputSignatureBlob(const void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10Blob **ppSignatureBlob); +HRESULT D3D10GetShaderDebugInfo(const void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10Blob** ppDebugInfo); diff --git a/src/gallium/state_trackers/d3d1x/d3dapi/d3d11.idl b/src/gallium/state_trackers/d3d1x/d3dapi/d3d11.idl new file mode 100644 index 00000000000..cac046fac77 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3dapi/d3d11.idl @@ -0,0 +1,2492 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + +import "oaidl.idl"; +import "ocidl.idl"; +import "dxgi.idl"; +import "d3dcommon.idl"; + +const unsigned int D3D11_SDK_VERSION = 7; + +cpp_quote("#ifndef _D3D11_CONSTANTS") +cpp_quote("#define _D3D11_CONSTANTS") +const unsigned int D3D11_16BIT_INDEX_STRIP_CUT_VALUE = 0xffff; +const unsigned int D3D11_32BIT_INDEX_STRIP_CUT_VALUE = 0xffffffff; +const unsigned int D3D11_8BIT_INDEX_STRIP_CUT_VALUE = 0xff; +const unsigned int D3D11_ARRAY_AXIS_ADDRESS_RANGE_BIT_COUNT = 9; +const unsigned int D3D11_CLIP_OR_CULL_DISTANCE_COUNT = 8; +const unsigned int D3D11_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT = 2; +const unsigned int D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT = 14; +const unsigned int D3D11_COMMONSHADER_CONSTANT_BUFFER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_COMMONSHADER_CONSTANT_BUFFER_COMPONENTS = 4; +const unsigned int D3D11_COMMONSHADER_CONSTANT_BUFFER_HW_SLOT_COUNT = 15; +const unsigned int D3D11_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COMPONENTS = 4; +const unsigned int D3D11_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COUNT = 15; +const unsigned int D3D11_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READ_PORTS = 1; +const unsigned int D3D11_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READS_PER_INST = 1; +const unsigned int D3D11_COMMONSHADER_FLOWCONTROL_NESTING_LIMIT = 64; +const unsigned int D3D11_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COMPONENTS = 4; +const unsigned int D3D11_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COUNT = 1; +const unsigned int D3D11_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READ_PORTS = 1; +const unsigned int D3D11_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READS_PER_INST = 1; +const unsigned int D3D11_COMMONSHADER_IMMEDIATE_VALUE_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_COMMONSHADER_INPUT_RESOURCE_REGISTER_COMPONENTS = 1; +const unsigned int D3D11_COMMONSHADER_INPUT_RESOURCE_REGISTER_COUNT = 128; +const unsigned int D3D11_COMMONSHADER_INPUT_RESOURCE_REGISTER_READ_PORTS = 1; +const unsigned int D3D11_COMMONSHADER_INPUT_RESOURCE_REGISTER_READS_PER_INST = 1; +const unsigned int D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT = 128; +const unsigned int D3D11_COMMONSHADER_SAMPLER_REGISTER_COMPONENTS = 1; +const unsigned int D3D11_COMMONSHADER_SAMPLER_REGISTER_COUNT = 16; +const unsigned int D3D11_COMMONSHADER_SAMPLER_REGISTER_READ_PORTS = 1; +const unsigned int D3D11_COMMONSHADER_SAMPLER_REGISTER_READS_PER_INST = 1; +const unsigned int D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT = 16; +const unsigned int D3D11_COMMONSHADER_SUBROUTINE_NESTING_LIMIT = 32; +const unsigned int D3D11_COMMONSHADER_TEMP_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_COMMONSHADER_TEMP_REGISTER_COMPONENTS = 4; +const unsigned int D3D11_COMMONSHADER_TEMP_REGISTER_COUNT = 4096; +const unsigned int D3D11_COMMONSHADER_TEMP_REGISTER_READ_PORTS = 3; +const unsigned int D3D11_COMMONSHADER_TEMP_REGISTER_READS_PER_INST = 3; +const unsigned int D3D11_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MAX = 10; +const int D3D11_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MIN = -10; +const int D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE = -8; +const unsigned int D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE = 7; +const unsigned int D3D11_CS_4_X_BUCKET00_MAX_BYTES_TGSM_WRITABLE_PER_THREAD = 256; +const unsigned int D3D11_CS_4_X_BUCKET00_MAX_NUM_THREADS_PER_GROUP = 64; +const unsigned int D3D11_CS_4_X_BUCKET01_MAX_BYTES_TGSM_WRITABLE_PER_THREAD = 240; +const unsigned int D3D11_CS_4_X_BUCKET01_MAX_NUM_THREADS_PER_GROUP = 68; +const unsigned int D3D11_CS_4_X_BUCKET02_MAX_BYTES_TGSM_WRITABLE_PER_THREAD = 224; +const unsigned int D3D11_CS_4_X_BUCKET02_MAX_NUM_THREADS_PER_GROUP = 72; +const unsigned int D3D11_CS_4_X_BUCKET03_MAX_BYTES_TGSM_WRITABLE_PER_THREAD = 208; +const unsigned int D3D11_CS_4_X_BUCKET03_MAX_NUM_THREADS_PER_GROUP = 76; +const unsigned int D3D11_CS_4_X_BUCKET04_MAX_BYTES_TGSM_WRITABLE_PER_THREAD = 192; +const unsigned int D3D11_CS_4_X_BUCKET04_MAX_NUM_THREADS_PER_GROUP = 84; +const unsigned int D3D11_CS_4_X_BUCKET05_MAX_BYTES_TGSM_WRITABLE_PER_THREAD = 176; +const unsigned int D3D11_CS_4_X_BUCKET05_MAX_NUM_THREADS_PER_GROUP = 92; +const unsigned int D3D11_CS_4_X_BUCKET06_MAX_BYTES_TGSM_WRITABLE_PER_THREAD = 160; +const unsigned int D3D11_CS_4_X_BUCKET06_MAX_NUM_THREADS_PER_GROUP = 100; +const unsigned int D3D11_CS_4_X_BUCKET07_MAX_BYTES_TGSM_WRITABLE_PER_THREAD = 144; +const unsigned int D3D11_CS_4_X_BUCKET07_MAX_NUM_THREADS_PER_GROUP = 112; +const unsigned int D3D11_CS_4_X_BUCKET08_MAX_BYTES_TGSM_WRITABLE_PER_THREAD = 128; +const unsigned int D3D11_CS_4_X_BUCKET08_MAX_NUM_THREADS_PER_GROUP = 128; +const unsigned int D3D11_CS_4_X_BUCKET09_MAX_BYTES_TGSM_WRITABLE_PER_THREAD = 112; +const unsigned int D3D11_CS_4_X_BUCKET09_MAX_NUM_THREADS_PER_GROUP = 144; +const unsigned int D3D11_CS_4_X_BUCKET10_MAX_BYTES_TGSM_WRITABLE_PER_THREAD = 96; +const unsigned int D3D11_CS_4_X_BUCKET10_MAX_NUM_THREADS_PER_GROUP = 168; +const unsigned int D3D11_CS_4_X_BUCKET11_MAX_BYTES_TGSM_WRITABLE_PER_THREAD = 80; +const unsigned int D3D11_CS_4_X_BUCKET11_MAX_NUM_THREADS_PER_GROUP = 204; +const unsigned int D3D11_CS_4_X_BUCKET12_MAX_BYTES_TGSM_WRITABLE_PER_THREAD = 64; +const unsigned int D3D11_CS_4_X_BUCKET12_MAX_NUM_THREADS_PER_GROUP = 256; +const unsigned int D3D11_CS_4_X_BUCKET13_MAX_BYTES_TGSM_WRITABLE_PER_THREAD = 48; +const unsigned int D3D11_CS_4_X_BUCKET13_MAX_NUM_THREADS_PER_GROUP = 340; +const unsigned int D3D11_CS_4_X_BUCKET14_MAX_BYTES_TGSM_WRITABLE_PER_THREAD = 32; +const unsigned int D3D11_CS_4_X_BUCKET14_MAX_NUM_THREADS_PER_GROUP = 512; +const unsigned int D3D11_CS_4_X_BUCKET15_MAX_BYTES_TGSM_WRITABLE_PER_THREAD = 16; +const unsigned int D3D11_CS_4_X_BUCKET15_MAX_NUM_THREADS_PER_GROUP = 768; +const unsigned int D3D11_CS_4_X_DISPATCH_MAX_THREAD_GROUPS_IN_Z_DIMENSION = 1; +const unsigned int D3D11_CS_4_X_RAW_UAV_BYTE_ALIGNMENT = 256; +const unsigned int D3D11_CS_4_X_THREAD_GROUP_MAX_THREADS_PER_GROUP = 768; +const unsigned int D3D11_CS_4_X_THREAD_GROUP_MAX_X = 768; +const unsigned int D3D11_CS_4_X_THREAD_GROUP_MAX_Y = 768; +const unsigned int D3D11_CS_4_X_UAV_REGISTER_COUNT = 1; +const unsigned int D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION = 65535; +const unsigned int D3D11_CS_TGSM_REGISTER_COUNT = 8192; +const unsigned int D3D11_CS_TGSM_REGISTER_READS_PER_INST = 1; +const unsigned int D3D11_CS_TGSM_RESOURCE_REGISTER_COMPONENTS = 1; +const unsigned int D3D11_CS_TGSM_RESOURCE_REGISTER_READ_PORTS = 1; +const unsigned int D3D11_CS_THREAD_GROUP_MAX_THREADS_PER_GROUP = 1024; +const unsigned int D3D11_CS_THREAD_GROUP_MAX_X = 1024; +const unsigned int D3D11_CS_THREAD_GROUP_MAX_Y = 1024; +const unsigned int D3D11_CS_THREAD_GROUP_MAX_Z = 64; +const unsigned int D3D11_CS_THREAD_GROUP_MIN_X = 1; +const unsigned int D3D11_CS_THREAD_GROUP_MIN_Y = 1; +const unsigned int D3D11_CS_THREAD_GROUP_MIN_Z = 1; +const unsigned int D3D11_CS_THREAD_LOCAL_TEMP_REGISTER_POOL = 16384; +const float D3D11_DEFAULT_BLEND_FACTOR_ALPHA = 1.0; +const float D3D11_DEFAULT_BLEND_FACTOR_BLUE = 1.0; +const float D3D11_DEFAULT_BLEND_FACTOR_GREEN = 1.0; +const float D3D11_DEFAULT_BLEND_FACTOR_RED = 1.0; +const float D3D11_DEFAULT_BORDER_COLOR_COMPONENT = 0.0; +const unsigned int D3D11_DEFAULT_DEPTH_BIAS = 0; +const float D3D11_DEFAULT_DEPTH_BIAS_CLAMP = 0.0; +const unsigned int D3D11_DEFAULT_MAX_ANISOTROPY = 16; +const float D3D11_DEFAULT_MIP_LOD_BIAS = 0.0; +const unsigned int D3D11_DEFAULT_RENDER_TARGET_ARRAY_INDEX = 0; +const unsigned int D3D11_DEFAULT_SAMPLE_MASK = 0xffffffff; +const unsigned int D3D11_DEFAULT_SCISSOR_ENDX = 0; +const unsigned int D3D11_DEFAULT_SCISSOR_ENDY = 0; +const unsigned int D3D11_DEFAULT_SCISSOR_STARTX = 0; +const unsigned int D3D11_DEFAULT_SCISSOR_STARTY = 0; +const float D3D11_DEFAULT_SLOPE_SCALED_DEPTH_BIAS = 0.0; +const unsigned int D3D11_DEFAULT_STENCIL_READ_MASK = 0xff; +const unsigned int D3D11_DEFAULT_STENCIL_REFERENCE = 0; +const unsigned int D3D11_DEFAULT_STENCIL_WRITE_MASK = 0xff; +const unsigned int D3D11_DEFAULT_VIEWPORT_AND_SCISSORRECT_INDEX = 0; +const unsigned int D3D11_DEFAULT_VIEWPORT_HEIGHT = 0; +const float D3D11_DEFAULT_VIEWPORT_MAX_DEPTH = 0.0; +const float D3D11_DEFAULT_VIEWPORT_MIN_DEPTH = 0.0; +const unsigned int D3D11_DEFAULT_VIEWPORT_TOPLEFTX = 0; +const unsigned int D3D11_DEFAULT_VIEWPORT_TOPLEFTY = 0; +const unsigned int D3D11_DEFAULT_VIEWPORT_WIDTH = 0; +const unsigned int D3D11_DS_INPUT_CONTROL_POINT_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_DS_INPUT_CONTROL_POINT_REGISTER_COMPONENTS = 4; +const unsigned int D3D11_DS_INPUT_CONTROL_POINT_REGISTER_COUNT = 32; +const unsigned int D3D11_DS_INPUT_CONTROL_POINT_REGISTER_READ_PORTS = 1; +const unsigned int D3D11_DS_INPUT_CONTROL_POINT_REGISTER_READS_PER_INST = 2; +const unsigned int D3D11_DS_INPUT_CONTROL_POINTS_MAX_TOTAL_SCALARS = 3968; +const unsigned int D3D11_DS_INPUT_DOMAIN_POINT_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_DS_INPUT_DOMAIN_POINT_REGISTER_COMPONENTS = 3; +const unsigned int D3D11_DS_INPUT_DOMAIN_POINT_REGISTER_COUNT = 1; +const unsigned int D3D11_DS_INPUT_DOMAIN_POINT_REGISTER_READ_PORTS = 1; +const unsigned int D3D11_DS_INPUT_DOMAIN_POINT_REGISTER_READS_PER_INST = 2; +const unsigned int D3D11_DS_INPUT_PATCH_CONSTANT_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_DS_INPUT_PATCH_CONSTANT_REGISTER_COMPONENTS = 4; +const unsigned int D3D11_DS_INPUT_PATCH_CONSTANT_REGISTER_COUNT = 32; +const unsigned int D3D11_DS_INPUT_PATCH_CONSTANT_REGISTER_READ_PORTS = 1; +const unsigned int D3D11_DS_INPUT_PATCH_CONSTANT_REGISTER_READS_PER_INST = 2; +const unsigned int D3D11_DS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_DS_OUTPUT_REGISTER_COMPONENTS = 4; +const unsigned int D3D11_DS_OUTPUT_REGISTER_COUNT = 32; +const unsigned int D3D11_FLOAT16_FUSED_TOLERANCE_IN_ULP = 0.6; +const float D3D11_FLOAT32_MAX = 3.402823466e+38; +const float D3D11_FLOAT32_TO_INTEGER_TOLERANCE_IN_ULP = 0.6; +const float D3D11_FLOAT_TO_SRGB_EXPONENT_DENOMINATOR = 2.4; +const float D3D11_FLOAT_TO_SRGB_EXPONENT_NUMERATOR = 1.0; +const float D3D11_FLOAT_TO_SRGB_OFFSET = 0.055; +const float D3D11_FLOAT_TO_SRGB_SCALE_1 = 12.92; +const float D3D11_FLOAT_TO_SRGB_SCALE_2 = 1.055; +const float D3D11_FLOAT_TO_SRGB_THRESHOLD = 0.0031308; +const float D3D11_FTOI_INSTRUCTION_MAX_INPUT = 2147483647.999; +const float D3D11_FTOI_INSTRUCTION_MIN_INPUT = -2147483648.999; +const float D3D11_FTOU_INSTRUCTION_MAX_INPUT = 4294967295.999; +const float D3D11_FTOU_INSTRUCTION_MIN_INPUT = 0.0; +const unsigned int D3D11_GS_INPUT_INSTANCE_ID_READ_PORTS = 1; +const unsigned int D3D11_GS_INPUT_INSTANCE_ID_READS_PER_INST = 2; +const unsigned int D3D11_GS_INPUT_INSTANCE_ID_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_GS_INPUT_INSTANCE_ID_REGISTER_COMPONENTS = 1; +const unsigned int D3D11_GS_INPUT_INSTANCE_ID_REGISTER_COUNT = 1; +const unsigned int D3D11_GS_INPUT_PRIM_CONST_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_GS_INPUT_PRIM_CONST_REGISTER_COMPONENTS = 1; +const unsigned int D3D11_GS_INPUT_PRIM_CONST_REGISTER_COUNT = 1; +const unsigned int D3D11_GS_INPUT_PRIM_CONST_REGISTER_READ_PORTS = 1; +const unsigned int D3D11_GS_INPUT_PRIM_CONST_REGISTER_READS_PER_INST = 2; +const unsigned int D3D11_GS_INPUT_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_GS_INPUT_REGISTER_COMPONENTS = 4; +const unsigned int D3D11_GS_INPUT_REGISTER_COUNT = 32; +const unsigned int D3D11_GS_INPUT_REGISTER_READ_PORTS = 1; +const unsigned int D3D11_GS_INPUT_REGISTER_READS_PER_INST = 2; +const unsigned int D3D11_GS_INPUT_REGISTER_VERTICES = 32; +const unsigned int D3D11_GS_MAX_INSTANCE_COUNT = 32; +const unsigned int D3D11_GS_MAX_OUTPUT_VERTEX_COUNT_ACROSS_INSTANCES = 1024; +const unsigned int D3D11_GS_OUTPUT_ELEMENTS = 32; +const unsigned int D3D11_GS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_GS_OUTPUT_REGISTER_COMPONENTS = 4; +const unsigned int D3D11_GS_OUTPUT_REGISTER_COUNT = 32; +const unsigned int D3D11_HS_CONTROL_POINT_PHASE_INPUT_REGISTER_COUNT = 32; +const unsigned int D3D11_HS_CONTROL_POINT_PHASE_OUTPUT_REGISTER_COUNT = 32; +const unsigned int D3D11_HS_CONTROL_POINT_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_HS_CONTROL_POINT_REGISTER_COMPONENTS = 4; +const unsigned int D3D11_HS_CONTROL_POINT_REGISTER_READ_PORTS = 1; +const unsigned int D3D11_HS_CONTROL_POINT_REGISTER_READS_PER_INST = 2; +const unsigned int D3D11_HS_FORK_PHASE_INSTANCE_COUNT_UPPER_BOUND = 0xffffffff; +const unsigned int D3D11_HS_INPUT_FORK_INSTANCE_ID_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_HS_INPUT_FORK_INSTANCE_ID_REGISTER_COMPONENTS = 1; +const unsigned int D3D11_HS_INPUT_FORK_INSTANCE_ID_REGISTER_COUNT = 1; +const unsigned int D3D11_HS_INPUT_FORK_INSTANCE_ID_REGISTER_READ_PORTS = 1; +const unsigned int D3D11_HS_INPUT_FORK_INSTANCE_ID_REGISTER_READS_PER_INST = 2; +const unsigned int D3D11_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_COMPONENTS = 1; +const unsigned int D3D11_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_COUNT = 1; +const unsigned int D3D11_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_READ_PORTS = 1; +const unsigned int D3D11_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_READS_PER_INST = 2; +const unsigned int D3D11_HS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_HS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENTS = 1; +const unsigned int D3D11_HS_INPUT_PRIMITIVE_ID_REGISTER_COUNT = 1; +const unsigned int D3D11_HS_INPUT_PRIMITIVE_ID_REGISTER_READ_PORTS = 1; +const unsigned int D3D11_HS_INPUT_PRIMITIVE_ID_REGISTER_READS_PER_INST = 2; +const unsigned int D3D11_HS_JOIN_PHASE_INSTANCE_COUNT_UPPER_BOUND = 0xffffffff; +const float D3D11_HS_MAXTESSFACTOR_LOWER_BOUND = 1.0; +const float D3D11_HS_MAXTESSFACTOR_UPPER_BOUND = 64.0; +const unsigned int D3D11_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_COMPONENTS = 1; +const unsigned int D3D11_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_COUNT = 1; +const unsigned int D3D11_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_READ_PORTS = 1; +const unsigned int D3D11_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_READS_PER_INST = 2; +const unsigned int D3D11_HS_OUTPUT_CONTROL_POINTS_MAX_TOTAL_SCALARS = 3968; +const unsigned int D3D11_HS_OUTPUT_PATCH_CONSTANT_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_HS_OUTPUT_PATCH_CONSTANT_REGISTER_COMPONENTS = 4; +const unsigned int D3D11_HS_OUTPUT_PATCH_CONSTANT_REGISTER_COUNT = 32; +const unsigned int D3D11_HS_OUTPUT_PATCH_CONSTANT_REGISTER_READ_PORTS = 1; +const unsigned int D3D11_HS_OUTPUT_PATCH_CONSTANT_REGISTER_READS_PER_INST = 2; +const unsigned int D3D11_IA_DEFAULT_INDEX_BUFFER_OFFSET_IN_BYTES = 0; +const unsigned int D3D11_IA_DEFAULT_PRIMITIVE_TOPOLOGY = 0; +const unsigned int D3D11_IA_DEFAULT_VERTEX_BUFFER_OFFSET_IN_BYTES = 0; +const unsigned int D3D11_IA_INDEX_INPUT_RESOURCE_SLOT_COUNT = 1; +const unsigned int D3D11_IA_INSTANCE_ID_BIT_COUNT = 32; +const unsigned int D3D11_IA_INTEGER_ARITHMETIC_BIT_COUNT = 32; +const unsigned int D3D11_IA_PATCH_MAX_CONTROL_POINT_COUNT = 32; +const unsigned int D3D11_IA_PRIMITIVE_ID_BIT_COUNT = 32; +const unsigned int D3D11_IA_VERTEX_ID_BIT_COUNT = 32; +const unsigned int D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT = 32; +const unsigned int D3D11_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT = 32; +const unsigned int D3D11_IA_VERTEX_INPUT_STRUCTURE_ELEMENTS_COMPONENTS = 128; +const unsigned int D3D11_INTEGER_DIVIDE_BY_ZERO_QUOTIENT = 0xffffffff; +const unsigned int D3D11_INTEGER_DIVIDE_BY_ZERO_REMAINDER = 0xffffffff; +const unsigned int D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL = 0xffffffff; +const unsigned int D3D11_KEEP_UNORDERED_ACCESS_VIEWS = 0xffffffff; +const float D3D11_LINEAR_GAMMA = 1.0; +const unsigned int D3D11_MAJOR_VERSION = 11; +const float D3D11_MAX_BORDER_COLOR_COMPONENT = 1.0; +const float D3D11_MAX_DEPTH = 1.0; +const unsigned int D3D11_MAX_MAXANISOTROPY = 16; +const unsigned int D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT = 32; +const float D3D11_MAX_POSITION_VALUE = 3.402823466e+34; +const unsigned int D3D11_MAX_TEXTURE_DIMENSION_2_TO_EXP = 17; +const float D3D11_MIN_BORDER_COLOR_COMPONENT = 0.0; +const float D3D11_MIN_DEPTH = 0.0; +const unsigned int D3D11_MIN_MAXANISOTROPY = 0; +const unsigned int D3D11_MINOR_VERSION = 0; +const float D3D11_MIP_LOD_BIAS_MAX = 15.99; +const float D3D11_MIP_LOD_BIAS_MIN = -16.0; +const unsigned int D3D11_MIP_LOD_FRACTIONAL_BIT_COUNT = 8; +const unsigned int D3D11_MIP_LOD_RANGE_BIT_COUNT = 8; +const float D3D11_MULTISAMPLE_ANTIALIAS_LINE_WIDTH = 1.4; +const unsigned int D3D11_NONSAMPLE_FETCH_OUT_OF_RANGE_ACCESS_RESULT = 0; +const unsigned int D3D11_PIXEL_ADDRESS_RANGE_BIT_COUNT = 15; +const unsigned int D3D11_PRE_SCISSOR_PIXEL_ADDRESS_RANGE_BIT_COUNT = 16; +const unsigned int D3D11_PS_CS_UAV_REGISTER_COMPONENTS = 1; +const unsigned int D3D11_PS_CS_UAV_REGISTER_COUNT = 8; +const unsigned int D3D11_PS_CS_UAV_REGISTER_READ_PORTS = 1; +const unsigned int D3D11_PS_CS_UAV_REGISTER_READS_PER_INST = 1; +const unsigned int D3D11_PS_FRONTFACING_DEFAULT_VALUE = 0xffffffff; +const unsigned int D3D11_PS_FRONTFACING_FALSE_VALUE = 0; +const unsigned int D3D11_PS_FRONTFACING_TRUE_VALUE = 0xffffffff; +const unsigned int D3D11_PS_INPUT_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_PS_INPUT_REGISTER_COMPONENTS = 4; +const unsigned int D3D11_PS_INPUT_REGISTER_COUNT = 32; +const unsigned int D3D11_PS_INPUT_REGISTER_READ_PORTS = 1; +const unsigned int D3D11_PS_INPUT_REGISTER_READS_PER_INST = 2; +const float D3D11_PS_LEGACY_PIXEL_CENTER_FRACTIONAL_COMPONENT = 0.0; +const unsigned int D3D11_PS_OUTPUT_DEPTH_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_PS_OUTPUT_DEPTH_REGISTER_COMPONENTS = 1; +const unsigned int D3D11_PS_OUTPUT_DEPTH_REGISTER_COUNT = 1; +const unsigned int D3D11_PS_OUTPUT_MASK_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_PS_OUTPUT_MASK_REGISTER_COMPONENTS = 1; +const unsigned int D3D11_PS_OUTPUT_MASK_REGISTER_COUNT = 1; +const unsigned int D3D11_PS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_PS_OUTPUT_REGISTER_COMPONENTS = 4; +const unsigned int D3D11_PS_OUTPUT_REGISTER_COUNT = 8; +const float D3D11_PS_PIXEL_CENTER_FRACTIONAL_COMPONENT = 0.5; +const unsigned int D3D11_RAW_UAV_SRV_BYTE_ALIGNMENT = 16; +const unsigned int D3D11_REQ_BLEND_OBJECT_COUNT_PER_DEVICE = 4096; +const unsigned int D3D11_REQ_BUFFER_RESOURCE_TEXEL_COUNT_2_TO_EXP = 27; +const unsigned int D3D11_REQ_CONSTANT_BUFFER_ELEMENT_COUNT = 4096; +const unsigned int D3D11_REQ_DEPTH_STENCIL_OBJECT_COUNT_PER_DEVICE = 4096; +const unsigned int D3D11_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP = 32; +const unsigned int D3D11_REQ_DRAW_VERTEX_COUNT_2_TO_EXP = 32; +const unsigned int D3D11_REQ_FILTERING_HW_ADDRESSABLE_RESOURCE_DIMENSION = 16384; +const unsigned int D3D11_REQ_GS_INVOCATION_32BIT_OUTPUT_COMPONENT_LIMIT = 1024; +const unsigned int D3D11_REQ_IMMEDIATE_CONSTANT_BUFFER_ELEMENT_COUNT = 4096; +const unsigned int D3D11_REQ_MAXANISOTROPY = 16; +const unsigned int D3D11_REQ_MIP_LEVELS = 15; +const unsigned int D3D11_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES = 2048; +const unsigned int D3D11_REQ_RASTERIZER_OBJECT_COUNT_PER_DEVICE = 4096; +const unsigned int D3D11_REQ_RENDER_TO_BUFFER_WINDOW_WIDTH = 16384; +const unsigned int D3D11_REQ_RESOURCE_SIZE_IN_MEGABYTES_EXPRESSION_A_TERM = 128; +const float D3D11_REQ_RESOURCE_SIZE_IN_MEGABYTES_EXPRESSION_B_TERM = 0.25; +const unsigned int D3D11_REQ_RESOURCE_VIEW_COUNT_PER_DEVICE_2_TO_EXP = 20; +const unsigned int D3D11_REQ_SAMPLER_OBJECT_COUNT_PER_DEVICE = 4096; +const unsigned int D3D11_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION = 2048; +const unsigned int D3D11_REQ_TEXTURE1D_U_DIMENSION = 16384; +const unsigned int D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION = 2048; +const unsigned int D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION = 16384; +const unsigned int D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION = 2048; +const unsigned int D3D11_REQ_TEXTURECUBE_DIMENSION = 16384; +const unsigned int D3D11_RESINFO_INSTRUCTION_MISSING_COMPONENT_RETVAL = 0; +const unsigned int D3D11_SHADER_MAJOR_VERSION = 5; +const unsigned int D3D11_SHADER_MAX_INSTANCES = 65535; +const unsigned int D3D11_SHADER_MAX_INTERFACE_CALL_SITES = 4096; +const unsigned int D3D11_SHADER_MAX_INTERFACES = 253; +const unsigned int D3D11_SHADER_MAX_TYPES = 65535; +const unsigned int D3D11_SHADER_MINOR_VERSION = 0; +const unsigned int D3D11_SHIFT_INSTRUCTION_PAD_VALUE = 0; +const unsigned int D3D11_SHIFT_INSTRUCTION_SHIFT_VALUE_BIT_COUNT = 5; +const unsigned int D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT = 8; +const unsigned int D3D11_SO_BUFFER_MAX_STRIDE_IN_BYTES = 2048; +const unsigned int D3D11_SO_BUFFER_MAX_WRITE_WINDOW_IN_BYTES = 512; +const unsigned int D3D11_SO_BUFFER_SLOT_COUNT = 4; +const unsigned int D3D11_SO_DDI_REGISTER_INDEX_DENOTING_GAP = 0xffffffff; +const unsigned int D3D11_SO_NO_RASTERIZED_STREAM = 0xffffffff; +const unsigned int D3D11_SO_OUTPUT_COMPONENT_COUNT = 128; +const unsigned int D3D11_SO_STREAM_COUNT = 4; +const unsigned int D3D11_SPEC_DATE_DAY = 04; +const unsigned int D3D11_SPEC_DATE_MONTH = 06; +const unsigned int D3D11_SPEC_DATE_YEAR = 2009; +const unsigned int D3D11_SPEC_VERSION = 1.0; +const float D3D11_SRGB_GAMMA = 2.2; +const float D3D11_SRGB_TO_FLOAT_DENOMINATOR_1 = 12.92; +const float D3D11_SRGB_TO_FLOAT_DENOMINATOR_2 = 1.055; +const float D3D11_SRGB_TO_FLOAT_EXPONENT = 2.4; +const float D3D11_SRGB_TO_FLOAT_OFFSET = 0.055; +const float D3D11_SRGB_TO_FLOAT_THRESHOLD = 0.04045; +const float D3D11_SRGB_TO_FLOAT_TOLERANCE_IN_ULP = 0.5; +const unsigned int D3D11_STANDARD_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_STANDARD_COMPONENT_BIT_COUNT_DOUBLED = 64; +const unsigned int D3D11_STANDARD_MAXIMUM_ELEMENT_ALIGNMENT_BYTE_MULTIPLE = 4; +const unsigned int D3D11_STANDARD_PIXEL_COMPONENT_COUNT = 128; +const unsigned int D3D11_STANDARD_PIXEL_ELEMENT_COUNT = 32; +const unsigned int D3D11_STANDARD_VECTOR_SIZE = 4; +const unsigned int D3D11_STANDARD_VERTEX_ELEMENT_COUNT = 32; +const unsigned int D3D11_STANDARD_VERTEX_TOTAL_COMPONENT_COUNT = 64; +const unsigned int D3D11_SUBPIXEL_FRACTIONAL_BIT_COUNT = 8; +const unsigned int D3D11_SUBTEXEL_FRACTIONAL_BIT_COUNT = 8; +const unsigned int D3D11_TESSELLATOR_MAX_EVEN_TESSELLATION_FACTOR = 64; +const unsigned int D3D11_TESSELLATOR_MAX_ISOLINE_DENSITY_TESSELLATION_FACTOR = 64; +const unsigned int D3D11_TESSELLATOR_MAX_ODD_TESSELLATION_FACTOR = 63; +const unsigned int D3D11_TESSELLATOR_MAX_TESSELLATION_FACTOR = 64; +const unsigned int D3D11_TESSELLATOR_MIN_EVEN_TESSELLATION_FACTOR = 2; +const unsigned int D3D11_TESSELLATOR_MIN_ISOLINE_DENSITY_TESSELLATION_FACTOR = 1; +const unsigned int D3D11_TESSELLATOR_MIN_ODD_TESSELLATION_FACTOR = 1; +const unsigned int D3D11_TEXEL_ADDRESS_RANGE_BIT_COUNT = 16; +const unsigned int D3D11_UNBOUND_MEMORY_ACCESS_RESULT = 0; +const unsigned int D3D11_VIEWPORT_AND_SCISSORRECT_MAX_INDEX = 15; +const unsigned int D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE = 16; +const unsigned int D3D11_VIEWPORT_BOUNDS_MAX = 32767; +const int D3D11_VIEWPORT_BOUNDS_MIN = -32768; +const unsigned int D3D11_VS_INPUT_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_VS_INPUT_REGISTER_COMPONENTS = 4; +const unsigned int D3D11_VS_INPUT_REGISTER_COUNT = 32; +const unsigned int D3D11_VS_INPUT_REGISTER_READ_PORTS = 1; +const unsigned int D3D11_VS_INPUT_REGISTER_READS_PER_INST = 2; +const unsigned int D3D11_VS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT = 32; +const unsigned int D3D11_VS_OUTPUT_REGISTER_COMPONENTS = 4; +const unsigned int D3D11_VS_OUTPUT_REGISTER_COUNT = 32; +const unsigned int D3D11_WHQL_CONTEXT_COUNT_FOR_RESOURCE_LIMIT = 10; +const unsigned int D3D11_WHQL_DRAWINDEXED_INDEX_COUNT_2_TO_EXP = 25; +const unsigned int D3D11_WHQL_DRAW_VERTEX_COUNT_2_TO_EXP = 25; +cpp_quote("#endif") + +const unsigned int _FACD3D11 = 0x87C; +const unsigned int _FACD3D11DEBUG = _FACD3D11 + 1; + +cpp_quote("#define MAKE_D3D11_HRESULT(c) MAKE_HRESULT(1, _FACD3D11, (c))") +cpp_quote("#define MAKE_D3D11_STATUS(c) MAKE_HRESULT(0, _FACD3D11, (c))") +cpp_quote("#define D3D11_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS MAKE_D3D11_HRESULT(1)") +cpp_quote("#define D3D11_ERROR_FILE_NOT_FOUND MAKE_D3D11_HRESULT(2)") +cpp_quote("#define D3D11_ERROR_TOO_MANY_UNIQUE_VIEW_OBJECTS MAKE_D3D11_HRESULT(3)") +cpp_quote("#define D3D11_ERROR_DEFERRED_CONTEXT_MAP_WITHOUT_INITIAL_DISCARD MAKE_D3D11_HRESULT(4)") + +typedef enum D3D11_INPUT_CLASSIFICATION +{ + D3D11_INPUT_PER_VERTEX_DATA, + D3D11_INPUT_PER_INSTANCE_DATA +} D3D11_INPUT_CLASSIFICATION; + +const unsigned int D3D11_APPEND_ALIGNED_ELEMENT = 0xffffffff; + +typedef struct D3D11_INPUT_ELEMENT_DESC +{ + LPCSTR SemanticName; + UINT SemanticIndex; + DXGI_FORMAT Format; + UINT InputSlot; + UINT AlignedByteOffset; + D3D11_INPUT_CLASSIFICATION InputSlotClass; + UINT InstanceDataStepRate; +} D3D11_INPUT_ELEMENT_DESC; + +typedef enum D3D11_FILL_MODE +{ + D3D11_FILL_WIREFRAME = 2, + D3D11_FILL_SOLID = 3 +} D3D11_FILL_MODE; + +typedef D3D_PRIMITIVE_TOPOLOGY D3D11_PRIMITIVE_TOPOLOGY; + +typedef D3D_PRIMITIVE D3D11_PRIMITIVE; + +typedef enum D3D11_CULL_MODE +{ + D3D11_CULL_NONE = 1, + D3D11_CULL_FRONT = 2, + D3D11_CULL_BACK = 3 +} D3D11_CULL_MODE; + +typedef struct D3D11_SO_DECLARATION_ENTRY +{ + UINT Stream; + LPCSTR SemanticName; + UINT SemanticIndex; + BYTE StartComponent; + BYTE ComponentCount; + BYTE OutputSlot; +} D3D11_SO_DECLARATION_ENTRY; + +typedef struct D3D11_VIEWPORT +{ + FLOAT TopLeftX; + FLOAT TopLeftY; + FLOAT Width; + FLOAT Height; + FLOAT MinDepth; + FLOAT MaxDepth; +} D3D11_VIEWPORT; + +typedef enum D3D11_RESOURCE_DIMENSION +{ + D3D11_RESOURCE_DIMENSION_UNKNOWN, + D3D11_RESOURCE_DIMENSION_BUFFER, + D3D11_RESOURCE_DIMENSION_TEXTURE1D, + D3D11_RESOURCE_DIMENSION_TEXTURE2D, + D3D11_RESOURCE_DIMENSION_TEXTURE3D, +} D3D11_RESOURCE_DIMENSION; + +typedef D3D_SRV_DIMENSION D3D11_SRV_DIMENSION; + +typedef enum D3D11_DSV_DIMENSION +{ + D3D11_DSV_DIMENSION_UNKNOWN, + D3D11_DSV_DIMENSION_TEXTURE1D, + D3D11_DSV_DIMENSION_TEXTURE1DARRAY, + D3D11_DSV_DIMENSION_TEXTURE2D, + D3D11_DSV_DIMENSION_TEXTURE2DARRAY, + D3D11_DSV_DIMENSION_TEXTURE2DMS, + D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY, +} D3D11_DSV_DIMENSION; + + +typedef enum D3D11_RTV_DIMENSION +{ + D3D11_RTV_DIMENSION_UNKNOWN, + D3D11_RTV_DIMENSION_BUFFER, + D3D11_RTV_DIMENSION_TEXTURE1D, + D3D11_RTV_DIMENSION_TEXTURE1DARRAY, + D3D11_RTV_DIMENSION_TEXTURE2D, + D3D11_RTV_DIMENSION_TEXTURE2DARRAY, + D3D11_RTV_DIMENSION_TEXTURE2DMS, + D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY, + D3D11_RTV_DIMENSION_TEXTURE3D +} D3D11_RTV_DIMENSION; + +typedef enum D3D11_UAV_DIMENSION +{ + D3D11_UAV_DIMENSION_UNKNOWN, + D3D11_UAV_DIMENSION_BUFFER, + D3D11_UAV_DIMENSION_TEXTURE1D, + D3D11_UAV_DIMENSION_TEXTURE1DARRAY, + D3D11_UAV_DIMENSION_TEXTURE2D, + D3D11_UAV_DIMENSION_TEXTURE2DARRAY, + D3D11_UAV_DIMENSION_TEXTURE3D = 8 +} D3D11_UAV_DIMENSION; + +typedef enum D3D11_USAGE +{ + D3D11_USAGE_DEFAULT, + D3D11_USAGE_IMMUTABLE, + D3D11_USAGE_DYNAMIC, + D3D11_USAGE_STAGING +} D3D11_USAGE; + +typedef enum D3D11_BIND_FLAG +{ + D3D11_BIND_VERTEX_BUFFER = 1, + D3D11_BIND_INDEX_BUFFER = 2, + D3D11_BIND_CONSTANT_BUFFER = 4, + D3D11_BIND_SHADER_RESOURCE = 8, + D3D11_BIND_STREAM_OUTPUT = 0x10, + D3D11_BIND_RENDER_TARGET = 0x20, + D3D11_BIND_DEPTH_STENCIL = 0x40, + D3D11_BIND_UNORDERED_ACCESS = 0x80 +} D3D11_BIND_FLAG; + +typedef enum D3D11_CPU_ACCESS_FLAG +{ + D3D11_CPU_ACCESS_WRITE = 0x10000, + D3D11_CPU_ACCESS_READ = 0x20000 +} D3D11_CPU_ACCESS_FLAG; + +typedef enum D3D11_RESOURCE_MISC_FLAG +{ + D3D11_RESOURCE_MISC_GENERATE_MIPS = 1, + D3D11_RESOURCE_MISC_SHARED = 2, + D3D11_RESOURCE_MISC_TEXTURECUBE = 4, + D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS = 0x10, + D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS = 0x20, + D3D11_RESOURCE_MISC_BUFFER_STRUCTURED = 0x40, + D3D11_RESOURCE_MISC_RESOURCE_CLAMP = 0x80, + D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX = 0x100, + D3D11_RESOURCE_MISC_GDI_COMPATIBLE = 0x200 +} D3D11_RESOURCE_MISC_FLAG; + +typedef enum D3D11_MAP +{ + D3D11_MAP_READ = 1, + D3D11_MAP_WRITE, + D3D11_MAP_READ_WRITE, + D3D11_MAP_WRITE_DISCARD, + D3D11_MAP_WRITE_NO_OVERWRITE +} D3D11_MAP; + +typedef enum D3D11_MAP_FLAG +{ + D3D11_MAP_FLAG_DO_NOT_WAIT = 0x100000 +} D3D11_MAP_FLAG; + +typedef enum D3D11_RAISE_FLAG +{ + D3D11_RAISE_FLAG_DRIVER_INTERNAL_ERROR = 1 +} D3D11_RAISE_FLAG; + +typedef +enum D3D11_CLEAR_FLAG +{ + D3D11_CLEAR_DEPTH = 1, + D3D11_CLEAR_STENCIL = 2 +} D3D11_CLEAR_FLAG; + +typedef RECT D3D11_RECT; + +typedef struct D3D11_BOX +{ + UINT left; + UINT top; + UINT front; + UINT right; + UINT bottom; + UINT back; +} D3D11_BOX; + +typedef enum D3D11_COMPARISON_FUNC +{ + D3D11_COMPARISON_NEVER = 1, + D3D11_COMPARISON_LESS, + D3D11_COMPARISON_EQUAL, + D3D11_COMPARISON_LESS_EQUAL, + D3D11_COMPARISON_GREATER, + D3D11_COMPARISON_NOT_EQUAL, + D3D11_COMPARISON_GREATER_EQUAL, + D3D11_COMPARISON_ALWAYS +} D3D11_COMPARISON_FUNC; + +typedef enum D3D11_DEPTH_WRITE_MASK +{ + D3D11_DEPTH_WRITE_MASK_ZERO, + D3D11_DEPTH_WRITE_MASK_ALL +} D3D11_DEPTH_WRITE_MASK; + +typedef enum D3D11_STENCIL_OP +{ + D3D11_STENCIL_OP_KEEP = 1, + D3D11_STENCIL_OP_ZERO, + D3D11_STENCIL_OP_REPLACE, + D3D11_STENCIL_OP_INCR_SAT, + D3D11_STENCIL_OP_DECR_SAT, + D3D11_STENCIL_OP_INVERT, + D3D11_STENCIL_OP_INCR, + D3D11_STENCIL_OP_DECR +} D3D11_STENCIL_OP; + +typedef struct D3D11_DEPTH_STENCILOP_DESC +{ + D3D11_STENCIL_OP StencilFailOp; + D3D11_STENCIL_OP StencilDepthFailOp; + D3D11_STENCIL_OP StencilPassOp; + D3D11_COMPARISON_FUNC StencilFunc; +} D3D11_DEPTH_STENCILOP_DESC; + +typedef struct D3D11_DEPTH_STENCIL_DESC +{ + BOOL DepthEnable; + D3D11_DEPTH_WRITE_MASK DepthWriteMask; + D3D11_COMPARISON_FUNC DepthFunc; + BOOL StencilEnable; + UINT8 StencilReadMask; + UINT8 StencilWriteMask; + D3D11_DEPTH_STENCILOP_DESC FrontFace; + D3D11_DEPTH_STENCILOP_DESC BackFace; +} D3D11_DEPTH_STENCIL_DESC; + + +typedef enum D3D11_BLEND +{ + D3D11_BLEND_ZERO = 1, + D3D11_BLEND_ONE, + D3D11_BLEND_SRC_COLOR, + D3D11_BLEND_INV_SRC_COLOR, + D3D11_BLEND_SRC_ALPHA, + D3D11_BLEND_INV_SRC_ALPHA, + D3D11_BLEND_DEST_ALPHA, + D3D11_BLEND_INV_DEST_ALPHA, + D3D11_BLEND_DEST_COLOR, + D3D11_BLEND_INV_DEST_COLOR , + D3D11_BLEND_SRC_ALPHA_SAT, + + D3D11_BLEND_BLEND_FACTOR = 14, + D3D11_BLEND_INV_BLEND_FACTOR, + D3D11_BLEND_SRC1_COLOR, + D3D11_BLEND_INV_SRC1_COLOR , + D3D11_BLEND_SRC1_ALPHA, + D3D11_BLEND_INV_SRC1_ALPHA +} D3D11_BLEND; + +typedef enum D3D11_BLEND_OP +{ + D3D11_BLEND_OP_ADD = 1, + D3D11_BLEND_OP_SUBTRACT, + D3D11_BLEND_OP_REV_SUBTRACT, + D3D11_BLEND_OP_MIN, + D3D11_BLEND_OP_MAX +} D3D11_BLEND_OP; + +typedef enum D3D11_COLOR_WRITE_ENABLE +{ + D3D11_COLOR_WRITE_ENABLE_RED = 1, + D3D11_COLOR_WRITE_ENABLE_GREEN = 2, + D3D11_COLOR_WRITE_ENABLE_BLUE = 4, + D3D11_COLOR_WRITE_ENABLE_ALPHA = 8, + D3D11_COLOR_WRITE_ENABLE_ALL = 0xf +} D3D11_COLOR_WRITE_ENABLE; + +typedef struct D3D11_RENDER_TARGET_BLEND_DESC +{ + BOOL BlendEnable; + D3D11_BLEND SrcBlend; + D3D11_BLEND DestBlend; + D3D11_BLEND_OP BlendOp; + D3D11_BLEND SrcBlendAlpha; + D3D11_BLEND DestBlendAlpha; + D3D11_BLEND_OP BlendOpAlpha; + UINT8 RenderTargetWriteMask; +} D3D11_RENDER_TARGET_BLEND_DESC; + +typedef struct D3D11_BLEND_DESC +{ + BOOL AlphaToCoverageEnable; + BOOL IndependentBlendEnable; + D3D11_RENDER_TARGET_BLEND_DESC RenderTarget[8]; +} D3D11_BLEND_DESC; + +typedef struct D3D11_RASTERIZER_DESC +{ + D3D11_FILL_MODE FillMode; + D3D11_CULL_MODE CullMode; + BOOL FrontCounterClockwise; + INT DepthBias; + FLOAT DepthBiasClamp; + FLOAT SlopeScaledDepthBias; + BOOL DepthClipEnable; + BOOL ScissorEnable; + BOOL MultisampleEnable; + BOOL AntialiasedLineEnable; +} D3D11_RASTERIZER_DESC; + +typedef struct D3D11_SUBRESOURCE_DATA +{ + const void *pSysMem; + UINT SysMemPitch; + UINT SysMemSlicePitch; +} D3D11_SUBRESOURCE_DATA; + +typedef struct D3D11_MAPPED_SUBRESOURCE +{ + void *pData; + UINT RowPitch; + UINT DepthPitch; +} D3D11_MAPPED_SUBRESOURCE; + +typedef struct D3D11_BUFFER_DESC +{ + UINT ByteWidth; + D3D11_USAGE Usage; + UINT BindFlags; + UINT CPUAccessFlags; + UINT MiscFlags; + UINT StructureByteStride; +} D3D11_BUFFER_DESC; + +typedef struct D3D11_TEXTURE1D_DESC +{ + UINT Width; + UINT MipLevels; + UINT ArraySize; + DXGI_FORMAT Format; + D3D11_USAGE Usage; + UINT BindFlags; + UINT CPUAccessFlags; + UINT MiscFlags; +} D3D11_TEXTURE1D_DESC; + +typedef struct D3D11_TEXTURE2D_DESC +{ + UINT Width; + UINT Height; + UINT MipLevels; + UINT ArraySize; + DXGI_FORMAT Format; + DXGI_SAMPLE_DESC SampleDesc; + D3D11_USAGE Usage; + UINT BindFlags; + UINT CPUAccessFlags; + UINT MiscFlags; +} D3D11_TEXTURE2D_DESC; + +typedef struct D3D11_TEXTURE3D_DESC +{ + UINT Width; + UINT Height; + UINT Depth; + UINT MipLevels; + DXGI_FORMAT Format; + D3D11_USAGE Usage; + UINT BindFlags; + UINT CPUAccessFlags; + UINT MiscFlags; +} D3D11_TEXTURE3D_DESC; + +typedef enum D3D11_TEXTURECUBE_FACE +{ + D3D11_TEXTURECUBE_FACE_POSITIVE_X, + D3D11_TEXTURECUBE_FACE_NEGATIVE_X, + D3D11_TEXTURECUBE_FACE_POSITIVE_Y, + D3D11_TEXTURECUBE_FACE_NEGATIVE_Y, + D3D11_TEXTURECUBE_FACE_POSITIVE_Z, + D3D11_TEXTURECUBE_FACE_NEGATIVE_Z +} D3D11_TEXTURECUBE_FACE; + +typedef struct D3D11_BUFFER_SRV +{ + union + { + UINT FirstElement; + UINT ElementOffset; + }; + union + { + UINT NumElements; + UINT ElementWidth; + }; +} D3D11_BUFFER_SRV; + +typedef enum D3D11_BUFFEREX_SRV_FLAG +{ + D3D11_BUFFEREX_SRV_FLAG_RAW = 1 +} D3D11_BUFFEREX_SRV_FLAG; + +typedef struct D3D11_BUFFEREX_SRV +{ + UINT FirstElement; + UINT NumElements; + UINT Flags; +} D3D11_BUFFEREX_SRV; + +typedef struct D3D11_TEX1D_SRV +{ + UINT MostDetailedMip; + UINT MipLevels; +} D3D11_TEX1D_SRV; + +typedef struct D3D11_TEX1D_ARRAY_SRV +{ + UINT MostDetailedMip; + UINT MipLevels; + UINT FirstArraySlice; + UINT ArraySize; +} D3D11_TEX1D_ARRAY_SRV; + +typedef struct D3D11_TEX2D_SRV +{ + UINT MostDetailedMip; + UINT MipLevels; +} D3D11_TEX2D_SRV; + +typedef struct D3D11_TEX2D_ARRAY_SRV +{ + UINT MostDetailedMip; + UINT MipLevels; + UINT FirstArraySlice; + UINT ArraySize; +} D3D11_TEX2D_ARRAY_SRV; + +typedef struct D3D11_TEX3D_SRV +{ + UINT MostDetailedMip; + UINT MipLevels; +} D3D11_TEX3D_SRV; + +typedef struct D3D11_TEXCUBE_SRV +{ + UINT MostDetailedMip; + UINT MipLevels; +} D3D11_TEXCUBE_SRV; + +typedef struct D3D11_TEXCUBE_ARRAY_SRV +{ + UINT MostDetailedMip; + UINT MipLevels; + UINT First2DArrayFace; + UINT NumCubes; +} D3D11_TEXCUBE_ARRAY_SRV; + +typedef struct D3D11_TEX2DMS_SRV +{ + UINT UnusedField_NothingToDefine; +} D3D11_TEX2DMS_SRV; + +typedef struct D3D11_TEX2DMS_ARRAY_SRV +{ + UINT FirstArraySlice; + UINT ArraySize; +} D3D11_TEX2DMS_ARRAY_SRV; + +typedef struct D3D11_SHADER_RESOURCE_VIEW_DESC +{ + DXGI_FORMAT Format; + D3D11_SRV_DIMENSION ViewDimension; + union + { + D3D11_BUFFER_SRV Buffer; + D3D11_TEX1D_SRV Texture1D; + D3D11_TEX1D_ARRAY_SRV Texture1DArray; + D3D11_TEX2D_SRV Texture2D; + D3D11_TEX2D_ARRAY_SRV Texture2DArray; + D3D11_TEX2DMS_SRV Texture2DMS; + D3D11_TEX2DMS_ARRAY_SRV Texture2DMSArray; + D3D11_TEX3D_SRV Texture3D; + D3D11_TEXCUBE_SRV TextureCube; + D3D11_TEXCUBE_ARRAY_SRV TextureCubeArray; + D3D11_BUFFEREX_SRV BufferEx; + }; +} D3D11_SHADER_RESOURCE_VIEW_DESC; + + +typedef struct D3D11_BUFFER_RTV +{ + union + { + UINT FirstElement; + UINT ElementOffset; + }; + union + { + UINT NumElements; + UINT ElementWidth; + }; +} D3D11_BUFFER_RTV; + +typedef struct D3D11_TEX1D_RTV +{ + UINT MipSlice; +} D3D11_TEX1D_RTV; + +typedef struct D3D11_TEX1D_ARRAY_RTV +{ + UINT MipSlice; + UINT FirstArraySlice; + UINT ArraySize; +} D3D11_TEX1D_ARRAY_RTV; + +typedef struct D3D11_TEX2D_RTV +{ + UINT MipSlice; +} D3D11_TEX2D_RTV; + +typedef struct D3D11_TEX2DMS_RTV +{ + UINT UnusedField_NothingToDefine; +} D3D11_TEX2DMS_RTV; + +typedef struct D3D11_TEX2D_ARRAY_RTV +{ + UINT MipSlice; + UINT FirstArraySlice; + UINT ArraySize; +} D3D11_TEX2D_ARRAY_RTV; + +typedef struct D3D11_TEX2DMS_ARRAY_RTV +{ + UINT FirstArraySlice; + UINT ArraySize; +} D3D11_TEX2DMS_ARRAY_RTV; + +typedef struct D3D11_TEX3D_RTV +{ + UINT MipSlice; + UINT FirstWSlice; + UINT WSize; +} D3D11_TEX3D_RTV; + +typedef struct D3D11_RENDER_TARGET_VIEW_DESC +{ + DXGI_FORMAT Format; + D3D11_RTV_DIMENSION ViewDimension; + union + { + D3D11_BUFFER_RTV Buffer; + D3D11_TEX1D_RTV Texture1D; + D3D11_TEX1D_ARRAY_RTV Texture1DArray; + D3D11_TEX2D_RTV Texture2D; + D3D11_TEX2D_ARRAY_RTV Texture2DArray; + D3D11_TEX2DMS_RTV Texture2DMS; + D3D11_TEX2DMS_ARRAY_RTV Texture2DMSArray; + D3D11_TEX3D_RTV Texture3D; + }; +} D3D11_RENDER_TARGET_VIEW_DESC; + +typedef struct D3D11_TEX1D_DSV +{ + UINT MipSlice; +} D3D11_TEX1D_DSV; + +typedef struct D3D11_TEX1D_ARRAY_DSV +{ + UINT MipSlice; + UINT FirstArraySlice; + UINT ArraySize; +} D3D11_TEX1D_ARRAY_DSV; + +typedef struct D3D11_TEX2D_DSV +{ + UINT MipSlice; +} D3D11_TEX2D_DSV; + +typedef struct D3D11_TEX2D_ARRAY_DSV +{ + UINT MipSlice; + UINT FirstArraySlice; + UINT ArraySize; +} D3D11_TEX2D_ARRAY_DSV; + +typedef struct D3D11_TEX2DMS_DSV +{ + UINT UnusedField_NothingToDefine; +} D3D11_TEX2DMS_DSV; + +typedef struct D3D11_TEX2DMS_ARRAY_DSV +{ + UINT FirstArraySlice; + UINT ArraySize; +} D3D11_TEX2DMS_ARRAY_DSV; + +typedef enum D3D11_DSV_FLAG +{ + D3D11_DSV_READ_ONLY_DEPTH = 1L, + D3D11_DSV_READ_ONLY_STENCIL = 2L +} D3D11_DSV_FLAG; + +typedef struct D3D11_DEPTH_STENCIL_VIEW_DESC +{ + DXGI_FORMAT Format; + D3D11_DSV_DIMENSION ViewDimension; + UINT Flags; + union + { + D3D11_TEX1D_DSV Texture1D; + D3D11_TEX1D_ARRAY_DSV Texture1DArray; + D3D11_TEX2D_DSV Texture2D; + D3D11_TEX2D_ARRAY_DSV Texture2DArray; + D3D11_TEX2DMS_DSV Texture2DMS; + D3D11_TEX2DMS_ARRAY_DSV Texture2DMSArray; + }; +} D3D11_DEPTH_STENCIL_VIEW_DESC; + +typedef enum D3D11_BUFFER_UAV_FLAG +{ + D3D11_BUFFER_UAV_FLAG_RAW = 1, + D3D11_BUFFER_UAV_FLAG_APPEND = 2, + D3D11_BUFFER_UAV_FLAG_COUNTER = 4 +} D3D11_BUFFER_UAV_FLAG; + +typedef struct D3D11_BUFFER_UAV +{ + UINT FirstElement; + UINT NumElements; + UINT Flags; +} D3D11_BUFFER_UAV; + +typedef struct D3D11_TEX1D_UAV +{ + UINT MipSlice; +} D3D11_TEX1D_UAV; + +typedef struct D3D11_TEX1D_ARRAY_UAV +{ + UINT MipSlice; + UINT FirstArraySlice; + UINT ArraySize; +} D3D11_TEX1D_ARRAY_UAV; + +typedef struct D3D11_TEX2D_UAV +{ + UINT MipSlice; +} D3D11_TEX2D_UAV; + +typedef struct D3D11_TEX2D_ARRAY_UAV +{ + UINT MipSlice; + UINT FirstArraySlice; + UINT ArraySize; +} D3D11_TEX2D_ARRAY_UAV; + +typedef struct D3D11_TEX3D_UAV +{ + UINT MipSlice; + UINT FirstWSlice; + UINT WSize; +} D3D11_TEX3D_UAV; + +typedef struct D3D11_UNORDERED_ACCESS_VIEW_DESC +{ + DXGI_FORMAT Format; + D3D11_UAV_DIMENSION ViewDimension; + union + { + D3D11_BUFFER_UAV Buffer; + D3D11_TEX1D_UAV Texture1D; + D3D11_TEX1D_ARRAY_UAV Texture1DArray; + D3D11_TEX2D_UAV Texture2D; + D3D11_TEX2D_ARRAY_UAV Texture2DArray; + D3D11_TEX3D_UAV Texture3D; + }; +} D3D11_UNORDERED_ACCESS_VIEW_DESC; + +typedef enum D3D11_FILTER +{ + D3D11_FILTER_MIN_MAG_MIP_POINT = 0, + D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR = 1, + D3D11_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT = 4, + D3D11_FILTER_MIN_POINT_MAG_MIP_LINEAR = 5, + D3D11_FILTER_MIN_LINEAR_MAG_MIP_POINT = 0x10, + D3D11_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x11, + D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT = 0x14, + D3D11_FILTER_MIN_MAG_MIP_LINEAR = 0x15, + D3D11_FILTER_ANISOTROPIC = 0x55, + D3D11_FILTER_COMPARISON_MIN_MAG_MIP_POINT = 0x80, + D3D11_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR = 0x81, + D3D11_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x84, + D3D11_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR = 0x85, + D3D11_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT = 0x90, + D3D11_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x91, + D3D11_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT = 0x94, + D3D11_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR = 0x95, + D3D11_FILTER_COMPARISON_ANISOTROPIC = 0xd5 +} D3D11_FILTER; + +typedef enum D3D11_FILTER_TYPE +{ + D3D11_FILTER_TYPE_POINT, + D3D11_FILTER_TYPE_LINEAR +} D3D11_FILTER_TYPE; + +const unsigned int D3D11_FILTER_TYPE_MASK = 3; +const unsigned int D3D11_MIN_FILTER_SHIFT = 4; +const unsigned int D3D11_MAG_FILTER_SHIFT = 2; +const unsigned int D3D11_MIP_FILTER_SHIFT = 0; +const unsigned int D3D11_COMPARISON_FILTERING_BIT = 0x80; +const unsigned int D3D11_ANISOTROPIC_FILTERING_BIT = 0x40; + +cpp_quote("#define D3D11_ENCODE_BASIC_FILTER(min, mag, mip, comp) ((D3D11_FILTER) (((comp) ? D3D11_COMPARISON_FILTERING_BIT : 0 ) | (((min) & D3D11_FILTER_TYPE_MASK ) << D3D11_MIN_FILTER_SHIFT ) | (((mag) & D3D11_FILTER_TYPE_MASK ) << D3D11_MAG_FILTER_SHIFT ) | (((mip) & D3D11_FILTER_TYPE_MASK) << D3D11_MIP_FILTER_SHIFT)))") +cpp_quote("#define D3D11_ENCODE_ANISOTROPIC_FILTER(comp) ((D3D11_FILTER)(D3D11_ANISOTROPIC_FILTERING_BIT | D3D11_ENCODE_BASIC_FILTER(D3D11_FILTER_TYPE_LINEAR, D3D11_FILTER_TYPE_LINEAR, D3D11_FILTER_TYPE_LINEAR, comp)))") +cpp_quote("#define D3D11_DECODE_MIN_FILTER(f) ((D3D11_FILTER_TYPE)(((f) >> D3D11_MIN_FILTER_SHIFT) & D3D11_FILTER_TYPE_MASK))") +cpp_quote("#define D3D11_DECODE_MAG_FILTER(f) ((D3D11_FILTER_TYPE)(((f) >> D3D11_MAG_FILTER_SHIFT) & D3D11_FILTER_TYPE_MASK))") +cpp_quote("#define D3D11_DECODE_MIP_FILTER(f) ((D3D11_FILTER_TYPE)(((f) >> D3D11_MIP_FILTER_SHIFT) & D3D11_FILTER_TYPE_MASK))") +cpp_quote("#define D3D11_DECODE_IS_COMPARISON_FILTER(f) ((f) & D3D11_COMPARISON_FILTERING_BIT)") +cpp_quote("#define D3D11_DECODE_IS_ANISOTROPIC_FILTER(f) (((f) & D3D11_ANISOTROPIC_FILTERING_BIT) && (D3D11_DECODE_MIN_FILTER(f) == D3D11_FILTER_TYPE_LINEAR) && (D3D11_DECODE_MAG_FILTER(f) == D3D11_FILTER_TYPE_LINEAR) && (D3D11_DECODE_MIP_FILTER( f ) == D3D11_FILTER_TYPE_LINEAR))") + +typedef enum D3D11_TEXTURE_ADDRESS_MODE +{ + D3D11_TEXTURE_ADDRESS_WRAP = 1, + D3D11_TEXTURE_ADDRESS_MIRROR = 2, + D3D11_TEXTURE_ADDRESS_CLAMP = 3, + D3D11_TEXTURE_ADDRESS_BORDER = 4, + D3D11_TEXTURE_ADDRESS_MIRROR_ONCE = 5 +} D3D11_TEXTURE_ADDRESS_MODE; + +typedef struct D3D11_SAMPLER_DESC +{ + D3D11_FILTER Filter; + D3D11_TEXTURE_ADDRESS_MODE AddressU; + D3D11_TEXTURE_ADDRESS_MODE AddressV; + D3D11_TEXTURE_ADDRESS_MODE AddressW; + FLOAT MipLODBias; + UINT MaxAnisotropy; + D3D11_COMPARISON_FUNC ComparisonFunc; + FLOAT BorderColor[ 4 ]; + FLOAT MinLOD; + FLOAT MaxLOD; +} D3D11_SAMPLER_DESC; + +typedef enum D3D11_FORMAT_SUPPORT +{ + D3D11_FORMAT_SUPPORT_BUFFER = 0x1, + D3D11_FORMAT_SUPPORT_IA_VERTEX_BUFFER = 0x2, + D3D11_FORMAT_SUPPORT_IA_INDEX_BUFFER = 0x4, + D3D11_FORMAT_SUPPORT_SO_BUFFER = 0x8, + D3D11_FORMAT_SUPPORT_TEXTURE1D = 0x10, + D3D11_FORMAT_SUPPORT_TEXTURE2D = 0x20, + D3D11_FORMAT_SUPPORT_TEXTURE3D = 0x40, + D3D11_FORMAT_SUPPORT_TEXTURECUBE = 0x80, + D3D11_FORMAT_SUPPORT_SHADER_LOAD = 0x100, + D3D11_FORMAT_SUPPORT_SHADER_SAMPLE = 0x200, + D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON = 0x400, + D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_MONO_TEXT = 0x800, + D3D11_FORMAT_SUPPORT_MIP = 0x1000, + D3D11_FORMAT_SUPPORT_MIP_AUTOGEN = 0x2000, + D3D11_FORMAT_SUPPORT_RENDER_TARGET = 0x4000, + D3D11_FORMAT_SUPPORT_BLENDABLE = 0x8000, + D3D11_FORMAT_SUPPORT_DEPTH_STENCIL = 0x10000, + D3D11_FORMAT_SUPPORT_CPU_LOCKABLE = 0x20000, + D3D11_FORMAT_SUPPORT_MULTISAMPLE_RESOLVE = 0x40000, + D3D11_FORMAT_SUPPORT_DISPLAY = 0x80000, + D3D11_FORMAT_SUPPORT_CAST_WITHIN_BIT_LAYOUT = 0x100000, + D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET = 0x200000, + D3D11_FORMAT_SUPPORT_MULTISAMPLE_LOAD = 0x400000, + D3D11_FORMAT_SUPPORT_SHADER_GATHER = 0x800000, + D3D11_FORMAT_SUPPORT_BACK_BUFFER_CAST = 0x1000000, + D3D11_FORMAT_SUPPORT_TYPED_UNORDERED_ACCESS_VIEW = 0x2000000, + D3D11_FORMAT_SUPPORT_SHADER_GATHER_COMPARISON = 0x4000000 +} D3D11_FORMAT_SUPPORT; + +typedef enum D3D11_FORMAT_SUPPORT2 +{ + D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_ADD = 1, + D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_BITWISE_OPS = 2, + D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_COMPARE_STORE_OR_COMPARE_EXCHANGE = 4, + D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_EXCHANGE = 8, + D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_SIGNED_MIN_OR_MAX = 0x10, + D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_UNSIGNED_MIN_OR_MAX = 0x20, + D3D11_FORMAT_SUPPORT2_UAV_TYPED_LOAD = 0x40, + D3D11_FORMAT_SUPPORT2_UAV_TYPED_STORE = 0x80 +} D3D11_FORMAT_SUPPORT2; + +typedef enum D3D11_ASYNC_GETDATA_FLAG +{ + D3D11_ASYNC_GETDATA_DONOTFLUSH = 1 +} D3D11_ASYNC_GETDATA_FLAG; + +typedef enum D3D11_QUERY +{ + D3D11_QUERY_EVENT, + D3D11_QUERY_OCCLUSION, + D3D11_QUERY_TIMESTAMP, + D3D11_QUERY_TIMESTAMP_DISJOINT, + D3D11_QUERY_PIPELINE_STATISTICS, + D3D11_QUERY_OCCLUSION_PREDICATE, + D3D11_QUERY_SO_STATISTICS, + D3D11_QUERY_SO_OVERFLOW_PREDICATE, + D3D11_QUERY_SO_STATISTICS_STREAM0, + D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM0, + D3D11_QUERY_SO_STATISTICS_STREAM1, + D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM1, + D3D11_QUERY_SO_STATISTICS_STREAM2, + D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM2, + D3D11_QUERY_SO_STATISTICS_STREAM3, + D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM3, +} D3D11_QUERY; + +typedef enum D3D11_QUERY_MISC_FLAG +{ + D3D11_QUERY_MISC_PREDICATEHINT = 1 +} D3D11_QUERY_MISC_FLAG; + +typedef struct D3D11_QUERY_DESC +{ + D3D11_QUERY Query; + UINT MiscFlags; +} D3D11_QUERY_DESC; + +typedef struct D3D11_QUERY_DATA_TIMESTAMP_DISJOINT +{ + UINT64 Frequency; + BOOL Disjoint; +} D3D11_QUERY_DATA_TIMESTAMP_DISJOINT; + +typedef struct D3D11_QUERY_DATA_PIPELINE_STATISTICS +{ + UINT64 IAVertices; + UINT64 IAPrimitives; + UINT64 VSInvocations; + UINT64 GSInvocations; + UINT64 GSPrimitives; + UINT64 CInvocations; + UINT64 CPrimitives; + UINT64 PSInvocations; + UINT64 HSInvocations; + UINT64 DSInvocations; + UINT64 CSInvocations; +} D3D11_QUERY_DATA_PIPELINE_STATISTICS; + +typedef struct D3D11_QUERY_DATA_SO_STATISTICS +{ + UINT64 NumPrimitivesWritten; + UINT64 PrimitivesStorageNeeded; +} D3D11_QUERY_DATA_SO_STATISTICS; + +typedef enum D3D11_COUNTER +{ + D3D11_COUNTER_DEVICE_DEPENDENT_0 = 0x40000000 +} D3D11_COUNTER; + +typedef enum D3D11_COUNTER_TYPE +{ + D3D11_COUNTER_TYPE_FLOAT32, + D3D11_COUNTER_TYPE_UINT16, + D3D11_COUNTER_TYPE_UINT32, + D3D11_COUNTER_TYPE_UINT64, +} D3D11_COUNTER_TYPE; + +typedef struct D3D11_COUNTER_DESC +{ + D3D11_COUNTER Counter; + UINT MiscFlags; +} D3D11_COUNTER_DESC; + +typedef struct D3D11_COUNTER_INFO +{ + D3D11_COUNTER LastDeviceDependentCounter; + UINT NumSimultaneousCounters; + UINT8 NumDetectableParallelUnits; +} D3D11_COUNTER_INFO; + +typedef enum D3D11_STANDARD_MULTISAMPLE_QUALITY_LEVELS +{ + D3D11_STANDARD_MULTISAMPLE_PATTERN = 0xffffffff, + D3D11_CENTER_MULTISAMPLE_PATTERN = 0xfffffffe +} D3D11_STANDARD_MULTISAMPLE_QUALITY_LEVELS; + +typedef enum D3D11_DEVICE_CONTEXT_TYPE +{ + D3D11_DEVICE_CONTEXT_IMMEDIATE, + D3D11_DEVICE_CONTEXT_DEFERRED, +} D3D11_DEVICE_CONTEXT_TYPE; + +typedef struct D3D11_CLASS_INSTANCE_DESC +{ + UINT InstanceId; + UINT InstanceIndex; + UINT TypeId; + UINT ConstantBuffer; + UINT BaseConstantBufferOffset; + UINT BaseTexture; + UINT BaseSampler; + BOOL Created; +} D3D11_CLASS_INSTANCE_DESC; + +typedef enum D3D11_FEATURE +{ + D3D11_FEATURE_THREADING, + D3D11_FEATURE_DOUBLES, + D3D11_FEATURE_FORMAT_SUPPORT, + D3D11_FEATURE_FORMAT_SUPPORT2, + D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS, +} D3D11_FEATURE; + +typedef struct D3D11_FEATURE_DATA_THREADING +{ + BOOL DriverConcurrentCreates; + BOOL DriverCommandLists; +} D3D11_FEATURE_DATA_THREADING; + +typedef struct D3D11_FEATURE_DATA_DOUBLES +{ + BOOL DoublePrecisionFloatShaderOps; +} D3D11_FEATURE_DATA_DOUBLES; + +typedef struct D3D11_FEATURE_DATA_FORMAT_SUPPORT +{ + DXGI_FORMAT InFormat; + UINT OutFormatSupport; +} D3D11_FEATURE_DATA_FORMAT_SUPPORT; + +typedef struct D3D11_FEATURE_DATA_FORMAT_SUPPORT2 +{ + DXGI_FORMAT InFormat; + UINT OutFormatSupport2; +} D3D11_FEATURE_DATA_FORMAT_SUPPORT2; + +typedef struct D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS +{ + BOOL ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x; +} D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS; + +interface ID3D11Device; + +[object, local, uuid("1841e5c8-16b0-489b-bcc8-44cfb0d5deae")] +interface ID3D11DeviceChild : IUnknown { + void GetDevice( + [out] ID3D11Device **a + ); + + HRESULT GetPrivateData( + [in] REFGUID a, + [in, out] UINT *b, + [out] void *c + ); + + HRESULT SetPrivateData( + [in] REFGUID a, + [in] UINT b, + [in] const void *c + ); + + HRESULT SetPrivateDataInterface( + [in] REFGUID a, + [in] const IUnknown *b + ); +}; + +[object, local, uuid("e4819ddc-4cf0-4025-bd26-5de82a3e07b7")] +interface ID3D11InputLayout : ID3D11DeviceChild +{ +}; + +[object, local, uuid("03823efb-8d8f-4e1c-9aa2-f64bb2cbfdf1")] +interface ID3D11DepthStencilState : ID3D11DeviceChild { + void GetDesc( + [out] D3D11_DEPTH_STENCIL_DESC *a + ); +}; + +[object, local, uuid("75b68faa-347d-4159-8f45-a0640f01cd9a")] +interface ID3D11BlendState : ID3D11DeviceChild { + void GetDesc( + [out] D3D11_BLEND_DESC *a + ); +}; + +[object, local, uuid("9bb4ab81-ab1a-4d8f-b506-fc04200b6ee7")] +interface ID3D11RasterizerState : ID3D11DeviceChild { + void GetDesc( + [out] D3D11_RASTERIZER_DESC *a + ); +}; + +[object, local, uuid("da6fea51-564c-4487-9810-f0d0f9b4e3a5")] +interface ID3D11SamplerState : ID3D11DeviceChild +{ + void GetDesc( + [out] D3D11_SAMPLER_DESC *a + ); + +}; + +[object, local, uuid("dc8e63f3-d12b-4952-b47b-5e45026a862d")] +interface ID3D11Resource : ID3D11DeviceChild { + void GetType( + [out] D3D11_RESOURCE_DIMENSION *a + ); + + void SetEvictionPriority( + [in] UINT a + ); + + UINT GetEvictionPriority( + ); +}; + +[object, local, uuid("48570b85-d1ee-4fcd-a250-eb350722b037")] +interface ID3D11Buffer : ID3D11Resource { + void GetDesc( + [out] D3D11_BUFFER_DESC *a + ); + +}; + +[object, local, uuid("f8fb5c27-c6b3-4f75-a4c8-439af2ef564c")] +interface ID3D11Texture1D : ID3D11Resource { + void GetDesc( + [out] D3D11_TEXTURE1D_DESC *a + ); +}; + +[object, local, uuid("6f15aaf2-d208-4e89-9ab4-489535d34f9c")] +interface ID3D11Texture2D : ID3D11Resource { + void GetDesc( + [out] D3D11_TEXTURE2D_DESC *a + ); +}; + +[object, local, uuid("037e866e-f56d-4357-a8af-9dabbe6e250e")] +interface ID3D11Texture3D : ID3D11Resource { + void GetDesc( + [out] D3D11_TEXTURE3D_DESC *a + ); +}; + +[object, local, uuid("839d1216-bb2e-412b-b7f4-a9dbebe08ed1")] +interface ID3D11View : ID3D11DeviceChild { + void GetResource( + [out] ID3D11Resource **a + ); + +}; + +[object, local, uuid("b0e06fe0-8192-4e1a-b1ca-36d7414710b2")] +interface ID3D11ShaderResourceView : ID3D11View { + void GetDesc( + [out] D3D11_SHADER_RESOURCE_VIEW_DESC *a + ); +}; + +[object, local, uuid("dfdba067-0b8d-4865-875b-d7b4516cc164")] +interface ID3D11RenderTargetView : ID3D11View +{ + void GetDesc( + [out] D3D11_RENDER_TARGET_VIEW_DESC *a + ); +}; + +[object, local, uuid("9fdac92a-1876-48c3-afad-25b94f84a9b6")] +interface ID3D11DepthStencilView : ID3D11View +{ + void GetDesc( + [out] D3D11_DEPTH_STENCIL_VIEW_DESC *a + ); +}; + +[object, local, uuid("28acf509-7f5c-48f6-8611-f316010a6380")] +interface ID3D11UnorderedAccessView : ID3D11View +{ + void GetDesc( + [out] D3D11_UNORDERED_ACCESS_VIEW_DESC *a + ); +}; + +[object, local, uuid("3b301d64-d678-4289-8897-22f8928b72f3")] +interface ID3D11VertexShader : ID3D11DeviceChild +{ +}; + +[object, local, uuid("8e5c6061-628a-4c8e-8264-bbe45cb3d5dd")] +interface ID3D11HullShader : ID3D11DeviceChild +{ +}; + +[object, local, uuid("f582c508-0f36-490c-9977-31eece268cfa")] +interface ID3D11DomainShader : ID3D11DeviceChild +{ +}; + + +[object, local, uuid("38325b96-effb-4022-ba02-2e795b70275c")] +interface ID3D11GeometryShader : ID3D11DeviceChild +{ +}; + +[object, local, uuid("ea82e40d-51dc-4f33-93d4-db7c9125ae8c")] +interface ID3D11PixelShader : ID3D11DeviceChild +{ +}; + +[object, local, uuid("4f5b196e-c2bd-495e-bd01-1fded38e4969")] +interface ID3D11ComputeShader : ID3D11DeviceChild +{ +}; + +[object, local, uuid("4b35d0cd-1e15-4258-9c98-1b1333f6dd3b")] +interface ID3D11Asynchronous : ID3D11DeviceChild +{ + UINT GetDataSize(); +}; + +[object, local, uuid("d6c00747-87b7-425e-b84d-44d108560afd")] +interface ID3D11Query : ID3D11Asynchronous +{ + void GetDesc( + [out] D3D11_QUERY_DESC *a + ); +}; + +[object, local, uuid("9eb576dd-9f77-4d86-81aa-8bab5fe490e2")] +interface ID3D11Predicate : ID3D11Query +{ +}; + +[object, local, uuid("6e8c49fb-a371-4770-b440-29086022b741")] +interface ID3D11Counter : ID3D11Asynchronous +{ + void GetDesc( + [out] D3D11_COUNTER_DESC *a + ); +}; + +interface ID3D11ClassLinkage; + +[object, local, uuid("a6cd7faa-b0b7-4a2f-9436-8662a65797cb")] +interface ID3D11ClassInstance : ID3D11DeviceChild +{ + void GetClassLinkage( + [out] ID3D11ClassLinkage **a + ); + + void GetDesc( + [out] D3D11_CLASS_INSTANCE_DESC *a + ); + + void GetInstanceName( + [out] LPSTR a, + [in, out] SIZE_T *b + ); + + void GetTypeName( + [out] LPSTR a, + [in, out] SIZE_T *b + ); +}; + +[object, local, uuid("ddf57cba-9543-46e4-a12b-f207a0fe7fed")] +interface ID3D11ClassLinkage : ID3D11DeviceChild +{ + HRESULT GetClassInstance( + [in] LPCSTR a, + [in] UINT b, + [out] ID3D11ClassInstance **c + ); + + HRESULT CreateClassInstance( + [in] LPCSTR a, + [in] UINT b, + [in] UINT c, + [in] UINT d, + [in] UINT e, + [out] ID3D11ClassInstance **f + ); +}; + +[object, local, uuid("a24bc4d1-769e-43f7-8013-98ff566c18e2")] +interface ID3D11CommandList : ID3D11DeviceChild +{ + UINT GetContextFlags(); +}; + +interface ID3D11DeviceContext; + +[object, local, uuid("db6f6ddb-ac77-4e88-8253-819df9bbf140")] +interface ID3D11Device : IUnknown +{ + HRESULT CreateBuffer( + [in] const D3D11_BUFFER_DESC *a, + [in] const D3D11_SUBRESOURCE_DATA *b, + [out] ID3D11Buffer **c + ); + + HRESULT CreateTexture1D( + [in] const D3D11_TEXTURE1D_DESC *a, + [in] const D3D11_SUBRESOURCE_DATA *b, + [out] ID3D11Texture1D **c + ); + + HRESULT CreateTexture2D( + [in] const D3D11_TEXTURE2D_DESC *a, + [in] const D3D11_SUBRESOURCE_DATA *b, + [out] ID3D11Texture2D **c + ); + + HRESULT CreateTexture3D( + [in] const D3D11_TEXTURE3D_DESC *a, + [in] const D3D11_SUBRESOURCE_DATA *b, + [out] ID3D11Texture3D **c + ); + + HRESULT CreateShaderResourceView( + [in] ID3D11Resource *a, + [in] const D3D11_SHADER_RESOURCE_VIEW_DESC *b, + [out] ID3D11ShaderResourceView **c + ); + + HRESULT CreateUnorderedAccessView( + [in] ID3D11Resource *a, + [in] const D3D11_UNORDERED_ACCESS_VIEW_DESC *b, + [out] ID3D11UnorderedAccessView **c + ); + + HRESULT CreateRenderTargetView( + [in] ID3D11Resource *a, + [in] const D3D11_RENDER_TARGET_VIEW_DESC *b, + [out] ID3D11RenderTargetView **c + ); + + HRESULT CreateDepthStencilView( + [in] ID3D11Resource *a, + [in] const D3D11_DEPTH_STENCIL_VIEW_DESC *b, + [out] ID3D11DepthStencilView **c + ); + + HRESULT CreateInputLayout( + [in] const D3D11_INPUT_ELEMENT_DESC *a, + [in] UINT b, + [in] const void *c, + [in] SIZE_T d, + [out] ID3D11InputLayout **e + ); + + HRESULT CreateVertexShader( + [in] const void *a, + [in] SIZE_T b, + [in] ID3D11ClassLinkage *c, + [out] ID3D11VertexShader **d + ); + + HRESULT CreateGeometryShader( + [in] const void *a, + [in] SIZE_T b, + [in] ID3D11ClassLinkage *c, + [out] ID3D11GeometryShader **d + ); + + HRESULT CreateGeometryShaderWithStreamOutput( + [in] const void *a, + [in] SIZE_T b, + [in] const D3D11_SO_DECLARATION_ENTRY *c, + [in] UINT d, + [in] const UINT *e, + [in] UINT f, + [in] UINT g, + [in] ID3D11ClassLinkage *h, + [out] ID3D11GeometryShader **i + ); + + HRESULT CreatePixelShader( + [in] const void *a, + [in] SIZE_T b, + [in] ID3D11ClassLinkage *c, + [out] ID3D11PixelShader **d + ); + + HRESULT CreateHullShader( + [in] const void *a, + [in] SIZE_T b, + [in] ID3D11ClassLinkage *c, + [out] ID3D11HullShader **d + ); + + HRESULT CreateDomainShader( + [in] const void *a, + [in] SIZE_T b, + [in] ID3D11ClassLinkage *c, + [out] ID3D11DomainShader **d + ); + + HRESULT CreateComputeShader( + [in] const void *a, + [in] SIZE_T b, + [in] ID3D11ClassLinkage *c, + [out] ID3D11ComputeShader **d + ); + + HRESULT CreateClassLinkage( + [out] ID3D11ClassLinkage **a + ); + + HRESULT CreateBlendState( + [in] const D3D11_BLEND_DESC *a, + [out] ID3D11BlendState **b + ); + + HRESULT CreateDepthStencilState( + [in] const D3D11_DEPTH_STENCIL_DESC *a, + [out] ID3D11DepthStencilState **b + ); + + HRESULT CreateRasterizerState( + [in] const D3D11_RASTERIZER_DESC *a, + [out] ID3D11RasterizerState **b + ); + + HRESULT CreateSamplerState( + [in] const D3D11_SAMPLER_DESC *a, + [out] ID3D11SamplerState **b + ); + + HRESULT CreateQuery( + [in] const D3D11_QUERY_DESC *a, + [out] ID3D11Query **b + ); + + HRESULT CreatePredicate( + [in] const D3D11_QUERY_DESC *a, + [out] ID3D11Predicate **b + ); + + HRESULT CreateCounter( + [in] const D3D11_COUNTER_DESC *a, + [out] ID3D11Counter **b + ); + + HRESULT CreateDeferredContext( + [in] UINT a, + [out] ID3D11DeviceContext **b + ); + + HRESULT OpenSharedResource( + [in] HANDLE a, + [in] REFIID b, + [out] void **c + ); + + HRESULT CheckFormatSupport( + [in] DXGI_FORMAT a, + [out] UINT *b + ); + + HRESULT CheckMultisampleQualityLevels( + [in] DXGI_FORMAT a, + [in] UINT b, + [out] UINT *c + ); + + void CheckCounterInfo( + [out] D3D11_COUNTER_INFO *a + ); + + HRESULT CheckCounter( + [in] const D3D11_COUNTER_DESC *a, + [out] D3D11_COUNTER_TYPE *b, + [out] UINT *c, + [out] LPSTR d, + [in, out, optional] UINT *e, + [out] LPSTR f, + [in, out, optional] UINT *g, + [out] LPSTR h, + [in, out, optional] UINT *i + ); + + HRESULT CheckFeatureSupport( + [in] D3D11_FEATURE a, + [out] void *b, + [in] UINT c + ); + + HRESULT GetPrivateData( + [in] REFGUID a, + [in, out] UINT *b, + [out] void *c + ); + + HRESULT SetPrivateData( + [in] REFGUID a, + [in] UINT b, + [in] const void *c + ); + + HRESULT SetPrivateDataInterface( + [in] REFGUID a, + [in] const IUnknown *b + ); + + D3D_FEATURE_LEVEL GetFeatureLevel(); + + UINT GetCreationFlags(); + + HRESULT GetDeviceRemovedReason(); + + void GetImmediateContext( + [out] ID3D11DeviceContext **a + ); + + HRESULT SetExceptionMode( + [in] UINT a + ); + + UINT GetExceptionMode(); +}; + +[object, local, uuid("c0bfa96c-e089-44fb-8eaf-26f8796190da")] +interface ID3D11DeviceContext : ID3D11DeviceChild +{ + void VSSetConstantBuffers( + [in] UINT a, + [in] UINT b, + [in] ID3D11Buffer *const *c + ); + + void PSSetShaderResources( + [in] UINT a, + [in] UINT b, + [in] ID3D11ShaderResourceView *const *c + ); + + void PSSetShader( + [in] ID3D11PixelShader *a, + [in] ID3D11ClassInstance *const *b, + [in] UINT c + ); + + void PSSetSamplers( + [in] UINT a, + [in] UINT b, + [in] ID3D11SamplerState *const *c + ); + + void VSSetShader( + [in] ID3D11VertexShader *a, + [in] ID3D11ClassInstance *const *b, + [in] UINT c + ); + + void DrawIndexed( + [in] UINT a, + [in] UINT b, + [in] INT c + ); + + void Draw( + [in] UINT a, + [in] UINT b + ); + + HRESULT Map( + [in] ID3D11Resource *a, + [in] UINT b, + [in] D3D11_MAP c, + [in] UINT d, + [out] D3D11_MAPPED_SUBRESOURCE *e + ); + + void Unmap( + [in] ID3D11Resource *a, + [in] UINT b + ); + + void PSSetConstantBuffers( + [in] UINT a, + [in] UINT b, + [in] ID3D11Buffer *const *c + ); + + void IASetInputLayout( + [in] ID3D11InputLayout *a + ); + + void IASetVertexBuffers( + [in] UINT a, + [in] UINT b, + [in] ID3D11Buffer *const *c, + [in] const UINT *d, + [in] const UINT *e + ); + + void IASetIndexBuffer( + [in] ID3D11Buffer *a, + [in] DXGI_FORMAT b, + [in] UINT c + ); + + void DrawIndexedInstanced( + [in] UINT a, + [in] UINT b, + [in] UINT c, + [in] INT d, + [in] UINT e + ); + + void DrawInstanced( + [in] UINT a, + [in] UINT b, + [in] UINT c, + [in] UINT d + ); + + void GSSetConstantBuffers( + [in] UINT a, + [in] UINT b, + [in] ID3D11Buffer *const *c + ); + + void GSSetShader( + [in] ID3D11GeometryShader *a, + [in] ID3D11ClassInstance *const *b, + [in] UINT c + ); + + void IASetPrimitiveTopology( + [in] D3D11_PRIMITIVE_TOPOLOGY a + ); + + void VSSetShaderResources( + [in] UINT a, + [in] UINT b, + [in] ID3D11ShaderResourceView *const *c + ); + + void VSSetSamplers( + [in] UINT a, + [in] UINT b, + [in] ID3D11SamplerState *const *c + ); + + void Begin( + [in] ID3D11Asynchronous *a + ); + + void End( + [in] ID3D11Asynchronous *a + ); + + HRESULT GetData( + [in] ID3D11Asynchronous *a, + [out] void *b, + [in] UINT c, + [in] UINT d + ); + + void SetPredication( + [in] ID3D11Predicate *a, + [in] BOOL b + ); + + void GSSetShaderResources( + [in] UINT a, + [in] UINT b, + [in] ID3D11ShaderResourceView *const *c + ); + + void GSSetSamplers( + [in] UINT a, + [in] UINT b, + [in] ID3D11SamplerState *const *c + ); + + void OMSetRenderTargets( + [in] UINT a, + [in] ID3D11RenderTargetView *const *b, + [in] ID3D11DepthStencilView *c + ); + + void OMSetRenderTargetsAndUnorderedAccessViews( + [in] UINT a, + [in] ID3D11RenderTargetView *const *b, + [in] ID3D11DepthStencilView *c, + [in] UINT d, + [in] UINT e, + [in] ID3D11UnorderedAccessView *const *f, + [in] const UINT *g + ); + + void OMSetBlendState( + [in] ID3D11BlendState *a, + [in] const FLOAT b[4], + [in] UINT c + ); + + void OMSetDepthStencilState( + [in] ID3D11DepthStencilState *a, + [in] UINT b + ); + + void SOSetTargets( + [in] UINT a, + [in] ID3D11Buffer *const *b, + [in] const UINT *c + ); + + void DrawAuto( + ); + + void DrawIndexedInstancedIndirect( + [in] ID3D11Buffer *a, + [in] UINT b + ); + + void DrawInstancedIndirect( + [in] ID3D11Buffer *a, + [in] UINT b + ); + + void Dispatch( + [in] UINT a, + [in] UINT b, + [in] UINT c + ); + + void DispatchIndirect( + [in] ID3D11Buffer *a, + [in] UINT b + ); + + void RSSetState( + [in] ID3D11RasterizerState *a + ); + + void RSSetViewports( + [in] UINT a, + [in] const D3D11_VIEWPORT *b + ); + + void RSSetScissorRects( + [in] UINT a, + [in] const D3D11_RECT *b + ); + + void CopySubresourceRegion( + [in] ID3D11Resource *a, + [in] UINT b, + [in] UINT c, + [in] UINT d, + [in] UINT e, + [in] ID3D11Resource *f, + [in] UINT g, + [in] const D3D11_BOX *h + ); + + void CopyResource( + [in] ID3D11Resource *a, + [in] ID3D11Resource *b + ); + + void UpdateSubresource( + [in] ID3D11Resource *a, + [in] UINT b, + [in] const D3D11_BOX *c, + [in] const void *d, + [in] UINT e, + [in] UINT f + ); + + void CopyStructureCount( + [in] ID3D11Buffer *a, + [in] UINT b, + [in] ID3D11UnorderedAccessView *c + ); + + void ClearRenderTargetView( + [in] ID3D11RenderTargetView *a, + [in] const FLOAT b[4] + ); + + void ClearUnorderedAccessViewUint( + [in] ID3D11UnorderedAccessView *a, + [in] const UINT b[4] + ); + + void ClearUnorderedAccessViewFloat( + [in] ID3D11UnorderedAccessView *a, + [in] const FLOAT b[4] + ); + + void ClearDepthStencilView( + [in] ID3D11DepthStencilView *a, + [in] UINT b, + [in] FLOAT c, + [in] UINT8 d + ); + + void GenerateMips( + [in] ID3D11ShaderResourceView *a + ); + + void SetResourceMinLOD( + [in] ID3D11Resource *a, + [in] FLOAT b + ); + + FLOAT GetResourceMinLOD( + [in] ID3D11Resource *a + ); + + void ResolveSubresource( + [in] ID3D11Resource *a, + [in] UINT b, + [in] ID3D11Resource *c, + [in] UINT d, + [in] DXGI_FORMAT e + ); + + void ExecuteCommandList( + [in] ID3D11CommandList *a, + [in] BOOL b + ); + + void HSSetShaderResources( + [in] UINT a, + [in] UINT b, + [in] ID3D11ShaderResourceView *const *c + ); + + void HSSetShader( + [in] ID3D11HullShader *a, + [in] ID3D11ClassInstance *const *b, + [in] UINT c + ); + + void HSSetSamplers( + [in] UINT a, + [in] UINT b, + [in] ID3D11SamplerState *const *c + ); + + void HSSetConstantBuffers( + [in] UINT a, + [in] UINT b, + [in] ID3D11Buffer *const *c + ); + + void DSSetShaderResources( + [in] UINT a, + [in] UINT b, + [in] ID3D11ShaderResourceView *const *c + ); + + void DSSetShader( + [in] ID3D11DomainShader *a, + [in] ID3D11ClassInstance *const *b, + [in] UINT c + ); + + void DSSetSamplers( + [in] UINT a, + [in] UINT b, + [in] ID3D11SamplerState *const *c + ); + + void DSSetConstantBuffers( + [in] UINT a, + [in] UINT b, + [in] ID3D11Buffer *const *c + ); + + void CSSetShaderResources( + [in] UINT a, + [in] UINT b, + [in] ID3D11ShaderResourceView *const *c + ); + + void CSSetUnorderedAccessViews( + [in] UINT a, + [in] UINT b, + [in] ID3D11UnorderedAccessView *const *c, + [in] const UINT *d + ); + + void CSSetShader( + [in] ID3D11ComputeShader *a, + [in] ID3D11ClassInstance *const *b, + [in] UINT c + ); + + void CSSetSamplers( + [in] UINT a, + [in] UINT b, + [in] ID3D11SamplerState *const *c + ); + + void CSSetConstantBuffers( + [in] UINT a, + [in] UINT b, + [in] ID3D11Buffer *const *c + ); + + void VSGetConstantBuffers( + [in] UINT a, + [in] UINT b, + [out] ID3D11Buffer **c + ); + + void PSGetShaderResources( + [in] UINT a, + [in] UINT b, + [out] ID3D11ShaderResourceView **c + ); + + void PSGetShader( + [out] ID3D11PixelShader **a, + [out] ID3D11ClassInstance **b, + [in, out, optional] UINT *c + ); + + void PSGetSamplers( + [in] UINT a, + [in] UINT b, + [out] ID3D11SamplerState **c + ); + + void VSGetShader( + [out] ID3D11VertexShader **a, + [out] ID3D11ClassInstance **b, + [in, out, optional] UINT *c + ); + + void PSGetConstantBuffers( + [in] UINT a, + [in] UINT b, + [out] ID3D11Buffer **c + ); + + void IAGetInputLayout( + [out] ID3D11InputLayout **a + ); + + void IAGetVertexBuffers( + [in] UINT a, + [in] UINT b, + [out] ID3D11Buffer **c, + [out] UINT *d, + [out] UINT *e + ); + + void IAGetIndexBuffer( + [out] ID3D11Buffer **a, + [out] DXGI_FORMAT *b, + [out] UINT *c + ); + + void GSGetConstantBuffers( + [in] UINT a, + [in] UINT b, + [out] ID3D11Buffer **c + ); + + void GSGetShader( + [out] ID3D11GeometryShader **a, + [out] ID3D11ClassInstance **b, + [in, out, optional] UINT *c + ); + + void IAGetPrimitiveTopology( + [out] D3D11_PRIMITIVE_TOPOLOGY *a + ); + + void VSGetShaderResources( + [in] UINT a, + [in] UINT b, + [out] ID3D11ShaderResourceView **c + ); + + void VSGetSamplers( + [in] UINT a, + [in] UINT b, + [out] ID3D11SamplerState **c + ); + + void GetPredication( + [out] ID3D11Predicate **a, + [out] BOOL *b + ); + + void GSGetShaderResources( + [in] UINT a, + [in] UINT b, + [out] ID3D11ShaderResourceView **c + ); + + void GSGetSamplers( + [in] UINT a, + [in] UINT b, + [out] ID3D11SamplerState **c + ); + + void OMGetRenderTargets( + [in] UINT a, + [out] ID3D11RenderTargetView **b, + [out] ID3D11DepthStencilView **c + ); + + void OMGetRenderTargetsAndUnorderedAccessViews( + [in] UINT a, + [out] ID3D11RenderTargetView **b, + [out] ID3D11DepthStencilView **c, + [in] UINT d, + [in] UINT e, + [out] ID3D11UnorderedAccessView **f + ); + + void OMGetBlendState( + [out] ID3D11BlendState **a, + [out] FLOAT b[4], + [out] UINT *c + ); + + void OMGetDepthStencilState( + [out] ID3D11DepthStencilState **a, + [out] UINT *b + ); + + void SOGetTargets( + [in] UINT a, + [out] ID3D11Buffer **b + ); + + void RSGetState( + [out] ID3D11RasterizerState **a + ); + + void RSGetViewports( + [in, out] UINT *a, + [out] D3D11_VIEWPORT *b + ); + + void RSGetScissorRects( + [in, out] UINT *a, + [out] D3D11_RECT *b + ); + + void HSGetShaderResources( + [in] UINT a, + [in] UINT b, + [out] ID3D11ShaderResourceView **c + ); + + void HSGetShader( + [out] ID3D11HullShader **a, + [out] ID3D11ClassInstance **b, + [in, out, optional] UINT *c + ); + + void HSGetSamplers( + [in] UINT a, + [in] UINT b, + [out] ID3D11SamplerState **c + ); + + void HSGetConstantBuffers( + [in] UINT a, + [in] UINT b, + [out] ID3D11Buffer **c + ); + + void DSGetShaderResources( + [in] UINT a, + [in] UINT b, + [out] ID3D11ShaderResourceView **c + ); + + void DSGetShader( + [out] ID3D11DomainShader **a, + [out] ID3D11ClassInstance **b, + [in, out, optional] UINT *c + ); + + void DSGetSamplers( + [in] UINT a, + [in] UINT b, + [out] ID3D11SamplerState **c + ); + + void DSGetConstantBuffers( + [in] UINT a, + [in] UINT b, + [out] ID3D11Buffer **c + ); + + void CSGetShaderResources( + [in] UINT a, + [in] UINT b, + [out] ID3D11ShaderResourceView **c + ); + + void CSGetUnorderedAccessViews( + [in] UINT a, + [in] UINT b, + [out] ID3D11UnorderedAccessView **c + ); + + void CSGetShader( + [out] ID3D11ComputeShader **a, + [out] ID3D11ClassInstance **b, + [in, out, optional] UINT *c + ); + + void CSGetSamplers( + [in] UINT a, + [in] UINT b, + [out] ID3D11SamplerState **c + ); + + void CSGetConstantBuffers( + [in] UINT a, + [in] UINT b, + [out] ID3D11Buffer **c + ); + + void ClearState(); + + void Flush(); + + D3D11_DEVICE_CONTEXT_TYPE GetType(); + + UINT GetContextFlags(); + + HRESULT FinishCommandList( + [in] BOOL a, + [out] ID3D11CommandList **b + ); +}; + +cpp_quote("#include \"d3d10_1.h\"") +cpp_quote("#include \"d3d10shader.h\"") +cpp_quote("#include \"d3d10effect.h\"") +/*cpp_quote("#include \"d3d10_1shader.h\"") */ + +typedef enum D3D11_CREATE_DEVICE_FLAG +{ + D3D11_CREATE_DEVICE_SINGLETHREADED = 1, + D3D11_CREATE_DEVICE_DEBUG = 2, + D3D11_CREATE_DEVICE_SWITCH_TO_REF = 4, + D3D11_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS = 8, + D3D11_CREATE_DEVICE_BGRA_SUPPORT = 0x20 +} D3D11_CREATE_DEVICE_FLAG; + + +HRESULT D3D11CreateDevice( + [in,optional] IDXGIAdapter* a, + [in] D3D_DRIVER_TYPE b, + [in] HMODULE c, + [in] UINT d, + [in,optional] const D3D_FEATURE_LEVEL* e, + [in] UINT f, + [in] UINT g, + [out,optional] ID3D11Device** h, + [out,optional] D3D_FEATURE_LEVEL* i, + [out,optional] ID3D11DeviceContext** j +); + +typedef HRESULT (* PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN)( + [in,optional] IDXGIAdapter*, + D3D_DRIVER_TYPE, + HMODULE, + UINT, + [in,optional] const D3D_FEATURE_LEVEL*, + UINT, + UINT, + [in, optional] const DXGI_SWAP_CHAIN_DESC*, + [out,optional] IDXGISwapChain**, + [out,optional] ID3D11Device**, + [out,optional] D3D_FEATURE_LEVEL*, + [out,optional] ID3D11DeviceContext** +); + +HRESULT D3D11CreateDeviceAndSwapChain( + [in,optional] IDXGIAdapter* a, + [in] D3D_DRIVER_TYPE b, + [in] HMODULE c, + [in] UINT d, + [in,optional] const D3D_FEATURE_LEVEL* e, + [in] UINT f, + [in] UINT g, + [in,optional] const DXGI_SWAP_CHAIN_DESC* h, + [out,optional] IDXGISwapChain** i, + [out,optional] ID3D11Device** j, + [out,optional] D3D_FEATURE_LEVEL* k, + [out,optional] ID3D11DeviceContext** l +); diff --git a/src/gallium/state_trackers/d3d1x/d3dapi/d3d11shader.idl b/src/gallium/state_trackers/d3d1x/d3dapi/d3d11shader.idl new file mode 100644 index 00000000000..bb20d91053e --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3dapi/d3d11shader.idl @@ -0,0 +1,287 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + +import "d3dcommon.idl"; + +typedef enum D3D11_SHADER_VERSION_TYPE +{ + D3D11_SHVER_PIXEL_SHADER, + D3D11_SHVER_VERTEX_SHADER, + D3D11_SHVER_GEOMETRY_SHADER, + + D3D11_SHVER_HULL_SHADER, + D3D11_SHVER_DOMAIN_SHADER, + D3D11_SHVER_COMPUTE_SHADER, +} D3D11_SHADER_VERSION_TYPE; + +cpp_quote("#define D3D11_SHVER_GET_TYPE(v) (((v) >> 16) & 0xffff)") +cpp_quote("#define D3D11_SHVER_GET_MAJOR(v) (((v) >> 4) & 0xf)") +cpp_quote("#define D3D11_SHVER_GET_MINOR(v) (((v) >> 0) & 0xf)") + +typedef D3D_RESOURCE_RETURN_TYPE D3D11_RESOURCE_RETURN_TYPE; +typedef D3D_CBUFFER_TYPE D3D11_CBUFFER_TYPE; + +typedef struct _D3D11_SIGNATURE_PARAMETER_DESC +{ + LPCSTR SemanticName; + UINT SemanticIndex; + UINT Register; + D3D_NAME SystemValueType; + D3D_REGISTER_COMPONENT_TYPE ComponentType; + BYTE Mask; + BYTE ReadWriteMask; + UINT Stream; +} D3D11_SIGNATURE_PARAMETER_DESC; + +typedef struct _D3D11_SHADER_BUFFER_DESC +{ + LPCSTR Name; + D3D_CBUFFER_TYPE Type; + UINT Variables; + UINT Size; + UINT uFlags; +} D3D11_SHADER_BUFFER_DESC; + +typedef struct _D3D11_SHADER_VARIABLE_DESC +{ + LPCSTR Name; + UINT StartOffset; + UINT Size; + UINT uFlags; + LPVOID DefaultValue; + UINT StartTexture; + UINT TextureSize; + UINT StartSampler; + UINT SamplerSize; +} D3D11_SHADER_VARIABLE_DESC; + +typedef struct _D3D11_SHADER_TYPE_DESC +{ + D3D_SHADER_VARIABLE_CLASS Class; + D3D_SHADER_VARIABLE_TYPE Type; + UINT Rows; + UINT Columns; + UINT Elements; + UINT Members; + UINT Offset; + LPCSTR Name; +} D3D11_SHADER_TYPE_DESC; + +typedef D3D_TESSELLATOR_DOMAIN D3D11_TESSELLATOR_DOMAIN; +typedef D3D_TESSELLATOR_PARTITIONING D3D11_TESSELLATOR_PARTITIONING; +typedef D3D_TESSELLATOR_OUTPUT_PRIMITIVE D3D11_TESSELLATOR_OUTPUT_PRIMITIVE; + +typedef struct _D3D11_SHADER_DESC +{ + UINT Version; + LPCSTR Creator; + UINT Flags; + + UINT ConstantBuffers; + UINT BoundResources; + UINT InputParameters; + UINT OutputParameters; + + UINT InstructionCount; + UINT TempRegisterCount; + UINT TempArrayCount; + UINT DefCount; + UINT DclCount; + UINT TextureNormalInstructions; + UINT TextureLoadInstructions; + UINT TextureCompInstructions; + UINT TextureBiasInstructions; + UINT TextureGradientInstructions; + UINT FloatInstructionCount; + UINT IntInstructionCount; + UINT UintInstructionCount; + UINT StaticFlowControlCount; + UINT DynamicFlowControlCount; + UINT MacroInstructionCount; + UINT ArrayInstructionCount; + UINT CutInstructionCount; + UINT EmitInstructionCount; + D3D_PRIMITIVE_TOPOLOGY GSOutputTopology; + UINT GSMaxOutputVertexCount; + D3D_PRIMITIVE InputPrimitive; + UINT PatchConstantParameters; + UINT cGSInstanceCount; + UINT cControlPoints; + D3D_TESSELLATOR_OUTPUT_PRIMITIVE HSOutputPrimitive; + D3D_TESSELLATOR_PARTITIONING HSPartitioning; + D3D_TESSELLATOR_DOMAIN TessellatorDomain; + + UINT cBarrierInstructions; + UINT cInterlockedInstructions; + UINT cTextureStoreInstructions; +} D3D11_SHADER_DESC; + +typedef struct _D3D11_SHADER_INPUT_BIND_DESC +{ + LPCSTR Name; + D3D_SHADER_INPUT_TYPE Type; + UINT BindPoint; + UINT BindCount; + + UINT uFlags; + D3D_RESOURCE_RETURN_TYPE ReturnType; + D3D_SRV_DIMENSION Dimension; + UINT NumSamples; +} D3D11_SHADER_INPUT_BIND_DESC; + +[local, object, uuid("6e6ffa6a-9bae-4613-a51e-91652d508c21")] +interface ID3D11ShaderReflectionType +{ + HRESULT GetDesc( + [out] D3D11_SHADER_TYPE_DESC *a + ); + + ID3D11ShaderReflectionType* GetMemberTypeByIndex( + [in] UINT a + ); + + ID3D11ShaderReflectionType* GetMemberTypeByName( + [in] LPCSTR a + ); + + LPCSTR GetMemberTypeName( + [in] UINT a + ); + + HRESULT IsEqual( + [in] ID3D11ShaderReflectionType* a + ); + ID3D11ShaderReflectionType* GetSubType(); + ID3D11ShaderReflectionType* GetBaseClass(); + UINT GetNumInterfaces(); + ID3D11ShaderReflectionType* GetInterfaceByIndex( + [in] UINT a + ); + HRESULT IsOfType( + [in] ID3D11ShaderReflectionType* a + ); + HRESULT ImplementsInterface( + [in] ID3D11ShaderReflectionType* a + ); +}; + +interface ID3D11ShaderReflectionConstantBuffer; + +[object, local, uuid("51f23923-f3e5-4bd1-91cb-606177d8db4c")] +interface ID3D11ShaderReflectionVariable +{ + HRESULT GetDesc( + [out] D3D11_SHADER_VARIABLE_DESC *a + ); + + ID3D11ShaderReflectionType* GetType(); + ID3D11ShaderReflectionConstantBuffer* GetBuffer(); + + UINT GetInterfaceSlot( + [in] UINT a + ); +}; + +[object, local, uuid("eb62d63d-93dd-4318-8ae8-c6f83ad371b8")] +interface ID3D11ShaderReflectionConstantBuffer +{ + HRESULT GetDesc( + [out] D3D11_SHADER_BUFFER_DESC *a + ); + + ID3D11ShaderReflectionVariable* GetVariableByIndex( + [in] UINT a + ); + + ID3D11ShaderReflectionVariable* GetVariableByName( + [in] LPCSTR a + ); +}; + +[object,local,uuid("0a233719-3960-4578-9d7c-203b8b1d9cc1")] +interface ID3D11ShaderReflection +{ + HRESULT GetDesc( + [out] D3D11_SHADER_DESC *a + ); + + ID3D11ShaderReflectionConstantBuffer* GetConstantBufferByIndex( + [in] UINT a + ); + + ID3D11ShaderReflectionConstantBuffer* GetConstantBufferByName( + [in] LPCSTR a + ); + + HRESULT GetResourceBindingDesc( + [in] UINT a, + [out] D3D11_SHADER_INPUT_BIND_DESC *b + ); + + HRESULT GetInputParameterDesc( + [in] UINT a, + [out] D3D11_SIGNATURE_PARAMETER_DESC *b + ); + + HRESULT GetOutputParameterDesc + ( + [in] UINT a, + [out] D3D11_SIGNATURE_PARAMETER_DESC *b + ); + + HRESULT GetPatchConstantParameterDesc( + [in] UINT a, + [out] D3D11_SIGNATURE_PARAMETER_DESC *b + ); + + ID3D11ShaderReflectionVariable* GetVariableByName( + [in] LPCSTR a + ); + + HRESULT GetResourceBindingDescByName( + [in] LPCSTR a, + [out] D3D11_SHADER_INPUT_BIND_DESC *b + ); + + UINT GetMovInstructionCount(); + UINT GetMovcInstructionCount(); + UINT GetConversionInstructionCount(); + UINT GetBitwiseInstructionCount(); + D3D_PRIMITIVE GetGSInputPrimitive(); + BOOL IsSampleFrequencyShader(); + UINT GetNumInterfaceSlots(); + + HRESULT GetMinFeatureLevel( + [out] D3D_FEATURE_LEVEL* a + ); + + UINT GetThreadGroupSize( + [out,optional] UINT* a, + [out,optional] UINT* b, + [out,optional] UINT* c + ); +}; + diff --git a/src/gallium/state_trackers/d3d1x/d3dapi/d3dcommon.idl b/src/gallium/state_trackers/d3d1x/d3dapi/d3dcommon.idl new file mode 100644 index 00000000000..dd901431684 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3dapi/d3dcommon.idl @@ -0,0 +1,704 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + +import "oaidl.idl"; +import "ocidl.idl"; + +typedef const void* LPCVOID; + +typedef enum D3D_DRIVER_TYPE +{ + D3D_DRIVER_TYPE_UNKNOWN, + D3D_DRIVER_TYPE_HARDWARE, + D3D_DRIVER_TYPE_REFERENCE, + D3D_DRIVER_TYPE_NULL, + D3D_DRIVER_TYPE_SOFTWARE, + D3D_DRIVER_TYPE_WARP, +} D3D_DRIVER_TYPE; + +typedef enum D3D_FEATURE_LEVEL +{ + D3D_FEATURE_LEVEL_9_1 = 0x9100, + D3D_FEATURE_LEVEL_9_2 = 0x9200, + D3D_FEATURE_LEVEL_9_3 = 0x9300, + D3D_FEATURE_LEVEL_10_0 = 0xa000, + D3D_FEATURE_LEVEL_10_1 = 0xa100, + D3D_FEATURE_LEVEL_11_0 = 0xb000 +} D3D_FEATURE_LEVEL; + +typedef enum D3D_PRIMITIVE_TOPOLOGY +{ + D3D_PRIMITIVE_TOPOLOGY_UNDEFINED = 0, + D3D_PRIMITIVE_TOPOLOGY_POINTLIST, + D3D_PRIMITIVE_TOPOLOGY_LINELIST, + D3D_PRIMITIVE_TOPOLOGY_LINESTRIP, + D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST, + D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, + + D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ = 10, + D3D_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ, + D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ, + D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ, + + D3D_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST = 33, + D3D_PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST, + D3D_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST, + + D3D10_PRIMITIVE_TOPOLOGY_UNDEFINED = 0, + D3D10_PRIMITIVE_TOPOLOGY_POINTLIST, + D3D10_PRIMITIVE_TOPOLOGY_LINELIST, + D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP, + D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST, + D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, + + D3D10_PRIMITIVE_TOPOLOGY_LINELIST_ADJ = 10, + D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ, + D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ, + D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ, + + D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED = 0, + D3D11_PRIMITIVE_TOPOLOGY_POINTLIST, + D3D11_PRIMITIVE_TOPOLOGY_LINELIST, + D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP, + D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST, + D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, + + D3D11_PRIMITIVE_TOPOLOGY_LINELIST_ADJ = 10, + D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ, + D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ, + D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ, + + D3D11_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST = 33, + D3D11_PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST, +} D3D_PRIMITIVE_TOPOLOGY; + +typedef enum D3D_PRIMITIVE +{ + D3D_PRIMITIVE_UNDEFINED = 0, + D3D_PRIMITIVE_POINT, + D3D_PRIMITIVE_LINE, + D3D_PRIMITIVE_TRIANGLE, + + D3D_PRIMITIVE_LINE_ADJ = 6, + D3D_PRIMITIVE_TRIANGLE_ADJ, + + D3D_PRIMITIVE_1_CONTROL_POINT_PATCH = 8, + D3D_PRIMITIVE_2_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_3_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_4_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_5_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_6_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_7_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_8_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_9_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_10_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_11_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_12_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_13_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_14_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_15_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_16_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_17_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_18_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_19_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_20_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_21_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_22_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_23_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_24_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_25_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_26_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_27_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_28_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_29_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_30_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_31_CONTROL_POINT_PATCH, + D3D_PRIMITIVE_32_CONTROL_POINT_PATCH, + + D3D10_PRIMITIVE_UNDEFINED = 0, + D3D10_PRIMITIVE_POINT, + D3D10_PRIMITIVE_LINE, + D3D10_PRIMITIVE_TRIANGLE, + + D3D10_PRIMITIVE_LINE_ADJ = 6, + D3D10_PRIMITIVE_TRIANGLE_ADJ, + + D3D11_PRIMITIVE_UNDEFINED = 0, + D3D11_PRIMITIVE_POINT, + D3D11_PRIMITIVE_LINE, + D3D11_PRIMITIVE_TRIANGLE, + + D3D11_PRIMITIVE_LINE_ADJ = 6, + D3D11_PRIMITIVE_TRIANGLE_ADJ, + + D3D11_PRIMITIVE_1_CONTROL_POINT_PATCH = 8, + D3D11_PRIMITIVE_2_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_3_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_4_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_5_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_6_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_7_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_8_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_9_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_10_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_11_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_12_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_13_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_14_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_15_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_16_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_17_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_18_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_19_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_20_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_21_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_22_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_23_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_24_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_25_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_26_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_27_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_28_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_29_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_30_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_31_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_32_CONTROL_POINT_PATCH, +} D3D_PRIMITIVE; + +typedef enum D3D_SRV_DIMENSION +{ + D3D_SRV_DIMENSION_UNKNOWN = 0, + D3D_SRV_DIMENSION_BUFFER, + D3D_SRV_DIMENSION_TEXTURE1D, + D3D_SRV_DIMENSION_TEXTURE1DARRAY, + D3D_SRV_DIMENSION_TEXTURE2D, + D3D_SRV_DIMENSION_TEXTURE2DARRAY, + D3D_SRV_DIMENSION_TEXTURE2DMS, + D3D_SRV_DIMENSION_TEXTURE2DMSARRAY, + D3D_SRV_DIMENSION_TEXTURE3D, + D3D_SRV_DIMENSION_TEXTURECUBE, + D3D_SRV_DIMENSION_TEXTURECUBEARRAY, + D3D_SRV_DIMENSION_BUFFEREX, + + D3D10_SRV_DIMENSION_UNKNOWN = 0, + D3D10_SRV_DIMENSION_BUFFER, + D3D10_SRV_DIMENSION_TEXTURE1D, + D3D10_SRV_DIMENSION_TEXTURE1DARRAY, + D3D10_SRV_DIMENSION_TEXTURE2D, + D3D10_SRV_DIMENSION_TEXTURE2DARRAY, + D3D10_SRV_DIMENSION_TEXTURE2DMS, + D3D10_SRV_DIMENSION_TEXTURE2DMSARRAY, + D3D10_SRV_DIMENSION_TEXTURE3D, + D3D10_SRV_DIMENSION_TEXTURECUBE, + + D3D10_1_SRV_DIMENSION_UNKNOWN = 0, + D3D10_1_SRV_DIMENSION_BUFFER, + D3D10_1_SRV_DIMENSION_TEXTURE1D, + D3D10_1_SRV_DIMENSION_TEXTURE1DARRAY, + D3D10_1_SRV_DIMENSION_TEXTURE2D, + D3D10_1_SRV_DIMENSION_TEXTURE2DARRAY, + D3D10_1_SRV_DIMENSION_TEXTURE2DMS, + D3D10_1_SRV_DIMENSION_TEXTURE2DMSARRAY, + D3D10_1_SRV_DIMENSION_TEXTURE3D, + D3D10_1_SRV_DIMENSION_TEXTURECUBE, + D3D10_1_SRV_DIMENSION_TEXTURECUBEARRAY, + + D3D11_SRV_DIMENSION_UNKNOWN = 0, + D3D11_SRV_DIMENSION_BUFFER, + D3D11_SRV_DIMENSION_TEXTURE1D, + D3D11_SRV_DIMENSION_TEXTURE1DARRAY, + D3D11_SRV_DIMENSION_TEXTURE2D, + D3D11_SRV_DIMENSION_TEXTURE2DARRAY, + D3D11_SRV_DIMENSION_TEXTURE2DMS, + D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY, + D3D11_SRV_DIMENSION_TEXTURE3D, + D3D11_SRV_DIMENSION_TEXTURECUBE, + D3D11_SRV_DIMENSION_TEXTURECUBEARRAY, + D3D11_SRV_DIMENSION_BUFFEREX, +} D3D_SRV_DIMENSION; + +typedef struct _D3D_SHADER_MACRO +{ + LPCSTR Name; + LPCSTR Definition; +} D3D_SHADER_MACRO; + +typedef struct _D3D_SHADER_MACRO *LPD3D_SHADER_MACRO; + +[object, local, uuid(8ba5fb08-5195-40e2-ac58-0d989c3a0102)] +interface ID3D10Blob : IUnknown +{ + LPVOID GetBufferPointer(); + SIZE_T GetBufferSize(); +}; + +typedef ID3D10Blob* LPD3D10BLOB; +typedef ID3D10Blob ID3DBlob; +typedef ID3DBlob* LPD3DBLOB; + +typedef enum _D3D_INCLUDE_TYPE +{ + D3D_INCLUDE_LOCAL = 0, + D3D_INCLUDE_SYSTEM, + + D3D10_INCLUDE_LOCAL = 0, + D3D10_INCLUDE_SYSTEM, + + D3D_INCLUDE_FORCE_DWORD = 0x7fffffff, +} D3D_INCLUDE_TYPE; + +[object, local] +interface ID3DInclude : IUnknown +{ + HRESULT Open( + [in] D3D_INCLUDE_TYPE a, + [in] LPCSTR b, + [in] LPCVOID c, + [out] LPCVOID *d, + [in] UINT *e + ); + HRESULT Close( + [in] LPCVOID a + ); +}; + +typedef enum _D3D_SHADER_VARIABLE_CLASS +{ + D3D_SVC_SCALAR = 0, + D3D_SVC_VECTOR, + D3D_SVC_MATRIX_ROWS, + D3D_SVC_MATRIX_COLUMNS, + D3D_SVC_OBJECT, + D3D_SVC_STRUCT, + D3D_SVC_INTERFACE_CLASS, + D3D_SVC_INTERFACE_POINTER, + + D3D10_SVC_SCALAR = 0, + D3D10_SVC_VECTOR, + D3D10_SVC_MATRIX_ROWS, + D3D10_SVC_MATRIX_COLUMNS, + D3D10_SVC_OBJECT, + D3D10_SVC_STRUCT, + D3D11_SVC_INTERFACE_CLASS, + D3D11_SVC_INTERFACE_POINTER, + D3D_SVC_FORCE_DWORD = 0x7fffffff +} D3D_SHADER_VARIABLE_CLASS; + +typedef enum _D3D_SHADER_VARIABLE_FLAGS +{ + D3D_SVF_USERPACKED = 1, + D3D_SVF_USED = 2, + D3D_SVF_INTERFACE_POINTER = 4, + D3D_SVF_INTERFACE_PARAMETER = 8, + + D3D10_SVF_USERPACKED = 1, + D3D10_SVF_USED = 2, + D3D10_SVF_INTERFACE_POINTER = 4, + D3D10_SVF_INTERFACE_PARAMETER = 8, + + D3D_SVF_FORCE_DWORD = 0x7fffffff +} D3D_SHADER_VARIABLE_FLAGS; + +typedef enum _D3D_SHADER_VARIABLE_TYPE +{ + D3D_SVT_VOID = 0, + D3D_SVT_BOOL, + D3D_SVT_INT, + D3D_SVT_FLOAT, + D3D_SVT_STRING, + D3D_SVT_TEXTURE, + D3D_SVT_TEXTURE1D, + D3D_SVT_TEXTURE2D, + D3D_SVT_TEXTURE3D, + D3D_SVT_TEXTURECUBE, + D3D_SVT_SAMPLER, + D3D_SVT_SAMPLER1D, + D3D_SVT_SAMPLER2D, + D3D_SVT_SAMPLER3D, + D3D_SVT_SAMPLERCUBE, + D3D_SVT_PIXELSHADER, + D3D_SVT_VERTEXSHADER, + D3D_SVT_PIXELFRAGMENT, + D3D_SVT_VERTEXFRAGMENT, + D3D_SVT_UINT, + D3D_SVT_UINT8, + D3D_SVT_GEOMETRYSHADER, + D3D_SVT_RASTERIZER, + D3D_SVT_DEPTHSTENCIL, + D3D_SVT_BLEND, + D3D_SVT_BUFFER, + D3D_SVT_CBUFFER, + D3D_SVT_TBUFFER, + D3D_SVT_TEXTURE1DARRAY, + D3D_SVT_TEXTURE2DARRAY, + D3D_SVT_RENDERTARGETVIEW, + D3D_SVT_DEPTHSTENCILVIEW, + D3D_SVT_TEXTURE2DMS, + D3D_SVT_TEXTURE2DMSARRAY, + D3D_SVT_TEXTURECUBEARRAY, + D3D_SVT_HULLSHADER, + D3D_SVT_DOMAINSHADER, + D3D_SVT_INTERFACE_POINTER, + D3D_SVT_COMPUTESHADER, + D3D_SVT_DOUBLE, + D3D_SVT_RWTEXTURE1D, + D3D_SVT_RWTEXTURE1DARRAY, + D3D_SVT_RWTEXTURE2D, + D3D_SVT_RWTEXTURE2DARRAY, + D3D_SVT_RWTEXTURE3D, + D3D_SVT_RWBUFFER, + D3D_SVT_BYTEADDRESS_BUFFER, + D3D_SVT_RWBYTEADDRESS_BUFFER, + D3D_SVT_STRUCTURED_BUFFER, + D3D_SVT_RWSTRUCTURED_BUFFER, + D3D_SVT_APPEND_STRUCTURED_BUFFER, + D3D_SVT_CONSUME_STRUCTURED_BUFFER, + + D3D10_SVT_VOID = 0, + D3D10_SVT_BOOL, + D3D10_SVT_INT, + D3D10_SVT_FLOAT, + D3D10_SVT_STRING, + D3D10_SVT_TEXTURE, + D3D10_SVT_TEXTURE1D, + D3D10_SVT_TEXTURE2D, + D3D10_SVT_TEXTURE3D, + D3D10_SVT_TEXTURECUBE, + D3D10_SVT_SAMPLER, + D3D10_SVT_SAMPLER1D, + D3D10_SVT_SAMPLER2D, + D3D10_SVT_SAMPLER3D, + D3D10_SVT_SAMPLERCUBE, + D3D10_SVT_PIXELSHADER, + D3D10_SVT_VERTEXSHADER, + D3D10_SVT_PIXELFRAGMENT, + D3D10_SVT_VERTEXFRAGMENT, + D3D10_SVT_UINT, + D3D10_SVT_UINT8, + D3D10_SVT_GEOMETRYSHADER, + D3D10_SVT_RASTERIZER, + D3D10_SVT_DEPTHSTENCIL, + D3D10_SVT_BLEND, + D3D10_SVT_BUFFER, + D3D10_SVT_CBUFFER, + D3D10_SVT_TBUFFER, + D3D10_SVT_TEXTURE1DARRAY, + D3D10_SVT_TEXTURE2DARRAY, + D3D10_SVT_RENDERTARGETVIEW, + D3D10_SVT_DEPTHSTENCILVIEW, + D3D10_SVT_TEXTURE2DMS, + D3D10_SVT_TEXTURE2DMSARRAY, + D3D10_SVT_TEXTURECUBEARRAY, + + D3D11_SVT_HULLSHADER, + D3D11_SVT_DOMAINSHADER, + D3D11_SVT_INTERFACE_POINTER, + D3D11_SVT_COMPUTESHADER, + D3D11_SVT_DOUBLE, + D3D11_SVT_RWTEXTURE1D, + D3D11_SVT_RWTEXTURE1DARRAY, + D3D11_SVT_RWTEXTURE2D, + D3D11_SVT_RWTEXTURE2DARRAY, + D3D11_SVT_RWTEXTURE3D, + D3D11_SVT_RWBUFFER, + D3D11_SVT_BYTEADDRESS_BUFFER, + D3D11_SVT_RWBYTEADDRESS_BUFFER, + D3D11_SVT_STRUCTURED_BUFFER, + D3D11_SVT_RWSTRUCTURED_BUFFER, + D3D11_SVT_APPEND_STRUCTURED_BUFFER, + D3D11_SVT_CONSUME_STRUCTURED_BUFFER, + + D3D_SVT_FORCE_DWORD = 0x7fffffff +} D3D_SHADER_VARIABLE_TYPE; + +typedef enum _D3D_SHADER_INPUT_FLAGS +{ + D3D_SIF_USERPACKED = 1, + D3D_SIF_COMPARISON_SAMPLER = 2, + D3D_SIF_TEXTURE_COMPONENT_0 = 4, + D3D_SIF_TEXTURE_COMPONENT_1 = 8, + D3D_SIF_TEXTURE_COMPONENTS = 12, + + D3D10_SIF_USERPACKED = 1, + D3D10_SIF_COMPARISON_SAMPLER = 2, + D3D10_SIF_TEXTURE_COMPONENT_0 = 4, + D3D10_SIF_TEXTURE_COMPONENT_1 = 8, + D3D10_SIF_TEXTURE_COMPONENTS = 12, + + D3D_SIF_FORCE_DWORD = 0x7fffffff + } D3D_SHADER_INPUT_FLAGS; + +typedef enum _D3D_SHADER_INPUT_TYPE +{ + D3D_SIT_CBUFFER = 0, + D3D_SIT_TBUFFER, + D3D_SIT_TEXTURE, + D3D_SIT_SAMPLER, + D3D_SIT_UAV_RWTYPED, + D3D_SIT_STRUCTURED, + D3D_SIT_UAV_RWSTRUCTURED, + D3D_SIT_BYTEADDRESS, + D3D_SIT_UAV_RWBYTEADDRESS, + D3D_SIT_UAV_APPEND_STRUCTURED, + D3D_SIT_UAV_CONSUME_STRUCTURED, + D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER, + + D3D10_SIT_CBUFFER = 0, + D3D10_SIT_TBUFFER, + D3D10_SIT_TEXTURE, + D3D10_SIT_SAMPLER, + + D3D11_SIT_UAV_RWTYPED, + D3D11_SIT_STRUCTURED, + D3D11_SIT_UAV_RWSTRUCTURED, + D3D11_SIT_BYTEADDRESS, + D3D11_SIT_UAV_RWBYTEADDRESS, + D3D11_SIT_UAV_APPEND_STRUCTURED, + D3D11_SIT_UAV_CONSUME_STRUCTURED, + D3D11_SIT_UAV_RWSTRUCTURED_WITH_COUNTER, + } D3D_SHADER_INPUT_TYPE; + +typedef enum _D3D_SHADER_CBUFFER_FLAGS +{ + D3D_CBF_USERPACKED = 1, + + D3D10_CBF_USERPACKED = 1, + + D3D_CBF_FORCE_DWORD = 0x7fffffff +} D3D_SHADER_CBUFFER_FLAGS; + +typedef enum _D3D_CBUFFER_TYPE +{ + D3D_CT_CBUFFER = 0, + D3D_CT_TBUFFER, + D3D_CT_INTERFACE_POINTERS, + D3D_CT_RESOURCE_BIND_INFO, + + D3D10_CT_CBUFFER = 0, + D3D10_CT_TBUFFER, + + D3D11_CT_CBUFFER = 0, + D3D11_CT_TBUFFER, + D3D11_CT_INTERFACE_POINTERS, + D3D11_CT_RESOURCE_BIND_INFO, +} D3D_CBUFFER_TYPE; + +typedef enum D3D_NAME +{ + D3D_NAME_UNDEFINED = 0, + D3D_NAME_POSITION, + D3D_NAME_CLIP_DISTANCE, + D3D_NAME_CULL_DISTANCE, + D3D_NAME_RENDER_TARGET_ARRAY_INDEX, + D3D_NAME_VIEWPORT_ARRAY_INDEX, + D3D_NAME_VERTEX_ID, + D3D_NAME_PRIMITIVE_ID, + D3D_NAME_INSTANCE_ID, + D3D_NAME_IS_FRONT_FACE, + D3D_NAME_SAMPLE_INDEX, + D3D_NAME_FINAL_QUAD_EDGE_TESSFACTOR, + D3D_NAME_FINAL_QUAD_INSIDE_TESSFACTOR, + D3D_NAME_FINAL_TRI_EDGE_TESSFACTOR, + D3D_NAME_FINAL_TRI_INSIDE_TESSFACTOR, + D3D_NAME_FINAL_LINE_DETAIL_TESSFACTOR, + D3D_NAME_FINAL_LINE_DENSITY_TESSFACTOR, + + D3D_NAME_TARGET = 64, + D3D_NAME_DEPTH, + D3D_NAME_COVERAGE, + D3D_NAME_DEPTH_GREATER_EQUAL, + D3D_NAME_DEPTH_LESS_EQUAL, + + D3D10_NAME_UNDEFINED = 0, + D3D10_NAME_POSITION, + D3D10_NAME_CLIP_DISTANCE, + D3D10_NAME_CULL_DISTANCE, + D3D10_NAME_RENDER_TARGET_ARRAY_INDEX, + D3D10_NAME_VIEWPORT_ARRAY_INDEX, + D3D10_NAME_VERTEX_ID, + D3D10_NAME_PRIMITIVE_ID, + D3D10_NAME_INSTANCE_ID, + D3D10_NAME_IS_FRONT_FACE, + D3D10_NAME_SAMPLE_INDEX, + + D3D11_NAME_FINAL_QUAD_EDGE_TESSFACTOR, + D3D11_NAME_FINAL_QUAD_INSIDE_TESSFACTOR, + D3D11_NAME_FINAL_TRI_EDGE_TESSFACTOR, + D3D11_NAME_FINAL_TRI_INSIDE_TESSFACTOR, + D3D11_NAME_FINAL_LINE_DETAIL_TESSFACTOR, + D3D11_NAME_FINAL_LINE_DENSITY_TESSFACTOR, + + D3D10_NAME_TARGET = 64, + D3D10_NAME_DEPTH , + D3D10_NAME_COVERAGE, + + D3D11_NAME_DEPTH_GREATER_EQUAL, + D3D11_NAME_DEPTH_LESS_EQUAL, +} D3D_NAME; + +typedef enum D3D_RESOURCE_RETURN_TYPE +{ + D3D_RETURN_TYPE_UNORM = 1, + D3D_RETURN_TYPE_SNORM, + D3D_RETURN_TYPE_SINT, + D3D_RETURN_TYPE_UINT, + D3D_RETURN_TYPE_FLOAT, + D3D_RETURN_TYPE_MIXED, + D3D_RETURN_TYPE_DOUBLE, + D3D_RETURN_TYPE_CONTINUED, + + D3D10_RETURN_TYPE_UNORM = 1, + D3D10_RETURN_TYPE_SNORM, + D3D10_RETURN_TYPE_SINT, + D3D10_RETURN_TYPE_UINT, + D3D10_RETURN_TYPE_FLOAT, + D3D10_RETURN_TYPE_MIXED, + + D3D11_RETURN_TYPE_UNORM = 1, + D3D11_RETURN_TYPE_SNORM, + D3D11_RETURN_TYPE_SINT, + D3D11_RETURN_TYPE_UINT, + D3D11_RETURN_TYPE_FLOAT, + D3D11_RETURN_TYPE_MIXED, + D3D11_RETURN_TYPE_DOUBLE, + D3D11_RETURN_TYPE_CONTINUED, +} D3D_RESOURCE_RETURN_TYPE; + +typedef enum D3D_REGISTER_COMPONENT_TYPE +{ + D3D_REGISTER_COMPONENT_UNKNOWN = 0, + D3D_REGISTER_COMPONENT_UINT32, + D3D_REGISTER_COMPONENT_SINT32, + D3D_REGISTER_COMPONENT_FLOAT32, + + D3D10_REGISTER_COMPONENT_UNKNOWN = 0, + D3D10_REGISTER_COMPONENT_UINT32, + D3D10_REGISTER_COMPONENT_SINT32, + D3D10_REGISTER_COMPONENT_FLOAT32, +} D3D_REGISTER_COMPONENT_TYPE; + +typedef enum D3D_TESSELLATOR_DOMAIN +{ + D3D_TESSELLATOR_DOMAIN_UNDEFINED = 0, + D3D_TESSELLATOR_DOMAIN_ISOLINE, + D3D_TESSELLATOR_DOMAIN_TRI, + D3D_TESSELLATOR_DOMAIN_QUAD, + + D3D11_TESSELLATOR_DOMAIN_UNDEFINED = 0, + D3D11_TESSELLATOR_DOMAIN_ISOLINE, + D3D11_TESSELLATOR_DOMAIN_TRI, + D3D11_TESSELLATOR_DOMAIN_QUAD, +} D3D_TESSELLATOR_DOMAIN; + +typedef enum D3D_TESSELLATOR_PARTITIONING +{ + D3D_TESSELLATOR_PARTITIONING_UNDEFINED = 0, + D3D_TESSELLATOR_PARTITIONING_INTEGER, + D3D_TESSELLATOR_PARTITIONING_POW2, + D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD, + D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN, + + D3D11_TESSELLATOR_PARTITIONING_UNDEFINED = 0, + D3D11_TESSELLATOR_PARTITIONING_INTEGER, + D3D11_TESSELLATOR_PARTITIONING_POW2, + D3D11_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD, + D3D11_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN, +} D3D_TESSELLATOR_PARTITIONING; + +typedef enum D3D_TESSELLATOR_OUTPUT_PRIMITIVE +{ + D3D_TESSELLATOR_OUTPUT_UNDEFINED = 0, + D3D_TESSELLATOR_OUTPUT_POINT, + D3D_TESSELLATOR_OUTPUT_LINE, + D3D_TESSELLATOR_OUTPUT_TRIANGLE_CW, + D3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW, + + D3D11_TESSELLATOR_OUTPUT_UNDEFINED = 0, + D3D11_TESSELLATOR_OUTPUT_POINT, + D3D11_TESSELLATOR_OUTPUT_LINE, + D3D11_TESSELLATOR_OUTPUT_TRIANGLE_CW, + D3D11_TESSELLATOR_OUTPUT_TRIANGLE_CCW, +} D3D_TESSELLATOR_OUTPUT_PRIMITIVE; + diff --git a/src/gallium/state_trackers/d3d1x/d3dapi/dxgi.idl b/src/gallium/state_trackers/d3d1x/d3dapi/dxgi.idl new file mode 100644 index 00000000000..86ef261f671 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3dapi/dxgi.idl @@ -0,0 +1,470 @@ +/* + * Copyright 2007 Andras Kovacs + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/*DXGI 1.1 IDL, and missing DXGI 1.0 parts added by Luca Barbieri on Sep 2010 */ + +import "dxgitype.idl"; + +const UINT _FACDXGI = 0x87a; + +cpp_quote("#define MAKE_DXGI_STATUS(x) MAKE_HRESULT(0, _FACDXGI, x)") +cpp_quote("#define DXGI_STATUS_OCCLUDED MAKE_DXGI_STATUS(1)") +cpp_quote("#define DXGI_STATUS_CLIPPED MAKE_DXGI_STATUS(2)") +cpp_quote("#define DXGI_STATUS_NO_REDIRECTION MAKE_DXGI_STATUS(4)") +cpp_quote("#define DXGI_STATUS_NO_DESKTOP_ACCESS MAKE_DXGI_STATUS(5)") +cpp_quote("#define DXGI_STATUS_GRAPHICS_VIDPN_SOURCE_IN_USE MAKE_DXGI_STATUS(6)") +cpp_quote("#define DXGI_STATUS_MODE_CHANGED MAKE_DXGI_STATUS(7)") +cpp_quote("#define DXGI_STATUS_MODE_CHANGE_IN_PROGRESS MAKE_DXGI_STATUS(8)") + +cpp_quote("#define MAKE_DXGI_HRESULT(x) MAKE_HRESULT(1, _FACDXGI, x)") +cpp_quote("#define DXGI_ERROR_INVALID_CALL MAKE_DXGI_HRESULT(1)") +cpp_quote("#define DXGI_ERROR_NOT_FOUND MAKE_DXGI_HRESULT(2)") +cpp_quote("#define DXGI_ERROR_MORE_DATA MAKE_DXGI_HRESULT(3)") +cpp_quote("#define DXGI_ERROR_UNSUPPORTED MAKE_DXGI_HRESULT(4)") +cpp_quote("#define DXGI_ERROR_DEVICE_REMOVED MAKE_DXGI_HRESULT(5)") +cpp_quote("#define DXGI_ERROR_DEVICE_HUNG MAKE_DXGI_HRESULT(6)") +cpp_quote("#define DXGI_ERROR_DEVICE_RESET MAKE_DXGI_HRESULT(7)") +cpp_quote("#define DXGI_ERROR_WAS_STILL_DRAWING MAKE_DXGI_HRESULT(10)") +cpp_quote("#define DXGI_ERROR_FRAME_STATISTICS_DISJOINT MAKE_DXGI_HRESULT(11)") +cpp_quote("#define DXGI_ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE MAKE_DXGI_HRESULT(12)") +cpp_quote("#define DXGI_ERROR_DRIVER_INTERNAL_ERROR MAKE_DXGI_HRESULT(32)") +cpp_quote("#define DXGI_ERROR_NONEXCLUSIVE MAKE_DXGI_HRESULT(33)") +cpp_quote("#define DXGI_ERROR_NOT_CURRENTLY_AVAILABLE MAKE_DXGI_HRESULT(34)") + +cpp_quote("#if 0") +typedef HANDLE HMONITOR; +typedef struct _LUID { + DWORD LowPart; + LONG HighPart; +} LUID, *PLUID; +cpp_quote("#endif") + +typedef UINT DXGI_USAGE; +const DXGI_USAGE DXGI_USAGE_SHADER_INPUT = 0x10L; +const DXGI_USAGE DXGI_USAGE_RENDER_TARGET_OUTPUT = 0x20L; +const DXGI_USAGE DXGI_USAGE_BACK_BUFFER = 0x40L; +const DXGI_USAGE DXGI_USAGE_SHARED = 0x80L; +const DXGI_USAGE DXGI_USAGE_READ_ONLY = 0x100L; + +typedef enum DXGI_SWAP_EFFECT { + DXGI_SWAP_EFFECT_DISCARD = 0, + DXGI_SWAP_EFFECT_SEQUENTIAL = 1, +} DXGI_SWAP_EFFECT; + +typedef enum DXGI_RESIDENCY { + DXGI_RESIDENCY_FULLY_RESIDENT = 1, + DXGI_RESIDENCY_RESIDENT_IN_SHARED_MEMORY = 2, + DXGI_RESIDENCY_EVICTED_TO_DISK = 3, +} DXGI_RESIDENCY; + +typedef struct DXGI_SURFACE_DESC { + UINT Width; + UINT Height; + DXGI_FORMAT Format; + DXGI_SAMPLE_DESC SampleDesc; +} DXGI_SURFACE_DESC; + +typedef struct DXGI_MAPPED_RECT { + INT Pitch; + BYTE *pBits; +} DXGI_MAPPED_RECT; + +typedef struct DXGI_OUTPUT_DESC { + WCHAR DeviceName[32]; + RECT DesktopCoordinates; + BOOL AttachedToDesktop; + DXGI_MODE_ROTATION Rotation; + HMONITOR Monitor; +} DXGI_OUTPUT_DESC; + +typedef struct DXGI_FRAME_STATISTICS { + UINT PresentCount; + UINT PresentRefreshCount; + UINT SyncRefreshCount; + LARGE_INTEGER SyncQPCTime; + LARGE_INTEGER SyncGPUTime; +} DXGI_FRAME_STATISTICS; + +typedef struct DXGI_ADAPTER_DESC { + WCHAR Description[128]; + UINT VendorId; + UINT DeviceId; + UINT SubSysId; + UINT Revision; + SIZE_T DedicatedVideoMemory; + SIZE_T DedicatedSystemMemory; + SIZE_T SharedSystemMemory; + LUID AdapterLuid; +} DXGI_ADAPTER_DESC; + +typedef struct DXGI_SWAP_CHAIN_DESC { + DXGI_MODE_DESC BufferDesc; + DXGI_SAMPLE_DESC SampleDesc; + DXGI_USAGE BufferUsage; + UINT BufferCount; + HWND OutputWindow; + BOOL Windowed; + DXGI_SWAP_EFFECT SwapEffect; + UINT Flags; +} DXGI_SWAP_CHAIN_DESC; + +typedef struct DXGI_SHARED_RESOURCE { + HANDLE Handle; +} DXGI_SHARED_RESOURCE; + +[ + object, + local, + uuid(aec22fb8-76f3-4639-9be0-28eb43a67a2e) +] +interface IDXGIObject : IUnknown +{ + HRESULT SetPrivateData( + [in] REFGUID a, + [in] UINT b, + [in] const void *c + ); + HRESULT SetPrivateDataInterface( + [in] REFGUID a, + [in] const IUnknown *b + ); + HRESULT GetPrivateData( + [in] REFGUID a, + [in, out] UINT *b, + [out] void *c + ); + HRESULT GetParent( + [in] REFIID a, + [out] void **b + ); +} + +[ + object, + local, + uuid(3d3e0379-f9de-4d58-bb6c-18d62992f1a6) +] +interface IDXGIDeviceSubObject : IDXGIObject +{ + HRESULT GetDevice( + [in] REFIID a, + [out] void **b + ); +} + +[ + object, + local, + uuid(cafcb56c-6ac3-4889-bf47-9e23bbd260ec) +] +interface IDXGISurface : IDXGIDeviceSubObject +{ + HRESULT GetDesc( + [out] DXGI_SURFACE_DESC *a + ); + HRESULT Map( + [out] DXGI_MAPPED_RECT *a, + [in] UINT b + ); + HRESULT Unmap( + ); +} + +[ + object, + local, + uuid(ae02eedb-c735-4690-8d52-5a8dc20213aa) +] +interface IDXGIOutput : IDXGIObject +{ + HRESULT GetDesc( + [out] DXGI_OUTPUT_DESC *a + ); + HRESULT GetDisplayModeList( + [in] DXGI_FORMAT a, + [in] UINT b, + [in, out] UINT *c, + [out] DXGI_MODE_DESC *d + ); + HRESULT FindClosestMatchingMode( + [in] const DXGI_MODE_DESC *a, + [out] DXGI_MODE_DESC *b, + [in] IUnknown *c + ); + HRESULT WaitForVBlank( + ); + HRESULT TakeOwnership( + [in] IUnknown *a, + [in] BOOL b + ); + void ReleaseOwnership( + ); + HRESULT GetGammaControlCapabilities( + [out] DXGI_GAMMA_CONTROL_CAPABILITIES *a + ); + HRESULT SetGammaControl( + [in] const DXGI_GAMMA_CONTROL *a + ); + HRESULT GetGammaControl( + [out] DXGI_GAMMA_CONTROL *a + ); + HRESULT SetDisplaySurface( + [in] IDXGISurface *a + ); + HRESULT GetDisplaySurfaceData( + [in] IDXGISurface *a + ); + HRESULT GetFrameStatistics( + [out] DXGI_FRAME_STATISTICS *a + ); +} + +[ + object, + local, + uuid(2411e7e1-12ac-4ccf-bd14-9798e8534dc0) +] +interface IDXGIAdapter : IDXGIObject +{ + HRESULT EnumOutputs( + [in] UINT a, + [in, out] IDXGIOutput **b + ); + HRESULT GetDesc( + [out] DXGI_ADAPTER_DESC *a + ); + HRESULT CheckInterfaceSupport( + [in] REFGUID a, + [out] LARGE_INTEGER *b + ); +} + +[ + object, + local, + uuid(310d36a0-d2e7-4c0a-aa04-6a9d23b8886a) +] +interface IDXGISwapChain : IDXGIDeviceSubObject +{ + HRESULT Present( + [in] UINT a, + [in] UINT b + ); + HRESULT GetBuffer( + [in] UINT a, + [in] REFIID b, + [in, out] void **c + ); + HRESULT SetFullscreenState( + [in] BOOL a, + [in] IDXGIOutput *b + ); + HRESULT GetFullscreenState( + [out] BOOL *a, + [out] IDXGIOutput **b + ); + HRESULT GetDesc( + [out] DXGI_SWAP_CHAIN_DESC *a + ); + HRESULT ResizeBuffers( + [in] UINT a, + [in] UINT b, + [in] UINT c, + [in] DXGI_FORMAT d, + [in] UINT e + ); + HRESULT ResizeTarget( + [in] const DXGI_MODE_DESC *a + ); + HRESULT GetContainingOutput( + [out] IDXGIOutput **a + ); + HRESULT GetFrameStatistics( + [out] DXGI_FRAME_STATISTICS *a + ); + HRESULT GetLastPresentCount( + [out] UINT *a + ); +} + +[ + object, + local, + uuid(7b7166ec-21c7-44ae-b21a-c9ae321ae369) +] +interface IDXGIFactory : IDXGIObject +{ + HRESULT EnumAdapters( + [in] UINT a, + [out] IDXGIAdapter **b + ); + HRESULT MakeWindowAssociation( + [in] HWND a, + [in] UINT b + ); + HRESULT GetWindowAssociation( + [in] HWND *a + ); + HRESULT CreateSwapChain( + [in] IUnknown *a, + [in] DXGI_SWAP_CHAIN_DESC *b, + [out] IDXGISwapChain **c + ); + HRESULT CreateSoftwareAdapter( + [in] HMODULE a, + [out] IDXGIAdapter **b + ); +} + +[local] HRESULT CreateDXGIFactory(REFIID riid, void **factory); + +[ + object, + local, + uuid(54ec77fa-1377-44e6-8c32-88fd5f44c84c) +] +interface IDXGIDevice : IDXGIObject +{ + HRESULT GetAdapter( + [out] IDXGIAdapter **a + ); + HRESULT CreateSurface( + [in] const DXGI_SURFACE_DESC *a, + [in] UINT b, + [in] DXGI_USAGE c, + [in] const DXGI_SHARED_RESOURCE *d, + [out] IDXGISurface **e + ); + HRESULT QueryResourceResidency( + [in] IUnknown *const *a, + [out] DXGI_RESIDENCY *b, + [in] UINT c + ); + HRESULT SetGPUThreadPriority( + [in] INT a + ); + HRESULT GetGPUThreadPriority( + [out] INT *a + ); +} + + +// BEGIN parts added for Gallium + +const unsigned int DXGI_MAP_READ = 1; +const unsigned int DXGI_MAP_WRITE = 2; +const unsigned int DXGI_MAP_DISCARD = 4; + +const unsigned int DXGI_CPU_ACCESS_NONE = 0; +const unsigned int DXGI_CPU_ACCESS_DYNAMIC = 1; +const unsigned int DXGI_CPU_ACCESS_READ_WRITE = 2; +const unsigned int DXGI_CPU_ACCESS_SCRATCH = 3; +const unsigned int DXGI_CPU_ACCESS_FIELD = 15; +const unsigned int DXGI_USAGE_DISCARD_ON_PRESENT = 0x200; +const unsigned int DXGI_USAGE_UNORDERED_ACCESS = 0x400; + +const unsigned int DXGI_PRESENT_TEST = 1; +const unsigned int DXGI_PRESENT_DO_NOT_SEQUENCE = 2; +const unsigned int DXGI_PRESENT_RESTART = 4; + +typedef enum DXGI_SWAP_CHAIN_FLAG +{ + DXGI_SWAP_CHAIN_FLAG_NONPREROTATED = 1, + DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH = 2, + DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE = 4 +} DXGI_SWAP_CHAIN_FLAG; + +typedef struct DXGI_ADAPTER_DESC1 +{ + WCHAR Description[128]; + UINT VendorId; + UINT DeviceId; + UINT SubSysId; + UINT Revision; + SIZE_T DedicatedVideoMemory; + SIZE_T DedicatedSystemMemory; + SIZE_T SharedSystemMemory; + LUID AdapterLuid; + UINT Flags; +} DXGI_ADAPTER_DESC1; + +[object, local, uuid("035f3ab4-482e-4e50-b41f-8a7f8bd8960b")] +interface IDXGIResource : IDXGIDeviceSubObject +{ + HRESULT GetSharedHandle( + [out] HANDLE *a + ); + + HRESULT GetUsage( + [out] DXGI_USAGE *a + ); + + HRESULT SetEvictionPriority( + [in] UINT a + ); + + HRESULT GetEvictionPriority( + [out] UINT *a + ); +}; + +[object, local, uuid("4AE63092-6327-4c1b-80AE-BFE12EA32B86")] +interface IDXGISurface1 : IDXGISurface +{ + HRESULT GetDC( + [in] BOOL a, + [out] HDC *b + ); + + HRESULT ReleaseDC( + [in, optional] RECT *a + ); + }; + +[object, local, uuid("77db970f-6276-48ba-ba28-070143b4392c")] +interface IDXGIDevice1 : IDXGIDevice +{ + HRESULT SetMaximumFrameLatency( + [in] UINT a + ); + + HRESULT GetMaximumFrameLatency( + [out] UINT *a + ); +}; + +[object, local, uuid("29038f61-3839-4626-91fd-086879011a05")] +interface IDXGIAdapter1 : IDXGIAdapter +{ + HRESULT GetDesc1( + [out] DXGI_ADAPTER_DESC1 *a + ); +}; + +[object, local, uuid("770aae78-f26f-4dba-a829-253c83d1b387")] +interface IDXGIFactory1 : IDXGIFactory +{ + HRESULT EnumAdapters1( + [in] UINT a, + [out] IDXGIAdapter1 **b + ); + + BOOL IsCurrent(); +}; + +[local] HRESULT CreateDXGIFactory1(REFIID riid, void **factory); diff --git a/src/gallium/state_trackers/d3d1x/d3dapi/dxgiformat.idl b/src/gallium/state_trackers/d3d1x/d3dapi/dxgiformat.idl new file mode 100644 index 00000000000..28846e96014 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3dapi/dxgiformat.idl @@ -0,0 +1,129 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + +typedef enum DXGI_FORMAT { + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R32G32B32A32_TYPELESS, + DXGI_FORMAT_R32G32B32A32_FLOAT, + DXGI_FORMAT_R32G32B32A32_UINT, + DXGI_FORMAT_R32G32B32A32_SINT, + DXGI_FORMAT_R32G32B32_TYPELESS, + DXGI_FORMAT_R32G32B32_FLOAT, + DXGI_FORMAT_R32G32B32_UINT, + DXGI_FORMAT_R32G32B32_SINT, + DXGI_FORMAT_R16G16B16A16_TYPELESS, + DXGI_FORMAT_R16G16B16A16_FLOAT, + DXGI_FORMAT_R16G16B16A16_UNORM, + DXGI_FORMAT_R16G16B16A16_UINT, + DXGI_FORMAT_R16G16B16A16_SNORM, + DXGI_FORMAT_R16G16B16A16_SINT, + DXGI_FORMAT_R32G32_TYPELESS, + DXGI_FORMAT_R32G32_FLOAT, + DXGI_FORMAT_R32G32_UINT, + DXGI_FORMAT_R32G32_SINT, + DXGI_FORMAT_R32G8X24_TYPELESS, + DXGI_FORMAT_D32_FLOAT_S8X24_UINT, + DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS, + DXGI_FORMAT_X32_TYPELESS_G8X24_UINT, + DXGI_FORMAT_R10G10B10A2_TYPELESS, + DXGI_FORMAT_R10G10B10A2_UNORM, + DXGI_FORMAT_R10G10B10A2_UINT, + DXGI_FORMAT_R11G11B10_FLOAT, + DXGI_FORMAT_R8G8B8A8_TYPELESS, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UINT, + DXGI_FORMAT_R8G8B8A8_SNORM, + DXGI_FORMAT_R8G8B8A8_SINT, + DXGI_FORMAT_R16G16_TYPELESS, + DXGI_FORMAT_R16G16_FLOAT, + DXGI_FORMAT_R16G16_UNORM, + DXGI_FORMAT_R16G16_UINT, + DXGI_FORMAT_R16G16_SNORM, + DXGI_FORMAT_R16G16_SINT, + DXGI_FORMAT_R32_TYPELESS, + DXGI_FORMAT_D32_FLOAT, + DXGI_FORMAT_R32_FLOAT, + DXGI_FORMAT_R32_UINT, + DXGI_FORMAT_R32_SINT, + DXGI_FORMAT_R24G8_TYPELESS, + DXGI_FORMAT_D24_UNORM_S8_UINT, + DXGI_FORMAT_R24_UNORM_X8_TYPELESS, + DXGI_FORMAT_X24_TYPELESS_G8_UINT, + DXGI_FORMAT_R8G8_TYPELESS, + DXGI_FORMAT_R8G8_UNORM, + DXGI_FORMAT_R8G8_UINT, + DXGI_FORMAT_R8G8_SNORM, + DXGI_FORMAT_R8G8_SINT, + DXGI_FORMAT_R16_TYPELESS, + DXGI_FORMAT_R16_FLOAT, + DXGI_FORMAT_D16_UNORM, + DXGI_FORMAT_R16_UNORM, + DXGI_FORMAT_R16_UINT, + DXGI_FORMAT_R16_SNORM, + DXGI_FORMAT_R16_SINT, + DXGI_FORMAT_R8_TYPELESS, + DXGI_FORMAT_R8_UNORM, + DXGI_FORMAT_R8_UINT, + DXGI_FORMAT_R8_SNORM, + DXGI_FORMAT_R8_SINT, + DXGI_FORMAT_A8_UNORM, + DXGI_FORMAT_R1_UNORM, + DXGI_FORMAT_R9G9B9E5_SHAREDEXP, + DXGI_FORMAT_R8G8_B8G8_UNORM, + DXGI_FORMAT_G8R8_G8B8_UNORM, + DXGI_FORMAT_BC1_TYPELESS, + DXGI_FORMAT_BC1_UNORM, + DXGI_FORMAT_BC1_UNORM_SRGB, + DXGI_FORMAT_BC2_TYPELESS, + DXGI_FORMAT_BC2_UNORM, + DXGI_FORMAT_BC2_UNORM_SRGB, + DXGI_FORMAT_BC3_TYPELESS, + DXGI_FORMAT_BC3_UNORM, + DXGI_FORMAT_BC3_UNORM_SRGB, + DXGI_FORMAT_BC4_TYPELESS, + DXGI_FORMAT_BC4_UNORM, + DXGI_FORMAT_BC4_SNORM, + DXGI_FORMAT_BC5_TYPELESS, + DXGI_FORMAT_BC5_UNORM, + DXGI_FORMAT_BC5_SNORM, + DXGI_FORMAT_B5G6R5_UNORM, + DXGI_FORMAT_B5G5R5A1_UNORM, + DXGI_FORMAT_B8G8R8A8_UNORM, + DXGI_FORMAT_B8G8R8X8_UNORM, + DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM, + DXGI_FORMAT_B8G8R8A8_TYPELESS, + DXGI_FORMAT_B8G8R8A8_UNORM_SRGB, + DXGI_FORMAT_B8G8R8X8_TYPELESS, + DXGI_FORMAT_B8G8R8X8_UNORM_SRGB, + DXGI_FORMAT_BC6H_TYPELESS, + DXGI_FORMAT_BC6H_UF16, + DXGI_FORMAT_BC6H_SF16, + DXGI_FORMAT_BC7_TYPELESS, + DXGI_FORMAT_BC7_UNORM, + DXGI_FORMAT_BC7_UNORM_SRGB, + DXGI_FORMAT_FORCE_UINT = 0xffffffff +} DXGI_FORMAT; diff --git a/src/gallium/state_trackers/d3d1x/d3dapi/dxgitype.idl b/src/gallium/state_trackers/d3d1x/d3dapi/dxgitype.idl new file mode 100644 index 00000000000..31eba08cff3 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/d3dapi/dxgitype.idl @@ -0,0 +1,84 @@ +/* + * Copyright 2007 Andras Kovacs + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* DXGI 1.1 IDL, and missing DXGI 1.0 parts added by Luca Barbieri on Sep 2010 */ + +import "oaidl.idl"; +import "ocidl.idl"; + +import "dxgiformat.idl"; + +typedef struct DXGI_SAMPLE_DESC { + UINT Count; + UINT Quality; +} DXGI_SAMPLE_DESC; + +typedef enum DXGI_MODE_ROTATION { + DXGI_MODE_ROTATION_UNSPECIFIED = 0, + DXGI_MODE_ROTATION_IDENTITY = 1, + DXGI_MODE_ROTATION_ROTATE90 = 2, + DXGI_MODE_ROTATION_ROTATE180 = 3, + DXGI_MODE_ROTATION_ROTATE270 = 4, +} DXGI_MODE_ROTATION; + +typedef enum DXGI_MODE_SCANLINE_ORDER { + DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED = 0, + DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE = 1, + DXGI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST = 2, + DXGI_MODE_SCANLINE_ORDER_LOWER_FIELD_FIRST = 3, +} DXGI_MODE_SCANLINE_ORDER; + +typedef enum DXGI_MODE_SCALING { + DXGI_MODE_SCALING_UNSPECIFIED = 0, + DXGI_MODE_SCALING_CENTERED = 1, + DXGI_MODE_SCALING_STRETCHED = 2, +} DXGI_MODE_SCALING; + +typedef struct DXGI_RATIONAL { + UINT Numerator; + UINT Denominator; +} DXGI_RATIONAL; + +typedef struct DXGI_MODE_DESC { + UINT Width; + UINT Height; + DXGI_RATIONAL RefreshRate; + DXGI_FORMAT Format; + DXGI_MODE_SCANLINE_ORDER ScanlineOrdering; + DXGI_MODE_SCALING Scaling; +} DXGI_MODE_DESC; + +typedef struct DXGI_GAMMA_CONTROL_CAPABILITIES { + BOOL ScaleAndOffsetSupported; + float MaxConvertedValue; + float MinConvertedValue; + UINT NumGammaControlPoints; + float ControlPointPositions[1025]; +} DXGI_GAMMA_CONTROL_CAPABILITIES; + +typedef struct DXGI_RGB { + float Red; + float Green; + float Blue; +} DXGI_RGB; + +typedef struct DXGI_GAMMA_CONTROL { + DXGI_RGB Scale; + DXGI_RGB Offset; + DXGI_RGB GammaCurve[1025]; +} DXGI_GAMMA_CONTROL; diff --git a/src/gallium/state_trackers/d3d1x/docs/Makefile b/src/gallium/state_trackers/d3d1x/docs/Makefile new file mode 100644 index 00000000000..7f38fa73fb4 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/docs/Makefile @@ -0,0 +1,5 @@ +all: module_dependencies.svg module_dependencies.pdf +.IGNORE: module_dependencies.svg module_dependencies.pdf + +include ../Makefile.inc + diff --git a/src/gallium/state_trackers/d3d1x/docs/coding_style.txt b/src/gallium/state_trackers/d3d1x/docs/coding_style.txt new file mode 100644 index 00000000000..fb09417eac6 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/docs/coding_style.txt @@ -0,0 +1,84 @@ +The goal of these guidelines is to allow as much freedom as possible, while keeping the code buildable and pleasant to read. + +* Formatting + +- Indent with a single tab character. This is the best choice, since anyone can use the visual indentation he prefers by adjust the tab width setting in his editor. +- Align multiline statements with an additional extra tab before each continuation line +- Keep in mind that people can program with proportional fonts: hence, don't attempt to align anything not at the start of the line, since it's impossible +- In general, there should never be two consecutive spaces in the source code +- There is no strict limit on line length, but try to not make lines too long, and insert a line break where it looks good + +* Language/platform features + +All language features of C++03 with TR1 and all the STL library may be used. +Obviously, try to keep the code simple, readable and intuitive, code size small, and compilation time short where possible. +Platform/compiler-specific extensions can be used if beneficial, protected by #ifs. + +C++0x is currently not used since it's unreleased and currently not well supported by clang. +Once GCC, clang and Visual C++ all have very good or complete support, and ideally the standard is finalized, we can start taking advantage of it. +Change this document once that happens. + +Boost is currently not used because it hasn't been necessary and it's best to keep things simple. +If really necessary, add a dependency on it, but use it judiciously. + +C should be used only for old code, and preferably completely avoided. + +You can freely assume that char is 8-bit, short 16-bit and int 32-bit, that long and pointers are 32-bit or 64-bit, that long long is at least 64-bit, that float is 32-bit and that double is 64-bit. +However, when you intend a specific size, int8_t, etc. are preferred. + +* Naming style + + Code implementing public parts of Windows interfaces (and derived ones) should follow Windows naming conventions: + - Classes are like GalliumD3D11VertexShader + - Functions are like CreateVertexShader + - Variables are like ppVertexShader + + Other code should follow Gallium/Linux/POSIX/STL/Boost naming conventions: + - Classes are like maybe_mutex_t + - Functions are like xs_create_shader + - Variables are like sampler_view + + Template parameters are named accordingly to what looks best for the specific case. + Typically it will be FooBar for typename parameters and foo_bar for non-typename ones. + + * Implementation style + +See the comments in d3d1xstutil.h for the COM implementation method. +In particular, avoid multiple/virtual inheritance in favor of mixins where possible. + +Try to limit or avoid preprocessor magic and multiline macros and use templates instead where possible. +Often, you can lessen the preprocessor magic by putting some of it in a template instantiated by the remaining magic. + +Forward declarations should not be used unless necessary. +In particular C++ classes should be implemented "inline" and should you should almost never have a forward declaration of a class. +To achieve this, you can opt to create an "interface class", which goes into an header or earlier in the C++ file, and an "implementation class" with goes in the C++ file. +Alternatively, use global helpers with forward declaration. + +Order definitions so that forward declarations are not necessary (e.g. put main at the end of the file). + +Choose between "struct" or "class" depending on whether the first declared member is public or private, to save the explicit specifier. + +Try to use const appropriately, esp. as a qualifier for member functions. + +Try to avoid Microsoft-style TYPES like FLOAT, UINT, etc. in favor of the usual C types like float, unsigned. + +Where feasible, if a platform is missing a function/keyword, add a definition of it with the standard name, rather than inventing an "abstraction layer". + +Try to use typedefs for STL maps on which you need to declare iterations, as well as function pointers or other "weird" C types. + + To iterate, use the following idiom from LLVM, which is optimal, unless end() is trivial: + for(iterator_type i = begin(), e = end(); i != e; ++i) + {} + + Otherwise, you risk the compiler evaluating end() for each loop iteration. + If end() is trivial, use this: + for(iterator_type i = begin(); i != end(); ++i) + {} + + Note the "++i" instead of the "i++" to avoid creating an unnecessary copy (esp. with overloaded operators). + + Declare variables just before they are needed, and inside the for() header. + Usually, you should initialize variable in the declaration if that's the only assignment or if it is a default value, and as a separate assignment if not. + +Try to use C++ references (with const if appropriate) when the pointer must be non-null, and that type is not already customarily passed with a pointer. + diff --git a/src/gallium/state_trackers/d3d1x/docs/module_dependencies.dot b/src/gallium/state_trackers/d3d1x/docs/module_dependencies.dot new file mode 100644 index 00000000000..3db6fb2167a --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/docs/module_dependencies.dot @@ -0,0 +1,25 @@ +digraph module_dependencies +{ + d3dapi -> w32api; + gd3dapi -> d3dapi; + progs -> d3dapi [style="dotted"]; + progs -> gd3dapi [style="dotted"]; + progs -> microsoft_directx_sdk [style="dotted"]; + d3d1xstutil -> gd3dapi + d3d1xshader -> d3dapi + gd3d1x -> d3d1xshader; + gd3d1x -> d3d1xstutil; + gd3d10 -> gd3d1x; + gd3d11 -> gd3d1x; + dxgi -> d3d1xstutil; + dxgi -> gd3dapi; + dxgid3d10 -> gd3dapi; + dxgid3d11 -> gd3dapi; + "d3d11.dll" -> gd3d11; + "d3d11.dll" -> dxgid3d11; + "d3d10.dll" -> gd3d10; + "d3d10.dll" -> dxgid3d10; + "dxgi.dll" -> dxgi; + tools -> mstools + mstools -> microsoft_directx_sdk +}; diff --git a/src/gallium/state_trackers/d3d1x/docs/source_layout.txt b/src/gallium/state_trackers/d3d1x/docs/source_layout.txt new file mode 100644 index 00000000000..46e9f2d9832 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/docs/source_layout.txt @@ -0,0 +1,17 @@ +Source layout and architecture of the Gallium D3D state tracker + +w32api is a link to Wine's include files for the Windows API +d3dapi contains the headers for Direct3D 10.0, 10.1 and 11.0 (independently created, except d3d10 which is based on Wine) +gd3dapi contains the Gallium COM state tracker API and extensions to the DXGI and Direct3D APIs, both for internal and external usage +d3d1xshader is a standalone module with a parser, disassembler and utility routines for Direct3D 10/11 shaders using Shader Model 4/5 instructions encoded using Tokenized Program Format embedded in a DXBC chunked container (the data format produced by the HLSL compiler). +mstools contains a downloader for the Microsoft HLSL compiler +tools contains the shader compiler, currently wrapping the Microsoft HLSL compiler +gd3d10 contains the implementation of Direct3D 10 and 10.1 with Gallium-specific entry points +gd3d11 contains the implementation of Direct3D 11 with Gallium-specific entry points +gd3d1x contains the shader translator and code not directly implementing Direct3D interfaces, but needed by those implementations +dxgid3d10 contains the DXGI-based "official" entry points to Direct3D 10.0 and 10.1 +dxgid3d11 contains the DXGI-based "official" entry points to Direct3D 11 +dxgi contains the implementation of DXGI (currently over the EGL native interface) +d3d1xstutil contains helper code shared among all the modules in the state tracker +programs contains the Gallium Direct3D 11 demos, runnable either on the Microsoft or Gallium implementations +docs contains documentation diff --git a/src/gallium/state_trackers/d3d1x/dxgi/Makefile b/src/gallium/state_trackers/d3d1x/dxgi/Makefile new file mode 100644 index 00000000000..6cdc33b8c4b --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/dxgi/Makefile @@ -0,0 +1,17 @@ +LIBNAME=dxgi +LIBRARY_INCLUDES=-I../../../../../include -Iinclude -I../gd3dapi -I../d3dapi -I../w32api -I../d3d1xstutil/include -I../include -I../../../include -I../../../auxiliary -I../../../state_trackers/egl/common +LIBRARY_DEFINES=-DDXGI_DRIVER_SEARCH_DIR=\"$(EGL_DRIVER_INSTALL_DIR)\" +CPP_SOURCES=$(wildcard src/*.cpp) + +include ../Makefile.inc + +ifneq ($(findstring x11, $(EGL_PLATFORMS)),) +LIBRARY_DEFINES += -DGALLIUM_DXGI_USE_X11 +endif +ifneq ($(findstring drm, $(EGL_PLATFORMS)),) +LIBRARY_DEFINES += -DGALLIUM_DXGI_USE_DRM +endif +ifneq ($(findstring fbdev, $(EGL_PLATFORMS)),) +LIBRARY_DEFINES += -DGALLIUM_DXGI_USE_FBDEV +endif + diff --git a/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_loader.cpp b/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_loader.cpp new file mode 100644 index 00000000000..7b720194589 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_loader.cpp @@ -0,0 +1,206 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * 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 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 AUTHORS OR COPYRIGHT HOLDERS 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. + * + * Authors: + * Chia-I Wu <[email protected]> + */ + +#include "dxgi_private.h" +#include <stdio.h> +extern "C" +{ +#include "state_tracker/drm_driver.h" +#include "util/u_dl.h" +} +#define PIPE_PREFIX "pipe_" + +static const char * +get_search_path(void) +{ + static const char *search_path; + + if (!search_path) { + static char buffer[1024]; + const char *p; + int ret; + + p = getenv("DXGI_DRIVERS_PATH"); + if(!p) + p = getenv("EGL_DRIVERS_PATH"); +#ifdef __unix__ + if (p && (geteuid() != getuid() || getegid() != getgid())) { + p = NULL; + } +#endif + + if (p) { + ret = snprintf(buffer, sizeof(buffer), + "%s:%s", p, DXGI_DRIVER_SEARCH_DIR); + if (ret > 0 && ret < (int)sizeof(buffer)) + search_path = buffer; + } + } + if (!search_path) + search_path = DXGI_DRIVER_SEARCH_DIR; + + return search_path; +} + +static void +for_each_colon_separated(const char *search_path, + bool (*loader)(const char *, size_t, void *), + void *loader_data) +{ + const char *cur, *next; + size_t len; + + cur = search_path; + while (cur) { + next = strchr(cur, ':'); + len = (next) ? next - cur : strlen(cur); + + if (!loader(cur, len, loader_data)) + break; + + cur = (next) ? next + 1 : NULL; + } +} + +void +for_each_in_search_path(bool (*callback)(const char *, size_t, void *), + void *callback_data) +{ + const char *search_path = get_search_path(); + for_each_colon_separated(search_path, callback, callback_data); +} + +static struct pipe_module { + boolean initialized; + char *name; + struct util_dl_library *lib; + const struct drm_driver_descriptor *drmdd; + struct pipe_screen *(*swrast_create_screen)(struct sw_winsys *); +} pipe_modules[16]; + +static bool +dlopen_pipe_module_cb(const char *dir, size_t len, void *callback_data) +{ + struct pipe_module *pmod = (struct pipe_module *) callback_data; + char path[1024]; + int ret; + + if (len) { + ret = snprintf(path, sizeof(path), + "%.*s/" PIPE_PREFIX "%s" UTIL_DL_EXT, len, dir, pmod->name); + } + else { + ret = snprintf(path, sizeof(path), + PIPE_PREFIX "%s" UTIL_DL_EXT, pmod->name); + } + if (ret > 0 && ret < (int)sizeof(path)) { + pmod->lib = util_dl_open(path); + } + + return !(pmod->lib); +} + +static bool +load_pipe_module(struct pipe_module *pmod, const char *name) +{ + pmod->name = strdup(name); + if (!pmod->name) + return FALSE; + + for_each_in_search_path(dlopen_pipe_module_cb, (void *) pmod); + if (pmod->lib) { + pmod->drmdd = (const struct drm_driver_descriptor *) + util_dl_get_proc_address(pmod->lib, "driver_descriptor"); + + /* sanity check on the name */ + if (pmod->drmdd && strcmp(pmod->drmdd->name, pmod->name) != 0) + pmod->drmdd = NULL; + + /* swrast */ + if (pmod->drmdd && !pmod->drmdd->driver_name) { + pmod->swrast_create_screen = + (struct pipe_screen *(*)(struct sw_winsys *)) + util_dl_get_proc_address(pmod->lib, "swrast_create_screen"); + if (!pmod->swrast_create_screen) + pmod->drmdd = NULL; + } + + if (!pmod->drmdd) { + util_dl_close(pmod->lib); + pmod->lib = NULL; + } + } + + return (pmod->drmdd != NULL); +} + + +static struct pipe_module * +get_pipe_module(const char *name) +{ + struct pipe_module *pmod = NULL; + unsigned i; + + if (!name) + return NULL; + + for (i = 0; i < sizeof(pipe_modules) / sizeof(pipe_modules[0]); i++) { + if (!pipe_modules[i].initialized || + strcmp(pipe_modules[i].name, name) == 0) { + pmod = &pipe_modules[i]; + break; + } + } + if (!pmod) + return NULL; + + if (!pmod->initialized) { + load_pipe_module(pmod, name); + pmod->initialized = TRUE; + } + + return pmod; +} + +struct native_display; + +struct pipe_screen * +dxgi_loader_create_drm_screen(struct native_display* dpy, const char *name, int fd) +{ + struct pipe_module *pmod = get_pipe_module(name); + return (pmod && pmod->drmdd && pmod->drmdd->create_screen) ? + pmod->drmdd->create_screen(fd) : NULL; +} + +struct pipe_screen * +dxgi_loader_create_sw_screen(struct native_display* dpy, struct sw_winsys *ws) +{ + struct pipe_module *pmod = get_pipe_module("swrast"); + return (pmod && pmod->swrast_create_screen) ? + pmod->swrast_create_screen(ws) : NULL; +} diff --git a/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp b/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp new file mode 100644 index 00000000000..e1c34611d14 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp @@ -0,0 +1,1500 @@ +/************************************************************************** + * + * 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 "dxgi_private.h" +extern "C" { +#include "native.h" +#include <util/u_format.h> +#include <util/u_inlines.h> +#include <util/u_simple_shaders.h> +#include <pipe/p_shader_tokens.h> +} +#include <iostream> +#include <memory> + +struct GalliumDXGIOutput; +struct GalliumDXGIAdapter; +struct GalliumDXGISwapChain; +struct GalliumDXGIFactory; + +static HRESULT GalliumDXGISwapChainCreate(GalliumDXGIFactory* factory, IUnknown* device, const DXGI_SWAP_CHAIN_DESC& desc, IDXGISwapChain** out_swap_chain); +static HRESULT GalliumDXGIAdapterCreate(GalliumDXGIFactory* adapter, const struct native_platform* platform, void* dpy, IDXGIAdapter1** out_adapter); +static HRESULT GalliumDXGIOutputCreate(GalliumDXGIAdapter* adapter, const std::string& name, const struct native_connector* connector, IDXGIOutput** out_output); +static void GalliumDXGISwapChainRevalidate(IDXGISwapChain* swap_chain); + +template<typename Base = IDXGIObject, typename Parent = IDXGIObject> +struct GalliumDXGIObject : public GalliumPrivateDataComObject<Base> +{ + ComPtr<Parent> parent; + + GalliumDXGIObject(Parent* p_parent = 0) + { + this->parent = p_parent; + } + + virtual HRESULT STDMETHODCALLTYPE GetParent( + REFIID riid, + void **out_parent) + { + return parent->QueryInterface(riid, out_parent); + } +}; + +COM_INTERFACE(IGalliumDXGIBackend, IUnknown) + +// TODO: somehow check whether the window is fully obscured or not +struct GalliumDXGIIdentityBackend : public GalliumComObject<IGalliumDXGIBackend> +{ + virtual HRESULT STDMETHODCALLTYPE BeginPresent( + HWND hwnd, + void** present_cookie, + void** window, + RECT *rect, + RGNDATA **rgndata, + BOOL* preserve_aspect_ratio + ) + { + *window = (void*)hwnd; + rect->left = 0; + rect->top = 0; + rect->right = INT_MAX; + rect->bottom = INT_MAX; + *rgndata = 0; + + // yes, because we like things looking good + *preserve_aspect_ratio = TRUE; + *present_cookie = 0; + return S_OK; + } + + virtual void STDMETHODCALLTYPE EndPresent( + HWND hwnd, + void* present_cookie + ) + {} + + virtual HRESULT STDMETHODCALLTYPE TestPresent(HWND hwnd) + { + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE GetPresentSize( + HWND hwnd, + unsigned* width, + unsigned* height + ) + { + *width = 0; + *height = 0; + return S_OK; + } +}; + +// TODO: maybe install an X11 error hook, so we can return errors properly +struct GalliumDXGIX11IdentityBackend : public GalliumDXGIIdentityBackend +{ + Display* dpy; + + GalliumDXGIX11IdentityBackend(Display* dpy) + : dpy(dpy) + {} + + virtual HRESULT STDMETHODCALLTYPE GetPresentSize( + HWND hwnd, + unsigned* width, + unsigned* height + ) + { + XWindowAttributes xwa; + XGetWindowAttributes(dpy, (Window)hwnd, &xwa); + *width = xwa.width; + *height = xwa.height; + return S_OK; + } +}; + +struct GalliumDXGIFactory : public GalliumDXGIObject<IDXGIFactory1, IUnknown> +{ + HWND associated_window; + const struct native_platform* platform; + void* display; + ComPtr<IGalliumDXGIBackend> backend; + void* resolver_cookie; + + GalliumDXGIFactory(const struct native_platform* platform, void* display, IGalliumDXGIBackend* p_backend) + : GalliumDXGIObject<IDXGIFactory1, IUnknown>((IUnknown*)NULL), platform(platform), display(display) + { + if(p_backend) + backend = p_backend; + else if(!strcmp(platform->name, "X11")) + backend.reset(new GalliumDXGIX11IdentityBackend((Display*)display)); + else + backend.reset(new GalliumDXGIIdentityBackend()); + } + + virtual HRESULT STDMETHODCALLTYPE EnumAdapters( + UINT adapter, + IDXGIAdapter **out_adapter) + { + return EnumAdapters1(adapter, (IDXGIAdapter1**)out_adapter); + } + + virtual HRESULT STDMETHODCALLTYPE EnumAdapters1( + UINT adapter, + IDXGIAdapter1 **out_adapter) + { + *out_adapter = 0; + if(adapter == 0) + { + return GalliumDXGIAdapterCreate(this, platform, display, out_adapter); + } +#if 0 + // TODO: enable this + if(platform == native_get_x11_platform()) + { + unsigned nscreens = ScreenCount((Display*)display); + if(adapter < nscreens) + { + unsigned def_screen = DefaultScreen(display); + if(adapter <= def_screen) + --adapter; + *out_adapter = GalliumDXGIAdapterCreate(this, platform, display, adapter); + return S_OK; + } + } +#endif + return DXGI_ERROR_NOT_FOUND; + } + + /* TODO: this is a mysterious underdocumented magic API + * Can we have multiple windows associated? + * Can we have multiple windows associated if we use multiple factories? + * If so, what should GetWindowAssociation return? + * If not, does a new swapchain steal the association? + * Does this act for existing swapchains? For new swapchains? + */ + virtual HRESULT STDMETHODCALLTYPE MakeWindowAssociation( + HWND window_handle, + UINT flags) + { + /* TODO: actually implement, for Wine, X11 and KMS*/ + associated_window = window_handle; + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE GetWindowAssociation( + HWND *pwindow_handle) + { + *pwindow_handle = associated_window; + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE CreateSwapChain( + IUnknown *device, + DXGI_SWAP_CHAIN_DESC *desc, + IDXGISwapChain **out_swap_chain) + { + return GalliumDXGISwapChainCreate(this, device, *desc, out_swap_chain); + } + + virtual HRESULT STDMETHODCALLTYPE CreateSoftwareAdapter( + HMODULE module, + IDXGIAdapter **out_adapter) + { + /* TODO: ignore the module, and just create a Gallium software screen */ + *out_adapter = 0; + return E_NOTIMPL; + } + + /* TODO: support hotplug */ + virtual BOOL STDMETHODCALLTYPE IsCurrent( void) + { + return TRUE; + } +}; + +struct GalliumDXGIAdapter + : public GalliumMultiComObject< + GalliumDXGIObject<IDXGIAdapter1, GalliumDXGIFactory>, + IGalliumAdapter> +{ + struct native_display* display; + const struct native_config** configs; + std::unordered_multimap<unsigned, unsigned> configs_by_pipe_format; + std::unordered_map<unsigned, unsigned> configs_by_native_visual_id; + const struct native_connector** connectors; + unsigned num_configs; + DXGI_ADAPTER_DESC1 desc; + std::vector<ComPtr<IDXGIOutput> > outputs; + int num_outputs; + struct native_event_handler handler; + + GalliumDXGIAdapter(GalliumDXGIFactory* factory, const struct native_platform* platform, void* dpy) + { + this->parent = factory; + + handler.invalid_surface = handle_invalid_surface; + handler.new_drm_screen = dxgi_loader_create_drm_screen; + handler.new_sw_screen = dxgi_loader_create_sw_screen; + display = platform->create_display(dpy, &handler, this); + if(!display) + throw E_FAIL; + memset(&desc, 0, sizeof(desc)); + std::string s = std::string("GalliumD3D on ") + display->screen->get_name(display->screen) + " by " + display->screen->get_vendor(display->screen); + + /* hopefully no one will decide to use UTF-8 in Gallium name/vendor strings */ + for(int i = 0; i < std::min((int)s.size(), 127); ++i) + desc.Description[i] = (WCHAR)s[i]; + + // TODO: add an interface to get these; for now, return mid/low values + desc.DedicatedVideoMemory = 256 << 20; + desc.DedicatedSystemMemory = 256 << 20; + desc.SharedSystemMemory = 1024 << 20; + + // TODO: we should actually use an unique ID instead + *(void**)&desc.AdapterLuid = dpy; + + configs = display->get_configs(display, (int*)&num_configs); + for(unsigned i = 0; i < num_configs; ++i) + { + if(configs[i]->window_bit) + { + configs_by_pipe_format.insert(std::make_pair(configs[i]->color_format, i)); + configs_by_native_visual_id[configs[i]->native_visual_id] = i; + } + } + + connectors = 0; + num_outputs = 0; + + if(display->modeset) + { + int num_crtcs; + + connectors = display->modeset->get_connectors(display, &num_outputs, &num_crtcs); + if(!connectors) + num_outputs = 0; + else if(!num_outputs) + { + free(connectors); + connectors = 0; + } + } + if(!num_outputs) + num_outputs = 1; + } + + static void handle_invalid_surface(struct native_display *ndpy, struct native_surface *nsurf, unsigned int seq_num) + { + GalliumDXGISwapChainRevalidate((IDXGISwapChain*)nsurf->user_data); + } + + ~GalliumDXGIAdapter() + { + display->destroy(display); + free(configs); + free(connectors); + } + + virtual HRESULT STDMETHODCALLTYPE EnumOutputs( + UINT output, + IDXGIOutput **out_output) + { + if(output >= (unsigned)num_outputs) + return DXGI_ERROR_NOT_FOUND; + + if(connectors) + { + std::ostringstream ss; + ss << "output #" << output; + return GalliumDXGIOutputCreate(this, ss.str(), connectors[output], out_output); + } + else + return GalliumDXGIOutputCreate(this, "Unique output", NULL, out_output); + } + + virtual HRESULT STDMETHODCALLTYPE GetDesc( + DXGI_ADAPTER_DESC *desc) + { + memcpy(desc, &desc, sizeof(*desc)); + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE GetDesc1( + DXGI_ADAPTER_DESC1 *desc) + { + memcpy(desc, &desc, sizeof(*desc)); + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE CheckInterfaceSupport( + REFGUID interface_name, + LARGE_INTEGER *u_m_d_version) + { + // these number was taken from Windows 7 with Catalyst 10.8: its meaning is unclear + if(interface_name == IID_ID3D11Device || interface_name == IID_ID3D10Device1 || interface_name == IID_ID3D10Device) + { + u_m_d_version->QuadPart = 0x00080011000a0411ULL; + return S_OK; + } + return DXGI_ERROR_UNSUPPORTED; + } + + pipe_screen* STDMETHODCALLTYPE GetGalliumScreen() + { + return display->screen; + } + + pipe_screen* STDMETHODCALLTYPE GetGalliumReferenceSoftwareScreen() + { + // TODO: give a softpipe screen + return display->screen; + } + + pipe_screen* STDMETHODCALLTYPE GetGalliumFastSoftwareScreen() + { + // TODO: give an llvmpipe screen + return display->screen; + } +}; + + +struct GalliumDXGIOutput : public GalliumDXGIObject<IDXGIOutput, GalliumDXGIAdapter> +{ + DXGI_OUTPUT_DESC desc; + const struct native_mode** modes; + DXGI_MODE_DESC* dxgi_modes; + unsigned num_modes; + const struct native_connector* connector; + DXGI_GAMMA_CONTROL* gamma; + + GalliumDXGIOutput(GalliumDXGIAdapter* adapter, std::string name, const struct native_connector* connector = 0) + : GalliumDXGIObject<IDXGIOutput, GalliumDXGIAdapter>(adapter), connector(connector) + { + memset(&desc, 0, sizeof(desc)); + for(unsigned i = 0; i < std::min(name.size(), sizeof(desc.DeviceName) - 1); ++i) + desc.DeviceName[i] = name[i]; + desc.AttachedToDesktop = TRUE; + /* TODO: should put an HMONITOR in desc.Monitor */ + + gamma = 0; + num_modes = 0; + modes = 0; + if(connector) + { + modes = parent->display->modeset->get_modes(parent->display, connector, (int*)&num_modes); + if(modes && num_modes) + { + dxgi_modes = new DXGI_MODE_DESC[num_modes]; + for(unsigned i = 0; i < num_modes; ++i) + { + dxgi_modes[i].Width = modes[i]->width; + dxgi_modes[i].Height = modes[i]->height; + dxgi_modes[i].RefreshRate.Numerator = modes[i]->refresh_rate; + dxgi_modes[i].RefreshRate.Denominator = 1; + dxgi_modes[i].Scaling = DXGI_MODE_SCALING_UNSPECIFIED; + dxgi_modes[i].ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; + } + } + else + { + if(modes) + { + free(modes); + modes = 0; + } + goto use_fake_mode; + } + } + else + { +use_fake_mode: + dxgi_modes = new DXGI_MODE_DESC[1]; + dxgi_modes[0].Width = 1920; + dxgi_modes[0].Height = 1200; + dxgi_modes[0].RefreshRate.Numerator = 60; + dxgi_modes[0].RefreshRate.Denominator = 1; + dxgi_modes[0].Scaling = DXGI_MODE_SCALING_UNSPECIFIED; + dxgi_modes[0].ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; + } + } + + ~GalliumDXGIOutput() + { + delete [] dxgi_modes; + free(modes); + if(gamma) + delete gamma; + } + + virtual HRESULT STDMETHODCALLTYPE GetDesc( + DXGI_OUTPUT_DESC *out_desc) + { + *out_desc = desc; + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE GetDisplayModeList( + DXGI_FORMAT enum_format, + UINT flags, + UINT *pcount, + DXGI_MODE_DESC *desc) + { + /* TODO: should we return DXGI_ERROR_NOT_CURRENTLY_AVAILABLE when we don't + * support modesetting instead of fake modes? + */ + pipe_format format = dxgi_to_pipe_format[enum_format]; + if(parent->configs_by_pipe_format.count(format)) + { + if(!desc) + { + *pcount = num_modes; + return S_OK; + } + + unsigned copy_modes = std::min(num_modes, *pcount); + for(unsigned i = 0; i < copy_modes; ++i) + { + desc[i] = dxgi_modes[i]; + desc[i].Format = enum_format; + } + *pcount = num_modes; + + if(copy_modes < num_modes) + return DXGI_ERROR_MORE_DATA; + else + return S_OK; + } + else + { + *pcount = 0; + return S_OK; + } + } + + virtual HRESULT STDMETHODCALLTYPE FindClosestMatchingMode( + const DXGI_MODE_DESC *pModeToMatch, + DXGI_MODE_DESC *closest_match, + IUnknown *concerned_device) + { + /* TODO: actually implement this */ + DXGI_FORMAT dxgi_format = pModeToMatch->Format; + enum pipe_format format = dxgi_to_pipe_format[dxgi_format]; + init_pipe_to_dxgi_format(); + if(!parent->configs_by_pipe_format.count(format)) + { + if(!concerned_device) + return E_FAIL; + else + { + format = parent->configs[0]->color_format; + dxgi_format = pipe_to_dxgi_format[format]; + } + } + + *closest_match = dxgi_modes[0]; + closest_match->Format = dxgi_format; + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE WaitForVBlank( void) + { + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE TakeOwnership( + IUnknown *device, + BOOL exclusive) + { + return S_OK; + } + + virtual void STDMETHODCALLTYPE ReleaseOwnership( void) + { + } + + virtual HRESULT STDMETHODCALLTYPE GetGammaControlCapabilities( + DXGI_GAMMA_CONTROL_CAPABILITIES *gamma_caps) + { + memset(gamma_caps, 0, sizeof(*gamma_caps)); + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE SetGammaControl( + const DXGI_GAMMA_CONTROL *pArray) + { + if(!gamma) + gamma = new DXGI_GAMMA_CONTROL; + *gamma = *pArray; + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE GetGammaControl( + DXGI_GAMMA_CONTROL *pArray) + { + if(gamma) + *pArray = *gamma; + else + { + pArray->Scale.Red = 1; + pArray->Scale.Green = 1; + pArray->Scale.Blue = 1; + pArray->Offset.Red = 0; + pArray->Offset.Green = 0; + pArray->Offset.Blue = 0; + for(unsigned i = 0; i <= 1024; ++i) + pArray->GammaCurve[i].Red = pArray->GammaCurve[i].Green = pArray->GammaCurve[i].Blue = (float)i / 1024.0; + } + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE SetDisplaySurface( + IDXGISurface *scanout_surface) + { + return E_NOTIMPL; + } + + virtual HRESULT STDMETHODCALLTYPE GetDisplaySurfaceData( + IDXGISurface *destination) + { + return E_NOTIMPL; + } + + virtual HRESULT STDMETHODCALLTYPE GetFrameStatistics( + DXGI_FRAME_STATISTICS *stats) + { + memset(stats, 0, sizeof(*stats)); +#ifdef _WIN32 + QueryPerformanceCounter(&stats->SyncQPCTime); +#endif + return E_NOTIMPL; + } +}; + +/* Swap chain are rather complex, and Microsoft's documentation is rather + * lacking. As far as I know, this is the most thorough publicly available + * description of how swap chains work, based on multiple sources and + * experimentation. + * + * There are two modes (called "swap effects") that a swap chain can operate in: + * discard and sequential. + * + * In discard mode, things always look as if there is a single buffer, which + * you can get with GetBuffers(0). + * The 2D texture returned by GetBuffers(0) and can only be + * used as a render target view and for resource copies, since no CPU access + * flags are set and only the D3D11_BIND_RENDER_TARGET bind flag is set. + * On Present, it is copied to the actual display + * surface and the contents become undefined. + * D3D may internally use multiple buffers, but you can't observe this, except + * by looking at the buffer contents after Present (but those are undefined). + * If it uses multiple buffers internally, then it will normally use buffer_count buffers + * (this has latency implications). + * Discard mode seems to internally use a single buffer in windowed mode, + * even if DWM is enabled, and buffer_count buffers in fullscreen mode. + * + * In sequential mode, the runtime alllocates buffer_count buffers. + * You can get each with GetBuffers(n). + * GetBuffers(0) ALWAYS points to the backbuffer to be presented and has the + * same usage constraints as the discard mode. + * GetBuffer(n) with n > 0 points to resources that are identical to buffer 0, but + * are classified as "read-only resources" (due to DXGI_USAGE_READ_ONLY), + * meaning that you can't create render target views on them, or use them as + * a CopyResource/CopySubresourceRegion destination. + * It appears the only valid operation is to use them as a source for CopyResource + * and CopySubresourceRegion as well as just waiting for them to become + * buffer 0 again. + * Buffer n - 1 is always displayed on screen. + * When you call Present(), the contents of the buffers are rotated, so that buffer 0 + * goes to buffer n - 1, and is thus displayed, and buffer 1 goes to buffer 0, becomes + * the accessible back buffer. + * The resources themselves are NOT rotated, so that you can still render on the + * same ID3D11Texture2D*, and views based on it, that you got before Present(). + * + * Present seems to happen by either copying the relevant buffer into the window, + * or alternatively making it the current one, either by programming the CRTC or + * by sending the resource name to the DWM compositor. + * + * Hence, you can call GetBuffer(0) once and keep using the same ID3D11Texture2D* + * and ID3D11RenderTargetView* (and other views if needed) you got from it. + * + * If the window gets resized, DXGI will then "emulate" all successive presentations, + * by using a stretched blit automatically. + * Thus, you should handle WM_SIZE and call ResizeBuffers to update the DXGI + * swapchain buffers size to the new window size. + * Doing so requires you to release all GetBuffers() results and anything referencing + * them, including views and Direct3D11 deferred context command lists (this is + * documented). + * + * How does Microsoft implement the rotation behavior? + * It turns out that it does it by calling RotateResourceIdentitiesDXGI in the user-mode + * DDI driver. + * This will rotate the kernel buffer handle, or possibly rotate the GPU virtual memory + * mappings. + * + * The reason this is done by driver instead of by the runtime appears to be that + * this is necessary to support driver-provided command list support, since otherwise + * the command list would not always target the current backbuffer, since it would + * be done at the driver level, while only the runtime knows about the rotation. + * + * OK, so how do we implement this in Gallium? + * + * There are three strategies: + * 1. Use a single buffer, and always copy it to a window system provided buffer, or + * just give the buffer to the window system if it supports that + * 2. Rotate the buffers in the D3D1x implementation, and recreate and rebind the views. + * Don't support driver-provided command lists + * 3. Add this rotation functionality to the Gallium driver, with the idea that it would rotate + * remap GPU virtual memory, so that virtual address are unchanged, but the physical + * ones are rotated (so that pushbuffers remain valid). + * If the driver does not support this, either fall back to (1), or have a layer doing this, + * putting a deferred context layer over this intermediate layer. + * + * (2) is not acceptable since it prevents an optimal implementation. + * (3) is the ideal solution, but it is complicated. + * + * Hence, we implement (1) for now, and will switch to (3) later. + * + * Note that (1) doesn't really work for DXGI_SWAP_EFFECT_SEQUENTIAL with more + * than one buffer, so we just pretend we got asked for a single buffer in that case + * Fortunately, no one seems to rely on that, so we'll just not implement it at first, and + * later perform the rotation with blits. + * Once we switch to (3), we'll just use real rotation to do it.. + * + * DXGI_SWAP_EFFECT_SEQUENTIAL with more than one buffer is of dubious use + * anyway, since you can only render or write to buffer 0, and other buffers can apparently + * be used only as sources for copies. + * I was unable to find any code using it either in DirectX SDK examples, or on the web. + * + * It seems the only reason you would use it is to not have to redraw from scratch, while + * also possibly avoid a copy compared to buffer_count == 1, assuming that your + * application is OK with having to redraw starting not from the last frame, but from + * one/two/more frames behind it. + * + * A better design would forbid the user specifying buffer_count explicitly, and + * would instead let the application give an upper bound on how old the buffer can + * become after presentation, with "infinite" being equivalent to discard. + * The runtime would then tell the application with frame number the buffer switched to + * after present. + * In addition, in a better design, the application would be allowed to specify the + * number of buffers available, having all them usable for rendering, so that things + * like video players could efficiently decode frames in parallel. + * Present would in such a better design gain a way to specify the number of buffers + * to present. + * + * Other miscellaneous info: + * DXGI_PRESENT_DO_NOT_SEQUENCE causes DXGI to hold the frame for another + * vblank interval without rotating the resource data. + * + * References: + * "DXGI Overview" in MSDN + * IDXGISwapChain documentation on MSDN + * "RotateResourceIdentitiesDXGI" on MSDN + * http://forums.xna.com/forums/p/42362/266016.aspx + */ + +static float quad_data[] = { + -1, -1, 0, 0, + -1, 1, 0, 1, + 1, 1, 1, 1, + 1, -1, 1, 0, +}; + +struct dxgi_blitter +{ + pipe_context* pipe; + bool normalized; + void* fs; + void* vs; + void* sampler[2]; + void* elements; + void* blend; + void* rasterizer; + void* zsa; + struct pipe_clip_state clip; + struct pipe_vertex_buffer vbuf; + struct pipe_draw_info draw; + + dxgi_blitter(pipe_context* pipe) + : pipe(pipe) + { + //normalized = !!pipe->screen->get_param(pipe, PIPE_CAP_NPOT_TEXTURES); + // TODO: need to update buffer in unnormalized case + normalized = true; + + struct pipe_rasterizer_state rs_state; + memset(&rs_state, 0, sizeof(rs_state)); + rs_state.cull_face = PIPE_FACE_NONE; + rs_state.gl_rasterization_rules = 1; + rs_state.flatshade = 1; + rasterizer = pipe->create_rasterizer_state(pipe, &rs_state); + + struct pipe_blend_state blendd; + memset(&blendd, 0, sizeof(blendd)); + blendd.rt[0].colormask = PIPE_MASK_RGBA; + blend = pipe->create_blend_state(pipe, &blendd); + + struct pipe_depth_stencil_alpha_state zsad; + memset(&zsad, 0, sizeof(zsad)); + zsa = pipe->create_depth_stencil_alpha_state(pipe, &zsad); + + struct pipe_vertex_element velem[2]; + memset(&velem[0], 0, sizeof(velem[0]) * 2); + velem[0].src_offset = 0; + velem[0].src_format = PIPE_FORMAT_R32G32_FLOAT; + velem[1].src_offset = 8; + velem[1].src_format = PIPE_FORMAT_R32G32_FLOAT; + elements = pipe->create_vertex_elements_state(pipe, 2, &velem[0]); + + for(unsigned stretch = 0; stretch < 2; ++stretch) + { + struct pipe_sampler_state sampler_state; + memset(&sampler_state, 0, sizeof(sampler_state)); + sampler_state.min_img_filter = stretch ? PIPE_TEX_FILTER_LINEAR : PIPE_TEX_FILTER_NEAREST; + sampler_state.mag_img_filter = stretch ? PIPE_TEX_FILTER_LINEAR : PIPE_TEX_FILTER_NEAREST; + sampler_state.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE; + sampler_state.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE; + sampler_state.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE; + sampler_state.normalized_coords = normalized; + + sampler[stretch] = pipe->create_sampler_state(pipe, &sampler_state); + } + + fs = util_make_fragment_tex_shader(pipe, normalized ? TGSI_TEXTURE_2D : TGSI_TEXTURE_RECT, TGSI_INTERPOLATE_LINEAR); + + const unsigned semantic_names[] = { TGSI_SEMANTIC_POSITION, TGSI_SEMANTIC_GENERIC }; + const unsigned semantic_indices[] = { 0, 0 }; + vs = util_make_vertex_passthrough_shader(pipe, 2, semantic_names, semantic_indices); + + vbuf.buffer = pipe_buffer_create(pipe->screen, PIPE_BIND_VERTEX_BUFFER, sizeof(quad_data)); + vbuf.buffer_offset = 0; + vbuf.max_index = ~0; + vbuf.stride = 4 * sizeof(float); + pipe_buffer_write(pipe, vbuf.buffer, 0, sizeof(quad_data), quad_data); + + memset(&clip, 0, sizeof(clip)); + + memset(&draw, 0, sizeof(draw)); + draw.mode = PIPE_PRIM_QUADS; + draw.count = 4; + draw.instance_count = 1; + draw.max_index = ~0; + } + + void blit(struct pipe_surface* surf, struct pipe_sampler_view* view, unsigned x, unsigned y, unsigned w, unsigned h) + { + struct pipe_framebuffer_state fb; + memset(&fb, 0, sizeof(fb)); + fb.nr_cbufs = 1; + fb.cbufs[0] = surf; + fb.width = surf->width; + fb.height = surf->height; + + struct pipe_viewport_state viewport; + float half_width = w * 0.5f; + float half_height = h * 0.5f; + viewport.scale[0] = half_width; + viewport.scale[1] = half_height; + viewport.scale[2] = 1.0f; + viewport.scale[3] = 1.0f; + viewport.translate[0] = x + half_width; + viewport.translate[1] = y + half_height; + viewport.translate[2] = 0.0f; + viewport.translate[3] = 1.0f; + + bool stretch = view->texture->width0 != w || view->texture->height0 != h; + if(pipe->render_condition) + pipe->render_condition(pipe, 0, 0); + pipe->set_framebuffer_state(pipe, &fb); + pipe->bind_fragment_sampler_states(pipe, 1, &sampler[stretch]); + pipe->set_viewport_state(pipe, &viewport); + pipe->set_clip_state(pipe, &clip); + pipe->bind_rasterizer_state(pipe, rasterizer); + pipe->bind_depth_stencil_alpha_state(pipe, zsa); + pipe->bind_blend_state(pipe, blend); + pipe->bind_vertex_elements_state(pipe, elements); + pipe->set_vertex_buffers(pipe, 1, &vbuf); + pipe->bind_fs_state(pipe, fs); + pipe->bind_vs_state(pipe, vs); + if(pipe->bind_gs_state) + pipe->bind_gs_state(pipe, 0); + if(pipe->bind_stream_output_state) + pipe->bind_stream_output_state(pipe, 0); + pipe->set_fragment_sampler_views(pipe, 1, &view); + + pipe->draw_vbo(pipe, &draw); + } + + ~dxgi_blitter() + { + pipe->delete_blend_state(pipe, blend); + pipe->delete_rasterizer_state(pipe, rasterizer); + pipe->delete_depth_stencil_alpha_state(pipe, zsa); + pipe->delete_sampler_state(pipe, sampler[0]); + pipe->delete_sampler_state(pipe, sampler[1]); + pipe->delete_vertex_elements_state(pipe, elements); + pipe->delete_vs_state(pipe, vs); + pipe->delete_fs_state(pipe, fs); + pipe->screen->resource_destroy(pipe->screen, vbuf.buffer); + } +}; + +struct GalliumDXGISwapChain : public GalliumDXGIObject<IDXGISwapChain, GalliumDXGIFactory> +{ + ComPtr<IDXGIDevice>dxgi_device; + ComPtr<IGalliumDevice>gallium_device; + ComPtr<GalliumDXGIAdapter> adapter; + ComPtr<IDXGIOutput> target; + + DXGI_SWAP_CHAIN_DESC desc; + + struct native_surface* surface; + const struct native_config* config; + + void* window; + struct pipe_resource* resources[NUM_NATIVE_ATTACHMENTS]; + int width; + int height; + unsigned seq_num; + bool ever_validated; + bool needs_validation; + unsigned present_count; + + ComPtr<IDXGISurface> buffer0; + struct pipe_resource* gallium_buffer0; + struct pipe_sampler_view* gallium_buffer0_view; + + struct pipe_context* pipe; + bool owns_pipe; + + BOOL fullscreen; + + std::auto_ptr<dxgi_blitter> blitter; + bool formats_compatible; + + GalliumDXGISwapChain(GalliumDXGIFactory* factory, IUnknown* p_device, const DXGI_SWAP_CHAIN_DESC& p_desc) + : GalliumDXGIObject<IDXGISwapChain, GalliumDXGIFactory>(factory), desc(p_desc), surface(0) + { + HRESULT hr; + + hr = p_device->QueryInterface(IID_IGalliumDevice, (void**)&gallium_device); + if(!SUCCEEDED(hr)) + throw hr; + + hr = p_device->QueryInterface(IID_IDXGIDevice, (void**)&dxgi_device); + if(!SUCCEEDED(hr)) + throw hr; + + hr = dxgi_device->GetAdapter((IDXGIAdapter**)&adapter); + if(!SUCCEEDED(hr)) + throw hr; + + memset(resources, 0, sizeof(resources)); + + if(desc.SwapEffect == DXGI_SWAP_EFFECT_SEQUENTIAL && desc.BufferCount != 1) + { + std::cerr << "Gallium DXGI: if DXGI_SWAP_EFFECT_SEQUENTIAL is specified, only buffer_count == 1 is implemented, but " << desc.BufferCount << " was specified: ignoring this" << std::endl; + // change the returned desc, so that the application might perhaps notice what we did and react well + desc.BufferCount = 1; + } + + pipe = gallium_device->GetGalliumContext(); + owns_pipe = false; + if(!pipe) + { + pipe = adapter->display->screen->context_create(adapter->display->screen, 0); + owns_pipe = true; + } + + blitter.reset(new dxgi_blitter(pipe)); + window = 0; + + hr = resolve_zero_width_height(true); + if(!SUCCEEDED(hr)) + throw hr; + } + + void init_for_window() + { + if(surface) + { + surface->destroy(surface); + surface = 0; + } + + unsigned config_num; + if(!strcmp(parent->platform->name, "X11")) + { + XWindowAttributes xwa; + XGetWindowAttributes((Display*)parent->display, (Window)window, &xwa); + assert(adapter->configs_by_native_visual_id.count(xwa.visual->visualid)); + config_num = adapter->configs_by_native_visual_id[xwa.visual->visualid]; + } + else + { + enum pipe_format format = dxgi_to_pipe_format[desc.BufferDesc.Format]; + if(!adapter->configs_by_pipe_format.count(format)) + { + if(adapter->configs_by_pipe_format.empty()) + throw E_FAIL; + // TODO: choose the best match + format = (pipe_format)adapter->configs_by_pipe_format.begin()->first; + } + // TODO: choose the best config + config_num = adapter->configs_by_pipe_format.find(format)->second; + } + + config = adapter->configs[config_num]; + surface = adapter->display->create_window_surface(adapter->display, (EGLNativeWindowType)window, config); + surface->user_data = this; + + width = 0; + height = 0; + seq_num = 0; + present_count = 0; + needs_validation = true; + ever_validated = false; + + formats_compatible = util_is_format_compatible( + util_format_description(dxgi_to_pipe_format[desc.BufferDesc.Format]), + util_format_description(config->color_format)); + } + + ~GalliumDXGISwapChain() + { + if(owns_pipe) + pipe->destroy(pipe); + } + + virtual HRESULT STDMETHODCALLTYPE GetDevice( + REFIID riid, + void **pdevice) + { + return dxgi_device->QueryInterface(riid, pdevice); + } + + HRESULT create_buffer0() + { + HRESULT hr; + ComPtr<IDXGISurface> new_buffer0; + DXGI_USAGE usage = DXGI_USAGE_BACK_BUFFER | DXGI_USAGE_RENDER_TARGET_OUTPUT; + if(desc.SwapEffect == DXGI_SWAP_EFFECT_DISCARD) + usage |= DXGI_USAGE_DISCARD_ON_PRESENT; + // for our blitter + usage |= DXGI_USAGE_SHADER_INPUT; + + DXGI_SURFACE_DESC surface_desc; + surface_desc.Format = desc.BufferDesc.Format; + surface_desc.Width = desc.BufferDesc.Width; + surface_desc.Height = desc.BufferDesc.Height; + surface_desc.SampleDesc = desc.SampleDesc; + hr = dxgi_device->CreateSurface(&surface_desc, 1, usage, 0, &new_buffer0); + if(!SUCCEEDED(hr)) + return hr; + + ComPtr<IGalliumResource> gallium_resource; + hr = new_buffer0->QueryInterface(IID_IGalliumResource, (void**)&gallium_resource); + if(!SUCCEEDED(hr)) + return hr; + + struct pipe_resource* new_gallium_buffer0 = gallium_resource->GetGalliumResource(); + if(!new_gallium_buffer0) + return E_FAIL; + + buffer0.reset(new_buffer0.steal()); + gallium_buffer0 = new_gallium_buffer0; + struct pipe_sampler_view templat; + memset(&templat, 0, sizeof(templat)); + templat.texture = gallium_buffer0; + templat.swizzle_r = 0; + templat.swizzle_g = 1; + templat.swizzle_b = 2; + templat.swizzle_a = 3; + templat.format = gallium_buffer0->format; + gallium_buffer0_view = pipe->create_sampler_view(pipe, gallium_buffer0, &templat); + return S_OK; + } + + bool validate() + { + unsigned new_seq_num; + needs_validation = false; + + if(!surface->validate(surface, (1 << NATIVE_ATTACHMENT_BACK_LEFT) | (1 << NATIVE_ATTACHMENT_FRONT_LEFT), &new_seq_num, resources, &width, &height)) + return false; + + if(!ever_validated || seq_num != new_seq_num) + { + seq_num = new_seq_num; + ever_validated = true; + } + return true; + } + + HRESULT resolve_zero_width_height(bool force = false) + { + if(!force && desc.BufferDesc.Width && desc.BufferDesc.Height) + return S_OK; + + unsigned width, height; + HRESULT hr = parent->backend->GetPresentSize(desc.OutputWindow, &width, &height); + if(!SUCCEEDED(hr)) + return hr; + + // On Windows, 8 is used, and a debug message saying so gets printed + if(!width) + width = 8; + if(!height) + height = 8; + + if(!desc.BufferDesc.Width) + desc.BufferDesc.Width = width; + if(!desc.BufferDesc.Height) + desc.BufferDesc.Height = height; + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE Present( + UINT sync_interval, + UINT flags) + { + HRESULT hr; + if(flags & DXGI_PRESENT_TEST) + return parent->backend->TestPresent(desc.OutputWindow); + + if(!buffer0) + { + HRESULT hr = create_buffer0(); + if(!SUCCEEDED(hr)) + return hr; + } + + void* cur_window = 0; + RECT rect; + RGNDATA* rgndata; + BOOL preserve_aspect_ratio; + unsigned dst_w, dst_h; + bool db; + struct pipe_resource* dst; + struct pipe_resource* src; + struct pipe_surface* dst_surface; + + void* present_cookie; + hr = parent->backend->BeginPresent(desc.OutputWindow, &present_cookie, &cur_window, &rect, &rgndata, &preserve_aspect_ratio); + if(hr != S_OK) + return hr; + + if(!cur_window || rect.left >= rect.right || rect.top >= rect.bottom) + goto end_present; + + if(cur_window != window) + { + window = cur_window; + init_for_window(); + } + + if(needs_validation) + { + if(!validate()) + return DXGI_ERROR_DEVICE_REMOVED; + } + + db = !!(config->buffer_mask & (1 << NATIVE_ATTACHMENT_BACK_LEFT)); + dst = resources[db ? NATIVE_ATTACHMENT_BACK_LEFT : NATIVE_ATTACHMENT_FRONT_LEFT]; + src = gallium_buffer0; + dst_surface = 0; + + assert(src); + assert(dst); + + /* TODO: sharing the context for blitting won't work correctly if queries are active + * Hopefully no one is crazy enough to keep queries active while presenting, expecting + * sensible results. + * We could alternatively force using another context, but that might cause inefficiency issues + */ + + if((unsigned)rect.right > dst->width0) + rect.right = dst->width0; + if((unsigned)rect.bottom > dst->height0) + rect.bottom = dst->height0; + if(rect.left > rect.right) + rect.left = rect.right; + if(rect.top > rect.bottom) + rect.top = rect.bottom; + + if(rect.left >= rect.right && rect.top >= rect.bottom) + goto end_present; + + dst_w = rect.right - rect.left; + dst_h = rect.bottom - rect.top; + + // TODO: add support for rgndata +// if(preserve_aspect_ratio || !rgndata) + if(1) + { + unsigned blit_x, blit_y, blit_w, blit_h; + float black[4] = {0, 0, 0, 0}; + + if(!formats_compatible || src->width0 != dst_w || src->height0 != dst_h) + dst_surface = pipe->screen->get_tex_surface(pipe->screen, dst, 0, 0, 0, PIPE_BIND_RENDER_TARGET); + + if(preserve_aspect_ratio) + { + int delta = src->width0 * dst_h - dst_w * src->height0; + if(delta > 0) + { + blit_w = dst_w; + blit_h = dst_w * src->height0 / src->width0; + } + else if(delta < 0) + { + blit_w = dst_h * src->width0 / src->height0; + blit_h = dst_h; + } + else + { + blit_w = dst_w; + blit_h = dst_h; + } + + blit_x = (dst_w - blit_w) >> 1; + blit_y = (dst_h - blit_h) >> 1; + } + else + { + blit_x = 0; + blit_y = 0; + blit_w = dst_w; + blit_h = dst_h; + } + + if(blit_x) + pipe->clear_render_target(pipe, dst_surface, black, rect.left, rect.top, blit_x, dst_h); + if(blit_y) + pipe->clear_render_target(pipe, dst_surface, black, rect.left, rect.top, dst_w, blit_y); + + if(formats_compatible && blit_w == src->width0 && blit_h == src->height0) + { + pipe_subresource sr; + sr.face = 0; + sr.level = 0; + pipe->resource_copy_region(pipe, dst, sr, rect.left, rect.top, 0, src, sr, 0, 0, 0, blit_w, blit_h); + } + else + { + blitter->blit(dst_surface, gallium_buffer0_view, rect.left + blit_x, rect.top + blit_y, blit_w, blit_h); + if(!owns_pipe) + gallium_device->RestoreGalliumState(); + } + + if(blit_w != dst_w) + pipe->clear_render_target(pipe, dst_surface, black, rect.left + blit_x + blit_w, rect.top, dst_w - blit_x - blit_w, dst_h); + if(blit_h != dst_h) + pipe->clear_render_target(pipe, dst_surface, black, rect.left, rect.top + blit_y + blit_h, dst_w, dst_h - blit_y - blit_h); + } + + if(dst_surface) + pipe->screen->tex_surface_destroy(dst_surface); + + pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, 0); + + if(db) + { + if(!surface->swap_buffers(surface)) + return DXGI_ERROR_DEVICE_REMOVED; + } + else + { + if(!surface->flush_frontbuffer(surface)) + return DXGI_ERROR_DEVICE_REMOVED; + } + +end_present: + parent->backend->EndPresent(desc.OutputWindow, present_cookie); + + ++present_count; + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE GetBuffer( + UINT Buffer, + REFIID riid, + void **ppSurface) + { + if(Buffer > 0) + { + if(desc.SwapEffect == DXGI_SWAP_EFFECT_SEQUENTIAL) + std::cerr << "DXGI unimplemented: GetBuffer(n) with n > 0 not supported, returning buffer 0 instead!" << std::endl; + else + std::cerr << "DXGI error: in GetBuffer(n), n must be 0 for DXGI_SWAP_EFFECT_DISCARD\n" << std::endl; + } + + if(!buffer0) + { + HRESULT hr = create_buffer0(); + if(!SUCCEEDED(hr)) + return hr; + } + return buffer0->QueryInterface(riid, ppSurface); + } + + /* TODO: implement somehow */ + virtual HRESULT STDMETHODCALLTYPE SetFullscreenState( + BOOL fullscreen, + IDXGIOutput *target) + { + fullscreen = fullscreen; + target = target; + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE GetFullscreenState( + BOOL *out_fullscreen, + IDXGIOutput **out_target) + { + if(out_fullscreen) + *out_fullscreen = fullscreen; + if(out_target) + *out_target = target.ref(); + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE GetDesc( + DXGI_SWAP_CHAIN_DESC *out_desc) + { + *out_desc = desc; + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE ResizeBuffers( + UINT buffer_count, + UINT width, + UINT height, + DXGI_FORMAT new_format, + UINT swap_chain_flags) + { + if(buffer0) + { + buffer0.p->AddRef(); + ULONG v = buffer0.p->Release(); + // we must fail if there are any references to buffer0 other than ours + if(v > 1) + return E_FAIL; + pipe_sampler_view_reference(&gallium_buffer0_view, 0); + buffer0 = (IUnknown*)NULL; + gallium_buffer0 = 0; + } + + if(desc.SwapEffect != DXGI_SWAP_EFFECT_SEQUENTIAL) + desc.BufferCount = buffer_count; + desc.BufferDesc.Format = new_format; + desc.BufferDesc.Width = width; + desc.BufferDesc.Height = height; + desc.Flags = swap_chain_flags; + return resolve_zero_width_height(); + } + + virtual HRESULT STDMETHODCALLTYPE ResizeTarget( + const DXGI_MODE_DESC *out_new_target_parameters) + { + /* TODO: implement */ + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE GetContainingOutput( + IDXGIOutput **out_output) + { + *out_output = adapter->outputs[0].ref(); + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE GetFrameStatistics( + DXGI_FRAME_STATISTICS *out_stats) + { + memset(out_stats, 0, sizeof(*out_stats)); +#ifdef _WIN32 + QueryPerformanceCounter(&out_stats->SyncQPCTime); +#endif + out_stats->PresentCount = present_count; + out_stats->PresentRefreshCount = present_count; + out_stats->SyncRefreshCount = present_count; + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE GetLastPresentCount( + UINT *last_present_count) + { + *last_present_count = present_count; + return S_OK; + } +}; + +static void GalliumDXGISwapChainRevalidate(IDXGISwapChain* swap_chain) +{ + ((GalliumDXGISwapChain*)swap_chain)->needs_validation = true; +} + +static HRESULT GalliumDXGIAdapterCreate(GalliumDXGIFactory* factory, const struct native_platform* platform, void* dpy, IDXGIAdapter1** out_adapter) +{ + try + { + *out_adapter = new GalliumDXGIAdapter(factory, platform, dpy); + return S_OK; + } + catch(HRESULT hr) + { + return hr; + } +} + +static HRESULT GalliumDXGIOutputCreate(GalliumDXGIAdapter* adapter, const std::string& name, const struct native_connector* connector, IDXGIOutput** out_output) +{ + try + { + *out_output = new GalliumDXGIOutput(adapter, name, connector); + return S_OK; + } + catch(HRESULT hr) + { + return hr; + } +} + +static HRESULT GalliumDXGISwapChainCreate(GalliumDXGIFactory* factory, IUnknown* device, const DXGI_SWAP_CHAIN_DESC& desc, IDXGISwapChain** out_swap_chain) +{ + try + { + *out_swap_chain = new GalliumDXGISwapChain(factory, device, desc); + return S_OK; + } + catch(HRESULT hr) + { + return hr; + } +} + +struct dxgi_binding +{ + const struct native_platform* platform; + void* display; + IGalliumDXGIBackend* backend; +}; + +static dxgi_binding dxgi_default_binding; +static __thread dxgi_binding dxgi_thread_binding; + +void STDMETHODCALLTYPE GalliumDXGIUseNothing() +{ + dxgi_thread_binding.platform = 0; + dxgi_thread_binding.display = 0; + if(dxgi_thread_binding.backend) + dxgi_thread_binding.backend->Release(); + dxgi_thread_binding.backend = 0; +} + +#ifdef GALLIUM_DXGI_USE_X11 +void STDMETHODCALLTYPE GalliumDXGIUseX11Display(Display* dpy, IGalliumDXGIBackend* backend) +{ + GalliumDXGIUseNothing(); + dxgi_thread_binding.platform = native_get_x11_platform(); + dxgi_thread_binding.display = dpy; + + if(backend) + { + dxgi_thread_binding.backend = backend; + backend->AddRef(); + } +} +#endif + +/* +#ifdef GALLIUM_DXGI_USE_DRM +void STDMETHODCALLTYPE GalliumDXGIUseDRMCard(int fd) +{ + GalliumDXGIUseNothing(); + dxgi_thread_binding.platform = native_get_drm_platform(); + dxgi_thread_binding.display = (void*)fd; + dxgi_thread_binding.backend = 0; +} +#endif + +#ifdef GALLIUM_DXGI_USE_FBDEV +void STDMETHODCALLTYPE GalliumDXGIUseFBDev(int fd) +{ + GalliumDXGIUseNothing(); + dxgi_thread_binding.platform = native_get_fbdev_platform(); + dxgi_thread_binding.display = (void*)fd; + dxgi_thread_binding.backend = 0; +} +#endif + +#ifdef GALLIUM_DXGI_USE_GDI +void STDMETHODCALLTYPE GalliumDXGIUseHDC(HDC hdc, PFNHWNDRESOLVER resolver, void* resolver_cookie) +{ + GalliumDXGIUseNothing(); + dxgi_thread_binding.platform = native_get_gdi_platform(); + dxgi_thread_binding.display = (void*)hdc; + dxgi_thread_binding.backend = 0; +} +#endif +*/ +void STDMETHODCALLTYPE GalliumDXGIMakeDefault() +{ + if(dxgi_default_binding.backend) + dxgi_default_binding.backend->Release(); + dxgi_default_binding = dxgi_thread_binding; + if(dxgi_default_binding.backend) + dxgi_default_binding.backend->AddRef(); +} + + /* TODO: why did Microsoft add this? should we do something different for DXGI 1.0 and 1.1? + * Or perhaps what they actually mean is "only create a single factory in your application"? + * TODO: should we use a singleton here, so we never have multiple DXGI objects for the same thing? */ + HRESULT STDMETHODCALLTYPE CreateDXGIFactory1( + REFIID riid, + void **out_factory +) + { + GalliumDXGIFactory* factory; + *out_factory = 0; + if(dxgi_thread_binding.platform) + factory = new GalliumDXGIFactory(dxgi_thread_binding.platform, dxgi_thread_binding.display, dxgi_thread_binding.backend); + else if(dxgi_default_binding.platform) + factory = new GalliumDXGIFactory(dxgi_default_binding.platform, dxgi_default_binding.display, dxgi_default_binding.backend); + else + factory = new GalliumDXGIFactory(native_get_x11_platform(), NULL, NULL); + HRESULT hres = factory->QueryInterface(riid, out_factory); + factory->Release(); + return hres; + } + + HRESULT STDMETHODCALLTYPE CreateDXGIFactory( + REFIID riid, + void **out_factor +) + { + return CreateDXGIFactory1(riid, out_factor); + } diff --git a/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_private.h b/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_private.h new file mode 100644 index 00000000000..187a0f986a5 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_private.h @@ -0,0 +1,49 @@ +/************************************************************************** + * + * 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 DXGI_PRIVATE_H_ +#define DXGI_PRIVATE_H_ + +#include <vector> +#include <string> +#include <sstream> + +#include "d3d1xstutil.h" + +#include <dxgi.h> +#include <d3d11.h> +#include <galliumcom.h> +#include <galliumdxgi.h> + +struct native_display; + +struct pipe_screen * +dxgi_loader_create_drm_screen(struct native_display* dpy, const char *name, int fd); + +struct pipe_screen * +dxgi_loader_create_sw_screen(struct native_display* dpy, struct sw_winsys *ws); + +#endif /* DXGI_PRIVATE_H_ */ diff --git a/src/gallium/state_trackers/d3d1x/dxgid3d10/Makefile b/src/gallium/state_trackers/d3d1x/dxgid3d10/Makefile new file mode 100644 index 00000000000..85f41e81586 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/dxgid3d10/Makefile @@ -0,0 +1,4 @@ +LIBNAME=dxgid3d10 +CPP_SOURCES=$(wildcard *.cpp) +LIBRARY_INCLUDES=-I../gd3dapi -I../d3dapi -I../w32api -I../d3d1xstutil/include -I../include -I../../../include -I../../../auxiliary +include ../Makefile.inc diff --git a/src/gallium/state_trackers/d3d1x/dxgid3d10/dxgid3d10.cpp b/src/gallium/state_trackers/d3d1x/dxgid3d10/dxgid3d10.cpp new file mode 100644 index 00000000000..96073d4ebc6 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/dxgid3d10/dxgid3d10.cpp @@ -0,0 +1,149 @@ +/************************************************************************** + * + * 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 "d3d1xstutil.h" +#include "galliumd3d10_1.h" +#include <dxgi.h> +#include <pipe/p_screen.h> +#include <pipe/p_context.h> + +HRESULT D3D10CreateDevice1( + IDXGIAdapter *adapter, + D3D10_DRIVER_TYPE driver_type, + HMODULE software, + unsigned flags, + D3D10_FEATURE_LEVEL1 hardware_level, + unsigned sdk_version, + ID3D10Device1 **out_device +) +{ + HRESULT hr; + ComPtr<IDXGIAdapter1> adapter_to_release; + if(!adapter) + { + ComPtr<IDXGIFactory1> factory; + hr = CreateDXGIFactory1(IID_IDXGIFactory1, (void**)&factory); + if(!SUCCEEDED(hr)) + return hr; + hr = factory->EnumAdapters1(0, &adapter_to_release); + if(!SUCCEEDED(hr)) + return hr; + adapter = adapter_to_release.p; + } + ComPtr<IGalliumAdapter> gallium_adapter; + hr = adapter->QueryInterface(IID_IGalliumAdapter, (void**)&gallium_adapter); + if(!SUCCEEDED(hr)) + return hr; + struct pipe_screen* screen; + // TODO: what should D3D_DRIVER_TYPE_SOFTWARE return? fast or reference? + if(driver_type == D3D10_DRIVER_TYPE_REFERENCE) + screen = gallium_adapter->GetGalliumReferenceSoftwareScreen(); + else if(driver_type == D3D10_DRIVER_TYPE_SOFTWARE || driver_type == D3D10_DRIVER_TYPE_WARP) + screen = gallium_adapter->GetGalliumFastSoftwareScreen(); + else + screen = gallium_adapter->GetGalliumScreen(); + if(!screen) + return E_FAIL; + struct pipe_context* context = screen->context_create(screen, 0); + if(!context) + return E_FAIL; + ComPtr<ID3D10Device1> device; + hr = GalliumD3D10DeviceCreate1(screen, context, TRUE, flags, adapter, &device); + if(!SUCCEEDED(hr)) + { + context->destroy(context); + return hr; + } + if(out_device) + *out_device = device.steal(); + return S_OK; +} + +HRESULT WINAPI D3D10CreateDeviceAndSwapChain1( + IDXGIAdapter* adapter, + D3D10_DRIVER_TYPE driver_type, + HMODULE software, + unsigned flags, + D3D10_FEATURE_LEVEL1 hardware_level, + unsigned sdk_version, + DXGI_SWAP_CHAIN_DESC* swap_chain_desc, + IDXGISwapChain** out_swap_chain, + ID3D10Device1** out_device +) +{ + ComPtr<ID3D10Device1> dev; + HRESULT hr; + hr = D3D10CreateDevice1(adapter, driver_type, software, flags, hardware_level, sdk_version, &dev); + if(!SUCCEEDED(hr)) + return hr; + if(out_swap_chain) + { + ComPtr<IDXGIFactory> factory; + ComPtr<IDXGIDevice> dxgi_device; + ComPtr<IDXGIAdapter> adapter; + hr = dev->QueryInterface(IID_IDXGIDevice, (void**)&dxgi_device); + if(!SUCCEEDED(hr)) + return hr; + + hr = dxgi_device->GetAdapter(&adapter); + if(!SUCCEEDED(hr)) + return hr; + + adapter->GetParent(IID_IDXGIFactory, (void**)&factory); + hr = factory->CreateSwapChain(dev.p, (DXGI_SWAP_CHAIN_DESC*)swap_chain_desc, out_swap_chain); + if(!SUCCEEDED(hr)) + return hr; + } + if(out_device) + *out_device = dev.steal(); + return hr; +} + +HRESULT D3D10CreateDevice( + IDXGIAdapter *adapter, + D3D10_DRIVER_TYPE driver_type, + HMODULE software, + unsigned flags, + unsigned sdk_version, + ID3D10Device **out_device +) +{ + return D3D10CreateDevice1(adapter, driver_type, software, flags, D3D10_FEATURE_LEVEL_10_0, sdk_version, (ID3D10Device1**)out_device); +} + +HRESULT WINAPI D3D10CreateDeviceAndSwapChain( + IDXGIAdapter* adapter, + D3D10_DRIVER_TYPE driver_type, + HMODULE software, + unsigned flags, + unsigned sdk_version, + DXGI_SWAP_CHAIN_DESC* swap_chain_desc, + IDXGISwapChain** out_swap_chain, + ID3D10Device** out_device +) +{ + return D3D10CreateDeviceAndSwapChain1(adapter, driver_type, software, flags, D3D10_FEATURE_LEVEL_10_0, sdk_version, swap_chain_desc, out_swap_chain, (ID3D10Device1**)out_device); +} diff --git a/src/gallium/state_trackers/d3d1x/dxgid3d11/Makefile b/src/gallium/state_trackers/d3d1x/dxgid3d11/Makefile new file mode 100644 index 00000000000..591d1bea940 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/dxgid3d11/Makefile @@ -0,0 +1,4 @@ +LIBNAME=dxgid3d11 +CPP_SOURCES=$(wildcard *.cpp) +LIBRARY_INCLUDES=-I../gd3dapi -I../d3dapi -I../w32api -I../d3d1xstutil/include -I../include -I../../../include -I../../../auxiliary +include ../Makefile.inc diff --git a/src/gallium/state_trackers/d3d1x/dxgid3d11/dxgid3d11.cpp b/src/gallium/state_trackers/d3d1x/dxgid3d11/dxgid3d11.cpp new file mode 100644 index 00000000000..1b1cb907d37 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/dxgid3d11/dxgid3d11.cpp @@ -0,0 +1,135 @@ +/************************************************************************** + * + * 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 "d3d1xstutil.h" +#include "galliumd3d11.h" +#include <dxgi.h> +#include <pipe/p_screen.h> +#include <pipe/p_context.h> + +HRESULT D3D11CreateDevice( + IDXGIAdapter *adapter, + D3D_DRIVER_TYPE driver_type, + HMODULE software, + unsigned flags, + const D3D_FEATURE_LEVEL *feature_levels, + unsigned num_feature_levels, + unsigned sdk_version, + ID3D11Device **out_device, + D3D_FEATURE_LEVEL *feature_level, + ID3D11DeviceContext **out_immediate_context +) +{ + HRESULT hr; + ComPtr<IDXGIAdapter1> adapter_to_release; + if(!adapter) + { + ComPtr<IDXGIFactory1> factory; + hr = CreateDXGIFactory1(IID_IDXGIFactory1, (void**)&factory); + if(!SUCCEEDED(hr)) + return hr; + hr = factory->EnumAdapters1(0, &adapter_to_release); + if(!SUCCEEDED(hr)) + return hr; + adapter = adapter_to_release.p; + } + ComPtr<IGalliumAdapter> gallium_adapter; + hr = adapter->QueryInterface(IID_IGalliumAdapter, (void**)&gallium_adapter); + if(!SUCCEEDED(hr)) + return hr; + struct pipe_screen* screen; + // TODO: what should D3D_DRIVER_TYPE_SOFTWARE return? fast or reference? + if(driver_type == D3D_DRIVER_TYPE_REFERENCE) + screen = gallium_adapter->GetGalliumReferenceSoftwareScreen(); + else if(driver_type == D3D_DRIVER_TYPE_SOFTWARE || driver_type == D3D_DRIVER_TYPE_WARP) + screen = gallium_adapter->GetGalliumFastSoftwareScreen(); + else + screen = gallium_adapter->GetGalliumScreen(); + if(!screen) + return E_FAIL; + struct pipe_context* context = screen->context_create(screen, 0); + if(!context) + return E_FAIL; + ComPtr<ID3D11Device> device; + hr = GalliumD3D11DeviceCreate(screen, context, TRUE, flags, adapter, &device); + if(!SUCCEEDED(hr)) + { + context->destroy(context); + return hr; + } + if(out_immediate_context) + device->GetImmediateContext(out_immediate_context); + if(feature_level) + *feature_level = device->GetFeatureLevel(); + if(out_device) + *out_device = device.steal(); + return S_OK; +} + +HRESULT WINAPI D3D11CreateDeviceAndSwapChain( + IDXGIAdapter* adapter, + D3D_DRIVER_TYPE driver_type, + HMODULE software, + unsigned flags, + CONST D3D_FEATURE_LEVEL* feature_levels, + unsigned num_feature_levels, + unsigned sdk_version, + CONST DXGI_SWAP_CHAIN_DESC* pSwapChainDesc, + IDXGISwapChain** out_swap_chain, + ID3D11Device** out_device, + D3D_FEATURE_LEVEL* feature_level, + ID3D11DeviceContext** out_immediate_context ) +{ + ComPtr<ID3D11Device> dev; + ComPtr<ID3D11DeviceContext> ctx; + HRESULT hr; + hr = D3D11CreateDevice(adapter, driver_type, software, flags, feature_levels, num_feature_levels, sdk_version, (ID3D11Device**)&dev, feature_level, (ID3D11DeviceContext**)&ctx); + if(!SUCCEEDED(hr)) + return hr; + if(out_swap_chain) + { + ComPtr<IDXGIFactory> factory; + ComPtr<IDXGIDevice> dxgi_device; + ComPtr<IDXGIAdapter> adapter; + hr = dev->QueryInterface(IID_IDXGIDevice, (void**)&dxgi_device); + if(!SUCCEEDED(hr)) + return hr; + + hr = dxgi_device->GetAdapter(&adapter); + if(!SUCCEEDED(hr)) + return hr; + + adapter->GetParent(IID_IDXGIFactory, (void**)&factory); + hr = factory->CreateSwapChain(dev.p, (DXGI_SWAP_CHAIN_DESC*)pSwapChainDesc, out_swap_chain); + if(!SUCCEEDED(hr)) + return hr; + } + if(out_device) + *out_device = dev.steal(); + if(out_immediate_context) + *out_immediate_context = ctx.steal(); + return hr; +} diff --git a/src/gallium/state_trackers/d3d1x/gd3d10/Makefile b/src/gallium/state_trackers/d3d1x/gd3d10/Makefile new file mode 100644 index 00000000000..300149d384e --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/gd3d10/Makefile @@ -0,0 +1,20 @@ +LIBNAME=gd3d10 +CPP_SOURCES=d3d10.generated.cpp +LIBRARY_INCLUDES=-I../gd3d1x -I../gd3dapi -I../d3dapi -I../w32api -I../d3d1xstutil/include -I../d3d1xshader/include -I../../../include -I../../../auxiliary -I../../../state_trackers/egl/common + +GEN_D3D10=perl d3d10.pl + +include ../Makefile.inc + +d3d10.generated.o: d3d10_objects.generated.h d3d10_screen.generated.h d3d10_context.generated.h d3d10_misc.generated.h + +d3d10.generated.cpp: ../gd3d11/d3d11.cpp d3d10.pl + $(GEN_D3D10) $< > $@ +d3d10_objects.generated.h: ../gd3d11/d3d11_objects.h d3d10.pl + $(GEN_D3D10) $< > $@ +d3d10_screen.generated.h: ../gd3d11/d3d11_screen.h d3d10.pl + $(GEN_D3D10) $< > $@ +d3d10_context.generated.h: ../gd3d11/d3d11_context.h d3d10.pl + $(GEN_D3D10) $< > $@ +d3d10_misc.generated.h: ../gd3d11/d3d11_misc.h d3d10.pl + $(GEN_D3D10) $< > $@ diff --git a/src/gallium/state_trackers/d3d1x/gd3d10/d3d10.pl b/src/gallium/state_trackers/d3d1x/gd3d10/d3d10.pl new file mode 100755 index 00000000000..4687b8365a6 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/gd3d10/d3d10.pl @@ -0,0 +1,12 @@ +#!/usr/bin/perl +while(<>) +{ + s/D3D11_SRV_DIMENSION_/D3D10_1_SRV_DIMENSION_/g; + s/D3D11/D3D10/g; + s/D3D10_SIGNATURE_PARAMETER_DESC/D3D11_SIGNATURE_PARAMETER_DESC/g; + s/D3D_FEATURE_LEVEL_/D3D10_FEATURE_LEVEL_/g; + s/D3D_FEATURE_LEVEL/D3D10_FEATURE_LEVEL1/g; + s/^#define API 11/#define API 10/; + s/^(#include "d3d1)1(_[^.]*)(.h")/${1}0$2.generated$3/; + print $_; +} diff --git a/src/gallium/state_trackers/d3d1x/gd3d11/Makefile b/src/gallium/state_trackers/d3d1x/gd3d11/Makefile new file mode 100644 index 00000000000..650c11d3d0a --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/gd3d11/Makefile @@ -0,0 +1,6 @@ +LIBNAME=gd3d11 +CPP_SOURCES=d3d11.cpp +LIBRARY_INCLUDES=-I../gd3d1x -I../gd3dapi -I../d3dapi -I../w32api -I../d3d1xstutil/include -I../d3d1xshader/include -I../../../include -I../../../auxiliary -I../../../state_trackers/egl/common + +include ../Makefile.inc + diff --git a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11.cpp b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11.cpp new file mode 100644 index 00000000000..27cfebc1b9c --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11.cpp @@ -0,0 +1,241 @@ +/************************************************************************** + * + * 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 "d3d1x_private.h" + +extern "C" +{ +#include "util/u_gen_mipmap.h" +#include "tgsi/tgsi_ureg.h" +#include "tgsi/tgsi_dump.h" +#include "cso_cache/cso_context.h" +} + + +// the perl script will change this to 10 for d3d10, and also do s/D3D11/D3D10 in the whole file +#define API 11 + +#if API >= 11 +#define DX10_ONLY(x) +#else +#define DX10_ONLY(x) x +#endif + +typedef D3D10_MAPPED_TEXTURE3D D3D10_MAPPED_SUBRESOURCE; + +// used to make QueryInterface know the IIDs of the interface and its ancestors +COM_INTERFACE(ID3D11DeviceChild, IUnknown) +COM_INTERFACE(ID3D11InputLayout, ID3D11DeviceChild) +COM_INTERFACE(ID3D11DepthStencilState, ID3D11DeviceChild) +COM_INTERFACE(ID3D11BlendState, ID3D11DeviceChild) +COM_INTERFACE(ID3D11RasterizerState, ID3D11DeviceChild) +COM_INTERFACE(ID3D11SamplerState, ID3D11DeviceChild) +COM_INTERFACE(ID3D11Resource, ID3D11DeviceChild) +COM_INTERFACE(ID3D11Buffer, ID3D11Resource) +COM_INTERFACE(ID3D11Texture1D, ID3D11Resource) +COM_INTERFACE(ID3D11Texture2D, ID3D11Resource) +COM_INTERFACE(ID3D11Texture3D, ID3D11Resource) +COM_INTERFACE(ID3D11View, ID3D11DeviceChild) +COM_INTERFACE(ID3D11ShaderResourceView, ID3D11View) +COM_INTERFACE(ID3D11RenderTargetView, ID3D11View) +COM_INTERFACE(ID3D11DepthStencilView, ID3D11View) +COM_INTERFACE(ID3D11VertexShader, ID3D11DeviceChild) +COM_INTERFACE(ID3D11GeometryShader, ID3D11DeviceChild) +COM_INTERFACE(ID3D11PixelShader, ID3D11DeviceChild) +COM_INTERFACE(ID3D11Asynchronous, ID3D11DeviceChild) +COM_INTERFACE(ID3D11Query, ID3D11Asynchronous) +COM_INTERFACE(ID3D11Predicate, ID3D11Query) +COM_INTERFACE(ID3D11Counter, ID3D11Asynchronous) +COM_INTERFACE(ID3D11Device, IUnknown) + +#if API >= 11 +COM_INTERFACE(ID3D11UnorderedAccessView, ID3D11View) +COM_INTERFACE(ID3D11HullShader, ID3D11DeviceChild) +COM_INTERFACE(ID3D11DomainShader, ID3D11DeviceChild) +COM_INTERFACE(ID3D11ComputeShader, ID3D11DeviceChild) +COM_INTERFACE(ID3D11ClassInstance, ID3D11DeviceChild) +COM_INTERFACE(ID3D11ClassLinkage, ID3D11DeviceChild) +COM_INTERFACE(ID3D11CommandList, ID3D11DeviceChild) +COM_INTERFACE(ID3D11DeviceContext, ID3D11DeviceChild) +#else +COM_INTERFACE(ID3D10BlendState1, ID3D10BlendState) +COM_INTERFACE(ID3D10ShaderResourceView1, ID3D10ShaderResourceView) +COM_INTERFACE(ID3D10Device1, ID3D10Device) +#endif + +struct GalliumD3D11Screen; + +#if API >= 11 +static ID3D11DeviceContext* GalliumD3D11ImmediateDeviceContext_Create(GalliumD3D11Screen* device, struct pipe_context* pipe, bool owns_pipe); +static void GalliumD3D11ImmediateDeviceContext_RestoreGalliumState(ID3D11DeviceContext* context); +static void GalliumD3D11ImmediateDeviceContext_RestoreGalliumStateBlitOnly(ID3D11DeviceContext* context); +static void GalliumD3D11ImmediateDeviceContext_Destroy(ID3D11DeviceContext* device); +#endif + +static inline pipe_box d3d11_to_pipe_box(struct pipe_resource* resource, unsigned level, const D3D11_BOX* pBox) +{ + pipe_box box; + if(pBox) + { + box.x = pBox->left; + box.y = pBox->top; + box.z = pBox->front; + box.width = pBox->right - pBox->left; + box.height = pBox->bottom - pBox->top; + box.depth = pBox->back - pBox->front; + } + else + { + box.x = box.y = box.z = 0; + box.width = u_minify(resource->width0, level); + box.height = u_minify(resource->height0, level); + box.depth = u_minify(resource->depth0, level); + } + return box; +} + +struct GalliumD3D11Caps +{ + bool so; + bool gs; + bool queries; + bool render_condition; + unsigned constant_buffers[D3D11_STAGES]; + unsigned stages; + unsigned stages_with_sampling; +}; + +typedef GalliumDXGIDevice< + GalliumMultiComObject< +#if API >= 11 + GalliumPrivateDataComObject<ID3D11Device>, +#else + GalliumPrivateDataComObject<ID3D10Device1>, +#endif + IGalliumDevice + > +> GalliumD3D11ScreenBase; + +// used to avoid needing to have forward declarations of functions +// this is called "screen" because in the D3D10 case it's only part of the device +struct GalliumD3D11Screen : public GalliumD3D11ScreenBase +{ + + pipe_screen* screen; + pipe_context* immediate_pipe; + GalliumD3D11Caps screen_caps; + +#if API >= 11 + ID3D11DeviceContext* immediate_context; + ID3D11DeviceContext* get_immediate_context() + { + return immediate_context; + } +#else + GalliumD3D11Screen* get_immediate_context() + { + return this; + } +#endif + + + GalliumD3D11Screen(pipe_screen* screen, struct pipe_context* immediate_pipe, IDXGIAdapter* adapter) + : GalliumD3D11ScreenBase(adapter), screen(screen), immediate_pipe(immediate_pipe) + { + } + +#if API < 11 + // we use a D3D11-like API internally + virtual HRESULT STDMETHODCALLTYPE Map( + ID3D11Resource *pResource, + unsigned Subresource, + D3D11_MAP MapType, + unsigned MapFlags, + D3D11_MAPPED_SUBRESOURCE *pMappedResource) = 0; + virtual void STDMETHODCALLTYPE Unmap( + ID3D11Resource *pResource, + unsigned Subresource) = 0; + virtual void STDMETHODCALLTYPE Begin( + ID3D11Asynchronous *pAsync) = 0; + virtual void STDMETHODCALLTYPE End( + ID3D11Asynchronous *pAsync) = 0; + virtual HRESULT STDMETHODCALLTYPE GetData( + ID3D11Asynchronous *pAsync, + void *pData, + unsigned DataSize, + unsigned GetDataFlags) = 0; + + // TODO: maybe we should use function overloading, but that might risk silent errors, + // and cannot be exported to a C interface + virtual void UnbindBlendState(ID3D11BlendState* state) = 0; + virtual void UnbindRasterizerState(ID3D11RasterizerState* state) = 0; + virtual void UnbindDepthStencilState(ID3D11DepthStencilState* state) = 0; + virtual void UnbindInputLayout(ID3D11InputLayout* state) = 0; + virtual void UnbindPixelShader(ID3D11PixelShader* state) = 0; + virtual void UnbindVertexShader(ID3D11VertexShader* state) = 0; + virtual void UnbindGeometryShader(ID3D11GeometryShader* state) = 0; + virtual void UnbindPredicate(ID3D11Predicate* predicate) = 0; + virtual void UnbindSamplerState(ID3D11SamplerState* state) = 0; + virtual void UnbindBuffer(ID3D11Buffer* buffer) = 0; + virtual void UnbindDepthStencilView(ID3D11DepthStencilView* view) = 0; + virtual void UnbindRenderTargetView(ID3D11RenderTargetView* view) = 0; + virtual void UnbindShaderResourceView(ID3D11ShaderResourceView* view) = 0; + + void UnbindBlendState1(ID3D11BlendState1* state) + { + UnbindBlendState(state); + } + void UnbindShaderResourceView1(ID3D11ShaderResourceView1* view) + { + UnbindShaderResourceView(view); + } +#endif +}; + +#include "d3d11_objects.h" +#include "d3d11_screen.h" +#include "d3d11_context.h" +#include "d3d11_misc.h" + +#if API >= 11 +HRESULT STDMETHODCALLTYPE GalliumD3D11DeviceCreate(struct pipe_screen* screen, struct pipe_context* context, BOOL owns_context, unsigned creation_flags, IDXGIAdapter* adapter, ID3D11Device** ppDevice) +{ + if(creation_flags & D3D11_CREATE_DEVICE_SINGLETHREADED) + *ppDevice = new GalliumD3D11ScreenImpl<false>(screen, context, owns_context, creation_flags, adapter); + else + *ppDevice = new GalliumD3D11ScreenImpl<true>(screen, context, owns_context, creation_flags, adapter); + return S_OK; +} +#else +HRESULT STDMETHODCALLTYPE GalliumD3D10DeviceCreate1(struct pipe_screen* screen, struct pipe_context* context, BOOL owns_context, unsigned creation_flags, IDXGIAdapter* adapter, ID3D10Device1** ppDevice) +{ + if(creation_flags & D3D10_CREATE_DEVICE_SINGLETHREADED) + *ppDevice = new GalliumD3D10Device<false>(screen, context, owns_context, creation_flags, adapter); + else + *ppDevice = new GalliumD3D10Device<true>(screen, context, owns_context, creation_flags, adapter); + return S_OK; +} +#endif diff --git a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h new file mode 100644 index 00000000000..36110595c20 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h @@ -0,0 +1,2069 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + +/* used to unbind things, we need 128 due to resources */ +static const void* zero_data[128]; + +#define UPDATE_VIEWS_SHIFT (D3D11_STAGES * 0) +#define UPDATE_SAMPLERS_SHIFT (D3D11_STAGES * 1) +#define UPDATE_VERTEX_BUFFERS (1 << (D3D11_STAGES * 2)) + +#if API >= 11 +template<typename PtrTraits> +struct GalliumD3D11DeviceContext : + public GalliumD3D11DeviceChild<ID3D11DeviceContext> +{ +#else +template<bool threadsafe> +struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe> +{ + typedef simple_ptr_traits PtrTraits; + typedef GalliumD3D10Device GalliumD3D10DeviceContext; +#endif + + refcnt_ptr<GalliumD3D11Shader<>, PtrTraits> shaders[D3D11_STAGES]; + refcnt_ptr<GalliumD3D11InputLayout, PtrTraits> input_layout; + refcnt_ptr<GalliumD3D11Buffer, PtrTraits> index_buffer; + refcnt_ptr<GalliumD3D11RasterizerState, PtrTraits> rasterizer_state; + refcnt_ptr<GalliumD3D11DepthStencilState, PtrTraits> depth_stencil_state; + refcnt_ptr<GalliumD3D11BlendState, PtrTraits> blend_state; + refcnt_ptr<GalliumD3D11DepthStencilView, PtrTraits> depth_stencil_view; + refcnt_ptr<GalliumD3D11Predicate, PtrTraits> render_predicate; + + refcnt_ptr<GalliumD3D11Buffer, PtrTraits> constant_buffers[D3D11_STAGES][D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT]; + refcnt_ptr<GalliumD3D11ShaderResourceView, PtrTraits> shader_resource_views[D3D11_STAGES][D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT]; + refcnt_ptr<GalliumD3D11SamplerState, PtrTraits> samplers[D3D11_STAGES][D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT]; + refcnt_ptr<GalliumD3D11Buffer, PtrTraits> input_buffers[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]; + refcnt_ptr<GalliumD3D11RenderTargetView, PtrTraits> render_target_views[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT]; + refcnt_ptr<GalliumD3D11Buffer, PtrTraits> so_targets[D3D11_SO_BUFFER_SLOT_COUNT]; + +#if API >= 11 + refcnt_ptr<ID3D11UnorderedAccessView, PtrTraits> cs_unordered_access_views[D3D11_PS_CS_UAV_REGISTER_COUNT]; + refcnt_ptr<ID3D11UnorderedAccessView, PtrTraits> om_unordered_access_views[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT]; +#endif + + D3D11_VIEWPORT viewports[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE]; + D3D11_RECT scissor_rects[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE]; + unsigned so_offsets[D3D11_SO_BUFFER_SLOT_COUNT]; + D3D11_PRIMITIVE_TOPOLOGY primitive_topology; + DXGI_FORMAT index_format; + unsigned index_offset; + BOOL render_predicate_value; + float blend_color[4]; + unsigned sample_mask; + unsigned stencil_ref; + bool depth_clamp; + + void* default_input_layout; + void* default_rasterizer; + void* default_depth_stencil; + void* default_blend; + void* default_sampler; + void* ld_sampler; + void * default_shaders[D3D11_STAGES]; + + // derived state + int primitive_mode; + struct pipe_vertex_buffer vertex_buffers[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]; + struct pipe_resource* so_buffers[D3D11_SO_BUFFER_SLOT_COUNT]; + struct pipe_sampler_view* sampler_views[D3D11_STAGES][D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT]; + struct + { + void* ld; // accessed with a -1 index from v + void* v[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT]; + } sampler_csos[D3D11_STAGES]; + struct pipe_resource * buffers[D3D11_SO_BUFFER_SLOT_COUNT]; + unsigned num_shader_resource_views[D3D11_STAGES]; + unsigned num_samplers[D3D11_STAGES]; + unsigned num_vertex_buffers; + unsigned num_render_target_views; + unsigned num_viewports; + unsigned num_scissor_rects; + unsigned num_so_targets; + + struct pipe_context* pipe; + unsigned update_flags; + + bool owns_pipe; + unsigned context_flags; + + GalliumD3D11Caps caps; + + cso_context* cso_ctx; + gen_mipmap_state* gen_mipmap; + +#if API >= 11 +#define SYNCHRONIZED do {} while(0) + + GalliumD3D11DeviceContext(GalliumD3D11Screen* device, pipe_context* pipe, bool owns_pipe, unsigned context_flags = 0) + : GalliumD3D11DeviceChild<ID3D11DeviceContext>(device), pipe(pipe), owns_pipe(owns_pipe), context_flags(context_flags) + { + caps = device->screen_caps; + init_context(); + } + + ~GalliumD3D11DeviceContext() + { + destroy_context(); + } +#else +#define SYNCHRONIZED lock_t<maybe_mutex_t<threadsafe> > lock_(this->mutex) + + GalliumD3D10Device(pipe_screen* screen, pipe_context* pipe, bool owns_pipe, unsigned creation_flags, IDXGIAdapter* adapter) + : GalliumD3D10ScreenImpl<threadsafe>(screen, pipe, owns_pipe, creation_flags, adapter), pipe(pipe), owns_pipe(owns_pipe), context_flags(0) + { + caps = this->screen_caps; + init_context(); + } + + ~GalliumD3D10Device() + { + destroy_context(); + } +#endif + + void init_context() + { + if(!pipe->begin_query) + caps.queries = false; + if(!pipe->render_condition) + caps.render_condition = false; + if(!pipe->bind_gs_state) + { + caps.gs = false; + caps.stages = 2; + } + if(!pipe->set_stream_output_buffers) + caps.so = false; + if(!pipe->set_geometry_sampler_views) + caps.stages_with_sampling &=~ (1 << PIPE_SHADER_GEOMETRY); + if(!pipe->set_fragment_sampler_views) + caps.stages_with_sampling &=~ (1 << PIPE_SHADER_FRAGMENT); + if(!pipe->set_vertex_sampler_views) + caps.stages_with_sampling &=~ (1 << PIPE_SHADER_VERTEX); + + update_flags = 0; + + // pipeline state + memset(viewports, 0, sizeof(viewports)); + memset(scissor_rects, 0, sizeof(scissor_rects)); + memset(so_offsets, 0, sizeof(so_offsets)); + primitive_topology = D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED; + index_format = DXGI_FORMAT_UNKNOWN; + index_offset = 0; + render_predicate_value = 0; + memset(blend_color, 0, sizeof(blend_color)); + sample_mask = ~0; + stencil_ref = 0; + depth_clamp = 0; + + // derived state + primitive_mode = 0; + memset(vertex_buffers, 0, sizeof(vertex_buffers)); + memset(so_buffers, 0, sizeof(so_buffers)); + memset(sampler_views, 0, sizeof(sampler_views)); + memset(sampler_csos, 0, sizeof(sampler_csos)); + memset(num_shader_resource_views, 0, sizeof(num_shader_resource_views)); + memset(num_samplers, 0, sizeof(num_samplers)); + num_vertex_buffers = 0; + num_render_target_views = 0; + num_viewports = 0; + num_scissor_rects = 0; + num_so_targets = 0; + + default_input_layout = pipe->create_vertex_elements_state(pipe, 0, 0); + + struct pipe_rasterizer_state rasterizerd; + memset(&rasterizerd, 0, sizeof(rasterizerd)); + rasterizerd.gl_rasterization_rules = 1; + rasterizerd.cull_face = PIPE_FACE_BACK; + default_rasterizer = pipe->create_rasterizer_state(pipe, &rasterizerd); + + struct pipe_depth_stencil_alpha_state depth_stencild; + memset(&depth_stencild, 0, sizeof(depth_stencild)); + depth_stencild.depth.enabled = TRUE; + depth_stencild.depth.writemask = 1; + depth_stencild.depth.func = PIPE_FUNC_LESS; + default_depth_stencil = pipe->create_depth_stencil_alpha_state(pipe, &depth_stencild); + + struct pipe_blend_state blendd; + memset(&blendd, 0, sizeof(blendd)); + blendd.rt[0].colormask = 0xf; + default_blend = pipe->create_blend_state(pipe, &blendd); + + struct pipe_sampler_state samplerd; + memset(&samplerd, 0, sizeof(samplerd)); + samplerd.normalized_coords = 1; + samplerd.min_img_filter = PIPE_TEX_FILTER_LINEAR; + samplerd.mag_img_filter = PIPE_TEX_FILTER_LINEAR; + samplerd.min_mip_filter = PIPE_TEX_MIPFILTER_LINEAR; + samplerd.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE; + samplerd.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE; + samplerd.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE; + samplerd.border_color[0] = 1.0f; + samplerd.border_color[1] = 1.0f; + samplerd.border_color[2] = 1.0f; + samplerd.border_color[3] = 1.0f; + samplerd.min_lod = -FLT_MAX; + samplerd.max_lod = FLT_MAX; + samplerd.max_anisotropy = 1; + default_sampler = pipe->create_sampler_state(pipe, &samplerd); + + memset(&samplerd, 0, sizeof(samplerd)); + samplerd.normalized_coords = 0; + samplerd.min_img_filter = PIPE_TEX_FILTER_NEAREST; + samplerd.mag_img_filter = PIPE_TEX_FILTER_NEAREST; + samplerd.min_mip_filter = PIPE_TEX_MIPFILTER_NONE; + samplerd.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_BORDER; + samplerd.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_BORDER; + samplerd.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_BORDER; + samplerd.min_lod = -FLT_MAX; + samplerd.max_lod = FLT_MAX; + samplerd.max_anisotropy = 1; + ld_sampler = pipe->create_sampler_state(pipe, &samplerd); + + for(unsigned s = 0; s < D3D11_STAGES; ++s) + { + sampler_csos[s].ld = ld_sampler; + for(unsigned i = 0; i < D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT; ++i) + sampler_csos[s].v[i] = default_sampler; + } + + // TODO: should this really be empty shaders, or should they be all-passthrough? + memset(default_shaders, 0, sizeof(default_shaders)); + struct ureg_program *ureg; + ureg = ureg_create(TGSI_PROCESSOR_FRAGMENT); + ureg_END(ureg); + default_shaders[PIPE_SHADER_FRAGMENT] = ureg_create_shader_and_destroy(ureg, pipe); + + ureg = ureg_create(TGSI_PROCESSOR_VERTEX); + ureg_END(ureg); + default_shaders[PIPE_SHADER_VERTEX] = ureg_create_shader_and_destroy(ureg, pipe); + + cso_ctx = cso_create_context(pipe); + gen_mipmap = util_create_gen_mipmap(pipe, cso_ctx); + + RestoreGalliumState(); + } + + void destroy_context() + { + util_destroy_gen_mipmap(gen_mipmap); + cso_destroy_context(cso_ctx); + + pipe->bind_vertex_elements_state(pipe, 0); + pipe->delete_vertex_elements_state(pipe, default_input_layout); + + pipe->bind_rasterizer_state(pipe, 0); + pipe->delete_rasterizer_state(pipe, default_rasterizer); + + pipe->bind_depth_stencil_alpha_state(pipe, 0); + pipe->delete_depth_stencil_alpha_state(pipe, default_depth_stencil); + + pipe->bind_blend_state(pipe, 0); + pipe->delete_blend_state(pipe, default_blend); + + pipe->bind_fragment_sampler_states(pipe, 0, 0); + pipe->bind_vertex_sampler_states(pipe, 0, 0); + if(pipe->bind_geometry_sampler_states) + pipe->bind_geometry_sampler_states(pipe, 0, 0); + pipe->delete_sampler_state(pipe, default_sampler); + pipe->delete_sampler_state(pipe, ld_sampler); + + pipe->bind_fs_state(pipe, 0); + pipe->delete_fs_state(pipe, default_shaders[PIPE_SHADER_FRAGMENT]); + + pipe->bind_vs_state(pipe, 0); + pipe->delete_vs_state(pipe, default_shaders[PIPE_SHADER_VERTEX]); + + if(owns_pipe) + pipe->destroy(pipe); + } + + virtual unsigned STDMETHODCALLTYPE GetContextFlags(void) + { + return context_flags; + } +#if API >= 11 +#define SET_SHADER_EXTRA_ARGS , \ + ID3D11ClassInstance *const *ppClassInstances, \ + unsigned count +#define GET_SHADER_EXTRA_ARGS , \ + ID3D11ClassInstance **ppClassInstances, \ + unsigned *out_count +#else +#define SET_SHADER_EXTRA_ARGS +#define GET_SHADER_EXTRA_ARGS +#endif + +/* On Windows D3D11, SetConstantBuffers and SetShaderResources crash if passed a null pointer. + * Instead, you have to pass a pointer to nulls to unbind things. + * We do the same. + * TODO: is D3D10 the same? + */ + template<unsigned s> + void xs_set_shader(GalliumD3D11Shader<>* shader) + { + if(shader != shaders[s].p) + { + shaders[s] = shader; + void* shader_cso = shader ? shader->object : default_shaders[s]; + switch(s) + { + case PIPE_SHADER_VERTEX: + pipe->bind_vs_state(pipe, shader_cso); + break; + case PIPE_SHADER_FRAGMENT: + pipe->bind_fs_state(pipe, shader_cso); + break; + case PIPE_SHADER_GEOMETRY: + pipe->bind_gs_state(pipe, shader_cso); + break; + } + update_flags |= (1 << (UPDATE_SAMPLERS_SHIFT + s)) | (1 << (UPDATE_VIEWS_SHIFT + s)); + } + } + + template<unsigned s> + void xs_set_constant_buffers(unsigned start, unsigned count, GalliumD3D11Buffer *const *constbufs) + { + for(unsigned i = 0; i < count; ++i) + { + if(constbufs[i] != constant_buffers[s][i].p) + { + constant_buffers[s][i] = constbufs[i]; + if(s < caps.stages && start + i < caps.constant_buffers[s]) + pipe->set_constant_buffer(pipe, s, start + i, constbufs[i] ? constbufs[i]->resource : NULL); + } + } + } + + template<unsigned s> + void xs_set_shader_resources(unsigned start, unsigned count, GalliumD3D11ShaderResourceView *const *srvs) + { + int last_different = -1; + for(unsigned i = 0; i < count; ++i) + { + if(shader_resource_views[s][start + i].p != srvs[i]) + { + shader_resource_views[s][start + i] = srvs[i]; + sampler_views[s][start + i] = srvs[i] ? srvs[i]->object : 0; + last_different = i; + } + } + if(last_different >= 0) + { + num_shader_resource_views[s] = std::max(num_shader_resource_views[s], start + last_different + 1); + update_flags |= 1 << (UPDATE_VIEWS_SHIFT + s); + } + } + + template<unsigned s> + void xs_set_samplers(unsigned start, unsigned count, GalliumD3D11SamplerState *const *samps) + { + int last_different = -1; + for(unsigned i = 0; i < count; ++i) + { + if(samplers[s][start + i].p != samps[i]) + { + samplers[s][start + i] = samps[i]; + sampler_csos[s].v[start + i] = samps[i] ? samps[i]->object : default_sampler; + } + if(last_different >= 0) + { + num_samplers[s] = std::max(num_samplers[s], start + last_different + 1); + update_flags |= (UPDATE_SAMPLERS_SHIFT + s); + } + } + } + +#define IMPLEMENT_SHADER_STAGE(XS, Stage) \ + virtual void STDMETHODCALLTYPE XS##SetShader( \ + ID3D11##Stage##Shader *pShader \ + SET_SHADER_EXTRA_ARGS) \ + { \ + SYNCHRONIZED; \ + xs_set_shader<D3D11_STAGE_##XS>((GalliumD3D11Shader<>*)pShader); \ + } \ + virtual void STDMETHODCALLTYPE XS##GetShader(\ + ID3D11##Stage##Shader **ppShader \ + GET_SHADER_EXTRA_ARGS) \ + { \ + SYNCHRONIZED; \ + *ppShader = (ID3D11##Stage##Shader*)shaders[D3D11_STAGE_##XS].ref(); \ + } \ + virtual void STDMETHODCALLTYPE XS##SetConstantBuffers(\ + unsigned start, \ + unsigned count, \ + ID3D11Buffer *const* constant_buffers) \ + { \ + SYNCHRONIZED; \ + xs_set_constant_buffers<D3D11_STAGE_##XS>(start, count, (GalliumD3D11Buffer *const *)constant_buffers); \ + } \ + virtual void STDMETHODCALLTYPE XS##GetConstantBuffers(\ + unsigned start, \ + unsigned count, \ + ID3D11Buffer **out_constant_buffers) \ + { \ + SYNCHRONIZED; \ + for(unsigned i = 0; i < count; ++i) \ + out_constant_buffers[i] = constant_buffers[D3D11_STAGE_##XS][start + i].ref(); \ + } \ + virtual void STDMETHODCALLTYPE XS##SetShaderResources(\ + unsigned start, \ + unsigned count, \ + ID3D11ShaderResourceView *const *new_shader_resource_views) \ + { \ + SYNCHRONIZED; \ + xs_set_shader_resources<D3D11_STAGE_##XS>(start, count, (GalliumD3D11ShaderResourceView *const *)new_shader_resource_views); \ + } \ + virtual void STDMETHODCALLTYPE XS##GetShaderResources(\ + unsigned start, \ + unsigned count, \ + ID3D11ShaderResourceView **out_shader_resource_views) \ + { \ + SYNCHRONIZED; \ + for(unsigned i = 0; i < count; ++i) \ + out_shader_resource_views[i] = shader_resource_views[D3D11_STAGE_##XS][start + i].ref(); \ + } \ + virtual void STDMETHODCALLTYPE XS##SetSamplers(\ + unsigned start, \ + unsigned count, \ + ID3D11SamplerState *const *new_samplers) \ + { \ + SYNCHRONIZED; \ + xs_set_samplers<D3D11_STAGE_##XS>(start, count, (GalliumD3D11SamplerState *const *)new_samplers); \ + } \ + virtual void STDMETHODCALLTYPE XS##GetSamplers( \ + unsigned start, \ + unsigned count, \ + ID3D11SamplerState **out_samplers) \ + { \ + SYNCHRONIZED; \ + for(unsigned i = 0; i < count; ++i) \ + out_samplers[i] = samplers[D3D11_STAGE_##XS][start + i].ref(); \ + } + +#define DO_VS(x) x +#define DO_GS(x) do {if(caps.gs) {x;}} while(0) +#define DO_PS(x) x +#define DO_HS(x) +#define DO_DS(x) +#define DO_CS(x) + IMPLEMENT_SHADER_STAGE(VS, Vertex) + IMPLEMENT_SHADER_STAGE(GS, Geometry) + IMPLEMENT_SHADER_STAGE(PS, Pixel) + +#if API >= 11 + IMPLEMENT_SHADER_STAGE(HS, Hull) + IMPLEMENT_SHADER_STAGE(DS, Domain) + IMPLEMENT_SHADER_STAGE(CS, Compute) + + virtual void STDMETHODCALLTYPE CSSetUnorderedAccessViews( + unsigned start, + unsigned count, + ID3D11UnorderedAccessView *const *new_unordered_access_views, + const unsigned *new_uav_initial_counts) + { + SYNCHRONIZED; + for(unsigned i = 0; i < count; ++i) + cs_unordered_access_views[start + i] = new_unordered_access_views[i]; + } + + virtual void STDMETHODCALLTYPE CSGetUnorderedAccessViews( + unsigned start, + unsigned count, + ID3D11UnorderedAccessView **out_unordered_access_views) + { + SYNCHRONIZED; + for(unsigned i = 0; i < count; ++i) + out_unordered_access_views[i] = cs_unordered_access_views[start + i].ref(); + } +#endif + + template<unsigned s> + void update_stage() + { + if(update_flags & (1 << (UPDATE_VIEWS_SHIFT + s))) + { + while(num_shader_resource_views[s] && !sampler_views[s][num_shader_resource_views[s] - 1]) \ + --num_shader_resource_views[s]; + if((1 << s) & caps.stages_with_sampling) + { + struct pipe_sampler_view* views_to_bind[PIPE_MAX_SAMPLERS]; + unsigned num_views_to_bind = shaders[s] ? shaders[s]->slot_to_resource.size() : 0; + for(unsigned i = 0; i < num_views_to_bind; ++i) + { + views_to_bind[i] = sampler_views[s][shaders[s]->slot_to_resource[i]]; + } + switch(s) + { + case PIPE_SHADER_VERTEX: + pipe->set_vertex_sampler_views(pipe, num_views_to_bind, views_to_bind); + break; + case PIPE_SHADER_FRAGMENT: + pipe->set_fragment_sampler_views(pipe, num_views_to_bind, views_to_bind); + break; + case PIPE_SHADER_GEOMETRY: + pipe->set_geometry_sampler_views(pipe, num_views_to_bind, views_to_bind); + break; + } + } + } + + if(update_flags & (1 << (UPDATE_SAMPLERS_SHIFT + s))) + { + while(num_samplers[s] && !sampler_csos[s].v[num_samplers[s] - 1]) + --num_samplers[s]; + if((1 << s) & caps.stages_with_sampling) + { + void* samplers_to_bind[PIPE_MAX_SAMPLERS]; + unsigned num_samplers_to_bind = shaders[s] ? shaders[s]->slot_to_sampler.size() : 0; + for(unsigned i = 0; i < num_samplers_to_bind; ++i) + { + // index can be -1 to access sampler_csos[s].ld + samplers_to_bind[i] = *(sampler_csos[s].v + shaders[s]->slot_to_sampler[i]); + } + switch(s) + { + case PIPE_SHADER_VERTEX: + pipe->bind_vertex_sampler_states(pipe, num_samplers_to_bind, samplers_to_bind); + break; + case PIPE_SHADER_FRAGMENT: + pipe->bind_fragment_sampler_states(pipe, num_samplers_to_bind, samplers_to_bind); + break; + case PIPE_SHADER_GEOMETRY: + pipe->bind_geometry_sampler_states(pipe, num_samplers_to_bind, samplers_to_bind); + break; + } + } + } + } + + void update_state() + { + update_stage<D3D11_STAGE_PS>(); + update_stage<D3D11_STAGE_VS>(); + update_stage<D3D11_STAGE_GS>(); +#if API >= 11 + update_stage<D3D11_STAGE_HS>(); + update_stage<D3D11_STAGE_DS>(); + update_stage<D3D11_STAGE_CS>(); +#endif + + if(update_flags & UPDATE_VERTEX_BUFFERS) + { + while(num_vertex_buffers && !vertex_buffers[num_vertex_buffers - 1].buffer) + --num_vertex_buffers; + pipe->set_vertex_buffers(pipe, num_vertex_buffers, vertex_buffers); + } + + update_flags = 0; + } + + virtual void STDMETHODCALLTYPE IASetInputLayout( + ID3D11InputLayout *new_input_layout) + { + SYNCHRONIZED; + if(new_input_layout != input_layout.p) + { + input_layout = new_input_layout; + pipe->bind_vertex_elements_state(pipe, new_input_layout ? ((GalliumD3D11InputLayout*)new_input_layout)->object : default_input_layout); + } + } + + virtual void STDMETHODCALLTYPE IAGetInputLayout( + ID3D11InputLayout **out_input_layout) + { + SYNCHRONIZED; + *out_input_layout = input_layout.ref(); + } + + virtual void STDMETHODCALLTYPE IASetVertexBuffers( + unsigned start, + unsigned count, + ID3D11Buffer *const *new_vertex_buffers, + const unsigned *new_strides, + const unsigned *new_offsets) + { + SYNCHRONIZED; + int last_different = -1; + for(unsigned i = 0; i < count; ++i) + { + ID3D11Buffer* buffer = new_vertex_buffers[i]; + if(buffer != input_buffers[start + i].p + || vertex_buffers[start + i].buffer_offset != new_offsets[i] + || vertex_buffers[start + i].stride != new_offsets[i] + ) + { + input_buffers[start + i] = buffer; + vertex_buffers[start + i].buffer = buffer ? ((GalliumD3D11Buffer*)buffer)->resource : 0; + vertex_buffers[start + i].buffer_offset = new_offsets[i]; + vertex_buffers[start + i].stride = new_strides[i]; + vertex_buffers[start + i].max_index = ~0; + last_different = i; + } + } + if(last_different >= 0) + { + num_vertex_buffers = std::max(num_vertex_buffers, start + count); + update_flags |= UPDATE_VERTEX_BUFFERS; + } + } + + virtual void STDMETHODCALLTYPE IAGetVertexBuffers( + unsigned start, + unsigned count, + ID3D11Buffer **out_vertex_buffers, + unsigned *out_strides, + unsigned *out_offsets) + { + SYNCHRONIZED; + if(out_vertex_buffers) + { + for(unsigned i = 0; i < count; ++i) + out_vertex_buffers[i] = input_buffers[start + i].ref(); + } + + if(out_offsets) + { + for(unsigned i = 0; i < count; ++i) + out_offsets[i] = vertex_buffers[start + i].buffer_offset; + } + + if(out_strides) + { + for(unsigned i = 0; i < count; ++i) + out_strides[i] = vertex_buffers[start + i].stride; + } + } + + void set_index_buffer() + { + pipe_index_buffer ib; + if(!index_buffer) + { + memset(&ib, 0, sizeof(ib)); + } + else + { + if(index_format == DXGI_FORMAT_R32_UINT) + ib.index_size = 4; + else if(index_format == DXGI_FORMAT_R16_UINT) + ib.index_size = 2; + else + ib.index_size = 1; + ib.offset = index_offset; + ib.buffer = index_buffer ? ((GalliumD3D11Buffer*)index_buffer.p)->resource : 0; + } + pipe->set_index_buffer(pipe, &ib); + } + + virtual void STDMETHODCALLTYPE IASetIndexBuffer( + ID3D11Buffer *new_index_buffer, + DXGI_FORMAT new_index_format, + unsigned new_index_offset) + { + SYNCHRONIZED; + if(index_buffer.p != new_index_buffer || index_format != new_index_format || index_offset != new_index_offset) + { + index_buffer = new_index_buffer; + index_format = new_index_format; + index_offset = new_index_offset; + + set_index_buffer(); + } + } + + virtual void STDMETHODCALLTYPE IAGetIndexBuffer( + ID3D11Buffer **out_index_buffer, + DXGI_FORMAT *out_index_format, + unsigned *out_index_offset) + { + SYNCHRONIZED; + if(out_index_buffer) + *out_index_buffer = index_buffer.ref(); + if(out_index_format) + *out_index_format = index_format; + if(out_index_offset) + *out_index_offset = index_offset; + } + + virtual void STDMETHODCALLTYPE IASetPrimitiveTopology( + D3D11_PRIMITIVE_TOPOLOGY new_primitive_topology) + { + SYNCHRONIZED; + if(primitive_topology != new_primitive_topology) + { + if(new_primitive_topology < D3D_PRIMITIVE_TOPOLOGY_COUNT) + primitive_mode = d3d_to_pipe_prim[new_primitive_topology]; + else + primitive_mode = 0; + primitive_topology = new_primitive_topology; + } + } + + virtual void STDMETHODCALLTYPE IAGetPrimitiveTopology( + D3D11_PRIMITIVE_TOPOLOGY *out_primitive_topology) + { + SYNCHRONIZED; + *out_primitive_topology = primitive_topology; + } + + virtual void STDMETHODCALLTYPE DrawIndexed( + unsigned index_count, + unsigned start_index_location, + int base_vertex_location) + { + SYNCHRONIZED; + if(update_flags) + update_state(); + + pipe_draw_info info; + info.mode = primitive_mode; + info.indexed = TRUE; + info.count = index_count; + info.start = start_index_location; + info.index_bias = base_vertex_location; + info.min_index = 0; + info.max_index = ~0; + info.start_instance = 0; + info.instance_count = 1; + + pipe->draw_vbo(pipe, &info); + } + + virtual void STDMETHODCALLTYPE Draw( + unsigned vertex_count, + unsigned start_vertex_location) + { + SYNCHRONIZED; + if(update_flags) + update_state(); + + pipe_draw_info info; + info.mode = primitive_mode; + info.indexed = FALSE; + info.count = vertex_count; + info.start = start_vertex_location; + info.index_bias = 0; + info.min_index = 0; + info.max_index = ~0; + info.start_instance = 0; + info.instance_count = 1; + + pipe->draw_vbo(pipe, &info); + } + + virtual void STDMETHODCALLTYPE DrawIndexedInstanced( + unsigned index_countPerInstance, + unsigned instance_count, + unsigned start_index_location, + int base_vertex_location, + unsigned start_instance_location) + { + SYNCHRONIZED; + if(update_flags) + update_state(); + + pipe_draw_info info; + info.mode = primitive_mode; + info.indexed = TRUE; + info.count = index_countPerInstance; + info.start = start_index_location; + info.index_bias = base_vertex_location; + info.min_index = 0; + info.max_index = ~0; + info.start_instance = start_instance_location; + info.instance_count = instance_count; + + pipe->draw_vbo(pipe, &info); + } + + virtual void STDMETHODCALLTYPE DrawInstanced( + unsigned vertex_countPerInstance, + unsigned instance_count, + unsigned start_vertex_location, + unsigned start_instance_location) + { + SYNCHRONIZED; + if(update_flags) + update_state(); + + pipe_draw_info info; + info.mode = primitive_mode; + info.indexed = FALSE; + info.count = vertex_countPerInstance; + info.start = start_vertex_location; + info.index_bias = 0; + info.min_index = 0; + info.max_index = ~0; + info.start_instance = start_instance_location; + info.instance_count = instance_count; + + pipe->draw_vbo(pipe, &info); + } + + virtual void STDMETHODCALLTYPE DrawAuto(void) + { + if(!caps.so) + return; + + SYNCHRONIZED; + if(update_flags) + update_state(); + + pipe->draw_stream_output(pipe, primitive_mode); + } + + virtual void STDMETHODCALLTYPE DrawIndexedInstancedIndirect( + ID3D11Buffer *buffer, + unsigned aligned_byte_offset) + { + SYNCHRONIZED; + if(update_flags) + update_state(); + + struct { + unsigned count; + unsigned instance_count; + unsigned start; + unsigned index_bias; + } data; + + pipe_buffer_read(pipe, ((GalliumD3D11Buffer*)buffer)->resource, aligned_byte_offset, sizeof(data), &data); + + pipe_draw_info info; + info.mode = primitive_mode; + info.indexed = TRUE; + info.start = data.start; + info.count = data.count; + info.index_bias = data.index_bias; + info.min_index = 0; + info.max_index = ~0; + info.start_instance = 0; + info.instance_count = data.instance_count; + + pipe->draw_vbo(pipe, &info); + } + + virtual void STDMETHODCALLTYPE DrawInstancedIndirect( + ID3D11Buffer *buffer, + unsigned aligned_byte_offset) + { + SYNCHRONIZED; + if(update_flags) + update_state(); + + struct { + unsigned count; + unsigned instance_count; + unsigned start; + } data; + + pipe_buffer_read(pipe, ((GalliumD3D11Buffer*)buffer)->resource, aligned_byte_offset, sizeof(data), &data); + + pipe_draw_info info; + info.mode = primitive_mode; + info.indexed = FALSE; + info.start = data.start; + info.count = data.count; + info.index_bias = 0; + info.min_index = 0; + info.max_index = ~0; + info.start_instance = 0; + info.instance_count = data.instance_count; + + pipe->draw_vbo(pipe, &info); + } + +#if API >= 11 + virtual void STDMETHODCALLTYPE Dispatch( + unsigned thread_group_count_x, + unsigned thread_group_count_y, + unsigned thread_group_count_z) + { +// uncomment this when this is implemented +// SYNCHRONIZED; +// if(update_flags) +// update_state(); + } + + virtual void STDMETHODCALLTYPE DispatchIndirect( + ID3D11Buffer *buffer, + unsigned aligned_byte_offset) + { +// uncomment this when this is implemented +// SYNCHRONIZED; +// if(update_flags) +// update_state(); + } +#endif + + void set_clip() + { + pipe_clip_state clip; + clip.nr = 0; + clip.depth_clamp = depth_clamp; + pipe->set_clip_state(pipe, &clip); + } + + virtual void STDMETHODCALLTYPE RSSetState( + ID3D11RasterizerState *new_rasterizer_state) + { + SYNCHRONIZED; + if(new_rasterizer_state != rasterizer_state.p) + { + rasterizer_state = new_rasterizer_state; + pipe->bind_rasterizer_state(pipe, new_rasterizer_state ? ((GalliumD3D11RasterizerState*)new_rasterizer_state)->object : default_rasterizer); + bool new_depth_clamp = new_rasterizer_state ? ((GalliumD3D11RasterizerState*)new_rasterizer_state)->depth_clamp : false; + if(depth_clamp != new_depth_clamp) + { + depth_clamp = new_depth_clamp; + set_clip(); + } + } + } + + virtual void STDMETHODCALLTYPE RSGetState( + ID3D11RasterizerState **out_rasterizer_state) + { + SYNCHRONIZED; + *out_rasterizer_state = rasterizer_state.ref(); + } + + void set_viewport() + { + // TODO: is depth correct? it seems D3D10/11 uses a [-1,1]x[-1,1]x[0,1] cube + pipe_viewport_state viewport; + float half_width = viewports[0].Width * 0.5f; + float half_height = viewports[0].Height * 0.5f; + + viewport.scale[0] = half_width; + viewport.scale[1] = -half_height; + viewport.scale[2] = (viewports[0].MaxDepth - viewports[0].MinDepth); + viewport.scale[3] = 1.0f; + viewport.translate[0] = half_width + viewports[0].TopLeftX; + viewport.translate[1] = half_height + viewports[0].TopLeftY; + viewport.translate[2] = viewports[0].MinDepth; + viewport.translate[3] = 1.0f; + pipe->set_viewport_state(pipe, &viewport); + } + + virtual void STDMETHODCALLTYPE RSSetViewports( + unsigned count, + const D3D11_VIEWPORT *new_viewports) + { + SYNCHRONIZED; + if(count) + { + if(memcmp(&viewports[0], &new_viewports[0], sizeof(viewports[0]))) + { + viewports[0] = new_viewports[0]; + set_viewport(); + } + for(unsigned i = 1; i < count; ++i) + viewports[i] = new_viewports[i]; + } + else if(num_viewports) + { + // TODO: what should we do here? + memset(&viewports[0], 0, sizeof(viewports[0])); + set_viewport(); + } + num_viewports = count; + } + + virtual void STDMETHODCALLTYPE RSGetViewports( + unsigned *out_count, + D3D11_VIEWPORT *out_viewports) + { + SYNCHRONIZED; + if(out_viewports) + { + unsigned i; + for(i = 0; i < std::min(*out_count, num_viewports); ++i) + out_viewports[i] = viewports[i]; + + memset(out_viewports + i, 0, (*out_count - i) * sizeof(D3D11_VIEWPORT)); + } + + *out_count = num_viewports; + } + + void set_scissor() + { + pipe_scissor_state scissor; + scissor.minx = scissor_rects[0].left; + scissor.miny = scissor_rects[0].top; + scissor.maxx = scissor_rects[0].right; + scissor.maxy = scissor_rects[0].bottom; + pipe->set_scissor_state(pipe, &scissor); + } + + virtual void STDMETHODCALLTYPE RSSetScissorRects( + unsigned count, + const D3D11_RECT *new_rects) + { + SYNCHRONIZED; + if(count) + { + if(memcmp(&scissor_rects[0], &new_rects[0], sizeof(scissor_rects[0]))) + { + scissor_rects[0] = new_rects[0]; + set_scissor(); + } + for(unsigned i = 1; i < count; ++i) + scissor_rects[i] = new_rects[i]; + } + else if(num_scissor_rects) + { + // TODO: what should we do here? + memset(&scissor_rects[0], 0, sizeof(scissor_rects[0])); + set_scissor(); + } + + num_scissor_rects = count; + } + + virtual void STDMETHODCALLTYPE RSGetScissorRects( + unsigned *out_count, + D3D11_RECT *out_rects) + { + SYNCHRONIZED; + if(out_rects) + { + unsigned i; + for(i = 0; i < std::min(*out_count, num_scissor_rects); ++i) + out_rects[i] = scissor_rects[i]; + + memset(out_rects + i, 0, (*out_count - i) * sizeof(D3D11_RECT)); + } + + *out_count = num_scissor_rects; + } + + virtual void STDMETHODCALLTYPE OMSetBlendState( + ID3D11BlendState *new_blend_state, + const float new_blend_factor[4], + unsigned new_sample_mask) + { + SYNCHRONIZED; + float white[4] = {1.0f, 1.0f, 1.0f, 1.0f}; + + if(blend_state.p != new_blend_state) + { + pipe->bind_blend_state(pipe, new_blend_state ? ((GalliumD3D11BlendState*)new_blend_state)->object : default_blend); + blend_state = new_blend_state; + } + + // Windows D3D11 does this, even though it's apparently undocumented + if(!new_blend_factor) + new_blend_factor = white; + + if(memcmp(blend_color, new_blend_factor, sizeof(blend_color))) + { + pipe->set_blend_color(pipe, (struct pipe_blend_color*)new_blend_factor); + memcpy(blend_color, new_blend_factor, sizeof(blend_color)); + } + + if(sample_mask != new_sample_mask) + { + pipe->set_sample_mask(pipe, new_sample_mask); + sample_mask = new_sample_mask; + } + } + + virtual void STDMETHODCALLTYPE OMGetBlendState( + ID3D11BlendState **out_blend_state, + float out_blend_factor[4], + unsigned *out_sample_mask) + { + SYNCHRONIZED; + if(out_blend_state) + *out_blend_state = blend_state.ref(); + if(out_blend_factor) + memcpy(out_blend_factor, blend_color, sizeof(blend_color)); + if(out_sample_mask) + *out_sample_mask = sample_mask; + } + + void set_stencil_ref() + { + struct pipe_stencil_ref sref; + sref.ref_value[0] = stencil_ref; + sref.ref_value[1] = stencil_ref; + pipe->set_stencil_ref(pipe, &sref); + } + + virtual void STDMETHODCALLTYPE OMSetDepthStencilState( + ID3D11DepthStencilState *new_depth_stencil_state, + unsigned new_stencil_ref) + { + SYNCHRONIZED; + if(new_depth_stencil_state != depth_stencil_state.p) + { + pipe->bind_depth_stencil_alpha_state(pipe, new_depth_stencil_state ? ((GalliumD3D11DepthStencilState*)new_depth_stencil_state)->object : default_depth_stencil); + depth_stencil_state = new_depth_stencil_state; + } + + if(new_stencil_ref != stencil_ref) + { + stencil_ref = new_stencil_ref; + set_stencil_ref(); + } + } + + virtual void STDMETHODCALLTYPE OMGetDepthStencilState( + ID3D11DepthStencilState **out_depth_stencil_state, + unsigned *out_stencil_ref) + { + SYNCHRONIZED; + if(*out_depth_stencil_state) + *out_depth_stencil_state = depth_stencil_state.ref(); + if(out_stencil_ref) + *out_stencil_ref = stencil_ref; + } + + void set_framebuffer() + { + struct pipe_framebuffer_state fb; + memset(&fb, 0, sizeof(fb)); + if(depth_stencil_view) + { + struct pipe_surface* surf = ((GalliumD3D11DepthStencilView*)depth_stencil_view.p)->object; + fb.zsbuf = surf; + if(surf->width > fb.width) + fb.width = surf->width; + if(surf->height > fb.height) + fb.height = surf->height; + } + fb.nr_cbufs = num_render_target_views; + unsigned i; + for(i = 0; i < num_render_target_views; ++i) + { + if(render_target_views[i]) + { + struct pipe_surface* surf = ((GalliumD3D11RenderTargetView*)render_target_views[i].p)->object; + fb.cbufs[i] = surf; + if(surf->width > fb.width) + fb.width = surf->width; + if(surf->height > fb.height) + fb.height = surf->height; + } + } + + pipe->set_framebuffer_state(pipe, &fb); + } + + /* TODO: the docs say that we should unbind conflicting resources (e.g. those bound for read while we are binding them for write too), but we aren't. + * Hopefully nobody relies on this happening + */ + + virtual void STDMETHODCALLTYPE OMSetRenderTargets( + unsigned count, + ID3D11RenderTargetView *const *new_render_target_views, + ID3D11DepthStencilView *new_depth_stencil_view) + { + SYNCHRONIZED; + if(!new_render_target_views) + count = 0; + if(count == num_render_target_views) + { + for(unsigned i = 0; i < count; ++i) + { + if(new_render_target_views[i] != render_target_views[i].p) + goto changed; + } + return; + } +changed: + depth_stencil_view = new_depth_stencil_view; + unsigned i; + for(i = 0; i < count; ++i) + { + render_target_views[i] = new_render_target_views[i]; +#if API >= 11 + om_unordered_access_views[i] = (ID3D11UnorderedAccessView*)NULL; +#endif + } + for(; i < num_render_target_views; ++i) + render_target_views[i] = (ID3D11RenderTargetView*)NULL; + num_render_target_views = count; + set_framebuffer(); + } + + virtual void STDMETHODCALLTYPE OMGetRenderTargets( + unsigned count, + ID3D11RenderTargetView **out_render_target_views, + ID3D11DepthStencilView **out_depth_stencil_view) + { + SYNCHRONIZED; + if(out_render_target_views) + { + unsigned i; + for(i = 0; i < std::min(num_render_target_views, count); ++i) + out_render_target_views[i] = render_target_views[i].ref(); + + for(; i < count; ++i) + out_render_target_views[i] = 0; + } + + if(out_depth_stencil_view) + *out_depth_stencil_view = depth_stencil_view.ref(); + } + +#if API >= 11 + /* TODO: what is this supposed to do _exactly_? are we doing the right thing? */ + virtual void STDMETHODCALLTYPE OMSetRenderTargetsAndUnorderedAccessViews( + unsigned rtv_count, + ID3D11RenderTargetView *const *new_render_target_views, + ID3D11DepthStencilView *new_depth_stencil_view, + unsigned uav_start, + unsigned uav_count, + ID3D11UnorderedAccessView *const *new_unordered_access_views, + const unsigned *new_uav_initial_counts) + { + SYNCHRONIZED; + if(rtv_count != D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL) + OMSetRenderTargets(rtv_count, new_render_target_views, new_depth_stencil_view); + + if(uav_count != D3D11_KEEP_UNORDERED_ACCESS_VIEWS) + { + for(unsigned i = 0; i < uav_count; ++i) + { + om_unordered_access_views[uav_start + i] = new_unordered_access_views[i]; + render_target_views[uav_start + i] = (ID3D11RenderTargetView*)0; + } + } + } + + virtual void STDMETHODCALLTYPE OMGetRenderTargetsAndUnorderedAccessViews( + unsigned rtv_count, + ID3D11RenderTargetView **out_render_target_views, + ID3D11DepthStencilView **out_depth_stencil_view, + unsigned uav_start, + unsigned uav_count, + ID3D11UnorderedAccessView **out_unordered_access_views) + { + SYNCHRONIZED; + if(out_render_target_views) + OMGetRenderTargets(rtv_count, out_render_target_views, out_depth_stencil_view); + + if(out_unordered_access_views) + { + for(unsigned i = 0; i < uav_count; ++i) + out_unordered_access_views[i] = om_unordered_access_views[uav_start + i].ref(); + } + } +#endif + + virtual void STDMETHODCALLTYPE SOSetTargets( + unsigned count, + ID3D11Buffer *const *new_so_targets, + const unsigned *new_offsets) + { + SYNCHRONIZED; + unsigned i; + if(!new_so_targets) + count = 0; + bool changed = false; + for(i = 0; i < count; ++i) + { + ID3D11Buffer* buffer = new_so_targets[i]; + if(buffer != so_targets[i].p || new_offsets[i] != so_offsets[i]) + { + so_buffers[i] = buffer ? ((GalliumD3D11Buffer*)buffer)->resource : 0; + so_targets[i] = buffer; + so_offsets[i] = new_offsets[i]; + changed = true; + } + } + for(; i < D3D11_SO_BUFFER_SLOT_COUNT; ++i) + { + if(so_targets[i].p || so_offsets[i]) + { + changed = true; + so_targets[i] = (ID3D11Buffer*)0; + so_offsets[i] = 0; + } + } + num_so_targets = count; + + if(changed && caps.so) + pipe->set_stream_output_buffers(pipe, so_buffers, (int*)so_offsets, num_so_targets); + } + + virtual void STDMETHODCALLTYPE SOGetTargets( + unsigned count, + ID3D11Buffer **out_so_targets +#if API < 11 + , UINT *out_offsets +#endif + ) + { + SYNCHRONIZED; + for(unsigned i = 0; i < count; ++i) + { + out_so_targets[i] = so_targets[i].ref(); +#if API < 11 + out_offsets[i] = so_offsets[i]; +#endif + } + } + + virtual void STDMETHODCALLTYPE Begin( + ID3D11Asynchronous *async) + { + SYNCHRONIZED; + if(caps.queries) + pipe->begin_query(pipe, ((GalliumD3D11Asynchronous<>*)async)->query); + } + + virtual void STDMETHODCALLTYPE End( + ID3D11Asynchronous *async) + { + SYNCHRONIZED; + if(caps.queries) + pipe->end_query(pipe, ((GalliumD3D11Asynchronous<>*)async)->query); + } + + virtual HRESULT STDMETHODCALLTYPE GetData( + ID3D11Asynchronous *iasync, + void *out_data, + unsigned data_size, + unsigned get_data_flags) + { + SYNCHRONIZED; + if(!caps.queries) + return E_NOTIMPL; + + GalliumD3D11Asynchronous<>* async = (GalliumD3D11Asynchronous<>*)iasync; + void* tmp_data = alloca(async->data_size); + boolean ret = pipe->get_query_result(pipe, async->query, !(get_data_flags & D3D11_ASYNC_GETDATA_DONOTFLUSH), tmp_data); + if(out_data) + memcpy(out_data, tmp_data, std::min(async->data_size, data_size)); + return ret ? S_OK : S_FALSE; + } + + void set_render_condition() + { + if(caps.render_condition) + { + if(!render_predicate) + pipe->render_condition(pipe, 0, 0); + else + { + GalliumD3D11Predicate* predicate = (GalliumD3D11Predicate*)render_predicate.p; + if(!render_predicate_value && predicate->desc.Query == D3D11_QUERY_OCCLUSION_PREDICATE) + { + unsigned mode = (predicate->desc.MiscFlags & D3D11_QUERY_MISC_PREDICATEHINT) ? PIPE_RENDER_COND_NO_WAIT : PIPE_RENDER_COND_WAIT; + pipe->render_condition(pipe, predicate->query, mode); + } + else + { + /* TODO: add inverted predication to Gallium*/ + pipe->render_condition(pipe, 0, 0); + } + } + } + } + + virtual void STDMETHODCALLTYPE SetPredication( + ID3D11Predicate *new_predicate, + BOOL new_predicate_value) + { + SYNCHRONIZED; + if(render_predicate.p != new_predicate || render_predicate_value != new_predicate_value) + { + render_predicate = new_predicate; + render_predicate_value = new_predicate_value; + set_render_condition(); + } + } + + virtual void STDMETHODCALLTYPE GetPredication( + ID3D11Predicate **out_predicate, + BOOL *out_predicate_value) + { + SYNCHRONIZED; + if(out_predicate) + *out_predicate = render_predicate.ref(); + if(out_predicate_value) + *out_predicate_value = render_predicate_value; + } + + static pipe_subresource d3d11_to_pipe_subresource(struct pipe_resource* resource, unsigned subresource) + { + pipe_subresource sr; + if(subresource <= resource->last_level) + { + sr.level = subresource; + sr.face = 0; + } + else + { + unsigned levels = resource->last_level + 1; + sr.level = subresource % levels; + sr.face = subresource / levels; + } + return sr; + } + + /* TODO: deferred contexts will need a different implementation of this, + * because we can't put the transfer info into the resource itself. + * Also, there are very different restrictions, for obvious reasons. + */ + virtual HRESULT STDMETHODCALLTYPE Map( + ID3D11Resource *iresource, + unsigned subresource, + D3D11_MAP map_type, + unsigned map_flags, + D3D11_MAPPED_SUBRESOURCE *mapped_resource) + { + SYNCHRONIZED; + GalliumD3D11Resource<>* resource = (GalliumD3D11Resource<>*)iresource; + if(resource->transfers.count(subresource)) + return E_FAIL; + pipe_subresource sr = d3d11_to_pipe_subresource(resource->resource, subresource); + pipe_box box = d3d11_to_pipe_box(resource->resource, sr.level, 0); + unsigned usage = 0; + if(map_type == D3D11_MAP_READ) + usage = PIPE_TRANSFER_READ; + else if(map_type == D3D11_MAP_WRITE) + usage = PIPE_TRANSFER_WRITE; + else if(map_type == D3D11_MAP_READ_WRITE) + usage = PIPE_TRANSFER_READ_WRITE; + else if(map_type == D3D11_MAP_WRITE_DISCARD) + usage = PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD; + else if(map_type == D3D11_MAP_WRITE_NO_OVERWRITE) + usage = PIPE_TRANSFER_WRITE | PIPE_TRANSFER_NOOVERWRITE; + else + return E_INVALIDARG; + if(map_type & D3D10_MAP_FLAG_DO_NOT_WAIT) + usage |= PIPE_TRANSFER_DONTBLOCK; + struct pipe_transfer* transfer = pipe->get_transfer(pipe, resource->resource, sr, usage, &box); + if(!transfer) { + if(map_type & D3D10_MAP_FLAG_DO_NOT_WAIT) + return DXGI_ERROR_WAS_STILL_DRAWING; + else + return E_FAIL; + } + resource->transfers[subresource] = transfer; + mapped_resource->pData = pipe->transfer_map(pipe, transfer); + mapped_resource->RowPitch = transfer->stride; + mapped_resource->DepthPitch = transfer->slice_stride; + return S_OK; + } + + virtual void STDMETHODCALLTYPE Unmap( + ID3D11Resource *iresource, + unsigned subresource) + { + SYNCHRONIZED; + GalliumD3D11Resource<>* resource = (GalliumD3D11Resource<>*)iresource; + std::unordered_map<unsigned, pipe_transfer*>::iterator i = resource->transfers.find(subresource); + if(i != resource->transfers.end()) + { + pipe->transfer_unmap(pipe, i->second); + pipe->transfer_destroy(pipe, i->second); + resource->transfers.erase(i); + } + } + + virtual void STDMETHODCALLTYPE CopySubresourceRegion( + ID3D11Resource *dst_resource, + unsigned dst_subresource, + unsigned dst_x, + unsigned dst_y, + unsigned dst_z, + ID3D11Resource *src_resource, + unsigned src_subresource, + const D3D11_BOX *src_box) + { + SYNCHRONIZED; + GalliumD3D11Resource<>* dst = (GalliumD3D11Resource<>*)dst_resource; + GalliumD3D11Resource<>* src = (GalliumD3D11Resource<>*)src_resource; + pipe_subresource subdst = d3d11_to_pipe_subresource(dst->resource, dst_subresource); + pipe_subresource subsrc = d3d11_to_pipe_subresource(src->resource, src_subresource); + pipe_box box = d3d11_to_pipe_box(src->resource, subsrc.level, src_box); + for(unsigned i = 0; i < box.depth; ++i) + { + pipe->resource_copy_region(pipe, + dst->resource, subdst, dst_x, dst_y, dst_z + i, + src->resource, subsrc, box.x, box.y, box.z + i, + box.width, box.height); + } + } + + virtual void STDMETHODCALLTYPE CopyResource( + ID3D11Resource *dst_resource, + ID3D11Resource *src_resource) + { + SYNCHRONIZED; + GalliumD3D11Resource<>* dst = (GalliumD3D11Resource<>*)dst_resource; + GalliumD3D11Resource<>* src = (GalliumD3D11Resource<>*)src_resource; + pipe_subresource sr; + unsigned faces = dst->resource->target == PIPE_TEXTURE_CUBE ? 6 : 1; + + for(sr.face = 0; sr.face < faces; ++sr.face) + { + for(sr.level = 0; sr.level <= dst->resource->last_level; ++sr.level) + { + unsigned w = u_minify(dst->resource->width0, sr.level); + unsigned h = u_minify(dst->resource->height0, sr.level); + unsigned d = u_minify(dst->resource->depth0, sr.level); + for(unsigned i = 0; i < d; ++i) + { + pipe->resource_copy_region(pipe, + dst->resource, sr, 0, 0, i, + src->resource, sr, 0, 0, i, + w, h); + } + } + } + } + + virtual void STDMETHODCALLTYPE UpdateSubresource( + ID3D11Resource *dst_resource, + unsigned dst_subresource, + const D3D11_BOX *pDstBox, + const void *pSrcData, + unsigned src_row_pitch, + unsigned src_depth_pitch) + { + SYNCHRONIZED; + GalliumD3D11Resource<>* dst = (GalliumD3D11Resource<>*)dst_resource; + pipe_subresource subdst = d3d11_to_pipe_subresource(dst->resource, dst_subresource); + pipe_box box = d3d11_to_pipe_box(dst->resource, subdst.level, pDstBox); + pipe->transfer_inline_write(pipe, dst->resource, subdst, PIPE_TRANSFER_WRITE, &box, pSrcData, src_row_pitch, src_depth_pitch); + } + +#if API >= 11 + virtual void STDMETHODCALLTYPE CopyStructureCount( + ID3D11Buffer *dst_buffer, + unsigned dst_aligned_byte_offset, + ID3D11UnorderedAccessView *src_view) + { + SYNCHRONIZED; + } +#endif + + virtual void STDMETHODCALLTYPE ClearRenderTargetView( + ID3D11RenderTargetView *render_target_view, + const float color[4]) + { + SYNCHRONIZED; + GalliumD3D11RenderTargetView* view = ((GalliumD3D11RenderTargetView*)render_target_view); + pipe->clear_render_target(pipe, view->object, color, 0, 0, view->object->width, view->object->height); + } + + virtual void STDMETHODCALLTYPE ClearDepthStencilView( + ID3D11DepthStencilView *depth_stencil_view, + unsigned clear_flags, + float depth, + UINT8 stencil) + { + SYNCHRONIZED; + GalliumD3D11DepthStencilView* view = ((GalliumD3D11DepthStencilView*)depth_stencil_view); + unsigned flags = 0; + if(clear_flags & D3D11_CLEAR_DEPTH) + flags |= PIPE_CLEAR_DEPTH; + if(clear_flags & D3D11_CLEAR_STENCIL) + flags |= PIPE_CLEAR_STENCIL; + pipe->clear_depth_stencil(pipe, view->object, flags, depth, stencil, 0, 0, view->object->width, view->object->height); + } + +#if API >= 11 + virtual void STDMETHODCALLTYPE ClearUnorderedAccessViewUint( + ID3D11UnorderedAccessView *unordered_access_view, + const unsigned values[4]) + { + SYNCHRONIZED; + } + + virtual void STDMETHODCALLTYPE ClearUnorderedAccessViewFloat( + ID3D11UnorderedAccessView *unordered_access_view, + const float values[4]) + { + SYNCHRONIZED; + } +#endif + + void restore_gallium_state_blit_only() + { + pipe->bind_blend_state(pipe, blend_state.p ? blend_state.p->object : default_blend); + pipe->bind_depth_stencil_alpha_state(pipe, depth_stencil_state.p ? depth_stencil_state.p->object : default_depth_stencil); + pipe->bind_rasterizer_state(pipe, rasterizer_state.p ? rasterizer_state.p->object : default_rasterizer); + pipe->bind_vertex_elements_state(pipe, input_layout.p ? input_layout.p->object : default_input_layout); + pipe->bind_fs_state(pipe, shaders[D3D11_STAGE_PS].p ? shaders[D3D11_STAGE_PS].p->object : default_shaders[PIPE_SHADER_FRAGMENT]); + pipe->bind_vs_state(pipe, shaders[D3D11_STAGE_VS].p ? shaders[D3D11_STAGE_VS].p->object : default_shaders[PIPE_SHADER_VERTEX]); + if(caps.gs) + pipe->bind_gs_state(pipe, shaders[D3D11_STAGE_GS].p ? shaders[D3D11_STAGE_GS].p->object : default_shaders[PIPE_SHADER_GEOMETRY]); + set_framebuffer(); + set_viewport(); + set_clip(); + set_render_condition(); + // TODO: restore stream output + + update_flags |= UPDATE_VERTEX_BUFFERS | (1 << (UPDATE_SAMPLERS_SHIFT + D3D11_STAGE_PS)) | (1 << (UPDATE_VIEWS_SHIFT + D3D11_STAGE_PS)); + } + + virtual void STDMETHODCALLTYPE RestoreGalliumStateBlitOnly() + { + SYNCHRONIZED; + restore_gallium_state_blit_only(); + } + + virtual void STDMETHODCALLTYPE GenerateMips( + ID3D11ShaderResourceView *shader_resource_view) + { + SYNCHRONIZED; + + GalliumD3D11ShaderResourceView* view = (GalliumD3D11ShaderResourceView*)shader_resource_view; + if(caps.gs) + pipe->bind_gs_state(pipe, 0); + if(caps.so) + pipe->bind_stream_output_state(pipe, 0); + if(pipe->render_condition) + pipe->render_condition(pipe, 0, 0); + util_gen_mipmap(gen_mipmap, view->object, 0, 0, view->object->texture->last_level, PIPE_TEX_FILTER_LINEAR); + restore_gallium_state_blit_only(); + } + + virtual void STDMETHODCALLTYPE RestoreGalliumState() + { + SYNCHRONIZED; + restore_gallium_state_blit_only(); + + set_index_buffer(); + set_stencil_ref(); + pipe->set_blend_color(pipe, (struct pipe_blend_color*)blend_color); + pipe->set_sample_mask(pipe, sample_mask); + + for(unsigned s = 0; s < 3; ++s) + { + unsigned num = std::min(caps.constant_buffers[s], (unsigned)D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT); + for(unsigned i = 0; i < num; ++i) + pipe->set_constant_buffer(pipe, s, i, constant_buffers[s][i].p ? constant_buffers[s][i].p->resource : 0); + } + + if(caps.so) + pipe->set_stream_output_buffers(pipe, so_buffers, (int*)so_offsets, num_so_targets); + + update_flags |= (1 << (UPDATE_SAMPLERS_SHIFT + D3D11_STAGE_VS)) | (1 << (UPDATE_VIEWS_SHIFT + D3D11_STAGE_VS)); + update_flags |= (1 << (UPDATE_SAMPLERS_SHIFT + D3D11_STAGE_GS)) | (1 << (UPDATE_VIEWS_SHIFT + D3D11_STAGE_GS)); + + set_scissor(); + } + +#if API >= 11 + /* TODO: hack SRVs or sampler states to handle this, or add to Gallium */ + virtual void STDMETHODCALLTYPE SetResourceMinLOD( + ID3D11Resource *iresource, + float min_lod) + { + SYNCHRONIZED; + GalliumD3D11Resource<>* resource = (GalliumD3D11Resource<>*)iresource; + if(resource->min_lod != min_lod) + { + // TODO: actually do anything? + resource->min_lod = min_lod; + } + } + + virtual float STDMETHODCALLTYPE GetResourceMinLOD( + ID3D11Resource *iresource) + { + SYNCHRONIZED; + GalliumD3D11Resource<>* resource = (GalliumD3D11Resource<>*)iresource; + return resource->min_lod; + } +#endif + + virtual void STDMETHODCALLTYPE ResolveSubresource( + ID3D11Resource *dst_resource, + unsigned dst_subresource, + ID3D11Resource *src_resource, + unsigned src_subresource, + DXGI_FORMAT format) + { + SYNCHRONIZED; + GalliumD3D11Resource<>* dst = (GalliumD3D11Resource<>*)dst_resource; + GalliumD3D11Resource<>* src = (GalliumD3D11Resource<>*)src_resource; + pipe_subresource subdst = d3d11_to_pipe_subresource(dst->resource, dst_subresource); + pipe_subresource subsrc = d3d11_to_pipe_subresource(src->resource, src_subresource); + pipe->resource_resolve(pipe, dst->resource, subdst, src->resource, subsrc); + } + +#if API >= 11 + virtual void STDMETHODCALLTYPE ExecuteCommandList( + ID3D11CommandList *command_list, + BOOL restore_context_state) + { + SYNCHRONIZED; + } + + virtual HRESULT STDMETHODCALLTYPE FinishCommandList( + BOOL restore_deferred_context_state, + ID3D11CommandList **out_command_list) + { + SYNCHRONIZED; + return E_NOTIMPL; + } +#endif + + virtual void STDMETHODCALLTYPE ClearState(void) + { + /* we don't take a lock here because we would deadlock otherwise + * TODO: this is probably incorrect, because ClearState should likely be atomic. + * However, I can't think of any correct usage that would be affected by this + * being non-atomic, and making this atomic is quite expensive and complicates + * the code + */ + + // we qualify all calls so that we avoid virtual dispatch and might get them inlined + // TODO: make sure all this gets inlined, which might require more compiler flags + // TODO: optimize this +#if API >= 11 + GalliumD3D11DeviceContext::PSSetShader(0, 0, 0); + GalliumD3D11DeviceContext::GSSetShader(0, 0, 0); + GalliumD3D11DeviceContext::VSSetShader(0, 0, 0); + GalliumD3D11DeviceContext::HSSetShader(0, 0, 0); + GalliumD3D11DeviceContext::DSSetShader(0, 0, 0); + GalliumD3D11DeviceContext::CSSetShader(0, 0, 0); +#else + GalliumD3D11DeviceContext::PSSetShader(0); + GalliumD3D11DeviceContext::GSSetShader(0); + GalliumD3D11DeviceContext::VSSetShader(0); +#endif + + GalliumD3D11DeviceContext::IASetInputLayout(0); + GalliumD3D11DeviceContext::IASetIndexBuffer(0, DXGI_FORMAT_UNKNOWN, 0); + GalliumD3D11DeviceContext::RSSetState(0); + GalliumD3D11DeviceContext::OMSetDepthStencilState(0, 0); + GalliumD3D11DeviceContext::OMSetBlendState(0, (float*)zero_data, ~0); + GalliumD3D11DeviceContext::SetPredication(0, 0); + GalliumD3D11DeviceContext::IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_UNDEFINED); + + GalliumD3D11DeviceContext::PSSetConstantBuffers(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, (ID3D11Buffer**)zero_data); + GalliumD3D11DeviceContext::GSSetConstantBuffers(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, (ID3D11Buffer**)zero_data); + GalliumD3D11DeviceContext::VSSetConstantBuffers(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, (ID3D11Buffer**)zero_data); +#if API >= 11 + GalliumD3D11DeviceContext::HSSetConstantBuffers(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, (ID3D11Buffer**)zero_data); + GalliumD3D11DeviceContext::DSSetConstantBuffers(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, (ID3D11Buffer**)zero_data); + GalliumD3D11DeviceContext::CSSetConstantBuffers(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, (ID3D11Buffer**)zero_data); +#endif + + GalliumD3D11DeviceContext::IASetVertexBuffers(0, num_vertex_buffers, (ID3D11Buffer**)zero_data, (unsigned*)zero_data, (unsigned*)zero_data); +#if API >= 11 + GalliumD3D11DeviceContext::OMSetRenderTargetsAndUnorderedAccessViews(0, 0, 0 , 0, 0, 0, 0); +#else + GalliumD3D11DeviceContext::OMSetRenderTargets(0, 0, 0 ); +#endif + GalliumD3D11DeviceContext::SOSetTargets(0, 0, 0); + + GalliumD3D11DeviceContext::PSSetShaderResources(0, num_shader_resource_views[D3D11_STAGE_PS], (ID3D11ShaderResourceView**)zero_data); + GalliumD3D11DeviceContext::GSSetShaderResources(0, num_shader_resource_views[D3D11_STAGE_GS], (ID3D11ShaderResourceView**)zero_data); + GalliumD3D11DeviceContext::VSSetShaderResources(0, num_shader_resource_views[D3D11_STAGE_VS], (ID3D11ShaderResourceView**)zero_data); +#if API >= 11 + GalliumD3D11DeviceContext::HSSetShaderResources(0, num_shader_resource_views[D3D11_STAGE_HS], (ID3D11ShaderResourceView**)zero_data); + GalliumD3D11DeviceContext::DSSetShaderResources(0, num_shader_resource_views[D3D11_STAGE_DS], (ID3D11ShaderResourceView**)zero_data); + GalliumD3D11DeviceContext::CSSetShaderResources(0, num_shader_resource_views[D3D11_STAGE_CS], (ID3D11ShaderResourceView**)zero_data); +#endif + + GalliumD3D11DeviceContext::PSSetSamplers(0, num_shader_resource_views[D3D11_STAGE_PS], (ID3D11SamplerState**)zero_data); + GalliumD3D11DeviceContext::GSSetSamplers(0, num_shader_resource_views[D3D11_STAGE_GS], (ID3D11SamplerState**)zero_data); + GalliumD3D11DeviceContext::VSSetSamplers(0, num_shader_resource_views[D3D11_STAGE_VS], (ID3D11SamplerState**)zero_data); +#if API >= 11 + GalliumD3D11DeviceContext::HSSetSamplers(0, num_shader_resource_views[D3D11_STAGE_HS], (ID3D11SamplerState**)zero_data); + GalliumD3D11DeviceContext::DSSetSamplers(0, num_shader_resource_views[D3D11_STAGE_DS], (ID3D11SamplerState**)zero_data); + GalliumD3D11DeviceContext::CSSetSamplers(0, num_shader_resource_views[D3D11_STAGE_CS], (ID3D11SamplerState**)zero_data); +#endif + + GalliumD3D11DeviceContext::RSSetViewports(0, 0); + GalliumD3D11DeviceContext::RSSetScissorRects(0, 0); + } + + virtual void STDMETHODCALLTYPE Flush(void) + { + SYNCHRONIZED; + pipe->flush(pipe, PIPE_FLUSH_FRAME, 0); + } + + /* In Direct3D 10, if the reference count of an object drops to 0, it is automatically + * cleanly unbound from the pipeline. + * In Direct3D 11, the pipeline holds a reference. + * + * Note that instead of always scanning the pipeline on destruction, we could + * maintain the internal reference count on DirectX 10 and use it to check if an + * object is still bound. + * Presumably, on average, scanning is faster if the application is well written. + */ +#if API < 11 +#define IMPLEMENT_SIMPLE_UNBIND(name, member, gallium, def) \ + void Unbind##name(ID3D11##name* state) \ + { \ + SYNCHRONIZED; \ + if((void*)state == (void*)member.p) \ + { \ + member.p = 0; \ + pipe->bind_##gallium##_state(pipe, default_##def); \ + } \ + } + IMPLEMENT_SIMPLE_UNBIND(BlendState, blend_state, blend, blend) + IMPLEMENT_SIMPLE_UNBIND(RasterizerState, rasterizer_state, rasterizer, rasterizer) + IMPLEMENT_SIMPLE_UNBIND(DepthStencilState, depth_stencil_state, depth_stencil_alpha, depth_stencil) + IMPLEMENT_SIMPLE_UNBIND(InputLayout, input_layout, vertex_elements, input_layout) + IMPLEMENT_SIMPLE_UNBIND(PixelShader, shaders[D3D11_STAGE_PS], fs, shaders[D3D11_STAGE_PS]) + IMPLEMENT_SIMPLE_UNBIND(VertexShader, shaders[D3D11_STAGE_VS], vs, shaders[D3D11_STAGE_VS]) + IMPLEMENT_SIMPLE_UNBIND(GeometryShader, shaders[D3D11_STAGE_GS], gs, shaders[D3D11_STAGE_GS]) + + void UnbindPredicate(ID3D11Predicate* predicate) + { + SYNCHRONIZED; + if(predicate == render_predicate) + { + render_predicate.p = NULL; + render_predicate_value = 0; + pipe->render_condition(pipe, 0, 0); + } + } + + void UnbindSamplerState(ID3D11SamplerState* state) + { + SYNCHRONIZED; + for(unsigned s = 0; s < D3D11_STAGES; ++s) + { + for(unsigned i = 0; i < num_samplers[s]; ++i) + { + if(samplers[s][i] == state) + { + samplers[s][i].p = NULL; + sampler_csos[s].v[i] = NULL; + update_flags |= (1 << (UPDATE_SAMPLERS_SHIFT + s)); + } + } + } + } + + void UnbindBuffer(ID3D11Buffer* buffer) + { + SYNCHRONIZED; + if(buffer == index_buffer) + { + index_buffer.p = 0; + index_format = DXGI_FORMAT_UNKNOWN; + index_offset = 0; + struct pipe_index_buffer ib; + memset(&ib, 0, sizeof(ib)); + pipe->set_index_buffer(pipe, &ib); + } + + for(unsigned i = 0; i < num_vertex_buffers; ++i) + { + if(buffer == input_buffers[i]) + { + input_buffers[i].p = 0; + memset(&vertex_buffers[num_vertex_buffers], 0, sizeof(vertex_buffers[num_vertex_buffers])); + update_flags |= UPDATE_VERTEX_BUFFERS; + } + } + + for(unsigned s = 0; s < D3D11_STAGES; ++s) + { + for(unsigned i = 0; i < sizeof(constant_buffers) / sizeof(constant_buffers[0]); ++i) + { + if(constant_buffers[s][i] == buffer) + { + constant_buffers[s][i] = (ID3D10Buffer*)NULL; + pipe->set_constant_buffer(pipe, s, i, NULL); + } + } + } + } + + void UnbindDepthStencilView(ID3D11DepthStencilView * view) + { + SYNCHRONIZED; + if(view == depth_stencil_view) + { + depth_stencil_view.p = NULL; + set_framebuffer(); + } + } + + void UnbindRenderTargetView(ID3D11RenderTargetView* view) + { + SYNCHRONIZED; + bool any_bound = false; + for(unsigned i = 0; i < num_render_target_views; ++i) + { + if(render_target_views[i] == view) + { + render_target_views[i].p = NULL; + any_bound = true; + } + } + if(any_bound) + set_framebuffer(); + } + + void UnbindShaderResourceView(ID3D11ShaderResourceView* view) + { + SYNCHRONIZED; + for(unsigned s = 0; s < D3D11_STAGES; ++s) + { + for(unsigned i = 0; i < num_shader_resource_views[s]; ++i) + { + if(shader_resource_views[s][i] == view) + { + shader_resource_views[s][i].p = NULL; + sampler_views[s][i] = NULL; + update_flags |= (1 << (UPDATE_VIEWS_SHIFT + s)); + } + } + } + } +#endif + +#undef SYNCHRONIZED +}; + +#if API >= 11 +/* This approach serves two purposes. + * First, we don't want to do an atomic operation to manipulate the reference + * count every time something is bound/unbound to the pipeline, since they are + * expensive. + * Fortunately, the immediate context can only be used by a single thread, so + * we don't have to use them, as long as a separate reference count is used + * (see dual_refcnt_t). + * + * Second, we want to avoid the Device -> DeviceContext -> bound DeviceChild -> Device + * garbage cycle. + * To avoid it, DeviceChild doesn't hold a reference to Device as usual, but adds + * one for each external reference count, while internal nonatomic_add_ref doesn't + * add any. + * + * Note that ideally we would to eliminate the non-atomic op too, but this is more + * complicated, since we would either need to use garbage collection and give up + * deterministic destruction (especially bad for large textures), or scan the whole + * pipeline state every time the reference count of object drops to 0, which risks + * pathological slowdowns. + * + * Since this microoptimization should matter relatively little, let's avoid it for now. + * + * Note that deferred contexts don't use this, since as a whole, they must thread-safe. + * Eliminating the atomic ops for deferred contexts seems substantially harder. + * This might be a problem if they are used in a one-shot multithreaded rendering + * fashion, where SMP cacheline bouncing on the reference count may be visible. + * + * The idea would be to attach a structure of reference counts indexed by deferred + * context id to each object. Ideally, this should be organized like ext2 block pointers. + * + * Every deferred context would get a reference count in its own cacheline. + * The external count is protected by a lock bit, and there is also a "lock bit" in each + * internal count. + * + * When the external count has to be dropped to 0, the lock bit is taken and all internal + * reference counts are scanned, taking a count of them. A flag would also be set on them. + * Deferred context manipulation would notice the flag, and update the count. + * Once the count goes to zero, the object is freed. + * + * The problem of this is that if the external reference count ping-pongs between + * zero and non-zero, the scans will take a lot of time. + * + * The idea to solve this is to compute the scans in a binary-tree like fashion, where + * each binary tree node would have a "determined bit", which would be invalidated + * by manipulations. + * + * However, all this complexity might actually be a loss in most cases, so let's just + * stick to a single atomic refcnt for now. + * + * Also, we don't even support deferred contexts yet, so this can wait. + */ +struct nonatomic_device_child_ptr_traits +{ + static void add_ref(void* p) + { + if(p) + ((GalliumD3D11DeviceChild<>*)p)->nonatomic_add_ref(); + } + + static void release(void* p) + { + if(p) + ((GalliumD3D11DeviceChild<>*)p)->nonatomic_release(); + } +}; + +struct GalliumD3D11ImmediateDeviceContext + : public GalliumD3D11DeviceContext<nonatomic_device_child_ptr_traits> +{ + GalliumD3D11ImmediateDeviceContext(GalliumD3D11Screen* device, pipe_context* pipe, unsigned context_flags = 0) + : GalliumD3D11DeviceContext<nonatomic_device_child_ptr_traits>(device, pipe, context_flags) + { + // not necessary, but tests that the API at least basically works + ClearState(); + } + + /* we do this since otherwise we would have a garbage cycle between this and the device */ + virtual ULONG STDMETHODCALLTYPE AddRef() + { + return this->device->AddRef(); + } + + virtual ULONG STDMETHODCALLTYPE Release() + { + return this->device->Release(); + } + + virtual D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE GetType() + { + return D3D11_DEVICE_CONTEXT_IMMEDIATE; + } +}; + +static ID3D11DeviceContext* GalliumD3D11ImmediateDeviceContext_Create(GalliumD3D11Screen* device, struct pipe_context* pipe, bool owns_pipe) +{ + return new GalliumD3D11ImmediateDeviceContext(device, pipe, owns_pipe); +} + +static void GalliumD3D11ImmediateDeviceContext_RestoreGalliumState(ID3D11DeviceContext* context) +{ + ((GalliumD3D11ImmediateDeviceContext*)context)->RestoreGalliumState(); +} + +static void GalliumD3D11ImmediateDeviceContext_RestoreGalliumStateBlitOnly(ID3D11DeviceContext* context) +{ + ((GalliumD3D11ImmediateDeviceContext*)context)->RestoreGalliumStateBlitOnly(); +} + +static void GalliumD3D11ImmediateDeviceContext_Destroy(ID3D11DeviceContext* context) +{ + delete (GalliumD3D11ImmediateDeviceContext*)context; +} +#endif diff --git a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_misc.h b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_misc.h new file mode 100644 index 00000000000..357f51bcb9b --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_misc.h @@ -0,0 +1,92 @@ +#if API < 11 +extern "C" HRESULT STDMETHODCALLTYPE D3D10CreateBlob( + SIZE_T num_bytes, + LPD3D10BLOB *out_buffer +); + +HRESULT STDMETHODCALLTYPE D3D10CreateBlob( + SIZE_T num_bytes, + LPD3D10BLOB *out_buffer +) +{ + void* data = malloc(num_bytes); + if(!data) + return E_OUTOFMEMORY; + *out_buffer = new GalliumD3DBlob(data, num_bytes); + return S_OK; +} + +LPCSTR STDMETHODCALLTYPE D3D10GetPixelShaderProfile( + ID3D10Device *device +) +{ + return "ps_4_0"; +} + +LPCSTR STDMETHODCALLTYPE D3D10GetVertexShaderProfile( + ID3D10Device *device +) +{ + return "vs_4_0"; +} + +LPCSTR STDMETHODCALLTYPE D3D10GetGeometryShaderProfile( + ID3D10Device *device +) +{ + return "gs_4_0"; +} + +static HRESULT dxbc_assemble_as_blob(struct dxbc_chunk_header** chunks, unsigned num_chunks, ID3D10Blob** blob) +{ + std::pair<void*, size_t> p = dxbc_assemble(chunks, num_chunks); + if(!p.first) + return E_OUTOFMEMORY; + *blob = new GalliumD3DBlob(p.first, p.second); + return S_OK; +} + +HRESULT D3D10GetInputSignatureBlob( + const void *shader_bytecode, + SIZE_T bytecode_length, + ID3D10Blob **signature_blob +) +{ + dxbc_chunk_signature* sig = dxbc_find_signature(shader_bytecode, bytecode_length, false); + if(!sig) + return E_FAIL; + + return dxbc_assemble_as_blob((dxbc_chunk_header**)&sig, 1, signature_blob); +} + +HRESULT D3D10GetOutputSignatureBlob( + const void *shader_bytecode, + SIZE_T bytecode_length, + ID3D10Blob **signature_blob +) +{ + dxbc_chunk_signature* sig = dxbc_find_signature(shader_bytecode, bytecode_length, true); + if(!sig) + return E_FAIL; + + return dxbc_assemble_as_blob((dxbc_chunk_header**)&sig, 1, signature_blob); +} + +HRESULT D3D10GetInputAndOutputSignatureBlob( + const void *shader_bytecode, + SIZE_T bytecode_length, + ID3D10Blob **signature_blob +) +{ + dxbc_chunk_signature* sigs[2]; + sigs[0] = dxbc_find_signature(shader_bytecode, bytecode_length, false); + if(!sigs[0]) + return E_FAIL; + sigs[1] = dxbc_find_signature(shader_bytecode, bytecode_length, true); + if(!sigs[1]) + return E_FAIL; + + return dxbc_assemble_as_blob((dxbc_chunk_header**)&sigs, 2, signature_blob); +} + +#endif diff --git a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_objects.h b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_objects.h new file mode 100644 index 00000000000..836603eccc3 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_objects.h @@ -0,0 +1,717 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + +template<typename Base = ID3D11DeviceChild> +struct GalliumD3D11DeviceChild : public GalliumPrivateDataComObject<Base, dual_refcnt_t> +{ + GalliumD3D11Screen* device; // must not be null + + + // if this is called, the subclass constructor must set device itself + GalliumD3D11DeviceChild() + : device(0) + {} + + GalliumD3D11DeviceChild(GalliumD3D11Screen* p_device) + { + // we store the reference count minus one in refcnt + device = p_device; + device->AddRef(); + } + + /* The purpose of this is to avoid cyclic garbage, since this won't hold + * a pointer to the device if it is only held by a pipeline binding in the immediate context + * + * TODO: we could only manipulate the device refcnt when atomic_refcnt == 0 changes, + * but this requires more complex atomic ops + */ + inline ULONG add_ref() + { + device->AddRef(); + return GalliumPrivateDataComObject<Base, dual_refcnt_t>::add_ref(); + } + + inline ULONG release() + { + device->Release(); + return GalliumPrivateDataComObject<Base, dual_refcnt_t>::release(); + } + + virtual ULONG STDMETHODCALLTYPE AddRef() + { + return add_ref(); + } + + virtual ULONG STDMETHODCALLTYPE Release() + { + return release(); + } + + virtual void STDMETHODCALLTYPE GetDevice( + ID3D11Device **out_device + ) + { + device->AddRef(); + *out_device = device; + } +}; + +template<typename Base = ID3D11DeviceChild, typename Object = void> +struct GalliumD3D11Object : public GalliumD3D11DeviceChild<Base> +{ + Object* object; + GalliumD3D11Object(GalliumD3D11Screen* device, Object* object) + : GalliumD3D11DeviceChild<Base>(device), object(object) + {} + + virtual ~GalliumD3D11Object(); +}; + +#define IMPLEMENT_OBJECT_DTOR(name, gallium) \ +template<> \ +GalliumD3D11Object<ID3D11##name, void>::~GalliumD3D11Object() \ +{ \ + DX10_ONLY(device->Unbind##name(this)); \ + device->immediate_pipe->delete_##gallium##_state(device->immediate_pipe, object); \ +} + +#define IMPLEMENT_VIEW_DTOR(name, gallium) \ +template<> \ +GalliumD3D11Object<ID3D11##name, struct pipe_##gallium>::~GalliumD3D11Object() \ +{ \ + DX10_ONLY(device->Unbind##name(this)); \ + pipe_##gallium##_reference(&object, 0); \ +} + +IMPLEMENT_OBJECT_DTOR(InputLayout, vertex_elements) +IMPLEMENT_OBJECT_DTOR(DepthStencilState, depth_stencil_alpha) +IMPLEMENT_OBJECT_DTOR(RasterizerState, rasterizer) +IMPLEMENT_OBJECT_DTOR(SamplerState, sampler) +IMPLEMENT_OBJECT_DTOR(BlendState, blend) +IMPLEMENT_OBJECT_DTOR(VertexShader, vs) +IMPLEMENT_OBJECT_DTOR(PixelShader, fs) +IMPLEMENT_OBJECT_DTOR(GeometryShader, gs) + +IMPLEMENT_VIEW_DTOR(ShaderResourceView, sampler_view) +IMPLEMENT_VIEW_DTOR(RenderTargetView, surface) +IMPLEMENT_VIEW_DTOR(DepthStencilView, surface) + +#if API >= 11 +// IMPLEMENT_VIEW_DTOR(UnorderedAccessView, surface); +// IMPLEMENT_OBJECT_DTOR(HullShader, tcs); +// IMPLEMENT_OBJECT_DTOR(DomainShader, tes); +// IMPLEMENT_OBJECT_DTOR(ComputeShader, cs); +#else +IMPLEMENT_OBJECT_DTOR(BlendState1, blend) +IMPLEMENT_VIEW_DTOR(ShaderResourceView1, sampler_view) +#endif + +template<typename Base, typename Desc, typename Object = void> +struct GalliumD3D11DescribedObject : public GalliumD3D11Object<Base, Object> +{ + Desc desc; + GalliumD3D11DescribedObject(GalliumD3D11Screen* device, Object* object, const Desc& desc) + : GalliumD3D11Object<Base, Object>(device, object), desc(desc) + {} + + virtual void STDMETHODCALLTYPE GetDesc(Desc *out_desc) + { + memcpy(out_desc, &desc, sizeof(desc)); + } +}; + +typedef GalliumD3D11Object<ID3D11InputLayout> GalliumD3D11InputLayout; +typedef GalliumD3D11DescribedObject<ID3D11DepthStencilState, D3D11_DEPTH_STENCIL_DESC> GalliumD3D11DepthStencilState; +typedef GalliumD3D11DescribedObject<ID3D11RasterizerState, D3D11_RASTERIZER_DESC> GalliumD3D11RasterizerStateBase; +typedef GalliumD3D11DescribedObject<ID3D11SamplerState, D3D11_SAMPLER_DESC> GalliumD3D11SamplerState; + +#if API >= 11 +typedef GalliumD3D11DescribedObject<ID3D11BlendState, D3D11_BLEND_DESC> GalliumD3D11BlendState; +#else +typedef GalliumD3D10DescribedObject<ID3D10BlendState1, D3D10_BLEND_DESC> GalliumD3D10BlendStateBase; + +struct GalliumD3D10BlendState : public GalliumD3D10BlendStateBase +{ + static D3D10_BLEND_DESC convert_to_d3d10(const D3D10_BLEND_DESC1& desc1) + { + D3D10_BLEND_DESC desc; + desc.AlphaToCoverageEnable = desc1.AlphaToCoverageEnable; + desc.SrcBlend = desc1.RenderTarget[0].SrcBlend; + desc.DestBlend = desc1.RenderTarget[0].DestBlend; + desc.BlendOp = desc1.RenderTarget[0].BlendOp; + desc.SrcBlendAlpha = desc1.RenderTarget[0].SrcBlendAlpha; + desc.DestBlendAlpha = desc1.RenderTarget[0].DestBlendAlpha; + desc.BlendOpAlpha = desc1.RenderTarget[0].BlendOpAlpha; + for(unsigned i = 0; i < 8; ++i) + { + desc.BlendEnable[i] = desc1.RenderTarget[i].BlendEnable; + desc.RenderTargetWriteMask[i] = desc1.RenderTarget[i].RenderTargetWriteMask; + } + return desc; + } + + D3D10_BLEND_DESC1 desc1; + + GalliumD3D10BlendState(GalliumD3D10Screen* device, void* object, const D3D10_BLEND_DESC& desc) + : GalliumD3D10BlendStateBase(device, object, desc) + { + memset(&desc1, 0, sizeof(desc1)); + desc1.AlphaToCoverageEnable = desc.AlphaToCoverageEnable; + desc1.RenderTarget[0].SrcBlend = desc.SrcBlend; + desc1.RenderTarget[0].DestBlend = desc.DestBlend; + desc1.RenderTarget[0].BlendOp = desc.BlendOp; + desc1.RenderTarget[0].SrcBlendAlpha = desc.SrcBlendAlpha; + desc1.RenderTarget[0].DestBlendAlpha = desc.DestBlendAlpha; + desc1.RenderTarget[0].BlendOpAlpha = desc.BlendOpAlpha; + for(unsigned i = 0; i < 8; ++i) + { + desc1.RenderTarget[i].BlendEnable = desc.BlendEnable[i]; + desc1.RenderTarget[i].RenderTargetWriteMask = desc.RenderTargetWriteMask[i]; + } + } + + GalliumD3D10BlendState(GalliumD3D10Screen* device, void* object, const D3D10_BLEND_DESC1& desc) + : GalliumD3D10BlendStateBase(device, object, convert_to_d3d10(desc)), desc1(desc1) + {} + + virtual void STDMETHODCALLTYPE GetDesc1(D3D10_BLEND_DESC1 *out_desc) + { + memcpy(out_desc, &desc1, sizeof(desc1)); + } +}; +#endif + +struct GalliumD3D11RasterizerState : public GalliumD3D11RasterizerStateBase +{ + bool depth_clamp; + + GalliumD3D11RasterizerState(GalliumD3D11Screen* device, void* object, const D3D11_RASTERIZER_DESC& desc, bool depth_clamp) + : GalliumD3D11RasterizerStateBase(device, object, desc), depth_clamp(depth_clamp) + {} +}; + +template<typename Base = ID3D11DeviceChild> +struct GalliumD3D11Shader : public GalliumD3D11Object<Base> +{ + std::vector<int> slot_to_resource; + std::vector<int> slot_to_sampler; + + GalliumD3D11Shader(GalliumD3D11Screen* device, void* object) + : GalliumD3D11Object<Base>(device, object) + {} +}; + +typedef GalliumD3D11Shader<ID3D11VertexShader> GalliumD3D11VertexShader; +typedef GalliumD3D11Shader<ID3D11GeometryShader> GalliumD3D11GeometryShader; +typedef GalliumD3D11Shader<ID3D11PixelShader> GalliumD3D11PixelShader; + +#if API >= 11 +/* +typedef GalliumD3D11Shader<ID3D11HullShader> GalliumD3D11HullShader; +typedef GalliumD3D11Shader<ID3D11DomainShader> GalliumD3D11DomainShader; +typedef GalliumD3D11Shader<ID3D11ComputeShader> GalliumD3D11ComputeShader; +*/ +#endif + +template<typename Base = ID3D11Resource> +struct GalliumD3D11ResourceBase : public GalliumD3D11DeviceChild<Base> +{ + unsigned eviction_priority; + + virtual void STDMETHODCALLTYPE SetEvictionPriority( + unsigned new_eviction_priority + ) + { + eviction_priority = new_eviction_priority; + } + + virtual unsigned STDMETHODCALLTYPE GetEvictionPriority() + { + return eviction_priority; + } +}; + +template<typename Real> +struct GalliumDXGIResource : public IDXGIResource +{ + virtual HRESULT STDMETHODCALLTYPE SetEvictionPriority( + unsigned new_eviction_priority + ) + { + static_cast<Real*>(this)->eviction_priority = new_eviction_priority; + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE GetEvictionPriority(unsigned* out_eviction_priority) + { + *out_eviction_priority = static_cast<Real*>(this)->eviction_priority; + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE GetDevice( + REFIID riid, + void **out_parent) + { + if(!static_cast<Real*>(this)->device) + return E_NOINTERFACE; + return static_cast<Real*>(this)->device->QueryInterface(riid, out_parent); + } + + virtual HRESULT STDMETHODCALLTYPE GetParent( + REFIID riid, + void **out_parent) + { + if(!static_cast<Real*>(this)->device) + return E_NOINTERFACE; + return static_cast<Real*>(this)->device->QueryInterface(riid, out_parent); + } +}; + +template<typename T> +struct com_traits<GalliumDXGIResource<T> > : public com_traits<IDXGIResource> +{}; + +template<typename Base = ID3D11Resource> +struct GalliumD3D11Resource + : public GalliumMultiComObject< + GalliumMultiPrivateDataComObject< + GalliumD3D11ResourceBase<Base>, + GalliumDXGIResource<GalliumD3D11Resource<Base> > + >, + IGalliumResource + > +{ + struct pipe_resource* resource; + std::unordered_map<unsigned, pipe_transfer*> transfers; + float min_lod; + DXGI_USAGE dxgi_usage; + + GalliumD3D11Resource(GalliumD3D11Screen* device = 0, struct pipe_resource* resource = 0, unsigned dxgi_usage = 0) + : resource(resource), min_lod(0), dxgi_usage(dxgi_usage) + { + this->device = device; + if(device) + device->AddRef(); + this->eviction_priority = 0; + } + + ~GalliumD3D11Resource() + { + pipe_resource_reference(&resource, 0); + } + + virtual HRESULT STDMETHODCALLTYPE GetUsage( + DXGI_USAGE *out_usage + ) + { + *out_usage = this->dxgi_usage; + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE GetSharedHandle(HANDLE *out_shared_handle) + { + return E_NOTIMPL; + } + + virtual struct pipe_resource* STDMETHODCALLTYPE GetGalliumResource() + { + return resource; + } +}; + +template<typename Base, typename Desc, D3D11_RESOURCE_DIMENSION Dim> +struct GalliumD3D11TypedResource : public GalliumD3D11Resource<Base> +{ + Desc desc; + GalliumD3D11TypedResource() {} + GalliumD3D11TypedResource(GalliumD3D11Screen* device, struct pipe_resource* resource, const Desc& desc, unsigned dxgi_usage) + : GalliumD3D11Resource<Base>(device, resource, dxgi_usage), desc(desc) + {} + virtual void STDMETHODCALLTYPE GetType( + D3D11_RESOURCE_DIMENSION *out_resource_dimension) + { + *out_resource_dimension = Dim; + } + virtual void STDMETHODCALLTYPE GetDesc(Desc *out_desc) + { + memcpy(out_desc, &desc, sizeof(desc)); + } +}; + +typedef GalliumD3D11TypedResource<ID3D11Texture1D, D3D11_TEXTURE1D_DESC, D3D11_RESOURCE_DIMENSION_TEXTURE1D> GalliumD3D11Texture1DBase; +typedef GalliumD3D11TypedResource<ID3D11Texture2D, D3D11_TEXTURE2D_DESC, D3D11_RESOURCE_DIMENSION_TEXTURE2D> GalliumD3D11Texture2DBase; +typedef GalliumD3D11TypedResource<ID3D11Texture3D, D3D11_TEXTURE3D_DESC, D3D11_RESOURCE_DIMENSION_TEXTURE3D> GalliumD3D11Texture3DBase; +typedef GalliumD3D11TypedResource<ID3D11Buffer, D3D11_BUFFER_DESC, D3D11_RESOURCE_DIMENSION_BUFFER> GalliumD3D11BufferBase; + +#if API >= 11 +typedef GalliumD3D11BufferBase GalliumD3D11Buffer; +typedef GalliumD3D11Texture1DBase GalliumD3D11Texture1D; +typedef GalliumD3D11Texture2DBase GalliumD3D11Texture2D; +typedef GalliumD3D11Texture3DBase GalliumD3D11Texture3D; +#else +struct GalliumD3D10Buffer : public GalliumD3D10BufferBase +{ + GalliumD3D10Buffer(GalliumD3D10Screen* device, struct pipe_resource* resource, const D3D10_BUFFER_DESC& desc, unsigned dxgi_usage) + : GalliumD3D10BufferBase(device, resource, desc, dxgi_usage) + {} + + ~GalliumD3D10Buffer() + { + device->UnbindBuffer(this); + } + + virtual HRESULT STDMETHODCALLTYPE Map( + D3D10_MAP map_type, + unsigned map_flags, + void **out_data) + { + D3D10_MAPPED_SUBRESOURCE msr; + HRESULT hr = device->Map(this, 0, map_type, map_flags, &msr); + if(!SUCCEEDED(hr)) + return hr; + *out_data = msr.pData; + return S_OK; + } + + virtual void STDMETHODCALLTYPE Unmap() + { + device->Unmap(this, 0); + } +}; + +struct GalliumD3D10Texture1D : public GalliumD3D10Texture1DBase +{ + GalliumD3D10Texture1D(GalliumD3D10Screen* device, struct pipe_resource* resource, const D3D10_TEXTURE1D_DESC& desc, unsigned dxgi_usage) + : GalliumD3D10Texture1DBase(device, resource, desc, dxgi_usage) + {} + + virtual HRESULT STDMETHODCALLTYPE Map( + unsigned subresource, + D3D10_MAP map_type, + unsigned map_flags, + void **out_data) + { + D3D10_MAPPED_SUBRESOURCE msr; + HRESULT hr = device->Map(this, subresource, map_type, map_flags, &msr); + if(!SUCCEEDED(hr)) + return hr; + *out_data = msr.pData; + return S_OK; + } + + virtual void STDMETHODCALLTYPE Unmap( + unsigned subresource + ) + { + device->Unmap(this, subresource); + } +}; + +struct GalliumD3D10Texture2D : public GalliumD3D10Texture2DBase +{ + GalliumD3D10Texture2D() {} + GalliumD3D10Texture2D(GalliumD3D10Screen* device, struct pipe_resource* resource, const D3D10_TEXTURE2D_DESC& desc, unsigned dxgi_usage) + : GalliumD3D10Texture2DBase(device, resource, desc, dxgi_usage) + {} + + virtual HRESULT STDMETHODCALLTYPE Map( + unsigned subresource, + D3D10_MAP map_type, + unsigned map_flags, + D3D10_MAPPED_TEXTURE2D *out_mapped_subresource) + { + D3D10_MAPPED_SUBRESOURCE msr; + HRESULT hr = device->Map(this, subresource, map_type, map_flags, &msr); + if(!SUCCEEDED(hr)) + return hr; + out_mapped_subresource->pData = msr.pData; + out_mapped_subresource->RowPitch = msr.RowPitch; + return S_OK; + } + + virtual void STDMETHODCALLTYPE Unmap( + unsigned subresource + ) + { + device->Unmap(this, subresource); + } +}; + + +struct GalliumD3D10Texture3D : public GalliumD3D10Texture3DBase +{ + GalliumD3D10Texture3D(GalliumD3D10Screen* device, struct pipe_resource* resource, const D3D10_TEXTURE3D_DESC& desc, unsigned dxgi_usage) + : GalliumD3D10Texture3DBase(device, resource, desc, dxgi_usage) + {} + + virtual HRESULT STDMETHODCALLTYPE Map( + unsigned subresource, + D3D10_MAP map_type, + unsigned map_flags, + D3D10_MAPPED_TEXTURE3D *out_mapped_subresource) + { + D3D10_MAPPED_SUBRESOURCE msr; + HRESULT hr = device->Map(this, subresource, map_type, map_flags, &msr); + if(!SUCCEEDED(hr)) + return hr; + out_mapped_subresource->pData = msr.pData; + out_mapped_subresource->RowPitch = msr.RowPitch; + out_mapped_subresource->DepthPitch = msr.DepthPitch; + return S_OK; + } + + virtual void STDMETHODCALLTYPE Unmap( + unsigned subresource + ) + { + device->Unmap(this, subresource); + } +}; +#endif + +struct GalliumD3D11Surface : public GalliumMultiPrivateDataComObject<GalliumD3D11Texture2D, IDXGISurface1> +{ + GalliumD3D11Surface(GalliumD3D11Screen* device, struct pipe_resource* resource, const D3D11_TEXTURE2D_DESC& desc, unsigned dxgi_usage) + { + this->device = device; + this->device->AddRef(); + this->resource = resource; + this->desc = desc; + this->dxgi_usage = dxgi_usage; + } + + virtual HRESULT STDMETHODCALLTYPE GetDesc( + DXGI_SURFACE_DESC *out_desc) + { + out_desc->Format = this->desc.Format; + out_desc->Width = this->desc.Width; + out_desc->Height = this->desc.Height; + out_desc->SampleDesc = this->desc.SampleDesc; + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE GetParent( + REFIID riid, + void **out_parent) + { + if(!device) + return E_NOINTERFACE; + return device->QueryInterface(riid, out_parent); + } + + /* TODO: somehow implement these */ + virtual HRESULT STDMETHODCALLTYPE GetDC( + BOOL discard, + HDC *out_hdc) + { + *out_hdc = 0; + return E_NOTIMPL; + } + + virtual HRESULT STDMETHODCALLTYPE ReleaseDC( + RECT *out_dirty_rect) + { + return E_NOTIMPL; + } + + virtual HRESULT STDMETHODCALLTYPE Map( + DXGI_MAPPED_RECT *out_locked_rect, + unsigned map_flags) + { + D3D11_MAP d3d_map; + if(map_flags & DXGI_MAP_DISCARD) + d3d_map = D3D11_MAP_WRITE_DISCARD; + else + { + if(map_flags & DXGI_MAP_READ) + { + if(map_flags & DXGI_MAP_WRITE) + d3d_map = D3D11_MAP_READ_WRITE; + else + d3d_map = D3D11_MAP_READ; + } + else + d3d_map = D3D11_MAP_WRITE; + } + D3D11_MAPPED_SUBRESOURCE d3d_mapped; + HRESULT hres = this->device->get_immediate_context()->Map(this, 0, d3d_map, 0, &d3d_mapped); + out_locked_rect->pBits = (uint8_t*)d3d_mapped.pData; + out_locked_rect->Pitch = d3d_mapped.RowPitch; + return hres; + } + + virtual HRESULT STDMETHODCALLTYPE Unmap(void) + { + this->device->get_immediate_context()->Unmap(this, 0); + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE GetDevice( + REFIID riid, + void **out_parent) + { + if(!device) + return E_NOINTERFACE; + return device->QueryInterface(riid, out_parent); + } +}; + +template<typename Base, typename Desc, typename Object> +struct GalliumD3D11View : public GalliumD3D11DescribedObject<Base, Desc, Object> +{ + GalliumD3D11Resource<>* resource; + GalliumD3D11View(GalliumD3D11Screen* device, GalliumD3D11Resource<>* resource, Object* object, const Desc& desc) + : GalliumD3D11DescribedObject<Base, Desc, Object>(device, object, desc), resource(resource) + { + resource->AddRef(); + } + + ~GalliumD3D11View() + { + resource->Release(); + } + + virtual void STDMETHODCALLTYPE GetResource(ID3D11Resource** out_resource) + { + resource->AddRef(); + *out_resource = resource; + } +}; + +typedef GalliumD3D11View<ID3D11DepthStencilView, D3D11_DEPTH_STENCIL_VIEW_DESC, struct pipe_surface> GalliumD3D11DepthStencilView; +typedef GalliumD3D11View<ID3D11RenderTargetView, D3D11_RENDER_TARGET_VIEW_DESC, struct pipe_surface> GalliumD3D11RenderTargetView; + +#if API >= 11 +typedef GalliumD3D11View<ID3D11ShaderResourceView, D3D11_SHADER_RESOURCE_VIEW_DESC, struct pipe_sampler_view> GalliumD3D11ShaderResourceView; +#else +typedef GalliumD3D10View<ID3D10ShaderResourceView1, D3D10_SHADER_RESOURCE_VIEW_DESC1, struct pipe_sampler_view> GalliumD3D10ShaderResourceViewBase; + +struct GalliumD3D10ShaderResourceView : public GalliumD3D10ShaderResourceViewBase +{ + GalliumD3D10ShaderResourceView(GalliumD3D10Screen* device, GalliumD3D10Resource<>* resource, struct pipe_sampler_view* view, const D3D10_SHADER_RESOURCE_VIEW_DESC1& desc) + : GalliumD3D10ShaderResourceViewBase(device, resource, view, desc) + {} + + virtual void STDMETHODCALLTYPE GetDesc1(D3D10_SHADER_RESOURCE_VIEW_DESC1 *out_desc) + { + memcpy(out_desc, &desc, sizeof(*out_desc)); + } + + virtual void STDMETHODCALLTYPE GetDesc(D3D10_SHADER_RESOURCE_VIEW_DESC *out_desc) + { + memcpy(out_desc, &desc, sizeof(*out_desc)); + } +}; +#endif + +template<typename Base = ID3D11Asynchronous> +struct GalliumD3D11Asynchronous : public GalliumD3D11DeviceChild<Base> +{ + struct pipe_query* query; + unsigned data_size; + + GalliumD3D11Asynchronous(GalliumD3D11Screen* device, struct pipe_query* query, unsigned data_size) + : GalliumD3D11DeviceChild<Base>(device), query(query), data_size(data_size) + {} + + ~GalliumD3D11Asynchronous() + { + this->device->immediate_pipe->destroy_query(this->device->immediate_pipe, query); + } + + virtual unsigned STDMETHODCALLTYPE GetDataSize() + { + return data_size; + } + +#if API < 11 + virtual void STDMETHODCALLTYPE Begin() + { + this->device->Begin(this); + } + + virtual void STDMETHODCALLTYPE End() + { + this->device->End(this); + } + + virtual HRESULT STDMETHODCALLTYPE GetData( + void * out_data, + unsigned data_size, + unsigned get_data_flags) + { + return this->device->GetData(this, out_data, data_size, get_data_flags); + } +#endif +}; + +template<typename Base = ID3D11Asynchronous> +struct GalliumD3D11QueryOrPredicate : public GalliumD3D11Asynchronous<Base> +{ + D3D11_QUERY_DESC desc; + GalliumD3D11QueryOrPredicate(GalliumD3D11Screen* device, struct pipe_query* query, unsigned data_size, const D3D11_QUERY_DESC& desc) + : GalliumD3D11Asynchronous<Base>(device, query, data_size), desc(desc) + {} + + virtual void STDMETHODCALLTYPE GetDesc( + D3D11_QUERY_DESC *out_desc) + { + *out_desc = desc; + } +}; + +struct GalliumD3D11Query : public GalliumD3D11QueryOrPredicate<ID3D11Query> +{ + GalliumD3D11Query(GalliumD3D11Screen* device, struct pipe_query* query, unsigned data_size, const D3D11_QUERY_DESC& desc) + : GalliumD3D11QueryOrPredicate<ID3D11Query>(device, query, data_size, desc) + {} +}; + +struct GalliumD3D11Predicate : public GalliumD3D11QueryOrPredicate<ID3D11Predicate> +{ + GalliumD3D11Predicate(GalliumD3D11Screen* device, struct pipe_query* query, unsigned data_size, const D3D11_QUERY_DESC& desc) + : GalliumD3D11QueryOrPredicate<ID3D11Predicate>(device, query, data_size, desc) + {} + + ~GalliumD3D11Predicate() + { + DX10_ONLY(device->UnbindPredicate(this)); + } +}; + +struct GalliumD3D11Counter : public GalliumD3D11Asynchronous<ID3D11Counter> +{ + D3D11_COUNTER_DESC desc; + GalliumD3D11Counter(GalliumD3D11Screen* device, struct pipe_query* query, unsigned data_size, const D3D11_COUNTER_DESC& desc) + : GalliumD3D11Asynchronous<ID3D11Counter>(device, query, data_size), desc(desc) + {} + + virtual void STDMETHODCALLTYPE GetDesc( + D3D11_COUNTER_DESC *out_desc) + { + *out_desc = desc; + } +}; diff --git a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_screen.h b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_screen.h new file mode 100644 index 00000000000..95ea4e00fc1 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_screen.h @@ -0,0 +1,1459 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + +DEBUG_GET_ONCE_BOOL_OPTION(dump_shaders, "D3D1X_DUMP_SHADERS", FALSE); + +/* These cap sets are much more correct than the ones in u_caps.c */ +/* TODO: it seems cube levels should be the same as 2D levels */ + +/* DX 9_1 */ +static unsigned caps_dx_9_1[] = { + UTIL_CHECK_INT(MAX_RENDER_TARGETS, 1), + UTIL_CHECK_INT(MAX_TEXTURE_2D_LEVELS, 12), /* 2048 */ + UTIL_CHECK_INT(MAX_TEXTURE_3D_LEVELS, 8), /* 256 */ + UTIL_CHECK_INT(MAX_TEXTURE_CUBE_LEVELS, 10), /* 512 */ + UTIL_CHECK_TERMINATE +}; + +/* DX 9_2 */ +static unsigned caps_dx_9_2[] = { + UTIL_CHECK_CAP(OCCLUSION_QUERY), + UTIL_CHECK_CAP(TWO_SIDED_STENCIL), + UTIL_CHECK_CAP(TEXTURE_MIRROR_CLAMP), + UTIL_CHECK_CAP(BLEND_EQUATION_SEPARATE), + UTIL_CHECK_INT(MAX_RENDER_TARGETS, 1), + UTIL_CHECK_INT(MAX_TEXTURE_2D_LEVELS, 12), /* 2048 */ + UTIL_CHECK_INT(MAX_TEXTURE_3D_LEVELS, 9), /* 256 */ + UTIL_CHECK_INT(MAX_TEXTURE_CUBE_LEVELS, 10), /* 512 */ + UTIL_CHECK_TERMINATE +}; + +/* DX 9_3 */ +static unsigned caps_dx_9_3[] = { + UTIL_CHECK_CAP(OCCLUSION_QUERY), + UTIL_CHECK_CAP(TWO_SIDED_STENCIL), + UTIL_CHECK_CAP(TEXTURE_MIRROR_CLAMP), + UTIL_CHECK_CAP(BLEND_EQUATION_SEPARATE), + UTIL_CHECK_CAP(SM3), + //UTIL_CHECK_CAP(INSTANCING), + UTIL_CHECK_CAP(OCCLUSION_QUERY), + UTIL_CHECK_INT(MAX_RENDER_TARGETS, 4), + UTIL_CHECK_INT(MAX_TEXTURE_2D_LEVELS, 13), /* 4096 */ + UTIL_CHECK_INT(MAX_TEXTURE_3D_LEVELS, 9), /* 256 */ + UTIL_CHECK_INT(MAX_TEXTURE_CUBE_LEVELS, 10), /* 512 */ + UTIL_CHECK_TERMINATE +}; + + +// this is called "screen" because in the D3D10 case it's only part of the device +template<bool threadsafe> +struct GalliumD3D11ScreenImpl : public GalliumD3D11Screen +{ + D3D_FEATURE_LEVEL feature_level; + int format_support[PIPE_FORMAT_COUNT]; + unsigned creation_flags; + unsigned exception_mode; + maybe_mutex_t<threadsafe> mutex; + +/* TODO: Direct3D 11 specifies that fine-grained locking should be used if the driver supports it. + * Right now, I don't trust Gallium drivers to get this right. + */ +#define SYNCHRONIZED lock_t<maybe_mutex_t<threadsafe> > lock_(mutex) + + GalliumD3D11ScreenImpl(struct pipe_screen* screen, struct pipe_context* immediate_pipe, BOOL owns_immediate_pipe,unsigned creation_flags, IDXGIAdapter* adapter) + : GalliumD3D11Screen(screen, immediate_pipe, adapter), creation_flags(creation_flags) + { + memset(&screen_caps, 0, sizeof(screen_caps)); + screen_caps.gs = screen->get_shader_param(screen, PIPE_SHADER_GEOMETRY, PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0; + screen_caps.so = !!screen->get_param(screen, PIPE_CAP_STREAM_OUTPUT); + screen_caps.queries = screen->get_param(screen, PIPE_CAP_OCCLUSION_QUERY); + screen_caps.render_condition = screen_caps.queries; + for(unsigned i = 0; i < PIPE_SHADER_TYPES; ++i) + screen_caps.constant_buffers[i] = screen->get_shader_param(screen, i, PIPE_SHADER_CAP_MAX_CONST_BUFFERS); + screen_caps.stages = 0; + for(unsigned i = 0; i < PIPE_SHADER_TYPES; ++i) + { + if(!screen->get_shader_param(screen, i, PIPE_SHADER_CAP_MAX_INSTRUCTIONS)) + break; + screen_caps.stages = i + 1; + } + + screen_caps.stages_with_sampling = (1 << screen_caps.stages) - 1; + if(!screen->get_param(screen, PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS)) + screen_caps.stages_with_sampling &=~ (1 << PIPE_SHADER_VERTEX); + + memset(format_support, 0xff, sizeof(format_support)); + + float default_level; + /* don't even attempt to autodetect D3D10 level support, since it's just not fully implemented yet */ + if(util_check_caps(screen, caps_dx_9_3)) + default_level = 9.3; + else if(util_check_caps(screen, caps_dx_9_2)) + default_level = 9.2; + else if(util_check_caps(screen, caps_dx_9_1)) + default_level = 9.1; + else + { + _debug_printf("Warning: driver does not even meet D3D_FEATURE_LEVEL_9_1 features, advertising it anyway!\n"); + default_level = 9.1; + } + + char default_level_name[64]; + sprintf(default_level_name, "%.1f", default_level); + float feature_level_number = atof(debug_get_option("D3D11_FEATURE_LEVEL", default_level_name)); + if(!feature_level_number) + feature_level_number = default_level; + +#if API >= 11 + if(feature_level_number >= 11.0f) + feature_level = D3D_FEATURE_LEVEL_11_0; + else +#endif + if(feature_level_number >= 10.1f) + feature_level = D3D_FEATURE_LEVEL_10_1; + else if(feature_level_number >= 10.0f) + feature_level = D3D_FEATURE_LEVEL_10_0; + else if(feature_level_number >= 9.3f) + feature_level = D3D_FEATURE_LEVEL_9_3; + else if(feature_level_number >= 9.2f) + feature_level = D3D_FEATURE_LEVEL_9_2; + else + feature_level = D3D_FEATURE_LEVEL_9_1; + +#if API >= 11 + immediate_context = GalliumD3D11ImmediateDeviceContext_Create(this, immediate_pipe, owns_immediate_pipe); + // release to the reference to ourselves that the immediate context took, to avoid a garbage cycle + immediate_context->Release(); +#endif + } + + ~GalliumD3D11ScreenImpl() + { +#if API >= 11 + GalliumD3D11ImmediateDeviceContext_Destroy(immediate_context); +#endif + } + + virtual D3D_FEATURE_LEVEL STDMETHODCALLTYPE GetFeatureLevel(void) + { + return feature_level; + } + + virtual unsigned STDMETHODCALLTYPE GetCreationFlags(void) + { + return creation_flags; + } + + virtual HRESULT STDMETHODCALLTYPE GetDeviceRemovedReason(void) + { + return S_OK; + } + +#if API >= 11 + virtual void STDMETHODCALLTYPE GetImmediateContext( + ID3D11DeviceContext **out_immediate_context) + { + immediate_context->AddRef(); + *out_immediate_context = immediate_context; + } +#endif + + virtual HRESULT STDMETHODCALLTYPE SetExceptionMode(unsigned RaiseFlags) + { + exception_mode = RaiseFlags; + return S_OK; + } + + virtual unsigned STDMETHODCALLTYPE GetExceptionMode(void) + { + return exception_mode; + } + + virtual HRESULT STDMETHODCALLTYPE CheckCounter( + const D3D11_COUNTER_DESC *desc, + D3D11_COUNTER_TYPE *type, + unsigned *active_counters, + LPSTR sz_name, + unsigned *name_length, + LPSTR sz_units, + unsigned *units_length, + LPSTR sz_description, + unsigned *description_length) + { + return E_NOTIMPL; + } + + virtual void STDMETHODCALLTYPE CheckCounterInfo( + D3D11_COUNTER_INFO *counter_info) + { + /* none supported at the moment */ + counter_info->LastDeviceDependentCounter = (D3D11_COUNTER)0; + counter_info->NumDetectableParallelUnits = 1; + counter_info->NumSimultaneousCounters = 0; + } + +#if API >= 11 + virtual HRESULT STDMETHODCALLTYPE CheckFeatureSupport( + D3D11_FEATURE feature, + void *out_feature_support_data, + unsigned feature_support_data_size) + { + SYNCHRONIZED; + + switch(feature) + { + case D3D11_FEATURE_THREADING: + { + D3D11_FEATURE_DATA_THREADING* data = (D3D11_FEATURE_DATA_THREADING*)out_feature_support_data; + if(feature_support_data_size != sizeof(*data)) + return E_INVALIDARG; + + data->DriverCommandLists = FALSE; + data->DriverConcurrentCreates = FALSE; + return S_OK; + } + case D3D11_FEATURE_DOUBLES: + { + D3D11_FEATURE_DATA_DOUBLES* data = (D3D11_FEATURE_DATA_DOUBLES*)out_feature_support_data; + if(feature_support_data_size != sizeof(*data)) + return E_INVALIDARG; + + data->DoublePrecisionFloatShaderOps = FALSE; + return S_OK; + } + case D3D11_FEATURE_FORMAT_SUPPORT: + { + D3D11_FEATURE_DATA_FORMAT_SUPPORT* data = (D3D11_FEATURE_DATA_FORMAT_SUPPORT*)out_feature_support_data; + if(feature_support_data_size != sizeof(*data)) + return E_INVALIDARG; + + return this->CheckFormatSupport(data->InFormat, &data->OutFormatSupport); + } + case D3D11_FEATURE_FORMAT_SUPPORT2: + { + D3D11_FEATURE_DATA_FORMAT_SUPPORT* data = (D3D11_FEATURE_DATA_FORMAT_SUPPORT*)out_feature_support_data; + if(feature_support_data_size != sizeof(*data)) + return E_INVALIDARG; + + data->OutFormatSupport = 0; + /* TODO: should this be S_OK? */ + return E_INVALIDARG; + } + case D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS: + { + D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS* data = (D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS*)out_feature_support_data; + if(feature_support_data_size != sizeof(*data)) + return E_INVALIDARG; + + data->ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x = FALSE; + return S_OK; + } + default: + return E_INVALIDARG; + } + } +#endif + + virtual HRESULT STDMETHODCALLTYPE CheckFormatSupport( + DXGI_FORMAT dxgi_format, + unsigned *out_format_support + ) + { + SYNCHRONIZED; + + /* TODO: MSAA, advanced features */ + pipe_format format = dxgi_to_pipe_format[dxgi_format]; + if(!format) + return E_INVALIDARG; + + int support = format_support[format]; + if(support < 0) + { + support = 0; + unsigned buffer = D3D11_FORMAT_SUPPORT_BUFFER | D3D11_FORMAT_SUPPORT_IA_VERTEX_BUFFER | D3D11_FORMAT_SUPPORT_IA_INDEX_BUFFER; + unsigned sampler_view = D3D11_FORMAT_SUPPORT_SHADER_SAMPLE | D3D11_FORMAT_SUPPORT_MIP | D3D11_FORMAT_SUPPORT_MIP_AUTOGEN; + if(util_format_is_depth_or_stencil(format)) + sampler_view |= D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON; + + /* TODO: do this properly when Gallium drivers actually support index/vertex format queries */ + if(screen->is_format_supported(screen, format, PIPE_BUFFER, 0, PIPE_BIND_VERTEX_BUFFER, 0) + || (screen->is_format_supported(screen, format, PIPE_BUFFER, 0, PIPE_BIND_INDEX_BUFFER, 0) + || format == PIPE_FORMAT_R8_UNORM)) + support |= buffer; + if(screen->is_format_supported(screen, format, PIPE_BUFFER, 0, PIPE_BIND_STREAM_OUTPUT, 0)) + support |= buffer | D3D11_FORMAT_SUPPORT_SO_BUFFER; + if(screen->is_format_supported(screen, format, PIPE_TEXTURE_1D, 0, PIPE_BIND_SAMPLER_VIEW, 0)) + support |= D3D11_FORMAT_SUPPORT_TEXTURE1D | sampler_view; + if(screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW, 0)) + support |= D3D11_FORMAT_SUPPORT_TEXTURE2D | sampler_view; + if(screen->is_format_supported(screen, format, PIPE_TEXTURE_CUBE, 0, PIPE_BIND_SAMPLER_VIEW, 0)) + support |= D3D11_FORMAT_SUPPORT_TEXTURE2D | sampler_view; + if(screen->is_format_supported(screen, format, PIPE_TEXTURE_3D, 0, PIPE_BIND_SAMPLER_VIEW, 0)) + support |= D3D11_FORMAT_SUPPORT_TEXTURE3D | sampler_view; + if(screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 0, PIPE_BIND_RENDER_TARGET, 0)) + support |= D3D11_FORMAT_SUPPORT_TEXTURE2D | D3D11_FORMAT_SUPPORT_RENDER_TARGET | D3D11_FORMAT_SUPPORT_BLENDABLE; + if(screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 0, PIPE_BIND_DEPTH_STENCIL, 0)) + support |= D3D11_FORMAT_SUPPORT_TEXTURE2D | D3D11_FORMAT_SUPPORT_DEPTH_STENCIL; + if(screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 0, PIPE_BIND_DISPLAY_TARGET, 0)) + support |= D3D11_FORMAT_SUPPORT_DISPLAY; + format_support[format] = support; + } + *out_format_support = support; + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE CheckMultisampleQualityLevels( + DXGI_FORMAT format, + unsigned sample_count, + unsigned *pcount + ) + { + SYNCHRONIZED; + + if(sample_count == 1) + *pcount = 1; + else + *pcount = 0; + return S_OK; + } + + template<typename T, typename U> + bool convert_blend_state(T& to, const U& from, unsigned BlendEnable, unsigned RenderTargetWriteMask) + { + if(invalid(0 + || from.SrcBlend >= D3D11_BLEND_COUNT + || from.SrcBlendAlpha >= D3D11_BLEND_COUNT + || from.DestBlend >= D3D11_BLEND_COUNT + || from.DestBlendAlpha >= D3D11_BLEND_COUNT + || from.BlendOp >= 6 + || from.BlendOpAlpha >= 6 + || !from.BlendOp + || !from.BlendOpAlpha + )) + return false; + + to.blend_enable = BlendEnable; + + to.rgb_func = from.BlendOp - 1; + to.alpha_func = from.BlendOpAlpha - 1; + + to.rgb_src_factor = d3d11_to_pipe_blend[from.SrcBlend]; + to.alpha_src_factor = d3d11_to_pipe_blend[from.SrcBlendAlpha]; + to.rgb_dst_factor = d3d11_to_pipe_blend[from.DestBlend]; + to.alpha_dst_factor = d3d11_to_pipe_blend[from.DestBlendAlpha]; + + to.colormask = RenderTargetWriteMask & 0xf; + return true; + } + +#if API >= 11 + virtual HRESULT STDMETHODCALLTYPE CreateBlendState( + const D3D11_BLEND_DESC *blend_state_desc, + ID3D11BlendState **out_blend_state + ) +#else + virtual HRESULT STDMETHODCALLTYPE CreateBlendState1( + const D3D10_BLEND_DESC1 *blend_state_desc, + ID3D10BlendState1 **out_blend_state + ) +#endif + { + SYNCHRONIZED; + + pipe_blend_state state; + memset(&state, 0, sizeof(state)); + state.alpha_to_coverage = !!blend_state_desc->AlphaToCoverageEnable; + state.independent_blend_enable = !!blend_state_desc->IndependentBlendEnable; + assert(PIPE_MAX_COLOR_BUFS >= 8); + for(unsigned i = 0; i < 8; ++i) + { + if(!convert_blend_state( + state.rt[i], + blend_state_desc->RenderTarget[i], + blend_state_desc->RenderTarget[i].BlendEnable, + blend_state_desc->RenderTarget[i].RenderTargetWriteMask)) + return E_INVALIDARG; + } + + if(!out_blend_state) + return S_FALSE; + + void* object = immediate_pipe->create_blend_state(immediate_pipe, &state); + if(!object) + return E_FAIL; + + *out_blend_state = new GalliumD3D11BlendState(this, object, *blend_state_desc); + return S_OK; + } + +#if API < 11 + virtual HRESULT STDMETHODCALLTYPE CreateBlendState( + const D3D10_BLEND_DESC *blend_state_desc, + ID3D10BlendState **out_blend_state + ) + { + SYNCHRONIZED; + + pipe_blend_state state; + memset(&state, 0, sizeof(state)); + state.alpha_to_coverage = !!blend_state_desc->AlphaToCoverageEnable; + assert(PIPE_MAX_COLOR_BUFS >= 8); + for(unsigned i = 0; i < 8; ++i) + { + if(!convert_blend_state( + state.rt[i], + *blend_state_desc, + blend_state_desc->BlendEnable[i], + blend_state_desc->RenderTargetWriteMask[i])) + return E_INVALIDARG; + } + + for(unsigned i = 1; i < 8; ++i) + { + if(memcmp(&state.rt[0], &state.rt[i], sizeof(state.rt[0]))) + { + state.independent_blend_enable = TRUE; + break; + } + } + + void* object = immediate_pipe->create_blend_state(immediate_pipe, &state); + if(!object) + return E_FAIL; + + *out_blend_state = new GalliumD3D11BlendState(this, object, *blend_state_desc); + return S_OK; + } +#endif + + virtual HRESULT STDMETHODCALLTYPE CreateDepthStencilState( + const D3D11_DEPTH_STENCIL_DESC *depth_stencil_state_desc, + ID3D11DepthStencilState **depth_stencil_state + ) + { + SYNCHRONIZED; + + pipe_depth_stencil_alpha_state state; + memset(&state, 0, sizeof(state)); + state.depth.enabled = !!depth_stencil_state_desc->DepthEnable; + state.depth.writemask = depth_stencil_state_desc->DepthWriteMask; + state.depth.func = depth_stencil_state_desc->DepthFunc - 1; + state.stencil[0].enabled = !!depth_stencil_state_desc->StencilEnable; + state.stencil[0].writemask = depth_stencil_state_desc->StencilWriteMask; + state.stencil[0].valuemask = depth_stencil_state_desc->StencilReadMask; + state.stencil[0].zpass_op = d3d11_to_pipe_stencil_op[depth_stencil_state_desc->FrontFace.StencilPassOp]; + state.stencil[0].fail_op = d3d11_to_pipe_stencil_op[depth_stencil_state_desc->FrontFace.StencilFailOp]; + state.stencil[0].zfail_op = d3d11_to_pipe_stencil_op[depth_stencil_state_desc->FrontFace.StencilDepthFailOp]; + state.stencil[0].func = depth_stencil_state_desc->FrontFace.StencilFunc - 1; + state.stencil[1].enabled = !!depth_stencil_state_desc->StencilEnable; + state.stencil[1].writemask = depth_stencil_state_desc->StencilWriteMask; + state.stencil[1].valuemask = depth_stencil_state_desc->StencilReadMask; + state.stencil[1].zpass_op = d3d11_to_pipe_stencil_op[depth_stencil_state_desc->BackFace.StencilPassOp]; + state.stencil[1].fail_op = d3d11_to_pipe_stencil_op[depth_stencil_state_desc->BackFace.StencilFailOp]; + state.stencil[1].zfail_op = d3d11_to_pipe_stencil_op[depth_stencil_state_desc->BackFace.StencilDepthFailOp]; + state.stencil[1].func = depth_stencil_state_desc->BackFace.StencilFunc - 1; + + if(!depth_stencil_state) + return S_FALSE; + + void* object = immediate_pipe->create_depth_stencil_alpha_state(immediate_pipe, &state); + if(!object) + return E_FAIL; + + *depth_stencil_state = new GalliumD3D11DepthStencilState(this, object, *depth_stencil_state_desc); + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE CreateRasterizerState( + const D3D11_RASTERIZER_DESC *rasterizer_desc, + ID3D11RasterizerState **out_rasterizer_state) + { + SYNCHRONIZED; + + pipe_rasterizer_state state; + memset(&state, 0, sizeof(state)); + state.gl_rasterization_rules = 1; /* D3D10/11 use GL rules */ + state.fill_front = state.fill_back = (rasterizer_desc->FillMode == D3D11_FILL_WIREFRAME) ? PIPE_POLYGON_MODE_LINE : PIPE_POLYGON_MODE_FILL; + if(rasterizer_desc->CullMode == D3D11_CULL_FRONT) + state.cull_face = PIPE_FACE_FRONT; + else if(rasterizer_desc->CullMode == D3D11_CULL_BACK) + state.cull_face = PIPE_FACE_BACK; + else + state.cull_face = PIPE_FACE_NONE; + state.front_ccw = !!rasterizer_desc->FrontCounterClockwise; + /* TODO: is this correct? */ + /* TODO: we are ignoring depthBiasClamp! */ + state.offset_tri = state.offset_line = state.offset_point = rasterizer_desc->SlopeScaledDepthBias || rasterizer_desc->DepthBias; + state.offset_scale = rasterizer_desc->SlopeScaledDepthBias; + state.offset_units = rasterizer_desc->DepthBias; + state.scissor = !!rasterizer_desc->ScissorEnable; + state.multisample = !!rasterizer_desc->MultisampleEnable; + state.line_smooth = !!rasterizer_desc->AntialiasedLineEnable; + + /* TODO: is this correct? */ + state.point_quad_rasterization = 1; + + if(!out_rasterizer_state) + return S_FALSE; + + void* object = immediate_pipe->create_rasterizer_state(immediate_pipe, &state); + if(!object) + return E_FAIL; + + *out_rasterizer_state = new GalliumD3D11RasterizerState(this, object, *rasterizer_desc, !rasterizer_desc->DepthClipEnable); + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE CreateSamplerState( + const D3D11_SAMPLER_DESC *sampler_desc, + ID3D11SamplerState **out_sampler_state) + { + SYNCHRONIZED; + + pipe_sampler_state state; + memset(&state, 0, sizeof(state)); + state.normalized_coords = 1; + state.min_mip_filter = (sampler_desc->Filter & 1); + state.mag_img_filter = ((sampler_desc->Filter >> 2) & 1); + state.min_img_filter = ((sampler_desc->Filter >> 4) & 1); + if(sampler_desc->Filter & 0x40) + state.max_anisotropy = sampler_desc->MaxAnisotropy; + if(sampler_desc->Filter & 0x80) + { + state.compare_mode = PIPE_TEX_COMPARE_R_TO_TEXTURE; + state.compare_func = sampler_desc->ComparisonFunc; + } + state.wrap_s = d3d11_to_pipe_wrap[sampler_desc->AddressU]; + state.wrap_t = d3d11_to_pipe_wrap[sampler_desc->AddressV]; + state.wrap_r = d3d11_to_pipe_wrap[sampler_desc->AddressW]; + state.lod_bias = sampler_desc->MipLODBias; + memcpy(state.border_color, sampler_desc->BorderColor, sizeof(state.border_color)); + state.min_lod = sampler_desc->MinLOD; + state.max_lod = sampler_desc->MaxLOD; + + if(!out_sampler_state) + return S_FALSE; + + void* object = immediate_pipe->create_sampler_state(immediate_pipe, &state); + if(!object) + return E_FAIL; + + *out_sampler_state = new GalliumD3D11SamplerState(this, object, *sampler_desc); + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE CreateInputLayout( + const D3D11_INPUT_ELEMENT_DESC *input_element_descs, + unsigned count, + const void *shader_bytecode_with_input_signature, + SIZE_T bytecode_length, + ID3D11InputLayout **out_input_layout) + { + SYNCHRONIZED; + + if(count > D3D11_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT) + return E_INVALIDARG; + assert(D3D11_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT <= PIPE_MAX_ATTRIBS); + + // putting semantics matching in the core API seems to be a (minor) design mistake + + struct dxbc_chunk_signature* sig = dxbc_find_signature(shader_bytecode_with_input_signature, bytecode_length, false); + D3D11_SIGNATURE_PARAMETER_DESC* params; + unsigned num_params = dxbc_parse_signature(sig, ¶ms); + + typedef std::unordered_map<std::pair<c_string, unsigned>, unsigned> semantic_to_idx_map_t; + semantic_to_idx_map_t semantic_to_idx_map; + for(unsigned i = 0; i < count; ++i) + semantic_to_idx_map[std::make_pair(c_string(input_element_descs[i].SemanticName), input_element_descs[i].SemanticIndex)] = i; + + struct pipe_vertex_element elements[D3D11_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT]; + + unsigned num_params_to_use = std::min(num_params, (unsigned)D3D11_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT); + for(unsigned i = 0; i < num_params_to_use; ++i) + { + int idx = -1; + semantic_to_idx_map_t::iterator iter = semantic_to_idx_map.find(std::make_pair(c_string(params[i].SemanticName), params[i].SemanticIndex)); + if(iter != semantic_to_idx_map.end()) + idx = iter->second; + + // TODO: I kind of doubt Gallium drivers will like null elements; should we do something about it, either here, in the interface, or in the drivers? + // TODO: also, in which cases should we return errors? (i.e. duplicate semantics in vs, duplicate semantics in layout, unmatched semantic in vs, unmatched semantic in layout) + memset(&elements[i], 0, sizeof(elements[i])); + if(idx >= 0) + { + elements[i].src_format = dxgi_to_pipe_format[input_element_descs[idx].Format]; + elements[i].src_offset = input_element_descs[idx].AlignedByteOffset; + elements[i].vertex_buffer_index = input_element_descs[idx].InputSlot; + elements[i].instance_divisor = input_element_descs[idx].InstanceDataStepRate; + } + } + + free(params); + + if(!out_input_layout) + return S_FALSE; + + void* object = immediate_pipe->create_vertex_elements_state(immediate_pipe, num_params_to_use, elements); + if(!object) + return E_FAIL; + + *out_input_layout = new GalliumD3D11InputLayout(this, object); + return S_OK; + } + + static unsigned d3d11_to_pipe_bind_flags(unsigned bind_flags) + { + unsigned bind = 0; + if(bind_flags & D3D11_BIND_VERTEX_BUFFER) + bind |= PIPE_BIND_VERTEX_BUFFER; + if(bind_flags & D3D11_BIND_INDEX_BUFFER) + bind |= PIPE_BIND_INDEX_BUFFER; + if(bind_flags & D3D11_BIND_CONSTANT_BUFFER) + bind |= PIPE_BIND_CONSTANT_BUFFER; + if(bind_flags & D3D11_BIND_SHADER_RESOURCE) + bind |= PIPE_BIND_SAMPLER_VIEW; + if(bind_flags & D3D11_BIND_STREAM_OUTPUT) + bind |= PIPE_BIND_STREAM_OUTPUT; + if(bind_flags & D3D11_BIND_RENDER_TARGET) + bind |= PIPE_BIND_RENDER_TARGET; + if(bind_flags & D3D11_BIND_DEPTH_STENCIL) + bind |= PIPE_BIND_DEPTH_STENCIL; + return bind; + } + + inline HRESULT create_resource( + pipe_texture_target target, + unsigned width, + unsigned height, + unsigned depth, + unsigned mip_levels, + unsigned array_size, + DXGI_FORMAT format, + const DXGI_SAMPLE_DESC* SampleDesc, + D3D11_USAGE usage, + unsigned bind_flags, + unsigned c_p_u_access_flags, + unsigned misc_flags, + const D3D11_SUBRESOURCE_DATA *initial_data, + DXGI_USAGE dxgi_usage, + struct pipe_resource** ppresource + ) + { + if(invalid(format >= DXGI_FORMAT_COUNT)) + return E_INVALIDARG; + if(misc_flags & D3D11_RESOURCE_MISC_TEXTURECUBE) + { + if(target != PIPE_TEXTURE_2D) + return E_INVALIDARG; + target = PIPE_TEXTURE_CUBE; + + if(array_size != 6) + return E_NOTIMPL; + } + else + { + if(array_size > 1) + return E_NOTIMPL; + array_size = 1; + } + /* TODO: msaa */ + struct pipe_resource templat; + memset(&templat, 0, sizeof(templat)); + templat.target = target; + templat.width0 = width; + templat.height0 = height; + templat.depth0 = depth; + if(mip_levels) + templat.last_level = mip_levels - 1; + else + templat.last_level = MAX2(MAX2(util_logbase2(templat.width0), util_logbase2(templat.height0)), util_logbase2(templat.depth0)); + templat.format = dxgi_to_pipe_format[format]; + templat.bind = d3d11_to_pipe_bind_flags(bind_flags); + if(c_p_u_access_flags & D3D11_CPU_ACCESS_READ) + templat.bind |= PIPE_BIND_TRANSFER_READ; + if(c_p_u_access_flags & D3D11_CPU_ACCESS_WRITE) + templat.bind |= PIPE_BIND_TRANSFER_WRITE; + if(misc_flags & D3D11_RESOURCE_MISC_SHARED) + templat.bind |= PIPE_BIND_SHARED; + if(misc_flags & D3D11_RESOURCE_MISC_GDI_COMPATIBLE) + templat.bind |= PIPE_BIND_TRANSFER_READ | PIPE_BIND_TRANSFER_WRITE; + if(dxgi_usage & DXGI_USAGE_BACK_BUFFER) + templat.bind |= PIPE_BIND_DISPLAY_TARGET; + templat.usage = d3d11_to_pipe_usage[usage]; + if(invalid(!templat.format)) + return E_NOTIMPL; + + if(!ppresource) + return S_FALSE; + + struct pipe_resource* resource = screen->resource_create(screen, &templat); + if(!resource) + return E_FAIL; + if(initial_data) + { + for(unsigned slice = 0; slice < array_size; ++slice) + { + for(unsigned level = 0; level <= templat.last_level; ++level) + { + struct pipe_subresource sr; + sr.level = level; + sr.face = slice; + struct pipe_box box; + box.x = box.y = box.z = 0; + box.width = u_minify(width, level); + box.height = u_minify(height, level); + box.depth = u_minify(depth, level); + immediate_pipe->transfer_inline_write(immediate_pipe, resource, sr, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD | PIPE_TRANSFER_UNSYNCHRONIZED, &box, initial_data->pSysMem, initial_data->SysMemPitch, initial_data->SysMemSlicePitch); + ++initial_data; + } + } + } + *ppresource = resource; + return S_OK; + } + + static unsigned d3d_to_dxgi_usage(unsigned bind, unsigned misc) + { + unsigned dxgi_usage = 0; + if(bind |= D3D11_BIND_RENDER_TARGET) + dxgi_usage |= DXGI_USAGE_RENDER_TARGET_OUTPUT; + if(bind & D3D11_BIND_SHADER_RESOURCE) + dxgi_usage |= DXGI_USAGE_SHADER_INPUT; +#if API >= 11 + if(bind & D3D11_BIND_UNORDERED_ACCESS) + dxgi_usage |= DXGI_USAGE_UNORDERED_ACCESS; +#endif + if(misc & D3D11_RESOURCE_MISC_SHARED) + dxgi_usage |= DXGI_USAGE_SHARED; + return dxgi_usage; + } + + virtual HRESULT STDMETHODCALLTYPE CreateTexture1D( + const D3D11_TEXTURE1D_DESC *desc, + const D3D11_SUBRESOURCE_DATA *initial_data, + ID3D11Texture1D **out_texture1d) + { + SYNCHRONIZED; + + struct pipe_resource* resource; + DXGI_USAGE dxgi_usage = d3d_to_dxgi_usage(desc->BindFlags, desc->MiscFlags); + HRESULT hr = create_resource(PIPE_TEXTURE_1D, desc->Width, 1, 1, desc->MipLevels, desc->ArraySize, desc->Format, 0, desc->Usage, desc->BindFlags, desc->CPUAccessFlags, desc->MiscFlags, initial_data, dxgi_usage, out_texture1d ? &resource : 0); + if(hr != S_OK) + return hr; + D3D11_TEXTURE1D_DESC cdesc = *desc; + cdesc.MipLevels = resource->last_level + 1; + *out_texture1d = new GalliumD3D11Texture1D(this, resource, cdesc, dxgi_usage); + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE CreateTexture2D( + const D3D11_TEXTURE2D_DESC *desc, + const D3D11_SUBRESOURCE_DATA *initial_data, + ID3D11Texture2D **out_texture2d) + { + SYNCHRONIZED; + + struct pipe_resource* resource; + DXGI_USAGE dxgi_usage = d3d_to_dxgi_usage(desc->BindFlags, desc->MiscFlags); + HRESULT hr = create_resource(PIPE_TEXTURE_2D, desc->Width, desc->Height, 1, desc->MipLevels, desc->ArraySize, desc->Format, &desc->SampleDesc, desc->Usage, desc->BindFlags, desc->CPUAccessFlags, desc->MiscFlags, initial_data, dxgi_usage, out_texture2d ? &resource : 0); + if(hr != S_OK) + return hr; + D3D11_TEXTURE2D_DESC cdesc = *desc; + cdesc.MipLevels = resource->last_level + 1; + if(cdesc.MipLevels == 1 && cdesc.ArraySize == 1) + *out_texture2d = new GalliumD3D11Surface(this, resource, cdesc, dxgi_usage); + else + *out_texture2d = new GalliumD3D11Texture2D(this, resource, cdesc, dxgi_usage); + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE CreateTexture3D( + const D3D11_TEXTURE3D_DESC *desc, + const D3D11_SUBRESOURCE_DATA *initial_data, + ID3D11Texture3D **out_texture3d) + { + SYNCHRONIZED; + + struct pipe_resource* resource; + DXGI_USAGE dxgi_usage = d3d_to_dxgi_usage(desc->BindFlags, desc->MiscFlags); + HRESULT hr = create_resource(PIPE_TEXTURE_3D, desc->Width, desc->Height, desc->Depth, desc->MipLevels, 1, desc->Format, 0, desc->Usage, desc->BindFlags, desc->CPUAccessFlags, desc->MiscFlags, initial_data, dxgi_usage, out_texture3d ? &resource : 0); + if(hr != S_OK) + return hr; + D3D11_TEXTURE3D_DESC cdesc = *desc; + cdesc.MipLevels = resource->last_level + 1; + *out_texture3d = new GalliumD3D11Texture3D(this, resource, cdesc, dxgi_usage); + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE CreateBuffer( + const D3D11_BUFFER_DESC *desc, + const D3D11_SUBRESOURCE_DATA *initial_data, + ID3D11Buffer **out_buffer) + { + SYNCHRONIZED; + + struct pipe_resource* resource; + DXGI_USAGE dxgi_usage = d3d_to_dxgi_usage(desc->BindFlags, desc->MiscFlags); + HRESULT hr = create_resource(PIPE_BUFFER, desc->ByteWidth, 1, 1, 1, 1, DXGI_FORMAT_R8_UNORM, 0, desc->Usage, desc->BindFlags, desc->CPUAccessFlags, desc->MiscFlags, initial_data, dxgi_usage, out_buffer ? &resource : 0); + if(hr != S_OK) + return hr; + *out_buffer = new GalliumD3D11Buffer(this, resource, *desc, dxgi_usage); + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE OpenGalliumResource( + struct pipe_resource* resource, + IUnknown** dxgi_resource) + { + SYNCHRONIZED; + + /* TODO: maybe support others */ + assert(resource->target == PIPE_TEXTURE_2D); + *dxgi_resource = 0; + D3D11_TEXTURE2D_DESC desc; + memset(&desc, 0, sizeof(desc)); + desc.Width = resource->width0; + desc.Height = resource->height0; + init_pipe_to_dxgi_format(); + desc.Format = pipe_to_dxgi_format[resource->format]; + desc.SampleDesc.Count = resource->nr_samples; + desc.SampleDesc.Quality = 0; + desc.ArraySize = 1; + desc.MipLevels = resource->last_level + 1; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE; + if(resource->bind & PIPE_BIND_RENDER_TARGET) + desc.BindFlags |= D3D11_BIND_RENDER_TARGET; + if(resource->bind & PIPE_BIND_DEPTH_STENCIL) + desc.BindFlags |= D3D11_BIND_DEPTH_STENCIL; + if(resource->bind & PIPE_BIND_SAMPLER_VIEW) + desc.BindFlags |= D3D11_BIND_SHADER_RESOURCE; + if(resource->bind & PIPE_BIND_SHARED) + desc.MiscFlags |= D3D11_RESOURCE_MISC_SHARED; + DXGI_USAGE dxgi_usage = d3d_to_dxgi_usage(desc.BindFlags, desc.MiscFlags); + if(desc.MipLevels == 1 && desc.ArraySize == 1) + *dxgi_resource = (ID3D11Texture2D*)new GalliumD3D11Surface(this, resource, desc, dxgi_usage); + else + *dxgi_resource = (ID3D11Texture2D*)new GalliumD3D11Texture2D(this, resource, desc, dxgi_usage); + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE CreateSurface( + const DXGI_SURFACE_DESC *dxgi_desc, + unsigned count, + DXGI_USAGE usage, + const DXGI_SHARED_RESOURCE *shared_resource, + IDXGISurface **out_surface) + { + SYNCHRONIZED; + + D3D11_TEXTURE2D_DESC desc; + memset(&desc, 0, sizeof(desc)); + + struct pipe_resource* resource; + desc.Width = dxgi_desc->Width; + desc.Height = dxgi_desc->Height; + desc.Format = dxgi_desc->Format; + desc.SampleDesc = dxgi_desc->SampleDesc; + desc.ArraySize = count; + desc.MipLevels = 1; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE; + if(usage & DXGI_USAGE_RENDER_TARGET_OUTPUT) + desc.BindFlags |= D3D11_BIND_RENDER_TARGET; + if(usage & DXGI_USAGE_SHADER_INPUT) + desc.BindFlags |= D3D11_BIND_SHADER_RESOURCE; +#if API >= 11 + if(usage & DXGI_USAGE_UNORDERED_ACCESS) + desc.BindFlags |= D3D11_BIND_UNORDERED_ACCESS; +#endif + if(usage & DXGI_USAGE_SHARED) + desc.MiscFlags |= D3D11_RESOURCE_MISC_SHARED; + HRESULT hr = create_resource(PIPE_TEXTURE_2D, dxgi_desc->Width, dxgi_desc->Height, 1, 1, count, dxgi_desc->Format, &dxgi_desc->SampleDesc, D3D11_USAGE_DEFAULT, desc.BindFlags, D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE, desc.MiscFlags, 0, usage, &resource); + if(hr != S_OK) + return hr; + *out_surface = new GalliumD3D11Surface(this, resource, desc, usage); + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE CreateShaderResourceView( + ID3D11Resource *iresource, + const D3D11_SHADER_RESOURCE_VIEW_DESC *desc, + ID3D11ShaderResourceView **out_srv) + { +#if API >= 11 + D3D11_SHADER_RESOURCE_VIEW_DESC def_desc; +#else + if(desc->ViewDimension == D3D10_1_SRV_DIMENSION_TEXTURECUBEARRAY) + return E_INVALIDARG; + D3D10_SHADER_RESOURCE_VIEW_DESC1 desc1; + memset(&desc1, 0, sizeof(desc1)); + memcpy(&desc1, desc, sizeof(*desc)); + return CreateShaderResourceView1(iresource, &desc1, (ID3D10ShaderResourceView1**)out_srv); + } + + virtual HRESULT STDMETHODCALLTYPE CreateShaderResourceView1( + ID3D11Resource *iresource, + const D3D10_SHADER_RESOURCE_VIEW_DESC1 *desc, + ID3D10ShaderResourceView1 **out_srv) + { + D3D10_SHADER_RESOURCE_VIEW_DESC1 def_desc; +#endif + SYNCHRONIZED; + + if(!desc) + { + struct pipe_resource* resource = ((GalliumD3D11Resource<>*)iresource)->resource; + init_pipe_to_dxgi_format(); + memset(&def_desc, 0, sizeof(def_desc)); + def_desc.Format = pipe_to_dxgi_format[resource->format]; + switch(resource->target) + { + case PIPE_BUFFER: + def_desc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER; + def_desc.Buffer.ElementWidth = resource->width0; + break; + case PIPE_TEXTURE_1D: + def_desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1D; + def_desc.Texture1D.MipLevels = resource->last_level + 1; + break; + case PIPE_TEXTURE_2D: + case PIPE_TEXTURE_RECT: + def_desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; + def_desc.Texture2D.MipLevels = resource->last_level + 1; + break; + case PIPE_TEXTURE_3D: + def_desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D; + def_desc.Texture3D.MipLevels = resource->last_level + 1; + break; + case PIPE_TEXTURE_CUBE: + def_desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE; + def_desc.TextureCube.MipLevels = resource->last_level + 1; + break; + default: + return E_INVALIDARG; + } + desc = &def_desc; + } + + struct pipe_sampler_view templat; + memset(&templat, 0, sizeof(templat)); + if(invalid(format >= DXGI_FORMAT_COUNT)) + return E_INVALIDARG; + templat.format = dxgi_to_pipe_format[desc->Format]; + if(!templat.format) + return E_NOTIMPL; + templat.swizzle_r = PIPE_SWIZZLE_RED; + templat.swizzle_g = PIPE_SWIZZLE_GREEN; + templat.swizzle_b = PIPE_SWIZZLE_BLUE; + templat.swizzle_a = PIPE_SWIZZLE_ALPHA; + + templat.texture = ((GalliumD3D11Resource<>*)iresource)->resource; + switch(desc->ViewDimension) + { + case D3D11_SRV_DIMENSION_TEXTURE1D: + case D3D11_SRV_DIMENSION_TEXTURE2D: + case D3D11_SRV_DIMENSION_TEXTURE3D: + case D3D11_SRV_DIMENSION_TEXTURE1DARRAY: + case D3D11_SRV_DIMENSION_TEXTURE2DARRAY: + /* yes, this works for all of these types (but TODO: texture arrays) */ + templat.first_level = desc->Texture1D.MostDetailedMip; + templat.last_level = templat.first_level + desc->Texture1D.MipLevels - 1; + break; + case D3D11_SRV_DIMENSION_BUFFER: + case D3D11_SRV_DIMENSION_TEXTURE2DMS: + case D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY: + return E_NOTIMPL; + default: + return E_INVALIDARG; + } + + if(!out_srv) + return S_FALSE; + + struct pipe_sampler_view* view = immediate_pipe->create_sampler_view(immediate_pipe, templat.texture, &templat); + if(!view) + return E_FAIL; + *out_srv = new GalliumD3D11ShaderResourceView(this, (GalliumD3D11Resource<>*)iresource, view, *desc); + return S_OK; + } + +#if API >= 11 + virtual HRESULT STDMETHODCALLTYPE CreateUnorderedAccessView( + ID3D11Resource *resource, + const D3D11_UNORDERED_ACCESS_VIEW_DESC *desc, + ID3D11UnorderedAccessView **out_uav) + { + SYNCHRONIZED; + + return E_NOTIMPL; + + // remember to return S_FALSE and not crash if out_u_a_view == 0 and parameters are valid + } +#endif + + virtual HRESULT STDMETHODCALLTYPE CreateRenderTargetView( + ID3D11Resource *iresource, + const D3D11_RENDER_TARGET_VIEW_DESC *desc, + ID3D11RenderTargetView **out_rtv) + { + SYNCHRONIZED; + + D3D11_RENDER_TARGET_VIEW_DESC def_desc; + if(!desc) + { + struct pipe_resource* resource = ((GalliumD3D11Resource<>*)iresource)->resource; + init_pipe_to_dxgi_format(); + memset(&def_desc, 0, sizeof(def_desc)); + def_desc.Format = pipe_to_dxgi_format[resource->format]; + switch(resource->target) + { + case PIPE_BUFFER: + def_desc.ViewDimension = D3D11_RTV_DIMENSION_BUFFER; + def_desc.Buffer.ElementWidth = resource->width0; + break; + case PIPE_TEXTURE_1D: + def_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE1D; + break; + case PIPE_TEXTURE_2D: + case PIPE_TEXTURE_RECT: + def_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; + break; + case PIPE_TEXTURE_3D: + def_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D; + def_desc.Texture3D.WSize = resource->depth0; + break; + case PIPE_TEXTURE_CUBE: + def_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY; + def_desc.Texture2DArray.ArraySize = 6; + break; + default: + return E_INVALIDARG; + } + desc = &def_desc; + } + + unsigned zslice = 0; + unsigned face = 0; + unsigned level; + enum pipe_format format; + if(invalid(desc->format >= DXGI_FORMAT_COUNT)) + return E_INVALIDARG; + format = dxgi_to_pipe_format[desc->Format]; + if(!format) + return E_NOTIMPL; + + switch(desc->ViewDimension) + { + case D3D11_RTV_DIMENSION_TEXTURE1D: + case D3D11_RTV_DIMENSION_TEXTURE2D: + level = desc->Texture1D.MipSlice; + break; + case D3D11_RTV_DIMENSION_TEXTURE3D: + level = desc->Texture3D.MipSlice; + zslice = desc->Texture3D.FirstWSlice; + break; + case D3D11_RTV_DIMENSION_TEXTURE1DARRAY: + case D3D11_RTV_DIMENSION_TEXTURE2DARRAY: + level = desc->Texture1DArray.MipSlice; + face = desc->Texture1DArray.FirstArraySlice; + break; + case D3D11_RTV_DIMENSION_BUFFER: + case D3D11_RTV_DIMENSION_TEXTURE2DMS: + case D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY: + return E_NOTIMPL; + default: + return E_INVALIDARG; + } + + if(!out_rtv) + return S_FALSE; + + struct pipe_surface* surface = screen->get_tex_surface(screen, + ((GalliumD3D11Resource<>*)iresource)->resource, + face, level, zslice, PIPE_BIND_RENDER_TARGET); + if(!surface) + return E_FAIL; + /* muhahahahaha, let's hope this actually works */ + surface->format = format; + *out_rtv = new GalliumD3D11RenderTargetView(this, (GalliumD3D11Resource<>*)iresource, surface, *desc); + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE CreateDepthStencilView( + ID3D11Resource *iresource, + const D3D11_DEPTH_STENCIL_VIEW_DESC *desc, + ID3D11DepthStencilView **out_depth_stencil_view) + { + SYNCHRONIZED; + + D3D11_DEPTH_STENCIL_VIEW_DESC def_desc; + if(!desc) + { + struct pipe_resource* resource = ((GalliumD3D11Resource<>*)iresource)->resource; + init_pipe_to_dxgi_format(); + memset(&def_desc, 0, sizeof(def_desc)); + def_desc.Format = pipe_to_dxgi_format[resource->format]; + switch(resource->target) + { + case PIPE_TEXTURE_1D: + def_desc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE1D; + break; + case PIPE_TEXTURE_2D: + case PIPE_TEXTURE_RECT: + def_desc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; + break; + case PIPE_TEXTURE_CUBE: + def_desc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY; + def_desc.Texture2DArray.ArraySize = 6; + break; + default: + return E_INVALIDARG; + } + desc = &def_desc; + } + + unsigned zslice = 0; + unsigned face = 0; + unsigned level; + enum pipe_format format; + if(invalid(desc->format >= DXGI_FORMAT_COUNT)) + return E_INVALIDARG; + format = dxgi_to_pipe_format[desc->Format]; + if(!format) + return E_NOTIMPL; + + switch(desc->ViewDimension) + { + case D3D11_DSV_DIMENSION_TEXTURE1D: + case D3D11_DSV_DIMENSION_TEXTURE2D: + level = desc->Texture1D.MipSlice; + break; + case D3D11_DSV_DIMENSION_TEXTURE1DARRAY: + case D3D11_DSV_DIMENSION_TEXTURE2DARRAY: + level = desc->Texture1DArray.MipSlice; + face = desc->Texture1DArray.FirstArraySlice; + break; + case D3D11_DSV_DIMENSION_TEXTURE2DMS: + case D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY: + return E_NOTIMPL; + default: + return E_INVALIDARG; + } + + if(!out_depth_stencil_view) + return S_FALSE; + + struct pipe_surface* surface = screen->get_tex_surface(screen, + ((GalliumD3D11Resource<>*)iresource)->resource, + face, level, zslice, PIPE_BIND_DEPTH_STENCIL); + if(!surface) + return E_FAIL; + /* muhahahahaha, let's hope this actually works */ + surface->format = format; + *out_depth_stencil_view = new GalliumD3D11DepthStencilView(this, (GalliumD3D11Resource<>*)iresource, surface, *desc); + return S_OK; + } + + GalliumD3D11Shader<>* create_stage_shader(unsigned type, const void* shader_bytecode, SIZE_T bytecode_length +#if API >= 11 + , ID3D11ClassLinkage *class_linkage +#endif + ) + { + bool dump = debug_get_option_dump_shaders(); + + dxbc_chunk_header* sm4_chunk = dxbc_find_shader_bytecode(shader_bytecode, bytecode_length); + if(!sm4_chunk) + return 0; + + std::auto_ptr<sm4_program> sm4(sm4_parse(sm4_chunk + 1, bswap_le32(sm4_chunk->size))); + if(!sm4.get()) + return 0; + + if(dump) + sm4->dump(); + + struct pipe_shader_state tgsi_shader; + memset(&tgsi_shader, 0, sizeof(tgsi_shader)); + tgsi_shader.tokens = (const tgsi_token*)sm4_to_tgsi(*sm4); + if(!tgsi_shader.tokens) + return 0; + + if(dump) + tgsi_dump(tgsi_shader.tokens, 0); + + void* shader_cso; + GalliumD3D11Shader<>* shader; + + switch(type) + { + case PIPE_SHADER_VERTEX: + shader_cso = immediate_pipe->create_vs_state(immediate_pipe, &tgsi_shader); + shader = (GalliumD3D11Shader<>*)new GalliumD3D11VertexShader(this, shader_cso); + break; + case PIPE_SHADER_FRAGMENT: + shader_cso = immediate_pipe->create_fs_state(immediate_pipe, &tgsi_shader); + shader = (GalliumD3D11Shader<>*)new GalliumD3D11PixelShader(this, shader_cso); + break; + case PIPE_SHADER_GEOMETRY: + shader_cso = immediate_pipe->create_gs_state(immediate_pipe, &tgsi_shader); + shader = (GalliumD3D11Shader<>*)new GalliumD3D11GeometryShader(this, shader_cso); + break; + default: + shader_cso = 0; + shader = 0; + break; + } + + if(shader) + { + shader->slot_to_resource = sm4->slot_to_resource; + shader->slot_to_sampler = sm4->slot_to_sampler; + } + + free((void*)tgsi_shader.tokens); + return shader; + } + +#if API >= 11 +#define CREATE_SHADER_ARGS \ + const void *shader_bytecode, \ + SIZE_T bytecode_length, \ + ID3D11ClassLinkage *class_linkage +#define PASS_SHADER_ARGS shader_bytecode, bytecode_length, class_linkage +#else +#define CREATE_SHADER_ARGS \ + const void *shader_bytecode, \ + SIZE_T bytecode_length +#define PASS_SHADER_ARGS shader_bytecode, bytecode_length +#endif + +#define IMPLEMENT_CREATE_SHADER(Stage, GALLIUM) \ + virtual HRESULT STDMETHODCALLTYPE Create##Stage##Shader( \ + CREATE_SHADER_ARGS, \ + ID3D11##Stage##Shader **out_shader) \ + { \ + SYNCHRONIZED; \ + GalliumD3D11##Stage##Shader* shader = (GalliumD3D11##Stage##Shader*)create_stage_shader(PIPE_SHADER_##GALLIUM, PASS_SHADER_ARGS); \ + if(!shader) \ + return E_FAIL; \ + if(out_shader) \ + { \ + *out_shader = shader; \ + return S_OK; \ + } \ + else \ + { \ + shader->Release(); \ + return S_FALSE; \ + } \ + } + +#define IMPLEMENT_NOTIMPL_CREATE_SHADER(Stage) \ + virtual HRESULT STDMETHODCALLTYPE Create##Stage##Shader( \ + CREATE_SHADER_ARGS, \ + ID3D11##Stage##Shader **out_shader) \ + { \ + return E_NOTIMPL; \ + } + + IMPLEMENT_CREATE_SHADER(Vertex, VERTEX) + IMPLEMENT_CREATE_SHADER(Pixel, FRAGMENT) + IMPLEMENT_CREATE_SHADER(Geometry, GEOMETRY) +#if API >= 11 + IMPLEMENT_NOTIMPL_CREATE_SHADER(Hull) + IMPLEMENT_NOTIMPL_CREATE_SHADER(Domain) + IMPLEMENT_NOTIMPL_CREATE_SHADER(Compute) +#endif + + virtual HRESULT STDMETHODCALLTYPE CreateGeometryShaderWithStreamOutput( + const void *shader_bytecode, + SIZE_T bytecode_length, + const D3D11_SO_DECLARATION_ENTRY *so_declaration, + unsigned num_entries, +#if API >= 11 + const unsigned *buffer_strides, + unsigned num_strides, + unsigned rasterized_stream, + ID3D11ClassLinkage *class_linkage, +#else + UINT output_stream_stride, +#endif + ID3D11GeometryShader **out_geometry_shader) + { + SYNCHRONIZED; + + return E_NOTIMPL; + + // remember to return S_FALSE if ppGeometyShader == NULL and the shader is OK + } + +#if API >= 11 + virtual HRESULT STDMETHODCALLTYPE CreateClassLinkage( + ID3D11ClassLinkage **out_linkage) + { + SYNCHRONIZED; + + return E_NOTIMPL; + } +#endif + + virtual HRESULT STDMETHODCALLTYPE CreateQuery( + const D3D11_QUERY_DESC *query_desc, + ID3D11Query **out_query) + { + SYNCHRONIZED; + + if(invalid(query_desc->Query >= D3D11_QUERY_COUNT)) + return E_INVALIDARG; + unsigned query_type = d3d11_to_pipe_query[query_desc->Query]; + if(!query_type) + return E_NOTIMPL; + + if(out_query) + return S_FALSE; + + struct pipe_query* query = immediate_pipe->create_query(immediate_pipe, query_type); + if(!query) + return E_FAIL; + + *out_query = new GalliumD3D11Query(this, query, d3d11_query_size[query_desc->Query], *query_desc); + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE CreatePredicate( + const D3D11_QUERY_DESC *predicate_desc, + ID3D11Predicate **out_predicate) + { + SYNCHRONIZED; + + unsigned query_type; + switch(predicate_desc->Query) + { + case D3D11_QUERY_SO_OVERFLOW_PREDICATE: + return E_NOTIMPL; + case D3D11_QUERY_OCCLUSION_PREDICATE: + query_type = PIPE_QUERY_OCCLUSION_COUNTER; + break; + default: + return E_INVALIDARG; + } + + if(out_predicate) + return S_FALSE; + + struct pipe_query* query = immediate_pipe->create_query(immediate_pipe, query_type); + if(!query) + return E_FAIL; + + *out_predicate = new GalliumD3D11Predicate(this, query, sizeof(BOOL), *predicate_desc); + return S_OK; + } + + + virtual HRESULT STDMETHODCALLTYPE CreateCounter( + const D3D11_COUNTER_DESC *counter_desc, + ID3D11Counter **out_counter) + { + SYNCHRONIZED; + + return E_NOTIMPL; + + // remember to return S_FALSE if out_counter == NULL and everything is OK + } + +#if API >= 11 + virtual HRESULT STDMETHODCALLTYPE CreateDeferredContext( + unsigned context_flags, + ID3D11DeviceContext **out_deferred_context) + { + SYNCHRONIZED; + + // TODO: this will have to be implemented using a new Gallium util module + return E_NOTIMPL; + + // remember to return S_FALSE if out_counter == NULL and everything is OK + } +#endif + + virtual HRESULT STDMETHODCALLTYPE OpenSharedResource( + HANDLE resource, + REFIID iid, + void **out_resource) + { + SYNCHRONIZED; + + // TODO: the problem here is that we need to communicate dimensions somehow + return E_NOTIMPL; + + // remember to return S_FALSE if out_counter == NULL and everything is OK +#if 0 + struct pipe_resou rce templat; + struct winsys_handle handle; + handle.stride = 0; + handle.handle = resource; + handle.type = DRM_API_HANDLE_TYPE_SHARED; + screen->resource_from_handle(screen, &templat, &handle); +#endif + } + +#if API < 11 + /* these are documented as "Not implemented". + * According to the UMDDI documentation, they apparently turn on a + * (width + 1) x (height + 1) convolution filter for 1-bit textures. + * Probably nothing uses these, assuming it has ever been implemented anywhere. + */ + void STDMETHODCALLTYPE SetTextFilterSize( + UINT width, + UINT height + ) + {} + + virtual void STDMETHODCALLTYPE GetTextFilterSize( + UINT *width, + UINT *height + ) + {} +#endif + +#if API >= 11 + virtual void STDMETHODCALLTYPE RestoreGalliumState() + { + GalliumD3D11ImmediateDeviceContext_RestoreGalliumState(immediate_context); + } + + virtual void STDMETHODCALLTYPE RestoreGalliumStateBlitOnly() + { + GalliumD3D11ImmediateDeviceContext_RestoreGalliumStateBlitOnly(immediate_context); + } +#endif + + virtual struct pipe_context* STDMETHODCALLTYPE GetGalliumContext(void) + { + return immediate_pipe; + } + +#undef SYNCHRONIZED +}; diff --git a/src/gallium/state_trackers/d3d1x/gd3d1x/Makefile b/src/gallium/state_trackers/d3d1x/gd3d1x/Makefile new file mode 100644 index 00000000000..32d29563ecc --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/gd3d1x/Makefile @@ -0,0 +1,7 @@ +LIBNAME=gd3d1x +CPP_SOURCES=$(wildcard *.cpp) +LIBRARY_INCLUDES=-Iinclude -I../gd3dapi -I../d3dapi -I../w32api -I../d3d1xstutil/include -I../d3d1xshader/include -I../../../include -I../../../auxiliary -I../../../state_trackers/egl/common +PROGS=tools/dxbc2tgsi +PROGS_DEPS=libgd3d1x.a ../d3d1xshader/libd3d1xshader.a ../d3d1xstutil/libd3d1xstutil.a ../../../auxiliary/libgallium.a +LIBS=$(PROGS_DEPS) -ldl +include ../Makefile.inc diff --git a/src/gallium/state_trackers/d3d1x/gd3d1x/d3d1x_private.h b/src/gallium/state_trackers/d3d1x/gd3d1x/d3d1x_private.h new file mode 100644 index 00000000000..977f0cd2cea --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/gd3d1x/d3d1x_private.h @@ -0,0 +1,95 @@ +/************************************************************************** + * + * 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 D3D1X_PRIVATE_H_ +#define D3D1X_PRIVATE_H_ + +#include <algorithm> +#include <vector> +#include <string> +#include <float.h> + +#include "dxbc.h" +#include "sm4.h" +#include "sm4_to_tgsi.h" + +#include "d3d1xstutil.h" + +#include <d3d11.h> +#include <d3d11shader.h> + +extern "C" +{ +#include <pipe/p_defines.h> +#include <pipe/p_screen.h> +#include <pipe/p_context.h> +#include <util/u_inlines.h> +#include <util/u_format.h> +#include <util/u_caps.h> +#include <util/u_debug.h> +#include <os/os_thread.h> +} + +#include "galliumdxgi.h" +#include "galliumd3d10_1.h" +#include "galliumd3d11.h" + +#ifdef CHECK +#define invalid(x) unlikely(x) +#else +#define invalid(x) (0) +#endif + +#define D3D10_STAGE_VS 0 +#define D3D10_STAGE_PS 1 +#define D3D10_STAGE_GS 2 +#define D3D10_STAGES 3 + +#define D3D11_STAGE_VS 0 +#define D3D11_STAGE_PS 1 +#define D3D11_STAGE_GS 2 +#define D3D11_STAGE_HS 3 +#define D3D11_STAGE_DS 4 +#define D3D11_STAGE_CS 5 +#define D3D11_STAGES 6 + +#define D3D11_BLEND_COUNT 20 +extern unsigned d3d11_to_pipe_blend[D3D11_BLEND_COUNT]; + +#define D3D11_USAGE_COUNT 4 +extern unsigned d3d11_to_pipe_usage[D3D11_USAGE_COUNT]; + +#define D3D11_STENCIL_OP_COUNT 9 +extern unsigned d3d11_to_pipe_stencil_op[D3D11_STENCIL_OP_COUNT]; + +#define D3D11_TEXTURE_ADDRESS_COUNT 6 +extern unsigned d3d11_to_pipe_wrap[D3D11_TEXTURE_ADDRESS_COUNT]; + +#define D3D11_QUERY_COUNT 16 +extern unsigned d3d11_to_pipe_query[D3D11_QUERY_COUNT]; +extern unsigned d3d11_query_size[D3D11_QUERY_COUNT]; + +#endif /* D3D1X_H_ */ diff --git a/src/gallium/state_trackers/d3d1x/gd3d1x/d3d_enums.cpp b/src/gallium/state_trackers/d3d1x/gd3d1x/d3d_enums.cpp new file mode 100644 index 00000000000..853d11410df --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/gd3d1x/d3d_enums.cpp @@ -0,0 +1,123 @@ +/************************************************************************** + * + * 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 "d3d1x_private.h" + +unsigned d3d11_to_pipe_blend[D3D11_BLEND_COUNT] = +{ + PIPE_BLENDFACTOR_ONE, /* absent in D3D11, but apparently accepted */ + PIPE_BLENDFACTOR_ZERO, + PIPE_BLENDFACTOR_ONE, + PIPE_BLENDFACTOR_SRC_COLOR, + PIPE_BLENDFACTOR_INV_SRC_COLOR, + PIPE_BLENDFACTOR_SRC_ALPHA, + PIPE_BLENDFACTOR_INV_SRC_ALPHA, + PIPE_BLENDFACTOR_DST_ALPHA, + PIPE_BLENDFACTOR_INV_DST_ALPHA, + PIPE_BLENDFACTOR_DST_COLOR, + PIPE_BLENDFACTOR_INV_DST_COLOR, + PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE, + 0, /* absent in D3D11 */ + 0, /* absent in D3D11 */ + PIPE_BLENDFACTOR_CONST_COLOR, + PIPE_BLENDFACTOR_INV_CONST_COLOR, + PIPE_BLENDFACTOR_SRC1_COLOR, + PIPE_BLENDFACTOR_INV_SRC1_COLOR, + PIPE_BLENDFACTOR_SRC1_ALPHA, + PIPE_BLENDFACTOR_INV_SRC1_ALPHA +}; + +unsigned d3d11_to_pipe_usage[D3D11_USAGE_COUNT] = +{ + PIPE_USAGE_DEFAULT, + PIPE_USAGE_IMMUTABLE, + PIPE_USAGE_DYNAMIC, + PIPE_USAGE_STAGING +}; + +unsigned d3d11_to_pipe_stencil_op[D3D11_STENCIL_OP_COUNT] = +{ + PIPE_STENCIL_OP_KEEP, + PIPE_STENCIL_OP_KEEP, + PIPE_STENCIL_OP_ZERO, + PIPE_STENCIL_OP_REPLACE, + PIPE_STENCIL_OP_INCR, + PIPE_STENCIL_OP_DECR, + PIPE_STENCIL_OP_INVERT, + PIPE_STENCIL_OP_INCR_WRAP, + PIPE_STENCIL_OP_DECR_WRAP, +}; + +unsigned d3d11_to_pipe_wrap[D3D11_TEXTURE_ADDRESS_COUNT] = +{ + PIPE_TEX_WRAP_REPEAT, + PIPE_TEX_WRAP_REPEAT, + PIPE_TEX_WRAP_MIRROR_REPEAT, + PIPE_TEX_WRAP_CLAMP_TO_EDGE, + PIPE_TEX_WRAP_CLAMP_TO_BORDER, + PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE, +}; + +unsigned d3d11_to_pipe_query[D3D11_QUERY_COUNT] = +{ + PIPE_QUERY_GPU_FINISHED, + PIPE_QUERY_OCCLUSION_COUNTER, + PIPE_QUERY_TIME_ELAPSED, + PIPE_QUERY_TIMESTAMP_DISJOINT, + 0, /* D3D11_QUERY_PIPELINE_STATISTICS */ + PIPE_QUERY_OCCLUSION_COUNTER, + PIPE_QUERY_SO_STATISTICS, + 0, /* D3D11_QUERY_SO_OVERFLOW_PREDICATE */ + /* per-stream SO queries */ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, +}; + +unsigned d3d11_query_size[D3D11_QUERY_COUNT] = +{ + sizeof(BOOL), + sizeof(UINT64), + sizeof(UINT64), + sizeof(UINT64), + 0, + sizeof(BOOL), + sizeof(D3D11_QUERY_DATA_SO_STATISTICS), + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 +}; diff --git a/src/gallium/state_trackers/d3d1x/gd3d1x/sm4_to_tgsi.cpp b/src/gallium/state_trackers/d3d1x/gd3d1x/sm4_to_tgsi.cpp new file mode 100644 index 00000000000..615ce8c2550 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/gd3d1x/sm4_to_tgsi.cpp @@ -0,0 +1,869 @@ +/************************************************************************** + * + * 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 "d3d1xstutil.h" +#include "sm4.h" +#include "tgsi/tgsi_ureg.h" +#include <vector> + +#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 tgsi_interpolation +{ + unsigned interpolation; + bool centroid; +}; + +static tgsi_interpolation sm4_to_pipe_interpolation[] = +{ + {TGSI_INTERPOLATE_PERSPECTIVE, false}, /* UNDEFINED */ + {TGSI_INTERPOLATE_CONSTANT, false}, + {TGSI_INTERPOLATE_PERSPECTIVE, false}, /* LINEAR */ + {TGSI_INTERPOLATE_PERSPECTIVE, true}, /* LINEAR_CENTROID */ + {TGSI_INTERPOLATE_LINEAR, false}, /* LINEAR_NOPERSPECTIVE */ + {TGSI_INTERPOLATE_LINEAR, true}, /* LINEAR_NOPERSPECTIVE_CENTROID */ + + // Added in D3D10.1 + {TGSI_INTERPOLATE_PERSPECTIVE, true}, /* LINEAR_SAMPLE */ + {TGSI_INTERPOLATE_LINEAR, true}, /* LINEAR_NOPERSPECTIVE_SAMPLE */ +}; + +static int sm4_to_pipe_sv[] = +{ + -1, + TGSI_SEMANTIC_POSITION, + -1, /*TGSI_SEMANTIC_CLIP_DISTANCE */ + -1, /*TGSI_SEMANTIC_CULL_DISTANCE */ + -1, /*TGSI_SEMANTIC_RENDER_TARGET_ARRAY_INDEX */ + -1, /*TGSI_SEMANTIC_VIEWPORT_ARRAY_INDEX */ + -1, /*TGSI_SEMANTIC_VERTEXID,*/ + TGSI_SEMANTIC_PRIMID, + TGSI_SEMANTIC_INSTANCEID, + TGSI_SEMANTIC_FACE, + -1, /*TGSI_SEMANTIC_SAMPLE_INDEX*/ +}; + +struct sm4_to_tgsi_converter +{ + struct ureg_program* ureg; + std::vector<struct ureg_dst> temps; + std::vector<struct ureg_dst> outputs; + std::vector<struct ureg_src> inputs; + std::vector<struct ureg_src> samplers; + std::vector<std::pair<unsigned, unsigned> > targets; // first is normal, second shadow/comparison + std::vector<unsigned> sampler_modes; // 0 = normal, 1 = shadow/comparison + std::vector<std::pair<unsigned, unsigned> > loops; + sm4_insn* insn; + struct sm4_program& program; + std::vector<unsigned> sm4_to_tgsi_insn_num; + std::vector<std::pair<unsigned, unsigned> > label_to_sm4_insn_num; + bool in_sub; + bool avoid_txf; + bool avoid_int; + + sm4_to_tgsi_converter(struct sm4_program& program) + : program(program) + { + avoid_txf = true; + avoid_int = false; + } + + struct ureg_dst _reg(sm4_op& op) + { + switch(op.file) + { + case SM4_FILE_NULL: + { + struct ureg_dst d; + memset(&d, 0, sizeof(d)); + d.File = TGSI_FILE_NULL; + return d; + } + case SM4_FILE_TEMP: + check(op.has_simple_index()); + check(op.indices[0].disp < temps.size()); + return temps[op.indices[0].disp]; + case SM4_FILE_OUTPUT: + check(op.has_simple_index()); + check(op.indices[0].disp < outputs.size()); + return outputs[op.indices[0].disp]; + default: + check(0); + return ureg_dst_undef(); + } + } + + struct ureg_dst _dst(unsigned i = 0) + { + check(i < insn->num_ops); + sm4_op& op = *insn->ops[i]; + check(op.mode == SM4_OPERAND_MODE_MASK || op.mode == SM4_OPERAND_MODE_SCALAR); + struct ureg_dst d = ureg_writemask(_reg(op), op.mask); + if(insn->insn.sat) + d = ureg_saturate(d); + return d; + } + + struct ureg_src _src(unsigned i) + { + check(i < insn->num_ops); + sm4_op& op = *insn->ops[i]; + struct ureg_src s; + switch(op.file) + { + case SM4_FILE_IMMEDIATE32: + s = ureg_imm4f(ureg, op.imm_values[0].f32, op.imm_values[1].f32, op.imm_values[2].f32, op.imm_values[3].f32); + break; + case SM4_FILE_INPUT: + check(op.is_index_simple(0)); + check(op.num_indices == 1 || op.num_indices == 2); + // TODO: is this correct, or are incorrectly swapping the two indices in the GS case? + check(op.indices[op.num_indices - 1].disp < inputs.size()); + s = inputs[op.indices[op.num_indices - 1].disp]; + if(op.num_indices == 2) + { + s.Dimension = 1; + s.DimensionIndex = op.indices[0].disp; + } + break; + case SM4_FILE_CONSTANT_BUFFER: + // TODO: indirect addressing + check(op.num_indices == 2); + check(op.is_index_simple(0)); + check(op.is_index_simple(1)); + s = ureg_src_register(TGSI_FILE_CONSTANT, (unsigned)op.indices[1].disp); + s.Dimension = 1; + s.DimensionIndex = op.indices[0].disp; + break; + default: + s = ureg_src(_reg(op)); + break; + } + if(op.mode == SM4_OPERAND_MODE_SWIZZLE || op.mode == SM4_OPERAND_MODE_SCALAR) + s = ureg_swizzle(s, op.swizzle[0], op.swizzle[1], op.swizzle[2], op.swizzle[3]); + else + { + /* immediates are masked to show needed values */ + check(op.file == SM4_FILE_IMMEDIATE32 || op.file == SM4_FILE_IMMEDIATE64); + } + if(op.abs) + s = ureg_abs(s); + if(op.neg) + s = ureg_negate(s); + return s; + }; + + int _idx(sm4_file file, unsigned i = 0) + { + check(i < insn->num_ops); + sm4_op& op = *insn->ops[i]; + check(op.file == file); + check(op.has_simple_index()); + return (int)op.indices[0].disp; + } + + int _texslot(bool have_sampler = true) + { + std::map<std::pair<int, int>, int>::iterator i; + i = program.resource_sampler_to_slot.find(std::make_pair(_idx(SM4_FILE_RESOURCE, 2), have_sampler ? _idx(SM4_FILE_SAMPLER, 3) : -1)); + check(i != program.resource_sampler_to_slot.end()); + return i->second; + } + + unsigned tex_target(unsigned texslot) + { + unsigned mode = sampler_modes[program.slot_to_sampler[texslot]]; + unsigned target; + if(mode) + target = targets[program.slot_to_resource[texslot]].second; + else + target = targets[program.slot_to_resource[texslot]].first; + check(target); + return target; + } + + std::vector<struct ureg_dst> insn_tmps; + + struct ureg_dst _tmp() + { + struct ureg_dst t = ureg_DECL_temporary(ureg); + insn_tmps.push_back(t); + return t; + } + + struct ureg_dst _tmp(struct ureg_dst d) + { + if(d.File == TGSI_FILE_TEMPORARY) + return d; + else + return ureg_writemask(_tmp(), d.WriteMask); + } + +#define OP1_(d, g) case SM4_OPCODE_##d: ureg_##g(ureg, _dst(), _src(1)); break +#define OP2_(d, g) case SM4_OPCODE_##d: ureg_##g(ureg, _dst(), _src(1), _src(2)); break +#define OP3_(d, g) case SM4_OPCODE_##d: ureg_##g(ureg, _dst(), _src(1), _src(2), _src(3)); break +#define OP1(n) OP1_(n, n) +#define OP2(n) OP2_(n, n) +#define OP3(n) OP3_(n, n) +#define OP_CF(d, g) case SM4_OPCODE_##d: ureg_##g(ureg, &label); label_to_sm4_insn_num.push_back(std::make_pair(label, program.cf_insn_linked[insn_num])); break; + + void translate_insns(unsigned begin, unsigned end) + { + for(unsigned insn_num = begin; insn_num < end; ++insn_num) + { + sm4_to_tgsi_insn_num[insn_num] = ureg_get_instruction_number(ureg); + unsigned label; + insn = program.insns[insn_num]; + bool ok; + ok = true; + switch(insn->opcode) + { + // trivial instructions + case SM4_OPCODE_NOP: + break; + OP1(MOV); + + // float + OP2(ADD); + OP2(MUL); + OP3(MAD); + OP2(DIV); + OP1(FRC); + OP1(RCP); + OP2(MIN); + OP2(MAX); + OP2_(LT, SLT); + OP2_(GE, SGE); + OP2_(EQ, SEQ); + OP2_(NE, SNE); + + // bitwise + OP1(NOT); + OP2(AND); + OP2(OR); + OP2(XOR); + + // special mathematical + OP2(DP2); + OP2(DP3); + OP2(DP4); + OP1(RSQ); + OP1_(LOG, LG2); + OP1_(EXP, EX2); + + // rounding + OP1_(ROUND_NE, ROUND); + OP1_(ROUND_Z, TRUNC); + OP1_(ROUND_PI, CEIL); + OP1_(ROUND_NI, FLR); + + // cross-thread + OP1_(DERIV_RTX, DDX); + OP1_(DERIV_RTX_COARSE, DDX); + OP1_(DERIV_RTX_FINE, DDX); + OP1_(DERIV_RTY, DDY); + OP1_(DERIV_RTY_COARSE, DDY); + OP1_(DERIV_RTY_FINE, DDY); + case SM4_OPCODE_EMIT: + ureg_EMIT(ureg); + break; + case SM4_OPCODE_CUT: + ureg_ENDPRIM(ureg); + break; + case SM4_OPCODE_EMITTHENCUT: + ureg_EMIT(ureg); + ureg_ENDPRIM(ureg); + break; + + // non-trivial instructions + case SM4_OPCODE_MOVC: + /* CMP checks for < 0, but MOVC checks for != 0 + * but fortunately, x != 0 is equivalent to -abs(x) < 0 + * XXX: can test_nz apply to this?! + */ + ureg_CMP(ureg, _dst(), ureg_negate(ureg_abs(_src(1))), _src(2), _src(3)); + break; + case SM4_OPCODE_SQRT: + { + struct ureg_dst d = _dst(); + struct ureg_dst t = _tmp(d); + ureg_RSQ(ureg, t, _src(1)); + ureg_RCP(ureg, d, ureg_src(t)); + break; + } + case SM4_OPCODE_SINCOS: + { + struct ureg_dst s = _dst(0); + struct ureg_dst c = _dst(1); + struct ureg_src v = _src(2); + if(s.File != TGSI_FILE_NULL) + ureg_SIN(ureg, s, v); + if(c.File != TGSI_FILE_NULL) + ureg_COS(ureg, c, v); + break; + } + + // control flow + case SM4_OPCODE_DISCARD: + ureg_KIL(ureg, _src(0)); + break; + OP_CF(LOOP, BGNLOOP); + OP_CF(ENDLOOP, ENDLOOP); + case SM4_OPCODE_BREAK: + ureg_BRK(ureg); + break; + case SM4_OPCODE_BREAKC: + // XXX: can test_nz apply to this?! + ureg_BREAKC(ureg, _src(0)); + break; + case SM4_OPCODE_CONTINUE: + ureg_CONT(ureg); + break; + case SM4_OPCODE_CONTINUEC: + // XXX: can test_nz apply to this?! + ureg_IF(ureg, _src(0), &label); + ureg_CONT(ureg); + ureg_fixup_label(ureg, label, ureg_get_instruction_number(ureg)); + ureg_ENDIF(ureg); + break; + case SM4_OPCODE_SWITCH: + ureg_SWITCH(ureg, _src(0)); + break; + case SM4_OPCODE_CASE: + ureg_CASE(ureg, _src(0)); + break; + case SM4_OPCODE_DEFAULT: + ureg_DEFAULT(ureg); + break; + case SM4_OPCODE_ENDSWITCH: + ureg_ENDSWITCH(ureg); + break; + case SM4_OPCODE_CALL: + ureg_CAL(ureg, &label); + label_to_sm4_insn_num.push_back(std::make_pair(label, program.label_to_insn_num[_idx(SM4_FILE_LABEL)])); + break; + case SM4_OPCODE_LABEL: + if(in_sub) + ureg_ENDSUB(ureg); + else + ureg_END(ureg); + ureg_BGNSUB(ureg); + in_sub = true; + break; + case SM4_OPCODE_RET: + if(in_sub || insn_num != (program.insns.size() - 1)) + ureg_RET(ureg); + break; + case SM4_OPCODE_RETC: + ureg_IF(ureg, _src(0), &label); + if(insn->insn.test_nz) + ureg_RET(ureg); + ureg_fixup_label(ureg, label, ureg_get_instruction_number(ureg)); + if(!insn->insn.test_nz) + { + ureg_ELSE(ureg, &label); + ureg_RET(ureg); + ureg_fixup_label(ureg, label, ureg_get_instruction_number(ureg)); + } + ureg_ENDIF(ureg); + break; + OP_CF(ELSE, ELSE); + case SM4_OPCODE_ENDIF: + ureg_ENDIF(ureg); + break; + case SM4_OPCODE_IF: + if(insn->insn.test_nz) + { + ureg_IF(ureg, _src(0), &label); + label_to_sm4_insn_num.push_back(std::make_pair(label, program.cf_insn_linked[insn_num])); + } + else + { + unsigned linked = program.cf_insn_linked[insn_num]; + if(program.insns[linked]->opcode == SM4_OPCODE_ENDIF) + { + ureg_IF(ureg, _src(0), &label); + ureg_fixup_label(ureg, label, ureg_get_instruction_number(ureg)); + ureg_ELSE(ureg, &label); + label_to_sm4_insn_num.push_back(std::make_pair(label, linked)); + } + else + { + /* we have to swap the branches in this case (fun!) + * TODO: maybe just emit a SEQ 0? + * */ + unsigned endif = program.cf_insn_linked[linked]; + + ureg_IF(ureg, _src(0), &label); + label_to_sm4_insn_num.push_back(std::make_pair(label, linked)); + + translate_insns(linked + 1, endif); + + sm4_to_tgsi_insn_num[linked] = ureg_get_instruction_number(ureg); + ureg_ELSE(ureg, &label); + label_to_sm4_insn_num.push_back(std::make_pair(label, endif)); + + translate_insns(insn_num + 1, linked); + + insn_num = endif - 1; + goto next; + } + } + break; + case SM4_OPCODE_RESINFO: + { + std::map<int, int>::iterator i; + i = program.resource_to_slot.find(_idx(SM4_FILE_RESOURCE, 2)); + check(i != program.resource_to_slot.end()); + unsigned texslot = i->second; + + // no driver actually provides this, unfortunately + ureg_TXQ(ureg, _dst(), tex_target(texslot), _src(1), samplers[texslot]); + break; + }; + // TODO: sample offset, sample index + case SM4_OPCODE_LD: // dst, coord_int, res; mipmap level in last coord_int arg (ouch) + case SM4_OPCODE_LD_MS: + { + unsigned texslot = _texslot(false); + unsigned dim = 0; + switch(targets[texslot].first) + { + case TGSI_TEXTURE_1D: + dim = 1; + break; + case TGSI_TEXTURE_2D: + case TGSI_TEXTURE_RECT: + dim = 2; + break; + case TGSI_TEXTURE_3D: + dim = 3; + break; + default: + check(0); + } + struct ureg_dst tmp = _tmp(); + if(avoid_txf) + { + struct ureg_src texcoord; + if(!avoid_int) + { + ureg_I2F(ureg, tmp, _src(1)); + texcoord = ureg_src(tmp); + } + else + texcoord = _src(1); + + ureg_TXL(ureg, _dst(), tex_target(texslot), ureg_swizzle(texcoord, 0, 1, 2, dim), samplers[texslot]); + } + else + ureg_TXF(ureg, _dst(), tex_target(texslot), ureg_swizzle(_src(1), 0, 1, 2, dim), samplers[texslot]); + break; + } + case SM4_OPCODE_SAMPLE: // dst, coord, res, samp + { + unsigned texslot = _texslot(); + ureg_TEX(ureg, _dst(), tex_target(texslot), _src(1), samplers[texslot]); + break; + } + case SM4_OPCODE_SAMPLE_B: // dst, coord, res, samp, bias.x + { + unsigned texslot = _texslot(); + struct ureg_dst tmp = _tmp(); + ureg_MOV(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_XYZ), _src(1)); + ureg_MOV(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_W), ureg_swizzle(_src(4), 0, 0, 0, 0)); + ureg_TXB(ureg, _dst(), tex_target(texslot), ureg_src(tmp), samplers[texslot]); + break; + } + case SM4_OPCODE_SAMPLE_C: // dst, coord, res, samp, comp.x + { + unsigned texslot = _texslot(); + struct ureg_dst tmp = _tmp(); + ureg_MOV(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_XY), _src(1)); + ureg_MOV(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_Z), ureg_swizzle(_src(4), 0, 0, 0, 0)); + ureg_TEX(ureg, _dst(), tex_target(texslot), ureg_src(tmp), samplers[texslot]); + break; + } + case SM4_OPCODE_SAMPLE_C_LZ: // dst, coord, res, samp, comp.x + { + unsigned texslot = _texslot(); + struct ureg_dst tmp = _tmp(); + ureg_MOV(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_XY), _src(1)); + ureg_MOV(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_Z), ureg_swizzle(_src(4), 0, 0, 0, 0)); + ureg_MOV(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_W), ureg_imm1f(ureg, 0.0)); + ureg_TXL(ureg, _dst(), tex_target(texslot), ureg_src(tmp), samplers[texslot]); + break; + } + case SM4_OPCODE_SAMPLE_D: // dst, coord, res, samp, ddx, ddy + { + unsigned texslot = _texslot(); + ureg_TXD(ureg, _dst(), tex_target(texslot), _src(1), samplers[texslot], _src(4), _src(5)); + break; + } + case SM4_OPCODE_SAMPLE_L: // dst, coord, res, samp, bias.x + { + unsigned texslot = _texslot(); + struct ureg_dst tmp = _tmp(); + ureg_MOV(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_XYZ), _src(1)); + ureg_MOV(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_W), ureg_swizzle(_src(4), 0, 0, 0, 0)); + ureg_TXL(ureg, _dst(), tex_target(texslot), ureg_src(tmp), samplers[texslot]); + break; + } + default: + ok = false; + break; + } + + if(!ok && !avoid_int) + { + ok = true; + switch(insn->opcode) + { + // integer + OP1_(ITOF, I2F); + OP1_(FTOI, F2I); + OP2_(IADD, UADD); + OP1(INEG); + OP2_(IMUL, UMUL); + OP3_(IMAD, UMAD); + OP2_(ISHL, SHL); + OP2_(ISHR, ISHR); + OP2(IMIN); + OP2(IMAX); + OP2_(ILT, ISLT); + OP2_(IGE, ISGE); + OP2_(IEQ, USEQ); + OP2_(INE, USNE); + + // unsigned + OP1_(UTOF, U2F); + OP1_(FTOU, F2U); + OP2(UMUL); + OP3(UMAD); + OP2(UMIN); + OP2(UMAX); + OP2_(ULT, USLT); + OP2_(UGE, USGE); + OP2(USHR); + + case SM4_OPCODE_UDIV: + { + struct ureg_dst q = _dst(0); + struct ureg_dst r = _dst(1); + struct ureg_src a = _src(2); + struct ureg_src b = _src(3); + if(q.File != TGSI_FILE_NULL) + ureg_UDIV(ureg, q, a, b); + if(r.File != TGSI_FILE_NULL) + ureg_UMOD(ureg, r, a, b); + break; + } + default: + ok = false; + } + } + + if(!ok && avoid_int) + { + ok = true; + switch(insn->opcode) + { + case SM4_OPCODE_ITOF: + case SM4_OPCODE_UTOF: + break; + OP1_(FTOI, TRUNC); + OP1_(FTOU, FLR); + // integer + OP2_(IADD, ADD); + OP2_(IMUL, MUL); + OP3_(IMAD, MAD); + OP2_(MIN, MIN); + OP2_(MAX, MAX); + OP2_(ILT, SLT); + OP2_(IGE, SGE); + OP2_(IEQ, SEQ); + OP2_(INE, SNE); + + // unsigned + OP2_(UMUL, MUL); + OP3_(UMAD, MAD); + OP2_(UMIN, MIN); + OP2_(UMAX, MAX); + OP2_(ULT, SLT); + OP2_(UGE, SGE); + + case SM4_OPCODE_INEG: + ureg_MOV(ureg, _dst(), ureg_negate(_src(1))); + break; + case SM4_OPCODE_ISHL: + { + struct ureg_dst d = _dst(); + struct ureg_dst t = _tmp(d); + ureg_EX2(ureg, t, _src(2)); + ureg_MUL(ureg, d, ureg_src(t), _src(1)); + break; + } + case SM4_OPCODE_ISHR: + case SM4_OPCODE_USHR: + { + struct ureg_dst d = _dst(); + struct ureg_dst t = _tmp(d); + ureg_EX2(ureg, t, ureg_negate(_src(2))); + ureg_MUL(ureg, t, ureg_src(t), _src(1)); + ureg_FLR(ureg, d, ureg_src(t)); + break; + } + case SM4_OPCODE_UDIV: + { + struct ureg_dst q = _dst(0); + struct ureg_dst r = _dst(1); + struct ureg_src a = _src(2); + struct ureg_src b = _src(3); + struct ureg_dst f = _tmp(); + ureg_DIV(ureg, f, a, b); + if(q.File != TGSI_FILE_NULL) + ureg_FLR(ureg, q, ureg_src(f)); + if(r.File != TGSI_FILE_NULL) + { + ureg_FRC(ureg, f, ureg_src(f)); + ureg_MUL(ureg, r, ureg_src(f), b); + } + break; + } + default: + ok = false; + } + } + + check(ok); + + if(!insn_tmps.empty()) + { + for(unsigned i = 0; i < insn_tmps.size(); ++i) + ureg_release_temporary(ureg, insn_tmps[i]); + insn_tmps.clear(); + } +next:; + } + } + + void* do_translate() + { + unsigned processor; + switch(program.version.type) + { + case 0: + processor = TGSI_PROCESSOR_FRAGMENT; + break; + case 1: + processor = TGSI_PROCESSOR_VERTEX; + break; + case 2: + processor = TGSI_PROCESSOR_GEOMETRY; + break; + default: + fail("Tessellation and compute shaders not yet supported"); + return 0; + } + + if(!sm4_link_cf_insns(program)) + fail("Malformed control flow"); + if(!sm4_find_labels(program)) + fail("Failed to locate labels"); + if(!sm4_allocate_resource_sampler_pairs(program)) + fail("Unsupported (indirect?) accesses to resources and/or samplers"); + + ureg = ureg_create(processor); + + in_sub = false; + + for(unsigned i = 0; i < program.slot_to_resource.size(); ++i) + samplers.push_back(ureg_DECL_sampler(ureg, i)); + + sm4_to_tgsi_insn_num.resize(program.insns.size()); + for(unsigned insn_num = 0; insn_num < program.dcls.size(); ++insn_num) + { + sm4_dcl& dcl = *program.dcls[insn_num]; + int idx = -1; + if(dcl.op.get() && dcl.op->is_index_simple(0)) + idx = dcl.op->indices[0].disp; + switch(dcl.opcode) + { + case SM4_OPCODE_DCL_GLOBAL_FLAGS: + break; + case SM4_OPCODE_DCL_TEMPS: + for(unsigned i = 0; i < dcl.num; ++i) + temps.push_back(ureg_DECL_temporary(ureg)); + break; + case SM4_OPCODE_DCL_INPUT: + check(idx >= 0); + if(processor == TGSI_PROCESSOR_VERTEX) + { + if(inputs.size() <= (unsigned)idx) + inputs.resize(idx + 1); + inputs[idx] = ureg_DECL_vs_input(ureg, idx); + } + else if(processor == TGSI_PROCESSOR_GEOMETRY) + { + // TODO: is this correct? + unsigned gsidx = dcl.op->indices[1].disp; + if(inputs.size() <= (unsigned)gsidx) + inputs.resize(gsidx + 1); + inputs[gsidx] = ureg_DECL_gs_input(ureg, gsidx, TGSI_SEMANTIC_GENERIC, gsidx); + } + else + check(0); + break; + case SM4_OPCODE_DCL_INPUT_PS: + check(idx >= 0); + if(inputs.size() <= (unsigned)idx) + inputs.resize(idx + 1); + inputs[idx] = ureg_DECL_fs_input_cyl_centroid(ureg, TGSI_SEMANTIC_GENERIC, idx, sm4_to_pipe_interpolation[dcl.dcl_input_ps.interpolation].interpolation, 0, sm4_to_pipe_interpolation[dcl.dcl_input_ps.interpolation].centroid); + break; + case SM4_OPCODE_DCL_OUTPUT: + check(idx >= 0); + if(outputs.size() <= (unsigned)idx) + outputs.resize(idx + 1); + if(processor == TGSI_PROCESSOR_FRAGMENT) + outputs[idx] = ureg_DECL_output(ureg, TGSI_SEMANTIC_COLOR, idx); + else + outputs[idx] = ureg_DECL_output(ureg, TGSI_SEMANTIC_GENERIC, idx); + 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: + check(idx >= 0); + if(inputs.size() <= (unsigned)idx) + inputs.resize(idx + 1); + // TODO: is this correct? + inputs[idx] = ureg_DECL_system_value(ureg, idx, sm4_to_pipe_sv[dcl.sv], 0); + break; + case SM4_OPCODE_DCL_OUTPUT_SIV: + case SM4_OPCODE_DCL_OUTPUT_SGV: + check(idx >= 0); + if(outputs.size() <= (unsigned)idx) + outputs.resize(idx + 1); + check(sm4_to_pipe_sv[dcl.sv] >= 0); + outputs[idx] = ureg_DECL_output(ureg, sm4_to_pipe_sv[dcl.sv], 0); + break; + case SM4_OPCODE_DCL_RESOURCE: + check(idx >= 0); + if(targets.size() <= (unsigned)idx) + targets.resize(idx + 1); + switch(dcl.dcl_resource.target) + { + case SM4_TARGET_TEXTURE1D: + targets[idx].first = TGSI_TEXTURE_1D; + targets[idx].second = TGSI_TEXTURE_SHADOW1D; + break; + case SM4_TARGET_TEXTURE2D: + targets[idx].first = TGSI_TEXTURE_2D; + targets[idx].second = TGSI_TEXTURE_SHADOW2D; + break; + case SM4_TARGET_TEXTURE3D: + targets[idx].first = TGSI_TEXTURE_3D; + targets[idx].second = 0; + break; + case SM4_TARGET_TEXTURECUBE: + targets[idx].first = TGSI_TEXTURE_CUBE; + targets[idx].second = 0; + break; + default: + // HACK to make SimpleSample10 work + //check(0); + targets[idx].first = TGSI_TEXTURE_2D; + targets[idx].second = TGSI_TEXTURE_SHADOW2D; + break; + } + break; + case SM4_OPCODE_DCL_SAMPLER: + check(idx >= 0); + if(sampler_modes.size() <= (unsigned)idx) + sampler_modes.resize(idx + 1); + check(!dcl.dcl_sampler.mono); + sampler_modes[idx] = dcl.dcl_sampler.shadow; + break; + case SM4_OPCODE_DCL_CONSTANT_BUFFER: + check(dcl.op->num_indices == 2); + check(dcl.op->is_index_simple(0)); + check(dcl.op->is_index_simple(1)); + idx = dcl.op->indices[0].disp; + ureg_DECL_constant2D(ureg, 0, (unsigned)dcl.op->indices[1].disp - 1, idx); + break; + case SM4_OPCODE_DCL_GS_INPUT_PRIMITIVE: + ureg_property_gs_input_prim(ureg, d3d_to_pipe_prim_type[dcl.dcl_gs_input_primitive.primitive]); + break; + case SM4_OPCODE_DCL_GS_OUTPUT_PRIMITIVE_TOPOLOGY: + ureg_property_gs_output_prim(ureg, d3d_to_pipe_prim[dcl.dcl_gs_output_primitive_topology.primitive_topology]); + break; + case SM4_OPCODE_DCL_MAX_OUTPUT_VERTEX_COUNT: + ureg_property_gs_max_vertices(ureg, dcl.num); + break; + default: + check(0); + } + } + + translate_insns(0, program.insns.size()); + sm4_to_tgsi_insn_num.push_back(ureg_get_instruction_number(ureg)); + if(in_sub) + ureg_ENDSUB(ureg); + else + ureg_END(ureg); + + for(unsigned i = 0; i < label_to_sm4_insn_num.size(); ++i) + ureg_fixup_label(ureg, label_to_sm4_insn_num[i].first, sm4_to_tgsi_insn_num[label_to_sm4_insn_num[i].second]); + + const struct tgsi_token * tokens = ureg_get_tokens(ureg, 0); + ureg_destroy(ureg); + return (void*)tokens; + } + + void* translate() + { + try + { + return do_translate(); + } + catch(const char*) + { + return 0; + } + } +}; + +void* sm4_to_tgsi(struct sm4_program& program) +{ + sm4_to_tgsi_converter conv(program); + return conv.translate(); +} diff --git a/src/gallium/state_trackers/d3d1x/gd3d1x/sm4_to_tgsi.h b/src/gallium/state_trackers/d3d1x/gd3d1x/sm4_to_tgsi.h new file mode 100644 index 00000000000..5722b277fb7 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/gd3d1x/sm4_to_tgsi.h @@ -0,0 +1,34 @@ +/************************************************************************** + * + * 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 SM4_TO_TGSI_H_ +#define SM4_TO_TGSI_H_ + +#include "sm4.h" + +void* sm4_to_tgsi(struct sm4_program& program); + +#endif /* SM4_TO_TGSI_H_ */ diff --git a/src/gallium/state_trackers/d3d1x/gd3d1x/tools/dxbc2tgsi.cpp b/src/gallium/state_trackers/d3d1x/gd3d1x/tools/dxbc2tgsi.cpp new file mode 100644 index 00000000000..d210f8acad1 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/gd3d1x/tools/dxbc2tgsi.cpp @@ -0,0 +1,82 @@ +/************************************************************************** + * + * 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 "../sm4_to_tgsi.h" +#include "tgsi/tgsi_dump.h" +#include <iostream> +#include <fstream> + +void usage() +{ + std::cerr << "Gallium Direct3D10/11 Shader to TGSI converter\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: dxbc2tgsi 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) + { + const struct tgsi_token* tokens = (const struct tgsi_token*)sm4_to_tgsi(*sm4); + if(tokens) + { + std::cout << *sm4; + std::cout << "\n# TGSI program: " << std::endl; + tgsi_dump(tokens, 0); + } + } + } + delete dxbc; + } +} diff --git a/src/gallium/state_trackers/d3d1x/gd3dapi/Makefile b/src/gallium/state_trackers/d3d1x/gd3dapi/Makefile new file mode 100644 index 00000000000..8b16b1bcbcf --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/gd3dapi/Makefile @@ -0,0 +1,4 @@ +all: idl + +include ../Makefile.inc + diff --git a/src/gallium/state_trackers/d3d1x/gd3dapi/galliumcom.idl b/src/gallium/state_trackers/d3d1x/gd3dapi/galliumcom.idl new file mode 100644 index 00000000000..96faf1c0701 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/gd3dapi/galliumcom.idl @@ -0,0 +1,76 @@ +/************************************************************************** + * + * 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 all COM-based Gallium APIs and state trackers */ + +import "oaidl.idl"; +import "ocidl.idl"; + +[object, local, uuid("481c9372-795f-4630-bd5b-1f46d33cc28b")] +interface IGalliumAdapter : IUnknown +{ + struct pipe_screen* GetGalliumScreen(); + struct pipe_screen* GetGalliumReferenceSoftwareScreen(); + struct pipe_screen* GetGalliumFastSoftwareScreen(); +} + +[object, local, uuid("2c0f7e72-d9fe-4e7b-9fee-d476695ad5d9")] +interface IGalliumDevice : IUnknown +{ + // turn Gallium resource into API resource + HRESULT OpenGalliumResource( + [in] struct pipe_resource* resource, + [out] IUnknown** api_resource + ); + + /* returns the Gallium context used by the device + * can return NULL if the device uses multiple contexts or doesn't want to implement GetGalliumContext() + * we have this function because often using one context is faster than using more (or it's the only working option) + */ + struct pipe_context* GetGalliumContext(); + + // restore the context state after using the Gallium context for something else + // does nothing if GetGalliumContext returns null + void RestoreGalliumState(); + + /* like RestoreGalliumState, but ignores: + * - constant buffers + * - non-PS samplers and shader resource views + * - blend color, sample mask + * - scissor + * - index buffer + * + * This is intended to restore state after a blit-like operation. + */ + void RestoreGalliumStateBlitOnly(); +}; + +[object, local, uuid("61934787-7aea-412c-8c72-8afe6a33d622")] +interface IGalliumResource : IUnknown +{ + struct pipe_resource* GetGalliumResource(); +}; + diff --git a/src/gallium/state_trackers/d3d1x/gd3dapi/galliumd3d10_1.idl b/src/gallium/state_trackers/d3d1x/gd3dapi/galliumd3d10_1.idl new file mode 100644 index 00000000000..dddb3431b6f --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/gd3dapi/galliumd3d10_1.idl @@ -0,0 +1,35 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + +import "ocidl.idl"; +import "d3d10_1.idl"; + +// just adding __stdcall to the function makes at least one version of widl crash +[object, local] +interface IDummyInterfaceToPutWidlInComModeForGalliumD3D10 +{} + +HRESULT GalliumD3D10DeviceCreate1(struct pipe_screen* screen, struct pipe_context* context, BOOL owns_context, unsigned creation_flags, IDXGIAdapter* adapter, ID3D10Device1** ppDevice); diff --git a/src/gallium/state_trackers/d3d1x/gd3dapi/galliumd3d11.idl b/src/gallium/state_trackers/d3d1x/gd3dapi/galliumd3d11.idl new file mode 100644 index 00000000000..76f8a7f7f6e --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/gd3dapi/galliumd3d11.idl @@ -0,0 +1,36 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + +import "ocidl.idl"; +import "d3d11.idl"; + +// just adding __stdcall to the function makes at least one version of widl crash +[object, local] +interface IDummyInterfaceToPutWidlInComModeForGalliumD3D11 +{} + +HRESULT GalliumD3D11DeviceCreate(struct pipe_screen* screen, struct pipe_context* context, BOOL owns_context, unsigned creation_flags, IDXGIAdapter* adapter, ID3D11Device** ppDevice); + diff --git a/src/gallium/state_trackers/d3d1x/gd3dapi/galliumdxgi.idl b/src/gallium/state_trackers/d3d1x/gd3dapi/galliumdxgi.idl new file mode 100644 index 00000000000..c6233c85b99 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/gd3dapi/galliumdxgi.idl @@ -0,0 +1,134 @@ +/************************************************************************** + * + * 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 the Gallium extensions to DXGI */ + +import "galliumcom.idl"; +import "../d3dapi/dxgi.idl"; + +/* These calls set the display system that will be associated + * to new DXGI factories created with CreateDXGIFactory and + * CreateDXGIFactory1 by the current thread. + * + * Existing factories and DXGI objects created from them are + * not affected. + * + * Gallium DXGI has both per-thread and per-process settings. + * If the per-thread display system has been set (i.e. a function + * of these was called, and the last one called was not UseNothing), + * it will be used. + * Otherwise, the per-process display system will be used if set, or + * and other the factory creation call may either fail, or use an + * user-specified default.. + * + * The per-process setting can be altered by calling + * GalliumDXGIMakeDefault, which will set the per-process setting + * according to the current per-thread setting. + * + * GalliumDXGIUseNothing() is the initial state, which means that + * the per-process default should be used, and if that is "use nothing" + * too, the call will either fail or use a user-specified default. + * + * NOTE that setting the per-process default is NOT atomic and must + * not be done concurrently with other calls to GalliumDXGIMakeDefault, + * CreateDXGIFactory or CreateDXGIFactory1. + * + * The PFNHWNDRESOLVER function is passed HWNDs coming from + * the API user and must return window-system-specific values: + * - X11: Window* + * - GDI: HWND + */ + +[object, local, uuid("c22d2f85-f7dd-40b0-a50b-5d308f973c5e")] +interface IGalliumDXGIBackend : IUnknown +{ + /* *present_cookie is set to a cookie that is passed to EndPresent + * + * *window and *rect are the window and subrectangle + * to present in. + * + * For X11, *window is a Window. + * For other systems, it will be the equivalent way to reference a window. + * + * The rectangle is clipped against the window size, so you can + * specify (0, 0, INT_MAX, INT_MAX) to use the whole window. + * + * rgndata is set to either NULL, or the region, in coordinates relative + * to the subrectangle, to clip presentation to. + * *rgndata is valid until EndPresent is called, at which point EndPresent + * may free the data. + * + * However, the rect field should still be set as normal if possible (especially + * the dimension).. + * + * If preserve_aspect_ratio is set, *rgndata will be ignored. This + * limitation may be lifted in future versions. + * + * If the window is fully obscured, return DXGI_STATUS_OCCLUDED. + * Everything else is ignored in that case. + * + * EndPresent is only called when S_OK is returned. + */ + HRESULT BeginPresent( + [in] HWND hwnd, + [out] void** present_cookie, + [out] void** window, + [out] RECT* rect, + [out] struct _RGNDATA** rgndata, + [out] BOOL* preserve_aspect_ratio + ); + + void EndPresent( + [in] HWND hwnd, + [out] void* present_cookie + ); + + /* If the window is fully obscured, return DXGI_STATUS_OCCLUDED, else S_OK */ + HRESULT TestPresent( + [in] HWND hwnd + ); + + /* Get size of rectangle that would be returned by BeginPresent */ + HRESULT GetPresentSize( + [in] HWND hwnd, + [out] unsigned* width, + [out] unsigned* height + ); +} + +void GalliumDXGIUseNothing(); + +/* only a subset of these may be available, depending on platform and compilation options */ +void GalliumDXGIUseX11Display(struct _XDisplay* dpy, IGalliumDXGIBackend* backend); + +/* these don't really work for now +void GalliumDXGIUseDRMCard(int fd); +void GalliumDXGIUseFBDev(int fd); +void GalliumDXGIUseHDC(HDC hdc, IGalliumDXGIGDIBackend* backend); +*/ + +void GalliumDXGIMakeDefault(); + diff --git a/src/gallium/state_trackers/d3d1x/mstools/download-mstools b/src/gallium/state_trackers/d3d1x/mstools/download-mstools new file mode 100755 index 00000000000..15a63171807 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/mstools/download-mstools @@ -0,0 +1,73 @@ +#!/bin/bash +ok=1 +for i in fxc.exe D3DCompiler_43.dll d3dx9_43.dll d3dx10_43.dll d3dx11_43.dll; do + if ! test -e "$i"; then + ok= + fi +done + +if test -n "$ok"; then + exit 0 +fi + +echo "To compile HLSL shaders, the Microsoft HLSL compiler needs to be downloaded." +echo +echo "Downloading Microsoft DirectX June 2010 SDK and extracting files..." +echo "Please wait, this will need to download and unpack a 600 MB file..." +echo +echo "The contribution of a free HLSL compiler would be greatly appreciated!" +echo + +ok=1 +if ! which wget >/dev/null; then + echo "Error: wget is required to download the files" + echo "On Debian or Ubuntu, run the following command to install it:" + echo "sudo apt-get install wget" + echo + ok= +fi + +if ! which cabextract >/dev/null; then + echo "Error: cabextract is required to unpack the files" + echo "On Debian or Ubuntu, run the following command to install it:" + echo "sudo apt-get install cabextract" + echo + ok= +fi + +if test -z "$ok"; then + exit 1 +fi + +dxsdk_file="DXSDK_Jun10.exe" +dxsdk_url="http://download.microsoft.com/download/A/E/7/AE743F1F-632B-4809-87A9-AA1BB3458E31/DXSDK_Jun10.exe" +dxsdk_size=599452800 + +fxc_path="DXSDK/Utilities/bin/x86/fxc.exe" +d3dcompiler_cab_path="DXSDK/Redist/Jun2010_D3DCompiler_43_x86.cab" +d3dx9_cab_path="DXSDK/Redist/Jun2010_d3dx9_43_x86.cab" +d3dx10_cab_path="DXSDK/Redist/Jun2010_d3dx10_43_x86.cab" +d3dx11_cab_path="DXSDK/Redist/Jun2010_d3dx11_43_x86.cab" + +if test "$(stat -c '%s' "$dxsdk_file" 2>/dev/null)" != $dxsdk_size; then + wget --continue "$dxsdk_url" + if test "$(stat -c '%s' "$dxsdk_file" 2>/dev/null)" != $dxsdk_size; then + echo "Failed to download DirectX SDK: expected $dxsdk_file with size $dxsdk_size" + echo "Download manually from $dxsdk_url" + exit 1 + fi +fi + +for i in "$fxc_path" "$d3dcompiler_cab_path" "$d3dx9_cab_path" "$d3dx10_cab_path" "$d3dx11_cab_path"; do + if ! test -e "$i"; then + echo "Please wait, this may take several minutes because a 600 MB archive may need to be fully decompressed..." + cabextract -F "$i" "$dxsdk_file" + fi +done + +for i in "$d3dcompiler_cab_path" "$d3dx9_cab_path" "$d3dx10_cab_path" "$d3dx11_cab_path"; do + cabextract -F "*.dll" "$i" +done + +/bin/cp -dpf "$fxc_path" . + diff --git a/src/gallium/state_trackers/d3d1x/progs/Makefile b/src/gallium/state_trackers/d3d1x/progs/Makefile new file mode 100644 index 00000000000..143e5316626 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/Makefile @@ -0,0 +1,46 @@ +LIBRARY_INCLUDES = -Id3d10app -Id3d11app -I../gd3dapi -I../d3dapi -I../w32api +LIBS= \ + ../dxgi/libdxgi.a \ + ../gd3d1x/libgd3d1x.a \ + ../d3d1xshader/libd3d1xshader.a \ + ../d3d1xstutil/libd3d1xstutil.a \ + ../../egl/libegl.a \ + ../../../auxiliary/libgallium.a \ + ../../../winsys/sw/wrapper/libwsw.a \ + ../../../winsys/sw/xlib/libws_xlib.a \ + ../../../winsys/sw/dri/libswdri.a \ + ../../../../../lib/libEGL.so + +LDADD=-ldl + +all: bin/d3d10tri bin/d3d11tri bin/d3d11tex bin/d3d11gears +include ../Makefile.inc + +ifneq ($(findstring fbdev, $(EGL_PLATFORMS)),) +LIBS += ../../../winsys/sw/fbdev/libfbdev.a +endif + +ifneq ($(findstring x11, $(EGL_PLATFORMS)),) +LDADD += -ldrm -lX11 -lXext -lXfixes +LIBS += ../../../winsys/sw/xlib/libws_xlib.a +endif + +ifneq ($(findstring kms, $(EGL_PLATFORMS)),) +LDADD += -ldrm +endif + +LIBS_D3D10 = ../dxgid3d10/libdxgid3d10.a ../gd3d10/libgd3d10.a $(LIBS) +LIBS_D3D11 = ../dxgid3d11/libdxgid3d11.a ../gd3d11/libgd3d11.a $(LIBS) + +bin/d3d10tri: d3d10app/d3d10x11main.o d3d10tri/d3d10tri.o $(LIBS_D3D10) + $(CXX) $(CXXFLAGS) $(LDFLAGS) $(filter %.o,$^) -o $@ -Wl,--start-group $(LIBS_D3D10) -Wl,--end-group $(LDADD) + +bin/d3d11tri: d3d11app/d3d11x11main.o d3d11tri/d3d11tri.o $(LIBS_D3D11) + $(CXX) $(CXXFLAGS) $(LDFLAGS) $(filter %.o,$^) -o $@ -Wl,--start-group $(LIBS_D3D11) -Wl,--end-group $(LDADD) + +bin/d3d11tex: d3d11app/d3d11x11main.o d3d11tex/d3d11tex.o $(LIBS_D3D11) + $(CXX) $(CXXFLAGS) $(LDFLAGS) $(filter %.o,$^) -o $@ -Wl,--start-group $(LIBS_D3D11) -Wl,--end-group $(LDADD) + +bin/d3d11gears: d3d11app/d3d11x11main.o d3d11gears/d3d11gears.o $(LIBS_D3D11) + $(CXX) $(CXXFLAGS) $(LDFLAGS) $(filter %.o,$^) -o $@ -Wl,--start-group $(LIBS_D3D11) -Wl,--end-group $(LDADD) + diff --git a/src/gallium/state_trackers/d3d1x/progs/bin/d3d10tri.exe b/src/gallium/state_trackers/d3d1x/progs/bin/d3d10tri.exe Binary files differnew file mode 100755 index 00000000000..77ab03fcce0 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/bin/d3d10tri.exe diff --git a/src/gallium/state_trackers/d3d1x/progs/bin/d3d11gears.exe b/src/gallium/state_trackers/d3d1x/progs/bin/d3d11gears.exe Binary files differnew file mode 100755 index 00000000000..c2cd296a40f --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/bin/d3d11gears.exe diff --git a/src/gallium/state_trackers/d3d1x/progs/bin/d3d11spikysphere.exe b/src/gallium/state_trackers/d3d1x/progs/bin/d3d11spikysphere.exe Binary files differnew file mode 100755 index 00000000000..c3bc667fb31 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/bin/d3d11spikysphere.exe diff --git a/src/gallium/state_trackers/d3d1x/progs/bin/d3d11tex.exe b/src/gallium/state_trackers/d3d1x/progs/bin/d3d11tex.exe Binary files differnew file mode 100755 index 00000000000..0be5cb8dd72 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/bin/d3d11tex.exe diff --git a/src/gallium/state_trackers/d3d1x/progs/bin/d3d11tri.exe b/src/gallium/state_trackers/d3d1x/progs/bin/d3d11tri.exe Binary files differnew file mode 100755 index 00000000000..abada5484bd --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/bin/d3d11tri.exe diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d10app/d3d10app.h b/src/gallium/state_trackers/d3d1x/progs/d3d10app/d3d10app.h new file mode 100755 index 00000000000..59fe338f565 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d10app/d3d10app.h @@ -0,0 +1,51 @@ +/************************************************************************** + * + * 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 D3D10APP_H +#define D3D10APP_H + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#include <objbase.h> +#include <d3d10_1.h> +#include <assert.h> +#include <stdio.h> +#include <float.h> + +#define ensure(x) do {HRESULT __hr = (x); if(!SUCCEEDED(__hr)) {fprintf(stderr, "COM error %08x\n", __hr); abort();}} while(0) + +struct d3d10_application +{ + virtual ~d3d10_application() {} + + virtual void draw(ID3D10Device* ctx, ID3D10RenderTargetView* rtv, unsigned width, unsigned height, double time) = 0; + virtual bool init(ID3D10Device* dev, int argc, char** argv) = 0; +}; + +/* this is the entry point you must provide */ +extern "C" d3d10_application* d3d10_application_create(); + +#endif diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d10app/d3d10winmain.cpp b/src/gallium/state_trackers/d3d1x/progs/d3d10app/d3d10winmain.cpp new file mode 100755 index 00000000000..94680977ebd --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d10app/d3d10winmain.cpp @@ -0,0 +1,188 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + +#define INITGUID +#include "d3d10app.h" +#include "stdio.h" + +static d3d10_application* app; +static IDXGISwapChain* swap_chain; +static unsigned width, height; +static DXGI_FORMAT format = DXGI_FORMAT_R8G8B8A8_UNORM; +static ID3D10Device* dev; +static ID3D10Device* ctx; +static int frames = 0; +static int buffer_count = 1; + +LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_SIZE: + width = lParam & 0xffff; + height = lParam >> 16; + + swap_chain->ResizeBuffers(buffer_count, width, height, format, 0); + frames = 0; + break; + case WM_DESTROY: + PostQuitMessage(0); + break; + default: + return DefWindowProc(hwnd, message, wParam, lParam); + } + return 0; +} + +int main(int argc, char** argv) +{ + HINSTANCE hInstance = GetModuleHandle(NULL); + WNDCLASSEXA wcex; + + wcex.cbSize = sizeof(WNDCLASSEX); + + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = 0; + wcex.hCursor = LoadCursor(NULL, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wcex.lpszMenuName = 0; + wcex.lpszClassName = "d3d10"; + wcex.hIconSm = 0; + + RegisterClassExA(&wcex); + + HWND hwnd = CreateWindowA("d3d10", "d3d10", WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); + + if(!hwnd) + return FALSE; + + RECT rc; + GetClientRect(hwnd, &rc ); + width = rc.right - rc.left; + height = rc.bottom - rc.top; + + DXGI_SWAP_CHAIN_DESC swap_chain_desc; + memset(&swap_chain_desc, 0, sizeof(swap_chain_desc)); + swap_chain_desc.BufferDesc.Width = width; + swap_chain_desc.BufferDesc.Height = height; + swap_chain_desc.BufferDesc.Format = format; + swap_chain_desc.SampleDesc.Count = 1; + swap_chain_desc.SampleDesc.Quality = 0; + swap_chain_desc.OutputWindow = hwnd; + swap_chain_desc.Windowed = TRUE; + swap_chain_desc.BufferCount = buffer_count; + swap_chain_desc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; + swap_chain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + swap_chain_desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; + + D3D10_FEATURE_LEVEL1 feature_level = D3D10_FEATURE_LEVEL_10_0; + + HRESULT hr; + if(1) + { + hr = D3D10CreateDeviceAndSwapChain( + NULL, + D3D10_DRIVER_TYPE_HARDWARE, + NULL, + D3D10_CREATE_DEVICE_SINGLETHREADED, // | D3D10_CREATE_DEVICE_DEBUG, + D3D10_SDK_VERSION, + &swap_chain_desc, + &swap_chain, + &dev); + } + else + { + hr = D3D10CreateDeviceAndSwapChain1( + NULL, + D3D10_DRIVER_TYPE_HARDWARE, + NULL, + D3D10_CREATE_DEVICE_SINGLETHREADED, // | D3D10_CREATE_DEVICE_DEBUG, + feature_level, + D3D10_SDK_VERSION, + &swap_chain_desc, + &swap_chain, + (ID3D10Device1**)&dev); + } + + if(!SUCCEEDED(hr)) + { + fprintf(stderr, "Failed to create D3D10 device (hresult %08x)\n", hr); + return 1; + } + + ctx = dev; + + app = d3d10_application_create(); + if(!app->init(dev, argc, argv)) + return 1; + + ShowWindow(hwnd, SW_SHOWDEFAULT); + UpdateWindow(hwnd); + + LARGE_INTEGER freq; + QueryPerformanceFrequency(&freq); + double period = 1.0 / (double)freq.QuadPart; + LARGE_INTEGER ctime_li; + QueryPerformanceCounter(&ctime_li); + double start_time = ctime_li.QuadPart * period; + + MSG msg; + for(;;) + { + if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) + { + if(msg.message == WM_QUIT) + break; + TranslateMessage(&msg); + DispatchMessage(&msg); + } + else if(width && height) + { + ID3D10Texture2D* tex; + static ID3D10RenderTargetView* rtv; + ensure(swap_chain->GetBuffer(0, __uuidof(tex), (void**)&tex)); + ensure(dev->CreateRenderTargetView(tex, NULL, &rtv)); + + QueryPerformanceCounter(&ctime_li); + double ctime = (double)ctime_li.QuadPart * period - start_time; + + app->draw(ctx, rtv, width, height, ctime); + ctx->OMSetRenderTargets(0, 0, 0); + + swap_chain->Present(0, 0); + rtv->Release(); + tex->Release(); + } + else + WaitMessage(); + } + return (int) msg.wParam; +} diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d10app/d3d10x11main.cpp b/src/gallium/state_trackers/d3d1x/progs/d3d10app/d3d10x11main.cpp new file mode 100755 index 00000000000..8f07380056c --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d10app/d3d10x11main.cpp @@ -0,0 +1,154 @@ +/************************************************************************** + * + * 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 "d3d10app.h" +#include <X11/Xlib.h> +#include <galliumdxgi.h> +#include <sys/time.h> + +static d3d10_application* app; +static IDXGISwapChain* swap_chain; +unsigned width, height; +DXGI_FORMAT format = DXGI_FORMAT_R8G8B8A8_UNORM; +static ID3D10Device* dev; +static ID3D10Device* ctx; + +double get_time() +{ + struct timeval tv; + gettimeofday(&tv, 0); + return (double)tv.tv_sec + (double)tv.tv_usec * 0.000001; +} + +int main(int argc, char** argv) +{ + Display* dpy = XOpenDisplay(0); + Visual* visual = DefaultVisual(dpy, DefaultScreen(dpy)); + Colormap cmap = XCreateColormap(dpy, RootWindow(dpy, DefaultScreen(dpy)), visual, AllocNone); + XSetWindowAttributes swa; + swa.colormap = cmap; + swa.border_pixel = 0; + swa.event_mask = StructureNotifyMask; + width = 512; + height = 512; + Window win = XCreateWindow(dpy, RootWindow(dpy, DefaultScreen(dpy)), 0, 0, width, height, 0, CopyFromParent, InputOutput, visual, CWBorderPixel | CWColormap| CWEventMask, &swa); + XMapWindow(dpy, win); + + GalliumDXGIUseX11Display(dpy, 0); + + DXGI_SWAP_CHAIN_DESC swap_chain_desc; + memset(&swap_chain_desc, 0, sizeof(swap_chain_desc)); + swap_chain_desc.BufferDesc.Width = width; + swap_chain_desc.BufferDesc.Height = height; + swap_chain_desc.BufferDesc.Format = format; + swap_chain_desc.SampleDesc.Count = 1; + swap_chain_desc.SampleDesc.Quality = 0; + swap_chain_desc.OutputWindow = (HWND)win; + swap_chain_desc.Windowed = TRUE; + swap_chain_desc.BufferCount = 3; + swap_chain_desc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; + swap_chain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + + D3D10_FEATURE_LEVEL1 feature_level = D3D10_FEATURE_LEVEL_10_0; + + HRESULT hr; + if(0) + { + hr = D3D10CreateDeviceAndSwapChain( + NULL, + D3D10_DRIVER_TYPE_HARDWARE, + NULL, + D3D10_CREATE_DEVICE_SINGLETHREADED, + D3D10_SDK_VERSION, + &swap_chain_desc, + &swap_chain, + &dev); + } + else + { + hr = D3D10CreateDeviceAndSwapChain1( + NULL, + D3D10_DRIVER_TYPE_HARDWARE, + NULL, + D3D10_CREATE_DEVICE_SINGLETHREADED, + feature_level, + D3D10_SDK_VERSION, + &swap_chain_desc, + &swap_chain, + (ID3D10Device1**)&dev); + } + if(!SUCCEEDED(hr)) + { + fprintf(stderr, "Failed to create D3D10 device (hresult %08x)\n", hr); + return 1; + } + ctx = dev; + + app = d3d10_application_create(); + if(!app->init(dev, argc, argv)) + return 1; + + double start_time = get_time(); + + MSG msg; + for(;;) + { + XEvent event; + if(XPending(dpy)) + { + XNextEvent(dpy, &event); + if(event.type == DestroyNotify) + break; + switch(event.type) + { + case ConfigureNotify: + width = event.xconfigure.width; + height = event.xconfigure.height; + swap_chain->ResizeBuffers(3, width, height, format, 0); + break; + } + } + else if(width && height) + { + ID3D10Texture2D* tex; + ID3D10RenderTargetView* rtv; + ensure(swap_chain->GetBuffer(0, IID_ID3D10Texture2D, (void**)&tex)); + ensure(dev->CreateRenderTargetView(tex, NULL, &rtv)); + + double ctime = get_time() - start_time; + + app->draw(ctx, rtv, width, height, ctime); + ctx->OMSetRenderTargets(0, 0, 0); + + tex->Release(); + rtv->Release(); + swap_chain->Present(0, 0); + } + else + XPeekEvent(dpy, &event); + } + return (int) msg.wParam; +} diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d10tri/d3d10tri.cpp b/src/gallium/state_trackers/d3d1x/progs/d3d10tri/d3d10tri.cpp new file mode 100755 index 00000000000..90b97f8a5d4 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d10tri/d3d10tri.cpp @@ -0,0 +1,118 @@ +/************************************************************************** + * + * 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 "d3d10app.h" +#include "d3d10tri.hlsl.ps.h" +#include "d3d10tri.hlsl.vs.h" + +struct vertex { + float position[4]; + float color[4]; +}; + +static struct vertex vertices[3] = +{ + { + { 0.0f, 0.9f, 0.5f, 1.0f }, + { 1.0f, 0.0f, 0.0f, 1.0f } + }, + { + { 0.9f, -0.9f, 0.5f, 1.0f }, + { 0.0f, 0.0f, 1.0f, 1.0f } + }, + { + { -0.9f, -0.9f, 0.5f, 1.0f }, + { 0.0f, 1.0f, 0.0f, 1.0f } + }, +}; + +struct d3d10tri : public d3d10_application +{ + ID3D10PixelShader* ps; + ID3D10VertexShader* vs; + ID3D10InputLayout* layout; + ID3D10Buffer* vb; + + virtual bool init(ID3D10Device* dev, int argc, char** argv) + { + ensure(dev->CreatePixelShader(g_ps, sizeof(g_ps), &ps)); + ensure(dev->CreateVertexShader(g_vs, sizeof(g_vs), &vs)); + + D3D10_INPUT_ELEMENT_DESC elements[] = + { + {"POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0}, + {"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 16, D3D10_INPUT_PER_VERTEX_DATA, 0}, + }; + + ensure(dev->CreateInputLayout(elements, sizeof(elements) / sizeof(elements[0]), g_vs, sizeof(g_vs), &layout)); + D3D10_BUFFER_DESC bufferd; + bufferd.ByteWidth = sizeof(vertices); + bufferd.Usage = D3D10_USAGE_IMMUTABLE; + bufferd.BindFlags = D3D10_BIND_VERTEX_BUFFER; + bufferd.CPUAccessFlags = 0; + bufferd.MiscFlags = 0; + + D3D10_SUBRESOURCE_DATA buffersd; + buffersd.pSysMem = vertices; + buffersd.SysMemPitch = sizeof(vertices); + buffersd.SysMemSlicePitch = sizeof(vertices); + + ensure(dev->CreateBuffer(&bufferd, &buffersd, &vb)); + + return true; + } + + virtual void draw(ID3D10Device* ctx, ID3D10RenderTargetView* rtv, unsigned width, unsigned height, double time) + { + float clear_color[4] = {1, 0, 1, 1}; + D3D10_VIEWPORT vp; + memset(&vp, 0, sizeof(vp)); + vp.Width = (unsigned)width; + vp.Height = (unsigned)height; + vp.MaxDepth = 1.0f; + + ctx->OMSetRenderTargets(1, &rtv, 0); + ctx->RSSetViewports(1, &vp); + + ctx->ClearRenderTargetView(rtv, clear_color); + + ctx->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + ctx->IASetInputLayout(layout); + unsigned stride = 2 * 4 * 4; + unsigned offset = 0; + ctx->IASetVertexBuffers(0, 1, &vb, &stride, &offset); + + ctx->VSSetShader(vs); + ctx->PSSetShader(ps); + + ctx->Draw(3, 0); + } +}; + +d3d10_application* d3d10_application_create() +{ + return new d3d10tri(); +} diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d10tri/d3d10tri.hlsl b/src/gallium/state_trackers/d3d1x/progs/d3d10tri/d3d10tri.hlsl new file mode 100755 index 00000000000..6bdd448ce0a --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d10tri/d3d10tri.hlsl @@ -0,0 +1,50 @@ +/**************************************************************************
+ *
+ * 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.
+ *
+ **************************************************************************/
+
+struct IA2VS
+{
+ float4 position : POSITION;
+ float4 color : COLOR;
+};
+
+struct VS2PS
+{
+ float4 position : SV_POSITION;
+ float4 color : COLOR;
+};
+
+VS2PS vs(IA2VS input)
+{
+ VS2PS result;
+ result.position = input.position;
+ result.color = input.color;
+ return result;
+}
+
+float4 ps(VS2PS input) : SV_TARGET
+{
+ return input.color;
+}
diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d10tri/d3d10tri.hlsl.ps.h b/src/gallium/state_trackers/d3d1x/progs/d3d10tri/d3d10tri.hlsl.ps.h new file mode 100755 index 00000000000..bc55cf8a472 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d10tri/d3d10tri.hlsl.ps.h @@ -0,0 +1,112 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 +// +// +// fxc /Fhd3d10tri.hlsl.ps.h /Eps /Tps_4_0 d3d10tri.hlsl +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_POSITION 0 xyzw 0 POS float +// COLOR 0 xyzw 1 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_TARGET 0 xyzw 0 TARGET float xyzw +// +ps_4_0 +dcl_input_ps linear v1.xyzw +dcl_output o0.xyzw +mov o0.xyzw, v1.xyzw +ret +// Approximately 2 instruction slots used +#endif + +const BYTE g_ps[] = +{ + 68, 88, 66, 67, 206, 120, + 117, 238, 118, 127, 10, 87, + 80, 75, 114, 198, 95, 2, + 120, 102, 1, 0, 0, 0, + 208, 1, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 140, 0, 0, 0, 224, 0, + 0, 0, 20, 1, 0, 0, + 84, 1, 0, 0, 82, 68, + 69, 70, 80, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 28, 0, 0, 0, 0, 4, + 255, 255, 0, 1, 0, 0, + 28, 0, 0, 0, 77, 105, + 99, 114, 111, 115, 111, 102, + 116, 32, 40, 82, 41, 32, + 72, 76, 83, 76, 32, 83, + 104, 97, 100, 101, 114, 32, + 67, 111, 109, 112, 105, 108, + 101, 114, 32, 57, 46, 50, + 57, 46, 57, 53, 50, 46, + 51, 49, 49, 49, 0, 171, + 171, 171, 73, 83, 71, 78, + 76, 0, 0, 0, 2, 0, + 0, 0, 8, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 68, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 15, 0, 0, + 83, 86, 95, 80, 79, 83, + 73, 84, 73, 79, 78, 0, + 67, 79, 76, 79, 82, 0, + 171, 171, 79, 83, 71, 78, + 44, 0, 0, 0, 1, 0, + 0, 0, 8, 0, 0, 0, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 83, 86, 95, 84, 65, 82, + 71, 69, 84, 0, 171, 171, + 83, 72, 68, 82, 56, 0, + 0, 0, 64, 0, 0, 0, + 14, 0, 0, 0, 98, 16, + 0, 3, 242, 16, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 242, 32, 16, 0, + 0, 0, 0, 0, 70, 30, + 16, 0, 1, 0, 0, 0, + 62, 0, 0, 1, 83, 84, + 65, 84, 116, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0 +}; diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d10tri/d3d10tri.hlsl.vs.h b/src/gallium/state_trackers/d3d1x/progs/d3d10tri/d3d10tri.hlsl.vs.h new file mode 100755 index 00000000000..7204281ea81 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d10tri/d3d10tri.hlsl.vs.h @@ -0,0 +1,128 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 +// +// +// fxc /Fhd3d10tri.hlsl.vs.h /Evs /Tvs_4_0 d3d10tri.hlsl +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// POSITION 0 xyzw 0 NONE float xyzw +// COLOR 0 xyzw 1 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_POSITION 0 xyzw 0 POS float xyzw +// COLOR 0 xyzw 1 NONE float xyzw +// +vs_4_0 +dcl_input v0.xyzw +dcl_input v1.xyzw +dcl_output_siv o0.xyzw, position +dcl_output o1.xyzw +mov o0.xyzw, v0.xyzw +mov o1.xyzw, v1.xyzw +ret +// Approximately 3 instruction slots used +#endif + +const BYTE g_vs[] = +{ + 68, 88, 66, 67, 190, 171, + 186, 20, 44, 105, 95, 129, + 137, 204, 223, 72, 251, 159, + 126, 176, 1, 0, 0, 0, + 28, 2, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 140, 0, 0, 0, 220, 0, + 0, 0, 48, 1, 0, 0, + 160, 1, 0, 0, 82, 68, + 69, 70, 80, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 28, 0, 0, 0, 0, 4, + 254, 255, 0, 1, 0, 0, + 28, 0, 0, 0, 77, 105, + 99, 114, 111, 115, 111, 102, + 116, 32, 40, 82, 41, 32, + 72, 76, 83, 76, 32, 83, + 104, 97, 100, 101, 114, 32, + 67, 111, 109, 112, 105, 108, + 101, 114, 32, 57, 46, 50, + 57, 46, 57, 53, 50, 46, + 51, 49, 49, 49, 0, 171, + 171, 171, 73, 83, 71, 78, + 72, 0, 0, 0, 2, 0, + 0, 0, 8, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 65, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 15, 0, 0, + 80, 79, 83, 73, 84, 73, + 79, 78, 0, 67, 79, 76, + 79, 82, 0, 171, 79, 83, + 71, 78, 76, 0, 0, 0, + 2, 0, 0, 0, 8, 0, + 0, 0, 56, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 68, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 80, + 79, 83, 73, 84, 73, 79, + 78, 0, 67, 79, 76, 79, + 82, 0, 171, 171, 83, 72, + 68, 82, 104, 0, 0, 0, + 64, 0, 1, 0, 26, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 1, 0, + 0, 0, 103, 0, 0, 4, + 242, 32, 16, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 1, 0, 0, 0, + 54, 0, 0, 5, 242, 32, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 242, 32, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 1, 0, 0, 0, 62, 0, + 0, 1, 83, 84, 65, 84, + 116, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 +}; diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d10tri/d3d10tri.vcxproj b/src/gallium/state_trackers/d3d1x/progs/d3d10tri/d3d10tri.vcxproj new file mode 100755 index 00000000000..f269e3bbc15 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d10tri/d3d10tri.vcxproj @@ -0,0 +1,98 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{5366F4FD-0E6C-40CC-B2F2-CE3D350F0729}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>d3d10tri</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(SolutionDir)\d3d10app</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>d3d10.lib;d3d10_1.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(SolutionDir)\d3d10app</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalDependencies>d3d10.lib;d3d10_1.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <CustomBuild Include="d3d10tri.hlsl">
+ <FileType>Document</FileType>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(DXSDK_DIR)\Utilities\bin\x86\fxc.exe" /Fh%(Identity).ps.h /Eps /Tps_4_0 %(Identity)
+"$(DXSDK_DIR)\Utilities\bin\x86\fxc.exe" /Fh%(Identity).vs.h /Evs /Tvs_4_0 %(Identity)</Command>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Identity).ps.h;%(Identity).vs.h;%(Outputs)</Outputs>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\d3d10app\d3d10app.h" />
+ <ClInclude Include="d3d10tri.hlsl.ps.h" />
+ <ClInclude Include="d3d10tri.hlsl.vs.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\d3d10app\d3d10winmain.cpp" />
+ <ClCompile Include="d3d10tri.cpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11app.h b/src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11app.h new file mode 100755 index 00000000000..53de10ab3e7 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11app.h @@ -0,0 +1,51 @@ +/************************************************************************** + * + * 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 D3D11APP_H +#define D3D11APP_H + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#include <objbase.h> +#include <d3d11.h> +#include <assert.h> +#include <stdio.h> +#include <float.h> + +#define ensure(x) do {HRESULT __hr = (x); if(!SUCCEEDED(__hr)) {fprintf(stderr, "COM error %08x\n", __hr); abort();}} while(0) + +struct d3d11_application +{ + virtual ~d3d11_application() {} + + virtual void draw(ID3D11DeviceContext* ctx, ID3D11RenderTargetView* rtv, unsigned width, unsigned height, double time) = 0; + virtual bool init(ID3D11Device* dev, int argc, char** argv) = 0; +}; + +/* this is the entry point you must provide */ +extern "C" d3d11_application* d3d11_application_create(); + +#endif diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11blit.hlsl b/src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11blit.hlsl new file mode 100755 index 00000000000..4075160d170 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11blit.hlsl @@ -0,0 +1,53 @@ +/**************************************************************************
+ *
+ * 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.
+ *
+ **************************************************************************/
+
+Texture2D tex;
+sampler samp;
+
+struct IA2VS
+{
+ float4 position : POSITION;
+ float2 texcoord : TEXCOORD;
+};
+
+struct VS2PS
+{
+ float4 position : SV_POSITION;
+ float2 texcoord : TEXCOORD;
+};
+
+VS2PS vs_blit(IA2VS input)
+{
+ VS2PS result;
+ result.position = input.position;
+ result.texcoord = input.texcoord;
+ return result;
+}
+
+float4 ps_blit(VS2PS input) : SV_TARGET
+{
+ return tex.Sample(samp, input.texcoord);
+}
diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11blit.hlsl.ps.h b/src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11blit.hlsl.ps.h new file mode 100755 index 00000000000..5823b4c9764 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11blit.hlsl.ps.h @@ -0,0 +1,142 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 +// +// +// fxc /Fhd3d11blit.hlsl.ps.h /Eps_blit /Tps_4_0 d3d11blit.hlsl +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// samp sampler NA NA 0 1 +// tex texture float4 2d 0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_POSITION 0 xyzw 0 POS float +// TEXCOORD 0 xy 1 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_TARGET 0 xyzw 0 TARGET float xyzw +// +ps_4_0 +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v1.xy +dcl_output o0.xyzw +sample o0.xyzw, v1.xyxx, t0.xyzw, s0 +ret +// Approximately 2 instruction slots used +#endif + +const BYTE g_ps_blit[] = +{ + 68, 88, 66, 67, 183, 100, + 39, 89, 244, 20, 241, 39, + 36, 169, 159, 230, 234, 214, + 114, 11, 1, 0, 0, 0, + 72, 2, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 212, 0, 0, 0, 44, 1, + 0, 0, 96, 1, 0, 0, + 204, 1, 0, 0, 82, 68, + 69, 70, 152, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 28, 0, 0, 0, 0, 4, + 255, 255, 0, 1, 0, 0, + 101, 0, 0, 0, 92, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 97, 0, 0, 0, 2, 0, + 0, 0, 5, 0, 0, 0, + 4, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 1, 0, 0, 0, 12, 0, + 0, 0, 115, 97, 109, 112, + 0, 116, 101, 120, 0, 77, + 105, 99, 114, 111, 115, 111, + 102, 116, 32, 40, 82, 41, + 32, 72, 76, 83, 76, 32, + 83, 104, 97, 100, 101, 114, + 32, 67, 111, 109, 112, 105, + 108, 101, 114, 32, 57, 46, + 50, 57, 46, 57, 53, 50, + 46, 51, 49, 49, 49, 0, + 171, 171, 73, 83, 71, 78, + 80, 0, 0, 0, 2, 0, + 0, 0, 8, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 68, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 3, 3, 0, 0, + 83, 86, 95, 80, 79, 83, + 73, 84, 73, 79, 78, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 171, 171, 171, + 79, 83, 71, 78, 44, 0, + 0, 0, 1, 0, 0, 0, + 8, 0, 0, 0, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 83, 86, + 95, 84, 65, 82, 71, 69, + 84, 0, 171, 171, 83, 72, + 68, 82, 100, 0, 0, 0, + 64, 0, 0, 0, 25, 0, + 0, 0, 90, 0, 0, 3, + 0, 96, 16, 0, 0, 0, + 0, 0, 88, 24, 0, 4, + 0, 112, 16, 0, 0, 0, + 0, 0, 85, 85, 0, 0, + 98, 16, 0, 3, 50, 16, + 16, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 69, 0, 0, 9, 242, 32, + 16, 0, 0, 0, 0, 0, + 70, 16, 16, 0, 1, 0, + 0, 0, 70, 126, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 62, 0, 0, 1, 83, 84, + 65, 84, 116, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0 +}; diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11blit.hlsl.vs.h b/src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11blit.hlsl.vs.h new file mode 100755 index 00000000000..5d9acd20f1d --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11blit.hlsl.vs.h @@ -0,0 +1,130 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 +// +// +// fxc /Fhd3d11blit.hlsl.vs.h /Evs_blit /Tvs_4_0 d3d11blit.hlsl +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// POSITION 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_POSITION 0 xyzw 0 POS float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// +vs_4_0 +dcl_input v0.xyzw +dcl_input v1.xy +dcl_output_siv o0.xyzw, position +dcl_output o1.xy +mov o0.xyzw, v0.xyzw +mov o1.xy, v1.xyxx +ret +// Approximately 3 instruction slots used +#endif + +const BYTE g_vs_blit[] = +{ + 68, 88, 66, 67, 142, 11, + 173, 22, 73, 47, 224, 51, + 147, 83, 148, 177, 56, 17, + 72, 237, 1, 0, 0, 0, + 36, 2, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 140, 0, 0, 0, 224, 0, + 0, 0, 56, 1, 0, 0, + 168, 1, 0, 0, 82, 68, + 69, 70, 80, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 28, 0, 0, 0, 0, 4, + 254, 255, 0, 1, 0, 0, + 28, 0, 0, 0, 77, 105, + 99, 114, 111, 115, 111, 102, + 116, 32, 40, 82, 41, 32, + 72, 76, 83, 76, 32, 83, + 104, 97, 100, 101, 114, 32, + 67, 111, 109, 112, 105, 108, + 101, 114, 32, 57, 46, 50, + 57, 46, 57, 53, 50, 46, + 51, 49, 49, 49, 0, 171, + 171, 171, 73, 83, 71, 78, + 76, 0, 0, 0, 2, 0, + 0, 0, 8, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 65, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 3, 3, 0, 0, + 80, 79, 83, 73, 84, 73, + 79, 78, 0, 84, 69, 88, + 67, 79, 79, 82, 68, 0, + 171, 171, 79, 83, 71, 78, + 80, 0, 0, 0, 2, 0, + 0, 0, 8, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 68, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 3, 12, 0, 0, + 83, 86, 95, 80, 79, 83, + 73, 84, 73, 79, 78, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 171, 171, 171, + 83, 72, 68, 82, 104, 0, + 0, 0, 64, 0, 1, 0, + 26, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 1, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 50, 32, 16, 0, 1, 0, + 0, 0, 54, 0, 0, 5, + 242, 32, 16, 0, 0, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 50, 32, 16, 0, + 1, 0, 0, 0, 70, 16, + 16, 0, 1, 0, 0, 0, + 62, 0, 0, 1, 83, 84, + 65, 84, 116, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0 +}; diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11u.h b/src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11u.h new file mode 100755 index 00000000000..1e0ce04ca65 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11u.h @@ -0,0 +1,424 @@ +/************************************************************************** + * + * 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 "d3d11blit.hlsl.ps.h" +#include "d3d11blit.hlsl.vs.h" + +template<typename index_type = unsigned> +struct triangle_list_indices : public std::vector<index_type> +{ + unsigned base; + bool flip; + + triangle_list_indices() + : base(0), flip(false) + {} + + void poly(unsigned a, unsigned b, unsigned c) + { + this->push_back(base + a); + this->push_back(base + (flip ? c : b)); + this->push_back(base + (flip ? b : c)); + } + + void poly(unsigned a, unsigned b, unsigned c, unsigned d) + { + poly(a, b, c); + poly(a, c, d); + } + + void poly(unsigned a, unsigned b, unsigned c, unsigned d, unsigned e) + { + poly(a, b, c, d); + poly(a, d, e); + } + + void poly(unsigned a, unsigned b, unsigned c, unsigned d, unsigned e, unsigned f) + { + poly(a, b, c, d, e); + poly(a, e, f); + } + + void poly(unsigned a, unsigned b, unsigned c, unsigned d, unsigned e, unsigned f, unsigned g) + { + poly(a, b, c, d, e, f); + poly(a, f, g); + } + + void poly(unsigned a, unsigned b, unsigned c, unsigned d, unsigned e, unsigned f, unsigned g, unsigned h) + { + poly(a, b, c, d, e, f, g); + poly(a, g, h); + } +}; + +struct mesh +{ + ID3D11InputLayout* layout; + ID3D11Buffer* buffer; + D3D11_PRIMITIVE_TOPOLOGY topology; + unsigned vertex_size; + unsigned draw_count; + DXGI_FORMAT index_format; + unsigned index_offset; + + mesh(ID3D11Device* dev, D3D11_PRIMITIVE_TOPOLOGY topology, + const D3D11_INPUT_ELEMENT_DESC *elements, unsigned num_elements, + const void* vs, unsigned vs_size, + const void* vertices, unsigned vertex_size, unsigned num_vertices, + const void* indices = 0, unsigned index_size = 0, unsigned num_indices = 0) + : topology(topology), vertex_size(vertex_size), draw_count(index_size ? num_indices : num_vertices) + { + dev->CreateInputLayout(elements, num_elements, vs, vs_size, &layout); + if(index_size == 2) + index_format = DXGI_FORMAT_R16_UINT; + else if(index_size == 4) + index_format = DXGI_FORMAT_R32_UINT; + else + index_format = DXGI_FORMAT_UNKNOWN; + this->vertex_size = vertex_size; + index_offset = vertex_size * num_vertices; + + D3D11_BUFFER_DESC bufferd; + memset(&bufferd, 0, sizeof(bufferd)); + bufferd.Usage = D3D11_USAGE_IMMUTABLE; + bufferd.BindFlags = D3D11_BIND_VERTEX_BUFFER; + if(index_format) + bufferd.BindFlags |= D3D11_BIND_INDEX_BUFFER; + bufferd.ByteWidth = index_offset + index_format * num_indices; + + char* data = (char*)malloc(bufferd.ByteWidth); + memcpy(data, vertices, vertex_size * num_vertices); + memcpy(data + index_offset, indices, index_size * num_indices); + + D3D11_SUBRESOURCE_DATA buffersd; + buffersd.pSysMem = data; + + ensure(dev->CreateBuffer(&bufferd, &buffersd, &buffer)); + free(data); + } + + ~mesh() + { + layout->Release(); + buffer->Release(); + } + + void bind(ID3D11DeviceContext* ctx) + { + unsigned offset = 0; + ctx->IASetPrimitiveTopology(topology); + ctx->IASetInputLayout(layout); + if(index_format) + ctx->IASetIndexBuffer(buffer, index_format, index_offset); + ctx->IASetVertexBuffers(0, 1, &buffer, &vertex_size, &offset); + } + + void draw_bound(ID3D11DeviceContext* ctx) + { + if(index_format) + ctx->DrawIndexed(draw_count, 0, 0); + else + ctx->Draw(draw_count, 0); + } + + void bind_and_draw(ID3D11DeviceContext* ctx) + { + bind(ctx); + draw_bound(ctx); + } +}; + +mesh* create_tex_quad(ID3D11Device* dev, const BYTE* vs, unsigned vs_size) +{ + float quad_data[] = { + -1, -1, 0, 1, + -1, 1, 0, 0, + 1, -1, 1, 1, + 1, 1, 1, 0, + }; + + D3D11_INPUT_ELEMENT_DESC elements[2] = + { + {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0}, + }; + + return new mesh(dev, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, + elements, 2, + vs, vs_size, + quad_data, 4 * sizeof(float), 4, + 0, 0, 0); +} + +struct d3d11_blitter +{ + mesh* quad; + ID3D11VertexShader* vs; + ID3D11PixelShader* ps; + ID3D11SamplerState* sampler[2]; + + d3d11_blitter(ID3D11Device* dev) + { + quad = create_tex_quad(dev, g_vs_blit, sizeof(g_vs_blit)); + + dev->CreateVertexShader(g_vs_blit, sizeof(g_vs_blit), 0, &vs); + dev->CreatePixelShader(g_ps_blit, sizeof(g_ps_blit), 0, &ps); + + for(unsigned i = 0; i < 2; ++i) + { + D3D11_SAMPLER_DESC samplerd; + memset(&samplerd, 0, sizeof(samplerd)); + samplerd.Filter = i ? D3D11_FILTER_MIN_MAG_MIP_LINEAR : D3D11_FILTER_MIN_MAG_MIP_LINEAR; + samplerd.AddressU = samplerd.AddressV = samplerd.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP; + dev->CreateSamplerState(&samplerd, &sampler[i]); + } + } + + void bind(ID3D11DeviceContext* ctx, ID3D11ShaderResourceView* srv, ID3D11RenderTargetView* rtv, float x, float y, float width, float height, bool linear) + { + D3D11_VIEWPORT vp; + vp.TopLeftX = x; + vp.TopLeftY = y; + vp.Width = width; + vp.Height = height; + vp.MinDepth = 0; + vp.MaxDepth = 1; + ctx->RSSetViewports(1, &vp); + ctx->RSSetState(0); + ctx->OMSetBlendState(0, 0, ~0); + ctx->OMSetDepthStencilState(0, 0); + ctx->OMSetRenderTargets(1, &rtv, 0); + ctx->VSSetShader(vs, 0, 0); + ctx->PSSetShader(ps, 0, 0); + ctx->PSSetShaderResources(0, 1, &srv); + ctx->PSSetSamplers(0, 1, &sampler[!!linear]); + quad->bind(ctx); + } + + void draw_bound(ID3D11DeviceContext* ctx) + { + quad->draw_bound(ctx); + } + + void bind_draw_and_unbind(ID3D11DeviceContext* ctx, ID3D11ShaderResourceView* srv, ID3D11RenderTargetView* rtv, float x, float y, float width, float height, bool linear) + { + bind(ctx, srv, rtv, x, y, width, height, linear); + draw_bound(ctx); + unbind(ctx); + } + + void unbind(ID3D11DeviceContext* ctx) + { + void* null = 0; + ctx->PSSetShaderResources(0, 1, (ID3D11ShaderResourceView**)&null); + ctx->PSSetSamplers(0, 1, (ID3D11SamplerState**)&null); + } +}; + +template<typename T, unsigned n> +struct vec_t +{ + T v[n]; + + T& operator [](unsigned i) + { + return v[i]; + } + + const T& operator [](unsigned i) const + { + return v[i]; + } +}; + +template<typename T, unsigned n> +vec_t<T, n> operator -(const vec_t<T, n> a) +{ + vec_t<T, n> r; + for(unsigned i = 0; i < n; ++i) + r[i] = -a[i]; + return r; +} + +template<typename T, unsigned n> +vec_t<T, n> operator +(const vec_t<T, n>& a, const vec_t<T, n>& b) +{ + vec_t<T, n> r; + for(unsigned i = 0; i < n; ++i) + r[i] = a[i] + b[i]; + return r; +} + +template<typename T, unsigned n> +vec_t<T, n>& operator +=(vec_t<T, n>& a, const vec_t<T, n>& b) +{ + for(unsigned i = 0; i < n; ++i) + a[i] += b[i]; + return a; +} + +template<typename T, unsigned r, unsigned c> +struct mat_t : public vec_t<vec_t<T, r>, c> +{}; + +template<typename T, unsigned n> +vec_t<T, n> operator *(const vec_t<T, n>& a, const T& b) +{ + vec_t<T, n> r; + for(unsigned i = 0; i < n; ++i) + r[i] = a[i] * b; + return r; +} + +template<typename T, unsigned n> +vec_t<T, n> operator *(const T& b, const vec_t<T, n>& a) +{ + vec_t<T, n> r; + for(unsigned i = 0; i < n; ++i) + r[i] = a[i] * b; + return r; +} + +template<typename T, unsigned d, unsigned e> +vec_t<T, e> operator *(const mat_t<T, e, d>& m, const vec_t<T, d>& b) +{ + vec_t<T, e> r; + r = m[0] * b[0]; + for(unsigned i = 1; i < d; ++i) + r += m[i] * b[i]; + return r; +} + +template<typename T, unsigned d, unsigned e, unsigned f> +mat_t<T, e, f> operator *(const mat_t<T, e, d>& m, const mat_t<T, d, f>& b) +{ + mat_t<T, e, f> r; + for(unsigned i = 0; i < d; ++i) + r[i] = m * b[i]; + return r; +} + +template<typename T> +vec_t<T, 3> vec(T a, T b, T c) +{ + vec_t<T, 4> v; + v[0] = a; + v[1] = b; + v[2] = c; + return v; +} + +template<typename T> +vec_t<T, 4> vec(T a, T b, T c, T d) +{ + vec_t<T, 4> v; + v[0] = a; + v[1] = b; + v[2] = c; + v[3] = d; + return v; +} + +typedef mat_t<float, 4, 4> float4x4; +typedef mat_t<float, 4, 3> float4x3; +typedef mat_t<float, 3, 4> float3x4; +typedef mat_t<float, 3, 3> float3x3; + +typedef vec_t<float, 3> float3; +typedef vec_t<float, 4> float4; + +template<typename T> +mat_t<T, 4, 4> mat4x4_frustum(T left, T right, T bottom, T top, T nearval, T farval) +{ + T x = (2.0f * nearval) / (right - left); + T y = (2.0f * nearval) / (top - bottom); + T a = (right + left) / (right - left); + T b = (top + bottom) / (top - bottom); + T c = -(farval + nearval) / (farval - nearval); + T d = -(2.0f * farval * nearval) / (farval - nearval); + T _0 = (T)0; + + mat_t<T, 4, 4> m; + m[0] = vec(x, _0, _0, _0); + m[1] = vec(_0, y, _0, _0); + m[2] = vec(a, b, c, (T)-1); + m[3] = vec(_0, _0, d, _0); + return m; +} + +template<typename T> +mat_t<T, 3, 3> mat3x3_diag(T v) +{ + mat_t<T, 3, 3> m; + T _0 = (T)0; + m[0] = vec(v, _0, _0); + m[1] = vec(_0, v, _0); + m[2] = vec(_0, _0, v); + return m; +} + +template<typename T> +mat_t<T, 4, 4> mat4x4_diag(T v) +{ + mat_t<T, 4, 4> m; + T _0 = (T)0; + m[0] = vec(v, _0, _0, _0); + m[1] = vec(_0, v, _0, _0); + m[2] = vec(_0, _0, v, _0); + m[3] = vec(_0, _0, _0, v); + return m; +} + +template<typename T, unsigned n> +mat_t<T, n, n> mat_push_rotate(const mat_t<T, n, n>& m, unsigned axis, T angle) +{ + T s = (T)sin(angle); + T c = (T)cos(angle); + + mat_t<T, n, n> r = m; + unsigned a = (axis + 1) % 3; + unsigned b = (axis + 2) % 3; + r[a] = (m[a] * c) + (m[b] * s); + r[b] = -(m[a] * s) + (m[b] * c); + return r; +} + +template<typename T, unsigned n> +mat_t<T, n, n> mat_push_translate(const mat_t<T, n, n>& m, float x, float y, float z) +{ + mat_t<T, n, n> r = m; + vec_t<T, n> v; + v[0] = x; + v[1] = y; + v[2] = z; + if(n >= 4) + v[3] = (T)0; + r[3] += m * v; + return r; +} diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11winmain.cpp b/src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11winmain.cpp new file mode 100755 index 00000000000..8e71ec367ea --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11winmain.cpp @@ -0,0 +1,172 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + +#define INITGUID +#include "d3d11app.h" +#include "stdio.h" + +static d3d11_application* app; +static IDXGISwapChain* swap_chain; +static unsigned width, height; +static DXGI_FORMAT format = DXGI_FORMAT_R8G8B8A8_UNORM; +static ID3D11Device* dev; +static ID3D11DeviceContext* ctx; +static int frames = 0; +static int buffer_count = 1; + +LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_SIZE: + width = lParam & 0xffff; + height = lParam >> 16; + + swap_chain->ResizeBuffers(buffer_count, width, height, format, 0); + frames = 0; + break; + case WM_DESTROY: + PostQuitMessage(0); + break; + default: + return DefWindowProc(hwnd, message, wParam, lParam); + } + return 0; +} + +int main(int argc, char** argv) +{ + HINSTANCE hInstance = GetModuleHandle(NULL); + WNDCLASSEXA wcex; + + wcex.cbSize = sizeof(WNDCLASSEX); + + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = 0; + wcex.hCursor = LoadCursor(NULL, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wcex.lpszMenuName = 0; + wcex.lpszClassName = "d3d11"; + wcex.hIconSm = 0; + + RegisterClassExA(&wcex); + + HWND hwnd = CreateWindowA("d3d11", "d3d11", WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); + + if(!hwnd) + return FALSE; + + RECT rc; + GetClientRect(hwnd, &rc ); + width = rc.right - rc.left; + height = rc.bottom - rc.top; + + DXGI_SWAP_CHAIN_DESC swap_chain_desc; + memset(&swap_chain_desc, 0, sizeof(swap_chain_desc)); + swap_chain_desc.BufferDesc.Width = width; + swap_chain_desc.BufferDesc.Height = height; + swap_chain_desc.BufferDesc.Format = format; + swap_chain_desc.SampleDesc.Count = 1; + swap_chain_desc.SampleDesc.Quality = 0; + swap_chain_desc.OutputWindow = hwnd; + swap_chain_desc.Windowed = TRUE; + swap_chain_desc.BufferCount = buffer_count; + swap_chain_desc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; + swap_chain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + swap_chain_desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; + + D3D_FEATURE_LEVEL feature_level = D3D_FEATURE_LEVEL_10_0; + + HRESULT hr = D3D11CreateDeviceAndSwapChain( + NULL, + D3D_DRIVER_TYPE_HARDWARE, + NULL, + D3D11_CREATE_DEVICE_SINGLETHREADED, // | D3D11_CREATE_DEVICE_DEBUG, + NULL, + 0, + D3D11_SDK_VERSION, + &swap_chain_desc, + &swap_chain, + &dev, + &feature_level, + &ctx); + if(!SUCCEEDED(hr)) + { + fprintf(stderr, "Failed to create D3D11 device (hresult %08x)\n", hr); + return 1; + } + + app = d3d11_application_create(); + if(!app->init(dev, argc, argv)) + return 1; + + ShowWindow(hwnd, SW_SHOWDEFAULT); + UpdateWindow(hwnd); + + LARGE_INTEGER freq; + QueryPerformanceFrequency(&freq); + double period = 1.0 / (double)freq.QuadPart; + LARGE_INTEGER ctime_li; + QueryPerformanceCounter(&ctime_li); + double start_time = ctime_li.QuadPart * period; + + MSG msg; + for(;;) + { + if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) + { + if(msg.message == WM_QUIT) + break; + TranslateMessage(&msg); + DispatchMessage(&msg); + } + else if(width && height) + { + ID3D11Texture2D* tex; + static ID3D11RenderTargetView* rtv; + ensure(swap_chain->GetBuffer(0, __uuidof(tex), (void**)&tex)); + ensure(dev->CreateRenderTargetView(tex, NULL, &rtv)); + + QueryPerformanceCounter(&ctime_li); + double ctime = (double)ctime_li.QuadPart * period - start_time; + + app->draw(ctx, rtv, width, height, ctime); + ctx->OMSetRenderTargets(0, 0, 0); + + swap_chain->Present(0, 0); + rtv->Release(); + tex->Release(); + } + else + WaitMessage(); + } + return (int) msg.wParam; +} diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11x11main.cpp b/src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11x11main.cpp new file mode 100755 index 00000000000..2fadf4eecd2 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11x11main.cpp @@ -0,0 +1,114 @@ +#include "d3d11app.h" +#include <X11/Xlib.h> +#include <galliumdxgi.h> +#include <sys/time.h> + +static d3d11_application* app; +static IDXGISwapChain* swap_chain; +unsigned width, height; +DXGI_FORMAT format = DXGI_FORMAT_R8G8B8A8_UNORM; +static ID3D11Device* dev; +static ID3D11DeviceContext* ctx; + +double get_time() +{ + struct timeval tv; + gettimeofday(&tv, 0); + return (double)tv.tv_sec + (double)tv.tv_usec * 0.000001; +} + +int main(int argc, char** argv) +{ + Display* dpy = XOpenDisplay(0); + Visual* visual = DefaultVisual(dpy, DefaultScreen(dpy)); + Colormap cmap = XCreateColormap(dpy, RootWindow(dpy, DefaultScreen(dpy)), visual, AllocNone); + XSetWindowAttributes swa; + swa.colormap = cmap; + swa.border_pixel = 0; + swa.event_mask = StructureNotifyMask; + width = 512; + height = 512; + Window win = XCreateWindow(dpy, RootWindow(dpy, DefaultScreen(dpy)), 0, 0, width, height, 0, CopyFromParent, InputOutput, visual, CWBorderPixel | CWColormap| CWEventMask, &swa); + XMapWindow(dpy, win); + + GalliumDXGIUseX11Display(dpy, 0); + + DXGI_SWAP_CHAIN_DESC swap_chain_desc; + memset(&swap_chain_desc, 0, sizeof(swap_chain_desc)); + swap_chain_desc.BufferDesc.Width = width; + swap_chain_desc.BufferDesc.Height = height; + swap_chain_desc.BufferDesc.Format = format; + swap_chain_desc.SampleDesc.Count = 1; + swap_chain_desc.SampleDesc.Quality = 0; + swap_chain_desc.OutputWindow = (HWND)win; + swap_chain_desc.Windowed = TRUE; + swap_chain_desc.BufferCount = 3; + swap_chain_desc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; + swap_chain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + + D3D_FEATURE_LEVEL feature_level = D3D_FEATURE_LEVEL_10_0; + + HRESULT hr =D3D11CreateDeviceAndSwapChain( + NULL, + D3D_DRIVER_TYPE_HARDWARE, + NULL, + D3D11_CREATE_DEVICE_SINGLETHREADED, + NULL, + 0, + D3D11_SDK_VERSION, + &swap_chain_desc, + &swap_chain, + &dev, + &feature_level, + &ctx); + if(!SUCCEEDED(hr)) + { + fprintf(stderr, "Failed to create D3D11 device (hresult %08x)\n", hr); + return 1; + } + + app = d3d11_application_create(); + if(!app->init(dev, argc, argv)) + return 1; + + double start_time = get_time(); + + MSG msg; + for(;;) + { + XEvent event; + if(XPending(dpy)) + { + XNextEvent(dpy, &event); + if(event.type == DestroyNotify) + break; + switch(event.type) + { + case ConfigureNotify: + width = event.xconfigure.width; + height = event.xconfigure.height; + swap_chain->ResizeBuffers(3, width, height, format, 0); + break; + } + } + else if(width && height) + { + ID3D11Texture2D* tex; + ID3D11RenderTargetView* rtv; + ensure(swap_chain->GetBuffer(0, IID_ID3D11Texture2D, (void**)&tex)); + ensure(dev->CreateRenderTargetView(tex, NULL, &rtv)); + + double ctime = get_time() - start_time; + + app->draw(ctx, rtv, width, height, ctime); + ctx->OMSetRenderTargets(0, 0, 0); + + tex->Release(); + rtv->Release(); + swap_chain->Present(0, 0); + } + else + XPeekEvent(dpy, &event); + } + return (int) msg.wParam; +} diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11gears/d3d11gears.cpp b/src/gallium/state_trackers/d3d1x/progs/d3d11gears/d3d11gears.cpp new file mode 100755 index 00000000000..0edf1f2ef13 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11gears/d3d11gears.cpp @@ -0,0 +1,573 @@ +/* +* Copyright (C) 1999-2001 Brian Paul All Rights Reserved. +* Copyright (C) 2009-2010 Luca Barbieri All Rights Reserved. +* +* 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 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 +* BRIAN PAUL 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. +*/ + +/* +* This is a port of the infamous "glxgears" demo to straight EGL +* Port by Dane Rushton 10 July 2005 +* +* This a rewrite of the 'eglgears' demo in straight Gallium +* Port by Luca Barbieri +* +* This a port of the 'galliumgears' demo to Direct3D 11 +* Port by Luca Barbieri +*/ + +#define _USE_MATH_DEFINES +#include "d3d11app.h" +#include "d3d11u.h" +#include "d3d11gears.hlsl.ps.h" +#include "d3d11gears.hlsl.vs.h" + +#include <stdlib.h> +#include <stdio.h> +#include <math.h> +#include <float.h> + +struct gear +{ + struct mesh* mesh; + float x; + float y; + float t0; + float wmul; + float4 color; +}; + +struct cbuf_t +{ + float4x4 projection; + float4x4 modelview; + float4 light; + float4 diffuse; + float4 specular; + float specular_power; + float padding[3]; +}; + +struct gear gears[3]; + +struct vertex +{ + float position[3]; + float normal[3]; + + vertex(float x, float y, float z, float nx, float ny, float nz) + { + position[0] = x; + position[1] = y; + position[2] = z; + normal[0] = nx; + normal[1] = ny; + normal[2] = nz; + } +}; + +#define VERT(x, y, z) vertices.push_back(vertex((x), (y), (z), (nx), (ny), (nz))) + +static mesh* build_gear(ID3D11Device* dev, int triangle_budget, float inner_radius, float outer_radius, float width, int teeth, float tooth_depth) +{ + int i, j, k; + float r0, r1, r2; + float da; + float nx, ny, nz; + int face; + int segs = 4; + int base_triangles = teeth * segs * 2 * 2; + int divs0 = (triangle_budget / base_triangles) - 1; + int divs = (divs0 > 0) ? divs0 : 1; + float* c = (float*)malloc(teeth * segs * sizeof(float)); + float* s = (float*)malloc(teeth * segs * sizeof(float)); + float* dc = (float*)malloc(teeth * segs * divs * sizeof(float)); + float* ds = (float*)malloc(teeth * segs * divs * sizeof(float)); + int num_vertices = teeth * segs * 2 * (3 + 2 * divs); + int num_triangles = base_triangles * (1 + divs); + printf("Creating gear with %i teeth using %i vertices used in %i triangles\n", teeth, num_vertices, num_triangles); + triangle_list_indices<> indices; + std::vector<vertex> vertices; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth / 2.0f; + r2 = outer_radius + tooth_depth / 2.0f; + + da = (float)(2.0 * M_PI / (teeth * segs * divs)); + for(i = 0; i < teeth * segs * divs; ++i) { + float angle = da * i; + ds[i] = sin(angle); + dc[i] = cos(angle); + } + + for(i = 0; i < teeth * segs; ++i) { + s[i] = ds[i * divs]; + c[i] = dc[i * divs]; + } + + /* faces */ + for(face = -1; face <= 1; face += 2) { + float z = width * face * 0.5f; + nx = 0.0f; + ny = 0.0f; + nz = (float)face; + + indices.flip = face > 0; + + assert(segs == 4); + for(i = 0; i < teeth; ++i) { + VERT(r1 * c[segs * i], r1 * s[segs * i], z); + VERT(r2 * c[segs * i + 1], r2 * s[segs * i + 1], z); + VERT(r2 * c[segs * i + 2], r2 * s[segs * i + 2], z); + VERT(r1 * c[segs * i + 3], r1 * s[segs * i + 3], z); + } + + for(i = 0; i < teeth * segs * divs; ++i) { + VERT(r0 * dc[i], r0 * ds[i], z); + } + + for(i = 0; i < teeth; ++i) { + for(j = i * segs; j < (i + 1) * segs; ++j) { + int nextj = j + 1; + if(nextj == teeth * segs) + nextj = 0; + + for(k = j * divs; k < (j + 1) * divs; ++k) { + int nextk = k + 1; + if(nextk == teeth * segs * divs) + nextk = 0; + indices.poly(teeth * segs + k, j, teeth * segs + nextk); + } + + indices.poly(teeth * segs + nextj * divs, j, nextj); + } + } + + indices.base += teeth * segs * (1 + divs); + } + + /* teeth faces */ + indices.flip = true; + float z = width * 0.5f; + + float* coords = (float*)malloc((segs + 1) * 2 * sizeof(float)); + nz = 0; + for(i = 0; i < teeth; i++) { + int next = i + 1; + if(next == teeth) + next = 0; + + coords[0] = r1 * c[segs * i]; + coords[1] = r1 * s[segs * i]; + coords[2] = r2 * c[segs * i + 1]; + coords[3] = r2 * s[segs * i + 1]; + coords[4] = r2 * c[segs * i + 2]; + coords[5] = r2 * s[segs * i + 2]; + coords[6] = r1 * c[segs * i + 3]; + coords[7] = r1 * s[segs * i + 3]; + coords[8] = r1 * c[segs * next]; + coords[9] = r1 * s[segs * next]; + + for(int j = 0; j < segs; ++j) { + float dx = coords[j * 2] - coords[j * 2 + 2]; + float dy = coords[j * 2 + 1] - coords[j * 2 + 3]; + float len = hypotf(dx, dy); + nx = -dy / len; + ny = dx / len; + VERT(coords[j * 2], coords[j * 2 + 1], z); + VERT(coords[j * 2], coords[j * 2 + 1], -z); + VERT(coords[j * 2 + 2], coords[j * 2 + 3], z); + VERT(coords[j * 2 + 2], coords[j * 2 + 3], -z); + + indices.poly(0, 1, 3, 2); + indices.base += 4; + } + } + free(coords); + + /* inner part - simulate a cylinder */ + indices.flip = true; + for(i = 0; i < teeth * segs * divs; i++) { + int next = i + 1; + if(next == teeth * segs * divs) + next = 0; + + nx = -dc[i]; + ny = -ds[i]; + VERT(r0 * dc[i], r0 * ds[i], -width * 0.5f); + VERT(r0 * dc[i], r0 * ds[i], width * 0.5f); + + indices.poly(i * 2, i * 2 + 1, next * 2 + 1, next * 2); + } + + indices.base += teeth * segs * divs * 2; + free(c); + free(s); + free(dc); + free(ds); + + D3D11_INPUT_ELEMENT_DESC elements[2] = + { + {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0}, + }; + + return new mesh(dev, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST, + elements, 2, + g_vs, sizeof(g_vs), + &vertices[0], sizeof(vertices[0]), vertices.size(), + &indices[0], sizeof(indices[0]), indices.size()); +} + +struct d3d11gears : public d3d11_application +{ + float view_rotx; + float view_roty; + float view_rotz; + int wireframe; + int triangles; + float speed; + float period; + unsigned impressions; + bool blue_only; + + float last_time; + + int cur_width; + int cur_height; + + ID3D11DepthStencilView* zsv; + ID3D11RenderTargetView* offscreen_rtv; + ID3D11ShaderResourceView* offscreen_srv; + + ID3D11Device* dev; + ID3D11BlendState* blend; + ID3D11DepthStencilState* zsa; + + ID3D11PixelShader* ps; + ID3D11VertexShader* vs; + ID3D11Buffer* cb; + + d3d11_blitter* blitter; + + d3d11gears() + : cur_width(-1), cur_height(-1), zsv(0), offscreen_rtv(0), offscreen_srv(0) + { + view_rotx = (float)(M_PI / 9.0); + view_roty = (float)(M_PI / 6.0); + view_rotz = 0.0f; + wireframe = 0; + triangles = 3200; + speed = 1.0f; + period = -1.0f; + impressions = 1; + blue_only = false; + } + + void draw_one(ID3D11DeviceContext* ctx, cbuf_t& cbd, const float4x4& modelview, float angle) + { + for(unsigned i = blue_only ? 2 : 0; i < 3; ++i) + { + float4x4 m2 = modelview; + m2 = mat_push_translate(m2, gears[i].x, gears[i].y, 0.0f); + m2 = mat_push_rotate(m2, 2, angle * gears[i].wmul + gears[i].t0); + + cbd.modelview = m2; + cbd.diffuse = gears[i].color; + cbd.specular = gears[i].color; + cbd.specular_power = 5.0f; + + ctx->UpdateSubresource(cb, 0, 0, &cbd, 0, 0); + + gears[i].mesh->bind_and_draw(ctx); + } + } + + float get_angle(double time) + { + // designed so that 1 = original glxgears speed + float mod_speed = M_PI * 70.0f / 180.0f * speed; + if(period < 0) + return (float)(time * mod_speed); + else + return (float)(cos(time / period) * period * mod_speed); + } + + void init_for_dimensions(unsigned width, unsigned height) + { + if(zsv) + zsv->Release(); + ID3D11Texture2D* zsbuf; + D3D11_TEXTURE2D_DESC zsbufd; + memset(&zsbufd, 0, sizeof(zsbufd)); + zsbufd.Width = width; + zsbufd.Height = height; + zsbufd.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; + zsbufd.ArraySize = 1; + zsbufd.MipLevels = 1; + zsbufd.SampleDesc.Count = 1; + zsbufd.BindFlags = D3D11_BIND_DEPTH_STENCIL; + ensure(dev->CreateTexture2D(&zsbufd, 0, &zsbuf)); + ensure(dev->CreateDepthStencilView(zsbuf, 0, &zsv)); + zsbuf->Release(); + + ID3D11Texture2D* offscreen; + if(offscreen_rtv) + { + offscreen_rtv->Release(); + offscreen_srv->Release(); + offscreen_rtv = 0; + offscreen_srv = 0; + } + + if(impressions > 1) + { + DXGI_FORMAT formats[] = { + DXGI_FORMAT_R32G32B32A32_FLOAT, + DXGI_FORMAT_R16G16B16A16_UNORM, + DXGI_FORMAT_R16G16B16A16_FLOAT, + DXGI_FORMAT_R10G10B10A2_UNORM, + }; + DXGI_FORMAT format = DXGI_FORMAT_R8G8B8A8_UNORM; // this won't work well at all + unsigned needed_support = D3D11_FORMAT_SUPPORT_RENDER_TARGET | D3D11_FORMAT_SUPPORT_BLENDABLE | D3D11_FORMAT_SUPPORT_SHADER_SAMPLE; + for(unsigned i = 0; i < sizeof(formats); ++i) + { + unsigned support; + dev->CheckFormatSupport(DXGI_FORMAT_R32G32B32A32_FLOAT, &support); + if((support & needed_support) == needed_support) + { + format = formats[i]; + break; + } + } + + + D3D11_TEXTURE2D_DESC offscreend; + memset(&offscreend, 0, sizeof(offscreend)); + offscreend.Width = width; + offscreend.Height = height; + + offscreend.Format = format; + offscreend.MipLevels = 1; + offscreend.ArraySize = 1; + offscreend.SampleDesc.Count = 1; + offscreend.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET; + ensure(dev->CreateTexture2D(&offscreend, 0, &offscreen)); + ensure(dev->CreateRenderTargetView(offscreen, 0, &offscreen_rtv)); + ensure(dev->CreateShaderResourceView(offscreen, 0, &offscreen_srv)); + offscreen->Release(); + } + + cur_width = width; + cur_height = height; + } + + void draw(ID3D11DeviceContext* ctx, ID3D11RenderTargetView* rtv, unsigned width, unsigned height, double time) + { + D3D11_VIEWPORT vp; + memset(&vp, 0, sizeof(vp)); + vp.Width = (float)width; + vp.Height = (float)height; + vp.MaxDepth = 1.0f; + + if((int)width != cur_width || (int)height != cur_height) + init_for_dimensions(width, height); + + float4 lightpos = vec(5.0f, 5.0f, 10.0f, 0.0f); + float black[4] = {0.0, 0.0, 0.0, 0}; + + float4x4 proj; + float4x4 m; + + float xr = (float)width / (float)height; + float yr = 1.0f; + if(xr < 1.0f) { + yr /= xr; + xr = 1.0f; + } + proj = mat4x4_frustum(-xr, xr, -yr, yr, 5.0f, 60.0f); + + m = mat4x4_diag(1.0f); + m = mat_push_translate(m, 0.0f, 0.0f, -40.0f); + m = mat_push_rotate(m, 0, view_rotx); + m = mat_push_rotate(m, 1, view_roty); + m = mat_push_rotate(m, 2, view_rotz); + + cbuf_t cbd; + + cbd.projection = proj; + cbd.light = lightpos; + + float blend_factor[4] = {1.0f / (float)impressions, 1.0f / (float)impressions, 1.0f / (float)impressions, 1.0f / (float)impressions}; + + ID3D11RenderTargetView* render_rtv; + if(impressions == 1) + render_rtv = rtv; + else + render_rtv = offscreen_rtv; + + ctx->RSSetViewports(1, &vp); + ctx->ClearRenderTargetView(render_rtv, black); + + ctx->PSSetShader(ps, 0, 0); + ctx->VSSetShader(vs, 0, 0); + + ctx->PSSetConstantBuffers(0, 1, &cb); + ctx->VSSetConstantBuffers(0, 1, &cb); + + if(impressions == 1) + { + ctx->OMSetBlendState(0, 0, ~0); + ctx->OMSetDepthStencilState(0, 0); + ctx->OMSetRenderTargets(1, &rtv, zsv); + ctx->ClearDepthStencilView(zsv, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0, 0); + draw_one(ctx, cbd, m, get_angle(time)); + } + else + { + ctx->OMSetBlendState(blend, blend_factor, ~0); + + float time_delta = (float)time - last_time; + float time_delta_per_impression = time_delta / impressions; + float base_time = last_time + time_delta_per_impression / 2; + for(unsigned impression = 0; impression < impressions; ++impression) + { + float impression_time = base_time + time_delta_per_impression * impression; + + ctx->ClearDepthStencilView(zsv, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0, 0); + + // do early z-pass since we must not write any pixel more than once due to blending + for(unsigned pass = 0; pass < 2; ++pass) + { + if(pass == 0) + { + ctx->OMSetRenderTargets(0, 0, zsv); + ctx->OMSetDepthStencilState(0, 0); + } + else + { + ctx->OMSetRenderTargets(1, &render_rtv, zsv); + ctx->OMSetDepthStencilState(zsa, 0); + } + + draw_one(ctx, cbd, m, get_angle(impression_time)); + } + } + + blitter->bind_draw_and_unbind(ctx, offscreen_srv, rtv, 0, 0, (float)width, (float)height, false); + } + last_time = (float)time; + } + + bool init(ID3D11Device* dev, int argc, char** argv) + { + this->dev = dev; + + for(char** p = argv + 1; *p; ++p) { + if(!strcmp(*p, "-w")) + wireframe = 1; + else if(!strcmp(*p, "-b")) + blue_only = true; + else if(!strcmp(*p, "-t")) + triangles = atoi(*++p); + else if(!strcmp(*p, "-m")) + impressions = (float)atof(*++p); + else if(!strcmp(*p, "-p")) + period = (float)atof(*++p); + else if(!strcmp(*p, "-s")) + speed = (float)atof(*++p); + else { + fprintf(stderr, "Usage: d3d11gears [-v|-w] [-t TRIANGLES]\n"); + fprintf(stderr, "d3d11gears is an enhanced port of glxgears to Direct3D 11\n"); + fprintf(stderr, "\n"); + //fprintf(stderr, "-v\t\tuse per-vertex diffuse-only lighting (classic glxgears look)\n"); + fprintf(stderr, "-w\t\twireframe mode\n"); + fprintf(stderr, "-t TRIANGLES\ttriangle budget (default is 3200)\n"); + fprintf(stderr, "-m IMPRESSIONS\tmotion blur impressions (default is 1)\n"); + fprintf(stderr, "-p PERIOD\tspeed reversal period (default is infinite)\n"); + fprintf(stderr, "-s SPEED\tgear speed (default is 1.0)\n"); + fprintf(stderr, "-b\tonly show blue gear (for faster motion blur)\n"); + return false; + } + } + + ensure(dev->CreatePixelShader(g_ps, sizeof(g_ps), NULL, &ps)); + ensure(dev->CreateVertexShader(g_vs, sizeof(g_vs), NULL, &vs)); + + gears[0].color = vec(0.8f, 0.1f, 0.0f, 1.0f); + gears[1].color = vec(0.0f, 0.8f, 0.2f, 1.0f); + gears[2].color = vec(0.2f, 0.2f, 1.0f, 1.0f); + + gears[0].mesh = build_gear(dev, triangles / 2, 1.0f, 4.0f, 1.0f, 20, 0.7f); + gears[1].mesh = build_gear(dev, triangles / 4, 0.5f, 2.0f, 2.0f, 10, 0.7f); + gears[2].mesh = build_gear(dev, triangles / 4, 1.3f, 2.0f, 0.5f, 10, 0.7f); + + gears[0].x = -3.0f; + gears[0].y = -2.0f; + gears[0].wmul = 1.0f; + gears[0].t0 = 0.0 * M_PI / 180.0f; + + gears[1].x = 3.1f; + gears[1].y = -2.0f; + gears[1].wmul = -2.0f; + gears[1].t0 = -9.0f * (float)M_PI / 180.0f; + + gears[2].x = -3.1f; + gears[2].y = 4.2f; + gears[2].wmul = -2.0f; + gears[2].t0 = -25.0f * (float)M_PI / 180.0f; + + D3D11_BUFFER_DESC bufferd; + memset(&bufferd, 0, sizeof(bufferd)); + bufferd.ByteWidth = sizeof(cbuf_t); + bufferd.Usage = D3D11_USAGE_DEFAULT; + bufferd.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + ensure(dev->CreateBuffer(&bufferd, 0, &cb)); + + if(impressions > 1) + { + D3D11_BLEND_DESC blendd; + memset(&blendd, 0, sizeof(blendd)); + blendd.RenderTarget[0].BlendEnable = TRUE; + blendd.RenderTarget[0].BlendOp = blendd.RenderTarget[0].BlendOpAlpha + = D3D11_BLEND_OP_ADD; + blendd.RenderTarget[0].SrcBlend = blendd.RenderTarget[0].SrcBlendAlpha + = D3D11_BLEND_BLEND_FACTOR; + blendd.RenderTarget[0].DestBlend = blendd.RenderTarget[0].DestBlendAlpha + = D3D11_BLEND_ONE; + blendd.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; + ensure(dev->CreateBlendState(&blendd, &blend)); + + D3D11_DEPTH_STENCIL_DESC zsad; + memset(&zsad, 0, sizeof(zsad)); + zsad.DepthEnable = TRUE; + zsad.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO; + zsad.DepthFunc = D3D11_COMPARISON_EQUAL; + ensure(dev->CreateDepthStencilState(&zsad, &zsa)); + + blitter = new d3d11_blitter(dev); + } + + return true; + } +}; + +d3d11_application* d3d11_application_create() +{ + return new d3d11gears(); +} diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11gears/d3d11gears.hlsl b/src/gallium/state_trackers/d3d1x/progs/d3d11gears/d3d11gears.hlsl new file mode 100755 index 00000000000..679d417cd78 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11gears/d3d11gears.hlsl @@ -0,0 +1,75 @@ +/**************************************************************************
+ *
+ * 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.
+ *
+ **************************************************************************/
+
+cbuffer cb
+{
+ float4x4 proj;
+ float4x4 modelview;
+ float4 light;
+ float4 diffuse;
+ float4 specular;
+ float specular_power;
+};
+
+struct IA2VS
+{
+ float4 position : POSITION;
+ float3 normal : NORMAL;
+};
+
+struct VS2PS
+{
+ float4 position : SV_POSITION;
+ float3 normal : NORMAL;
+ float3 eye : EYE;
+ float3 light : LIGHT;
+};
+
+VS2PS vs(IA2VS input)
+{
+ VS2PS result;
+
+ float3 view = mul((float3x4)modelview, input.position);
+ result.position = mul((float4x4)proj, float4(view, 1));
+ result.light = light - view;
+ result.eye = -view;
+ result.normal = mul((float3x3)modelview, input.normal);
+
+ return result;
+}
+
+float4 ps(VS2PS input) : SV_TARGET
+{
+ float3 nlight = normalize(input.light);
+ float3 nnormal = normalize(input.normal);
+
+ float diffuse_c = saturate(dot(nnormal, nlight));
+ float specular_c = pow(saturate(dot(nnormal, normalize(normalize(input.eye) + nlight))), specular_power);
+
+ return diffuse * diffuse_c + specular * specular_c;
+}
+
+
diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11gears/d3d11gears.hlsl.ps.h b/src/gallium/state_trackers/d3d1x/progs/d3d11gears/d3d11gears.hlsl.ps.h new file mode 100755 index 00000000000..e83b5bb5a8f --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11gears/d3d11gears.hlsl.ps.h @@ -0,0 +1,309 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 +// +// +// fxc /Fhd3d11gears.hlsl.ps.h /Eps /Tps_4_0 d3d11gears.hlsl +// +// +// Buffer Definitions: +// +// cbuffer cb +// { +// +// float4x4 proj; // Offset: 0 Size: 64 [unused] +// float4x4 modelview; // Offset: 64 Size: 64 [unused] +// float4 light; // Offset: 128 Size: 16 [unused] +// float4 diffuse; // Offset: 144 Size: 16 +// float4 specular; // Offset: 160 Size: 16 +// float specular_power; // Offset: 176 Size: 4 +// +// } +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// cb cbuffer NA NA 0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_POSITION 0 xyzw 0 POS float +// NORMAL 0 xyz 1 NONE float xyz +// EYE 0 xyz 2 NONE float xyz +// LIGHT 0 xyz 3 NONE float xyz +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_TARGET 0 xyzw 0 TARGET float xyzw +// +ps_4_0 +dcl_constantbuffer cb0[12], immediateIndexed +dcl_input_ps linear v1.xyz +dcl_input_ps linear v2.xyz +dcl_input_ps linear v3.xyz +dcl_output o0.xyzw +dcl_temps 3 +dp3 r0.x, v2.xyzx, v2.xyzx +rsq r0.x, r0.x +dp3 r0.y, v3.xyzx, v3.xyzx +rsq r0.y, r0.y +mul r0.yzw, r0.yyyy, v3.xxyz +mad r1.xyz, v2.xyzx, r0.xxxx, r0.yzwy +dp3 r0.x, r1.xyzx, r1.xyzx +rsq r0.x, r0.x +mul r1.xyz, r0.xxxx, r1.xyzx +dp3 r0.x, v1.xyzx, v1.xyzx +rsq r0.x, r0.x +mul r2.xyz, r0.xxxx, v1.xyzx +dp3_sat r0.x, r2.xyzx, r1.xyzx +dp3_sat r0.y, r2.xyzx, r0.yzwy +log r0.x, r0.x +mul r0.x, r0.x, cb0[11].x +exp r0.x, r0.x +mul r1.xyzw, r0.xxxx, cb0[10].xyzw +mad o0.xyzw, cb0[9].xyzw, r0.yyyy, r1.xyzw +ret +// Approximately 20 instruction slots used +#endif + +const BYTE g_ps[] = +{ + 68, 88, 66, 67, 91, 23, + 206, 102, 23, 38, 122, 59, + 55, 123, 215, 57, 98, 213, + 215, 191, 1, 0, 0, 0, + 92, 5, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 192, 1, 0, 0, 80, 2, + 0, 0, 132, 2, 0, 0, + 224, 4, 0, 0, 82, 68, + 69, 70, 132, 1, 0, 0, + 1, 0, 0, 0, 64, 0, + 0, 0, 1, 0, 0, 0, + 28, 0, 0, 0, 0, 4, + 255, 255, 0, 1, 0, 0, + 80, 1, 0, 0, 60, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 99, 98, 0, 171, 60, 0, + 0, 0, 6, 0, 0, 0, + 88, 0, 0, 0, 192, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 232, 0, + 0, 0, 0, 0, 0, 0, + 64, 0, 0, 0, 0, 0, + 0, 0, 240, 0, 0, 0, + 0, 0, 0, 0, 0, 1, + 0, 0, 64, 0, 0, 0, + 64, 0, 0, 0, 0, 0, + 0, 0, 240, 0, 0, 0, + 0, 0, 0, 0, 10, 1, + 0, 0, 128, 0, 0, 0, + 16, 0, 0, 0, 0, 0, + 0, 0, 16, 1, 0, 0, + 0, 0, 0, 0, 32, 1, + 0, 0, 144, 0, 0, 0, + 16, 0, 0, 0, 2, 0, + 0, 0, 16, 1, 0, 0, + 0, 0, 0, 0, 40, 1, + 0, 0, 160, 0, 0, 0, + 16, 0, 0, 0, 2, 0, + 0, 0, 16, 1, 0, 0, + 0, 0, 0, 0, 49, 1, + 0, 0, 176, 0, 0, 0, + 4, 0, 0, 0, 2, 0, + 0, 0, 64, 1, 0, 0, + 0, 0, 0, 0, 112, 114, + 111, 106, 0, 171, 171, 171, + 3, 0, 3, 0, 4, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 109, 111, + 100, 101, 108, 118, 105, 101, + 119, 0, 108, 105, 103, 104, + 116, 0, 1, 0, 3, 0, + 1, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 100, 105, 102, 102, 117, 115, + 101, 0, 115, 112, 101, 99, + 117, 108, 97, 114, 0, 115, + 112, 101, 99, 117, 108, 97, + 114, 95, 112, 111, 119, 101, + 114, 0, 0, 0, 3, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 77, 105, 99, 114, 111, 115, + 111, 102, 116, 32, 40, 82, + 41, 32, 72, 76, 83, 76, + 32, 83, 104, 97, 100, 101, + 114, 32, 67, 111, 109, 112, + 105, 108, 101, 114, 32, 57, + 46, 50, 57, 46, 57, 53, + 50, 46, 51, 49, 49, 49, + 0, 171, 171, 171, 73, 83, + 71, 78, 136, 0, 0, 0, + 4, 0, 0, 0, 8, 0, + 0, 0, 104, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 116, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 7, 7, + 0, 0, 123, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 7, 7, + 0, 0, 127, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 7, 7, + 0, 0, 83, 86, 95, 80, + 79, 83, 73, 84, 73, 79, + 78, 0, 78, 79, 82, 77, + 65, 76, 0, 69, 89, 69, + 0, 76, 73, 71, 72, 84, + 0, 171, 171, 171, 79, 83, + 71, 78, 44, 0, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 84, + 65, 82, 71, 69, 84, 0, + 171, 171, 83, 72, 68, 82, + 84, 2, 0, 0, 64, 0, + 0, 0, 149, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 12, 0, 0, 0, 98, 16, + 0, 3, 114, 16, 16, 0, + 1, 0, 0, 0, 98, 16, + 0, 3, 114, 16, 16, 0, + 2, 0, 0, 0, 98, 16, + 0, 3, 114, 16, 16, 0, + 3, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 104, 0, + 0, 2, 3, 0, 0, 0, + 16, 0, 0, 7, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 2, 0, + 0, 0, 70, 18, 16, 0, + 2, 0, 0, 0, 68, 0, + 0, 5, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 7, 34, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 3, 0, + 0, 0, 70, 18, 16, 0, + 3, 0, 0, 0, 68, 0, + 0, 5, 34, 0, 16, 0, + 0, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 226, 0, + 16, 0, 0, 0, 0, 0, + 86, 5, 16, 0, 0, 0, + 0, 0, 6, 25, 16, 0, + 3, 0, 0, 0, 50, 0, + 0, 9, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 18, + 16, 0, 2, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 150, 7, 16, 0, + 0, 0, 0, 0, 16, 0, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 68, 0, 0, 5, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 1, 0, 0, 0, 6, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 16, 0, 0, 7, + 18, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 68, 0, 0, 5, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 2, 0, + 0, 0, 6, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 16, 32, 0, 7, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 16, 32, + 0, 7, 34, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 150, 7, 16, 0, 0, 0, + 0, 0, 47, 0, 0, 5, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 11, 0, 0, 0, + 25, 0, 0, 5, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 242, 0, 16, 0, 1, 0, + 0, 0, 6, 0, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 10, 0, 0, 0, 50, 0, + 0, 10, 242, 32, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 9, 0, 0, 0, 86, 5, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 62, 0, 0, 1, + 83, 84, 65, 84, 116, 0, + 0, 0, 20, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 17, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11gears/d3d11gears.hlsl.vs.h b/src/gallium/state_trackers/d3d1x/progs/d3d11gears/d3d11gears.hlsl.vs.h new file mode 100755 index 00000000000..ee931091c29 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11gears/d3d11gears.hlsl.vs.h @@ -0,0 +1,308 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 +// +// +// fxc /Fhd3d11gears.hlsl.vs.h /Evs /Tvs_4_0 d3d11gears.hlsl +// +// +// Buffer Definitions: +// +// cbuffer cb +// { +// +// float4x4 proj; // Offset: 0 Size: 64 +// float4x4 modelview; // Offset: 64 Size: 64 +// float4 light; // Offset: 128 Size: 16 +// float4 diffuse; // Offset: 144 Size: 16 [unused] +// float4 specular; // Offset: 160 Size: 16 [unused] +// float specular_power; // Offset: 176 Size: 4 [unused] +// +// } +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// cb cbuffer NA NA 0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// POSITION 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_POSITION 0 xyzw 0 POS float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// EYE 0 xyz 2 NONE float xyz +// LIGHT 0 xyz 3 NONE float xyz +// +vs_4_0 +dcl_constantbuffer cb0[9], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_output_siv o0.xyzw, position +dcl_output o1.xyz +dcl_output o2.xyz +dcl_output o3.xyz +dcl_temps 2 +mul r0.xyz, v0.yyyy, cb0[5].xyzx +mad r0.xyz, cb0[4].xyzx, v0.xxxx, r0.xyzx +mad r0.xyz, cb0[6].xyzx, v0.zzzz, r0.xyzx +mad r0.xyz, cb0[7].xyzx, v0.wwww, r0.xyzx +mul r1.xyzw, r0.yyyy, cb0[1].xyzw +mad r1.xyzw, cb0[0].xyzw, r0.xxxx, r1.xyzw +mad r1.xyzw, cb0[2].xyzw, r0.zzzz, r1.xyzw +add o0.xyzw, r1.xyzw, cb0[3].xyzw +mul r1.xyz, v1.yyyy, cb0[5].xyzx +mad r1.xyz, cb0[4].xyzx, v1.xxxx, r1.xyzx +mad o1.xyz, cb0[6].xyzx, v1.zzzz, r1.xyzx +mov o2.xyz, -r0.xyzx +add o3.xyz, -r0.xyzx, cb0[8].xyzx +ret +// Approximately 14 instruction slots used +#endif + +const BYTE g_vs[] = +{ + 68, 88, 66, 67, 251, 82, + 65, 114, 135, 66, 139, 83, + 7, 10, 20, 121, 102, 38, + 44, 36, 1, 0, 0, 0, + 104, 5, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 192, 1, 0, 0, 16, 2, + 0, 0, 160, 2, 0, 0, + 236, 4, 0, 0, 82, 68, + 69, 70, 132, 1, 0, 0, + 1, 0, 0, 0, 64, 0, + 0, 0, 1, 0, 0, 0, + 28, 0, 0, 0, 0, 4, + 254, 255, 0, 1, 0, 0, + 80, 1, 0, 0, 60, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 99, 98, 0, 171, 60, 0, + 0, 0, 6, 0, 0, 0, + 88, 0, 0, 0, 192, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 232, 0, + 0, 0, 0, 0, 0, 0, + 64, 0, 0, 0, 2, 0, + 0, 0, 240, 0, 0, 0, + 0, 0, 0, 0, 0, 1, + 0, 0, 64, 0, 0, 0, + 64, 0, 0, 0, 2, 0, + 0, 0, 240, 0, 0, 0, + 0, 0, 0, 0, 10, 1, + 0, 0, 128, 0, 0, 0, + 16, 0, 0, 0, 2, 0, + 0, 0, 16, 1, 0, 0, + 0, 0, 0, 0, 32, 1, + 0, 0, 144, 0, 0, 0, + 16, 0, 0, 0, 0, 0, + 0, 0, 16, 1, 0, 0, + 0, 0, 0, 0, 40, 1, + 0, 0, 160, 0, 0, 0, + 16, 0, 0, 0, 0, 0, + 0, 0, 16, 1, 0, 0, + 0, 0, 0, 0, 49, 1, + 0, 0, 176, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 64, 1, 0, 0, + 0, 0, 0, 0, 112, 114, + 111, 106, 0, 171, 171, 171, + 3, 0, 3, 0, 4, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 109, 111, + 100, 101, 108, 118, 105, 101, + 119, 0, 108, 105, 103, 104, + 116, 0, 1, 0, 3, 0, + 1, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 100, 105, 102, 102, 117, 115, + 101, 0, 115, 112, 101, 99, + 117, 108, 97, 114, 0, 115, + 112, 101, 99, 117, 108, 97, + 114, 95, 112, 111, 119, 101, + 114, 0, 0, 0, 3, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 77, 105, 99, 114, 111, 115, + 111, 102, 116, 32, 40, 82, + 41, 32, 72, 76, 83, 76, + 32, 83, 104, 97, 100, 101, + 114, 32, 67, 111, 109, 112, + 105, 108, 101, 114, 32, 57, + 46, 50, 57, 46, 57, 53, + 50, 46, 51, 49, 49, 49, + 0, 171, 171, 171, 73, 83, + 71, 78, 72, 0, 0, 0, + 2, 0, 0, 0, 8, 0, + 0, 0, 56, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 15, + 0, 0, 65, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 7, 7, + 0, 0, 80, 79, 83, 73, + 84, 73, 79, 78, 0, 78, + 79, 82, 77, 65, 76, 0, + 79, 83, 71, 78, 136, 0, + 0, 0, 4, 0, 0, 0, + 8, 0, 0, 0, 104, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 116, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 7, 8, 0, 0, 123, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 7, 8, 0, 0, 127, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 7, 8, 0, 0, 83, 86, + 95, 80, 79, 83, 73, 84, + 73, 79, 78, 0, 78, 79, + 82, 77, 65, 76, 0, 69, + 89, 69, 0, 76, 73, 71, + 72, 84, 0, 171, 171, 171, + 83, 72, 68, 82, 68, 2, + 0, 0, 64, 0, 1, 0, + 145, 0, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 9, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 95, 0, 0, 3, + 114, 16, 16, 0, 1, 0, + 0, 0, 103, 0, 0, 4, + 242, 32, 16, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 114, 32, + 16, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 114, 32, + 16, 0, 2, 0, 0, 0, + 101, 0, 0, 3, 114, 32, + 16, 0, 3, 0, 0, 0, + 104, 0, 0, 2, 2, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 0, 0, + 0, 0, 86, 21, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 50, 0, + 0, 10, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 6, 16, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 10, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 6, 0, + 0, 0, 166, 26, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 7, 0, 0, 0, + 246, 31, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 242, 0, 16, 0, + 1, 0, 0, 0, 86, 5, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 50, 0, 0, 10, 242, 0, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 50, 0, + 0, 10, 242, 0, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 166, 10, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 0, 0, 0, 8, + 242, 32, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 1, 0, 0, 0, 86, 21, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 5, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 6, 16, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 50, 0, + 0, 10, 114, 32, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 6, 0, 0, 0, 166, 26, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 54, 0, 0, 6, + 114, 32, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 9, + 114, 32, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 8, 0, + 0, 0, 62, 0, 0, 1, + 83, 84, 65, 84, 116, 0, + 0, 0, 14, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 6, 0, 0, 0, + 5, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11gears/d3d11gears.vcxproj b/src/gallium/state_trackers/d3d1x/progs/d3d11gears/d3d11gears.vcxproj new file mode 100755 index 00000000000..eb2c37a9615 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11gears/d3d11gears.vcxproj @@ -0,0 +1,100 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{706313AB-8F2C-48D2-9F67-31AA043F48C9}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>d3d11gears</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(SolutionDir)\d3d11app</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>d3d11.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(SolutionDir)\d3d11app</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalDependencies>d3d11.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\d3d11app\d3d11winmain.cpp" />
+ <ClCompile Include="d3d11gears.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <CustomBuild Include="d3d11gears.hlsl">
+ <FileType>Document</FileType>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(DXSDK_DIR)\Utilities\bin\x86\fxc.exe" /Fh%(Identity).ps.h /Eps /Tps_4_0 %(Identity)
+"$(DXSDK_DIR)\Utilities\bin\x86\fxc.exe" /Fh%(Identity).vs.h /Evs /Tvs_4_0 %(Identity)</Command>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Identity).ps.h;%(Identity).vs.h;%(Outputs)</Outputs>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\d3d11app\d3d11app.h" />
+ <ClInclude Include="d3d11gears.hlsl.ps.h" />
+ <ClInclude Include="d3d11gears.hlsl.vs.h" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.cpp b/src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.cpp new file mode 100755 index 00000000000..54ca08f23c8 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.cpp @@ -0,0 +1,227 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + +#define _USE_MATH_DEFINES +#include "d3d11app.h" +#include "d3d11spikysphere.hlsl.vs.h" +#include "d3d11spikysphere.hlsl.hs.h" +#include "d3d11spikysphere.hlsl.ds.h" +#include "d3d11spikysphere.hlsl.ps.h" + +#include <stdlib.h> +#include <stdio.h> +#include <math.h> +#include <float.h> +#include <D3DX10math.h> + +struct cb_frame_t +{ + D3DXMATRIX model; + D3DXMATRIX view_proj; + float disp_scale; + float disp_freq; + float tess_factor; +}; + +static float vertex_data[] = +{ + 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0, + + 0.0, 1.0, 0.0, + -1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, + + 0.0, -1.0, 0.0, + 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, + + -1.0, 0.0, 0.0, + 0.0, -1.0, 0.0, + 0.0, 0.0, 1.0, + + 0.0, 1.0, 0.0, + 1.0, 0.0, 0.0, + 0.0, 0.0, -1.0, + + -1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, -1.0, + + 1.0, 0.0, 0.0, + 0.0, -1.0, 0.0, + 0.0, 0.0, -1.0, + + 0.0, -1.0, 0.0, + -1.0, 0.0, 0.0, + 0.0, 0.0, -1.0, +}; + +struct d3d11spikysphere : public d3d11_application +{ + ID3D11Device* dev; + ID3D11PixelShader* ps; + ID3D11DomainShader* ds; + ID3D11HullShader* hs; + ID3D11VertexShader* vs; + ID3D11InputLayout* layout; + ID3D11Buffer* vb; + ID3D11RenderTargetView* rtv; + ID3D11DepthStencilView* zsv; + ID3D11Buffer* cb_frame; + + int cur_width; + int cur_height; + + d3d11spikysphere() + : cur_width(-1), cur_height(-1), zsv(0) + {} + + bool init(ID3D11Device* dev, int argc, char** argv) + { + this->dev = dev; + ensure(dev->CreateVertexShader(g_vs, sizeof(g_vs), NULL, &vs)); + ensure(dev->CreateHullShader(g_hs, sizeof(g_hs), NULL, &hs)); + ensure(dev->CreateDomainShader(g_ds, sizeof(g_ds), NULL, &ds)); + ensure(dev->CreatePixelShader(g_ps, sizeof(g_ps), NULL, &ps)); + + D3D11_INPUT_ELEMENT_DESC elements[1] = + { + {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, + 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, + }; + + ensure(dev->CreateInputLayout(elements, 1, g_vs, sizeof(g_vs), &layout)); + + D3D11_BUFFER_DESC bufferd; + bufferd.ByteWidth = sizeof(vertex_data); + bufferd.Usage = D3D11_USAGE_IMMUTABLE; + bufferd.BindFlags = D3D11_BIND_VERTEX_BUFFER; + bufferd.CPUAccessFlags = 0; + bufferd.MiscFlags = 0; + bufferd.StructureByteStride = 0; + + D3D11_SUBRESOURCE_DATA buffersd; + buffersd.pSysMem = vertex_data; + + ensure(dev->CreateBuffer(&bufferd, &buffersd, &vb)); + + D3D11_BUFFER_DESC cbd; + cbd.ByteWidth = (sizeof(cb_frame_t) + 15) & ~15; + cbd.Usage = D3D11_USAGE_DYNAMIC; + cbd.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + cbd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + cbd.MiscFlags = 0; + cbd.StructureByteStride = 0; + + ensure(dev->CreateBuffer(&cbd, NULL, &cb_frame)); + return true; + } + + void draw(ID3D11DeviceContext* ctx, ID3D11RenderTargetView* rtv, unsigned width, unsigned height, double time) + { + D3D11_VIEWPORT vp; + memset(&vp, 0, sizeof(vp)); + vp.Width = (float)width; + vp.Height = (float)height; + vp.MaxDepth = 1.0f; + + if(width != cur_width || height != cur_height) + { + if(zsv) + zsv->Release(); + ID3D11Texture2D* zsbuf; + D3D11_TEXTURE2D_DESC zsbufd; + memset(&zsbufd, 0, sizeof(zsbufd)); + zsbufd.Width = width; + zsbufd.Height = height; + zsbufd.Format = DXGI_FORMAT_D32_FLOAT; + zsbufd.ArraySize = 1; + zsbufd.MipLevels = 1; + zsbufd.SampleDesc.Count = 1; + zsbufd.BindFlags = D3D11_BIND_DEPTH_STENCIL; + ensure(dev->CreateTexture2D(&zsbufd, 0, &zsbuf)); + ensure(dev->CreateDepthStencilView(zsbuf, 0, &zsv)); + zsbuf->Release(); + } + + float black[4] = {0, 0, 0, 0}; + + D3D11_MAPPED_SUBRESOURCE map; + ensure(ctx->Map(cb_frame, 0, D3D11_MAP_WRITE_DISCARD, 0, &map)); + cb_frame_t* cb_frame_data = (cb_frame_t*)map.pData; + D3DXMatrixIdentity(&cb_frame_data->model); + + D3DXMATRIX view; + D3DXVECTOR3 eye(2.0f * (float)sin(time), 0.0f, 2.0f * (float)cos(time)); + D3DXVECTOR3 at(0, 0, 0); + D3DXVECTOR3 up(0, 1, 0); + D3DXMatrixLookAtLH(&view, &eye, &at, &up); + D3DXMATRIX proj; + D3DXMatrixPerspectiveLH(&proj, 1.1f, 1.1f, 1.0f, 3.0f); + + cb_frame_data->view_proj = view * proj; + float min_tess_factor = 1.0f; + cb_frame_data->tess_factor = (1.0f - (float)cos(time)) * ((64.0f - min_tess_factor) / 2.0f) + min_tess_factor; + cb_frame_data->disp_scale = 0.9f; + //cb_frame_data->disp_scale = (sin(time) + 1.0) / 2.0; + cb_frame_data->disp_freq = 5.0f * (float)M_PI; + //cb_frame_data->disp_freq = (4.0 + 4.0 * cos(time / 5.0)) * PI; + ctx->Unmap(cb_frame, 0); + + ctx->HSSetConstantBuffers(0, 1, &cb_frame); + ctx->DSSetConstantBuffers(0, 1, &cb_frame); + + //ctx->OMSetBlendState(bs, black, ~0); + //ctx->OMSetDepthStencilState(dss, 0); + ctx->OMSetRenderTargets(1, &rtv, zsv); + //ctx->RSSetState(rs); + ctx->RSSetViewports(1, &vp); + + ctx->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST); + ctx->IASetInputLayout(layout); + unsigned stride = 3 * 4; + unsigned offset = 0; + ctx->IASetVertexBuffers(0, 1, &vb, &stride, &offset); + + ctx->VSSetShader(vs, NULL, 0); + ctx->HSSetShader(hs, NULL, 0); + ctx->DSSetShader(ds, NULL, 0); + ctx->GSSetShader(NULL, NULL, 0); + ctx->PSSetShader(ps, NULL, 0); + + ctx->ClearRenderTargetView(rtv, black); + ctx->ClearDepthStencilView(zsv, D3D11_CLEAR_DEPTH, 1.0f, 0); + + ctx->Draw(3 * 8, 0); + } +}; + +d3d11_application* d3d11_application_create() +{ + return new d3d11spikysphere(); +} diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.hlsl b/src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.hlsl new file mode 100755 index 00000000000..1edf42f7693 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.hlsl @@ -0,0 +1,193 @@ +/**************************************************************************
+ *
+ * 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.
+ *
+ **************************************************************************/
+
+#define INPUT_PATCH_SIZE 3
+#define OUTPUT_PATCH_SIZE 3
+
+static const float PI = 3.141592653589793238462643f;
+
+cbuffer cb_frame
+{
+ float4x4 model;
+ float4x4 view_proj;
+ float disp_scale;
+ float disp_freq;
+ float tess_factor;
+};
+
+struct IA2VS
+{
+ float3 position : POSITION;
+};
+
+struct VS2HS
+{
+ float3 position : POSITION;
+};
+
+VS2HS vs(IA2VS input)
+{
+ VS2HS result;
+ result.position = input.position;
+ return result;
+}
+
+struct HS2DS_PATCH
+{
+ float tessouter[3] : SV_TessFactor;
+ float tessinner[1] : SV_InsideTessFactor;
+};
+
+struct HS2DS
+{
+ float3 position : POSITION;
+};
+
+HS2DS_PATCH hs_patch(InputPatch<VS2HS, INPUT_PATCH_SIZE> ip)
+{
+ HS2DS_PATCH result;
+
+ result.tessouter[0] = result.tessouter[1] = result.tessouter[2]
+ = result.tessinner[0] = tess_factor;
+ return result;
+}
+
+[domain("tri")]
+[partitioning("fractional_even")]
+[outputtopology("triangle_cw")]
+[outputcontrolpoints(OUTPUT_PATCH_SIZE)]
+[patchconstantfunc("hs_patch")]
+HS2DS hs(InputPatch<VS2HS, INPUT_PATCH_SIZE> p, uint i : SV_OutputControlPointID)
+{
+ HS2DS result;
+ result.position = p[i].position;
+ return result;
+}
+
+struct DS2PS
+{
+ float4 position : SV_POSITION;
+ float3 objpos : OBJPOS;
+ // float3 worldpos : WORLDPOS;
+ float3 objnormal : OBJNORMAL;
+ float3 worldnormal : WORLDNORMAL;
+};
+
+float3 dnormf_dt(float3 f, float3 dfdt)
+{
+ float ff = dot(f, f);
+ return (ff * dfdt - dot(f, dfdt) * f) / (ff * sqrt(ff));
+}
+
+float3 map(float3 p, float3 q, float3 r, float3 k)
+{
+ return normalize(p * k.x + q * k.y + r * k.z);
+}
+
+float3 dmap_du(float3 p, float3 q, float3 r, float3 k)
+{
+ return dnormf_dt(p * k.x + q * k.y + r * k.z, p);
+}
+
+float dispf(float v)
+{
+ return cos(v * disp_freq);
+}
+
+float ddispf(float v)
+{
+ return -sin(v * disp_freq) * disp_freq;
+}
+
+float disp(float3 k)
+{
+ return dispf(k.x) * dispf(k.y) * dispf(k.z);
+}
+
+float ddisp_du(float3 k)
+{
+ return ddispf(k.x) * dispf(k.y) * dispf(k.z);
+}
+
+float3 ddisp(float3 k)
+{
+ float3 f = float3(dispf(k.x), dispf(k.y), dispf(k.z));
+ return float3(ddispf(k.x) * f.y * f.z, ddispf(k.y) * f.z * f.x, ddispf(k.z) * f.x * f.y);
+}
+
+[domain("tri")]
+DS2PS ds(HS2DS_PATCH input,
+ float3 k : SV_DomainLocation,
+ const OutputPatch<HS2DS, OUTPUT_PATCH_SIZE> patch)
+{
+ DS2PS result;
+
+ float3 s = map(patch[0].position, patch[1].position, patch[2].position, k);
+ float3 d = 1.0 + disp(s) * disp_scale;
+ result.objpos = s * d;
+ result.objpos /= (1.0 + disp_scale);
+ float3 worldpos = mul(model, float4(result.objpos, 1.0f));
+ result.position = mul(view_proj, float4(worldpos, 1.0f));
+
+ float3 dd = ddisp(s) * disp_scale;
+
+ /*
+ float3 ds_du = dmap_du(patch[0].position, patch[1].position, patch[2].position, k);
+ float3 ds_dv = dmap_du(patch[1].position, patch[2].position, patch[0].position, k.yzx);
+ float3 ds_dw = dmap_du(patch[2].position, patch[0].position, patch[1].position, k.zxy);
+
+ float3 ds_dU = ds_du - ds_dw;
+ float3 ds_dV = ds_dv - ds_dw;
+
+ float3 dc_dU = s * dot(dd, ds_dU) + ds_dU * d;
+ float3 dc_dV = s * dot(dd, ds_dV) + ds_dV * d;
+ */
+
+ // this should be faster
+ float3 _u = normalize((abs(s.x) > abs(s.y)) ? float3(-s.z, 0, s.x) : float3(0, -s.z, s.y));
+ float3 _v = normalize(cross(s, _u));
+ float3 dc_dU = s * dot(dd, _u) + _u * d;
+ float3 dc_dV = s * dot(dd, _v) + _v * d;
+
+ result.objnormal = normalize(cross(dc_dU, dc_dV));
+ result.worldnormal = mul(model, result.objnormal);
+ return result;
+}
+
+float4 ps(DS2PS input) : SV_TARGET
+{
+ float3 pseudoambient = float3(0.4, 0.4, 0.6);
+ float3 diffuse = float3(0.6, 0.6, 0.4);
+ float3 light = normalize(float3(0, 1, -1));
+
+ float4 r;
+// r.xyz = normalize(input.objpos + 2 * input.objnormal);
+ r.xyz = pseudoambient * saturate(dot(normalize(input.objnormal), normalize(input.objpos)));
+ r.xyz += saturate(dot(light, normalize(input.worldnormal))) * diffuse;
+
+ r.w = 1;
+ return r;
+}
diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.hlsl.ds.h b/src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.hlsl.ds.h new file mode 100755 index 00000000000..45045e5c613 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.hlsl.ds.h @@ -0,0 +1,623 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 +// +// +// fxc /Fhd3d11spikysphere.hlsl.ds.h /Eds /Tds_5_0 d3d11spikysphere.hlsl +// +// +// Buffer Definitions: +// +// cbuffer cb_frame +// { +// +// float4x4 model; // Offset: 0 Size: 64 +// float4x4 view_proj; // Offset: 64 Size: 64 +// float disp_scale; // Offset: 128 Size: 4 +// float disp_freq; // Offset: 132 Size: 4 +// float tess_factor; // Offset: 136 Size: 4 [unused] +// +// } +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// cb_frame cbuffer NA NA 0 1 +// +// +// +// Patch Constant signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_TessFactor 0 x 0 TRIEDGE float +// SV_TessFactor 1 x 1 TRIEDGE float +// SV_TessFactor 2 x 2 TRIEDGE float +// SV_InsideTessFactor 0 x 3 TRIINT float +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// POSITION 0 xyz 0 NONE float xyz +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_POSITION 0 xyzw 0 POS float xyzw +// OBJPOS 0 xyz 1 NONE float xyz +// OBJNORMAL 0 xyz 2 NONE float xyz +// WORLDNORMAL 0 xyz 3 NONE float xyz +// +// Tessellation Domain # of control points +// -------------------- -------------------- +// Triangle 3 +// +ds_5_0 +dcl_input_control_point_count 3 +dcl_tessellator_domain domain_tri +dcl_globalFlags refactoringAllowed +dcl_constantbuffer cb0[9], immediateIndexed +dcl_input vDomain.xyz +dcl_input vicp[3][0].xyz +dcl_output_siv o0.xyzw, position +dcl_output o1.xyz +dcl_output o2.xyz +dcl_output o3.xyz +dcl_temps 5 +add r0.x, cb0[8].x, l(1.000000) +mul r0.yzw, vDomain.yyyy, vicp[1][0].yyzx +mad r0.yzw, vicp[0][0].yyzx, vDomain.xxxx, r0.yyzw +mad r0.yzw, vicp[2][0].yyzx, vDomain.zzzz, r0.yyzw +dp3 r1.x, r0.yzwy, r0.yzwy +rsq r1.x, r1.x +mul r0.yzw, r0.yyzw, r1.xxxx +mul r1.xyz, r0.wyzw, cb0[8].yyyy +sincos null, r2.xyz, r1.zxyz +sincos r1.xyz, null, -r1.xyzx +mul r1.xyz, r1.xyzx, cb0[8].yyyy +mul r1.xyz, r2.zxyz, r1.xyzx +mul r1.xyz, r2.xyzx, r1.xyzx +mul r1.xyz, r1.xyzx, cb0[8].xxxx +mul r1.w, r2.z, r2.y +mul r1.w, r2.x, r1.w +mad r1.w, r1.w, cb0[8].x, l(1.000000) +mul r2.xyz, r0.wyzw, r1.wwww +div r2.xyz, r2.xyzx, r0.xxxx +mul r3.xyz, r2.yyyy, cb0[1].xyzx +mad r3.xyz, cb0[0].xyzx, r2.xxxx, r3.xyzx +mad r3.xyz, cb0[2].xyzx, r2.zzzz, r3.xyzx +mov o1.xyz, r2.xyzx +add r2.xyz, r3.xyzx, cb0[3].xyzx +mul r3.xyzw, r2.yyyy, cb0[5].xyzw +mad r3.xyzw, cb0[4].xyzw, r2.xxxx, r3.xyzw +mad r2.xyzw, cb0[6].xyzw, r2.zzzz, r3.xyzw +add o0.xyzw, r2.xyzw, cb0[7].xyzw +mov r2.y, l(0) +lt r0.x, |r0.y|, |r0.w| +mul r2.xz, r0.zzwz, l(-1.000000, 0.000000, 1.000000, 0.000000) +mov r2.w, r0.y +movc r2.xyz, r0.xxxx, r2.zxyz, r2.wyxw +dp3 r0.x, r2.xyzx, r2.xyzx +rsq r0.x, r0.x +mul r2.xyz, r0.xxxx, r2.xyzx +mul r3.xyz, r0.wyzw, r2.xyzx +mad r3.xyz, r0.zwyz, r2.yzxy, -r3.xyzx +dp3 r0.x, r3.xyzx, r3.xyzx +rsq r0.x, r0.x +mul r3.xyz, r0.xxxx, r3.xyzx +dp3 r0.x, r1.yzxy, r3.xyzx +mul r3.xyz, r1.wwww, r3.xyzx +mul r4.xyz, r1.wwww, r2.xyzx +dp3 r1.x, r1.zxyz, r2.xyzx +mad r1.xyz, r0.zwyz, r1.xxxx, r4.xyzx +mad r0.xyz, r0.yzwy, r0.xxxx, r3.xyzx +mul r2.xyz, r0.xyzx, r1.xyzx +mad r0.xyz, r1.zxyz, r0.yzxy, -r2.xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +mov o2.xyz, r0.xyzx +mul r1.xyz, r0.yyyy, cb0[1].xyzx +mad r0.xyw, cb0[0].xyxz, r0.xxxx, r1.xyxz +mad o3.xyz, cb0[2].xyzx, r0.zzzz, r0.xywx +ret +// Approximately 57 instruction slots used +#endif + +const BYTE g_ds[] = +{ + 68, 88, 66, 67, 0, 128, + 111, 5, 170, 61, 238, 30, + 169, 104, 139, 245, 182, 233, + 180, 255, 1, 0, 0, 0, + 112, 11, 0, 0, 6, 0, + 0, 0, 56, 0, 0, 0, + 68, 2, 0, 0, 120, 2, + 0, 0, 12, 3, 0, 0, + 168, 3, 0, 0, 212, 10, + 0, 0, 82, 68, 69, 70, + 4, 2, 0, 0, 1, 0, + 0, 0, 104, 0, 0, 0, + 1, 0, 0, 0, 60, 0, + 0, 0, 0, 5, 83, 68, + 0, 1, 0, 0, 210, 1, + 0, 0, 82, 68, 49, 49, + 60, 0, 0, 0, 24, 0, + 0, 0, 32, 0, 0, 0, + 40, 0, 0, 0, 36, 0, + 0, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 92, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 99, 98, 95, 102, 114, 97, + 109, 101, 0, 171, 171, 171, + 92, 0, 0, 0, 5, 0, + 0, 0, 128, 0, 0, 0, + 144, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 72, 1, 0, 0, 0, 0, + 0, 0, 64, 0, 0, 0, + 2, 0, 0, 0, 88, 1, + 0, 0, 0, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 124, 1, + 0, 0, 64, 0, 0, 0, + 64, 0, 0, 0, 2, 0, + 0, 0, 88, 1, 0, 0, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 134, 1, 0, 0, + 128, 0, 0, 0, 4, 0, + 0, 0, 2, 0, 0, 0, + 152, 1, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 188, 1, 0, 0, 132, 0, + 0, 0, 4, 0, 0, 0, + 2, 0, 0, 0, 152, 1, + 0, 0, 0, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 198, 1, + 0, 0, 136, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 152, 1, 0, 0, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 109, 111, 100, 101, + 108, 0, 102, 108, 111, 97, + 116, 52, 120, 52, 0, 171, + 3, 0, 3, 0, 4, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 78, 1, 0, 0, + 118, 105, 101, 119, 95, 112, + 114, 111, 106, 0, 100, 105, + 115, 112, 95, 115, 99, 97, + 108, 101, 0, 102, 108, 111, + 97, 116, 0, 171, 0, 0, + 3, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 145, 1, 0, 0, 100, 105, + 115, 112, 95, 102, 114, 101, + 113, 0, 116, 101, 115, 115, + 95, 102, 97, 99, 116, 111, + 114, 0, 77, 105, 99, 114, + 111, 115, 111, 102, 116, 32, + 40, 82, 41, 32, 72, 76, + 83, 76, 32, 83, 104, 97, + 100, 101, 114, 32, 67, 111, + 109, 112, 105, 108, 101, 114, + 32, 57, 46, 50, 57, 46, + 57, 53, 50, 46, 51, 49, + 49, 49, 0, 171, 73, 83, + 71, 78, 44, 0, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 7, 7, + 0, 0, 80, 79, 83, 73, + 84, 73, 79, 78, 0, 171, + 171, 171, 80, 67, 83, 71, + 140, 0, 0, 0, 4, 0, + 0, 0, 8, 0, 0, 0, + 104, 0, 0, 0, 0, 0, + 0, 0, 13, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 104, 0, 0, 0, 1, 0, + 0, 0, 13, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 1, 0, 0, 0, + 104, 0, 0, 0, 2, 0, + 0, 0, 13, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 1, 0, 0, 0, + 118, 0, 0, 0, 0, 0, + 0, 0, 14, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 83, 86, 95, 84, 101, 115, + 115, 70, 97, 99, 116, 111, + 114, 0, 83, 86, 95, 73, + 110, 115, 105, 100, 101, 84, + 101, 115, 115, 70, 97, 99, + 116, 111, 114, 0, 171, 171, + 79, 83, 71, 78, 148, 0, + 0, 0, 4, 0, 0, 0, + 8, 0, 0, 0, 104, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 116, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 7, 8, 0, 0, 123, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 7, 8, 0, 0, 133, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 7, 8, 0, 0, 83, 86, + 95, 80, 79, 83, 73, 84, + 73, 79, 78, 0, 79, 66, + 74, 80, 79, 83, 0, 79, + 66, 74, 78, 79, 82, 77, + 65, 76, 0, 87, 79, 82, + 76, 68, 78, 79, 82, 77, + 65, 76, 0, 171, 171, 171, + 83, 72, 69, 88, 36, 7, + 0, 0, 80, 0, 4, 0, + 201, 1, 0, 0, 147, 24, + 0, 1, 149, 16, 0, 1, + 106, 8, 0, 1, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 9, 0, + 0, 0, 95, 0, 0, 2, + 114, 192, 1, 0, 95, 0, + 0, 4, 114, 144, 33, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 103, 0, 0, 4, + 242, 32, 16, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 114, 32, + 16, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 114, 32, + 16, 0, 2, 0, 0, 0, + 101, 0, 0, 3, 114, 32, + 16, 0, 3, 0, 0, 0, + 104, 0, 0, 2, 5, 0, + 0, 0, 0, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 128, 32, 0, + 0, 0, 0, 0, 8, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 56, 0, + 0, 7, 226, 0, 16, 0, + 0, 0, 0, 0, 86, 197, + 1, 0, 86, 146, 33, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 50, 0, 0, 9, + 226, 0, 16, 0, 0, 0, + 0, 0, 86, 146, 33, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 6, 192, 1, 0, + 86, 14, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 9, + 226, 0, 16, 0, 0, 0, + 0, 0, 86, 146, 33, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 166, 202, 1, 0, + 86, 14, 16, 0, 0, 0, + 0, 0, 16, 0, 0, 7, + 18, 0, 16, 0, 1, 0, + 0, 0, 150, 7, 16, 0, + 0, 0, 0, 0, 150, 7, + 16, 0, 0, 0, 0, 0, + 68, 0, 0, 5, 18, 0, + 16, 0, 1, 0, 0, 0, + 10, 0, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 7, + 226, 0, 16, 0, 0, 0, + 0, 0, 86, 14, 16, 0, + 0, 0, 0, 0, 6, 0, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 1, 0, 0, 0, + 118, 14, 16, 0, 0, 0, + 0, 0, 86, 133, 32, 0, + 0, 0, 0, 0, 8, 0, + 0, 0, 77, 0, 0, 6, + 0, 208, 0, 0, 114, 0, + 16, 0, 2, 0, 0, 0, + 38, 9, 16, 0, 1, 0, + 0, 0, 77, 0, 0, 7, + 114, 0, 16, 0, 1, 0, + 0, 0, 0, 208, 0, 0, + 70, 2, 16, 128, 65, 0, + 0, 0, 1, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 86, 133, 32, 0, + 0, 0, 0, 0, 8, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 1, 0, + 0, 0, 38, 9, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 6, 128, 32, 0, 0, 0, + 0, 0, 8, 0, 0, 0, + 56, 0, 0, 7, 130, 0, + 16, 0, 1, 0, 0, 0, + 42, 0, 16, 0, 2, 0, + 0, 0, 26, 0, 16, 0, + 2, 0, 0, 0, 56, 0, + 0, 7, 130, 0, 16, 0, + 1, 0, 0, 0, 10, 0, + 16, 0, 2, 0, 0, 0, + 58, 0, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 10, + 130, 0, 16, 0, 1, 0, + 0, 0, 58, 0, 16, 0, + 1, 0, 0, 0, 10, 128, + 32, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 7, 114, 0, + 16, 0, 2, 0, 0, 0, + 118, 14, 16, 0, 0, 0, + 0, 0, 246, 15, 16, 0, + 1, 0, 0, 0, 14, 0, + 0, 7, 114, 0, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 3, 0, + 0, 0, 86, 5, 16, 0, + 2, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 50, 0, + 0, 10, 114, 0, 16, 0, + 3, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 6, 0, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 50, 0, 0, 10, + 114, 0, 16, 0, 3, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 166, 10, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 54, 0, 0, 5, 114, 32, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 0, 0, 0, 8, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 56, 0, + 0, 8, 242, 0, 16, 0, + 3, 0, 0, 0, 86, 5, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 5, 0, 0, 0, + 50, 0, 0, 10, 242, 0, + 16, 0, 3, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 6, 0, 16, 0, 2, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 50, 0, + 0, 10, 242, 0, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 6, 0, 0, 0, 166, 10, + 16, 0, 2, 0, 0, 0, + 70, 14, 16, 0, 3, 0, + 0, 0, 0, 0, 0, 8, + 242, 32, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 7, 0, 0, 0, 54, 0, + 0, 5, 34, 0, 16, 0, + 2, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 49, 0, 0, 9, 18, 0, + 16, 0, 0, 0, 0, 0, + 26, 0, 16, 128, 129, 0, + 0, 0, 0, 0, 0, 0, + 58, 0, 16, 128, 129, 0, + 0, 0, 0, 0, 0, 0, + 56, 0, 0, 10, 82, 0, + 16, 0, 2, 0, 0, 0, + 166, 11, 16, 0, 0, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 128, 191, 0, 0, + 0, 0, 0, 0, 128, 63, + 0, 0, 0, 0, 54, 0, + 0, 5, 130, 0, 16, 0, + 2, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 55, 0, 0, 9, 114, 0, + 16, 0, 2, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 38, 9, 16, 0, + 2, 0, 0, 0, 118, 12, + 16, 0, 2, 0, 0, 0, + 16, 0, 0, 7, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 68, 0, + 0, 5, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 2, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 3, 0, 0, 0, 118, 14, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 50, 0, 0, 10, + 114, 0, 16, 0, 3, 0, + 0, 0, 230, 9, 16, 0, + 0, 0, 0, 0, 150, 4, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 128, 65, 0, + 0, 0, 3, 0, 0, 0, + 16, 0, 0, 7, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 68, 0, + 0, 5, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 3, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 150, 4, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 3, 0, + 0, 0, 246, 15, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 4, 0, 0, 0, + 246, 15, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 16, 0, + 0, 7, 18, 0, 16, 0, + 1, 0, 0, 0, 38, 9, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 50, 0, 0, 9, + 114, 0, 16, 0, 1, 0, + 0, 0, 230, 9, 16, 0, + 0, 0, 0, 0, 6, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 50, 0, 0, 9, + 114, 0, 16, 0, 0, 0, + 0, 0, 150, 7, 16, 0, + 0, 0, 0, 0, 6, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 0, 0, 0, 0, + 38, 9, 16, 0, 1, 0, + 0, 0, 150, 4, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 128, 65, 0, 0, 0, + 2, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 0, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 114, 32, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 1, 0, 0, 0, 86, 5, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 50, 0, 0, 10, 178, 0, + 16, 0, 0, 0, 0, 0, + 70, 136, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 70, 8, 16, 0, + 1, 0, 0, 0, 50, 0, + 0, 10, 114, 32, 16, 0, + 3, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 166, 10, + 16, 0, 0, 0, 0, 0, + 70, 3, 16, 0, 0, 0, + 0, 0, 62, 0, 0, 1, + 83, 84, 65, 84, 148, 0, + 0, 0, 57, 0, 0, 0, + 5, 0, 0, 0, 0, 0, + 0, 0, 6, 0, 0, 0, + 38, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 +}; diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.hlsl.hs.h b/src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.hlsl.hs.h new file mode 100755 index 00000000000..d37502a5a86 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.hlsl.hs.h @@ -0,0 +1,297 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 +// +// +// fxc /Fhd3d11spikysphere.hlsl.hs.h /Ehs /Ths_5_0 d3d11spikysphere.hlsl +// +// +// Buffer Definitions: +// +// cbuffer cb_frame +// { +// +// float4x4 model; // Offset: 0 Size: 64 [unused] +// float4x4 view_proj; // Offset: 64 Size: 64 [unused] +// float disp_scale; // Offset: 128 Size: 4 [unused] +// float disp_freq; // Offset: 132 Size: 4 [unused] +// float tess_factor; // Offset: 136 Size: 4 +// +// } +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// cb_frame cbuffer NA NA 0 1 +// +// +// +// Patch Constant signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_TessFactor 0 x 0 TRIEDGE float x +// SV_TessFactor 1 x 1 TRIEDGE float x +// SV_TessFactor 2 x 2 TRIEDGE float x +// SV_InsideTessFactor 0 x 3 TRIINT float x +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// POSITION 0 xyz 0 NONE float xyz +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// POSITION 0 xyz 0 NONE float xyz +// +// Tessellation Domain # of control points +// -------------------- -------------------- +// Triangle 3 +// +// Tessellation Output Primitive Partitioning Type +// ------------------------------ ------------------ +// Clockwise Triangles Even Fractional +// +hs_5_0 +hs_decls +dcl_input_control_point_count 3 +dcl_output_control_point_count 3 +dcl_tessellator_domain domain_tri +dcl_tessellator_partitioning partitioning_fractional_even +dcl_tessellator_output_primitive output_triangle_cw +dcl_globalFlags refactoringAllowed +dcl_constantbuffer cb0[9], immediateIndexed +hs_fork_phase +dcl_hs_fork_phase_instance_count 3 +dcl_input vForkInstanceID +dcl_output_siv o0.x, finalTriUeq0EdgeTessFactor +dcl_output_siv o1.x, finalTriVeq0EdgeTessFactor +dcl_output_siv o2.x, finalTriWeq0EdgeTessFactor +dcl_temps 1 +dcl_indexrange o0.x 3 +mov r0.x, vForkInstanceID.x +mov o[r0.x + 0].x, cb0[8].z +ret +hs_fork_phase +dcl_output_siv o3.x, finalTriInsideTessFactor +mov o3.x, cb0[8].z +ret +// Approximately 5 instruction slots used +#endif + +const BYTE g_hs[] = +{ + 68, 88, 66, 67, 174, 23, + 253, 184, 171, 234, 181, 122, + 114, 17, 23, 172, 69, 130, + 17, 19, 1, 0, 0, 0, + 212, 4, 0, 0, 6, 0, + 0, 0, 56, 0, 0, 0, + 68, 2, 0, 0, 120, 2, + 0, 0, 172, 2, 0, 0, + 64, 3, 0, 0, 56, 4, + 0, 0, 82, 68, 69, 70, + 4, 2, 0, 0, 1, 0, + 0, 0, 104, 0, 0, 0, + 1, 0, 0, 0, 60, 0, + 0, 0, 0, 5, 83, 72, + 0, 1, 0, 0, 210, 1, + 0, 0, 82, 68, 49, 49, + 60, 0, 0, 0, 24, 0, + 0, 0, 32, 0, 0, 0, + 40, 0, 0, 0, 36, 0, + 0, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 92, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 99, 98, 95, 102, 114, 97, + 109, 101, 0, 171, 171, 171, + 92, 0, 0, 0, 5, 0, + 0, 0, 128, 0, 0, 0, + 144, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 72, 1, 0, 0, 0, 0, + 0, 0, 64, 0, 0, 0, + 0, 0, 0, 0, 88, 1, + 0, 0, 0, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 124, 1, + 0, 0, 64, 0, 0, 0, + 64, 0, 0, 0, 0, 0, + 0, 0, 88, 1, 0, 0, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 134, 1, 0, 0, + 128, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 152, 1, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 188, 1, 0, 0, 132, 0, + 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 152, 1, + 0, 0, 0, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 198, 1, + 0, 0, 136, 0, 0, 0, + 4, 0, 0, 0, 2, 0, + 0, 0, 152, 1, 0, 0, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 109, 111, 100, 101, + 108, 0, 102, 108, 111, 97, + 116, 52, 120, 52, 0, 171, + 3, 0, 3, 0, 4, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 78, 1, 0, 0, + 118, 105, 101, 119, 95, 112, + 114, 111, 106, 0, 100, 105, + 115, 112, 95, 115, 99, 97, + 108, 101, 0, 102, 108, 111, + 97, 116, 0, 171, 0, 0, + 3, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 145, 1, 0, 0, 100, 105, + 115, 112, 95, 102, 114, 101, + 113, 0, 116, 101, 115, 115, + 95, 102, 97, 99, 116, 111, + 114, 0, 77, 105, 99, 114, + 111, 115, 111, 102, 116, 32, + 40, 82, 41, 32, 72, 76, + 83, 76, 32, 83, 104, 97, + 100, 101, 114, 32, 67, 111, + 109, 112, 105, 108, 101, 114, + 32, 57, 46, 50, 57, 46, + 57, 53, 50, 46, 51, 49, + 49, 49, 0, 171, 73, 83, + 71, 78, 44, 0, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 7, 7, + 0, 0, 80, 79, 83, 73, + 84, 73, 79, 78, 0, 171, + 171, 171, 79, 83, 71, 78, + 44, 0, 0, 0, 1, 0, + 0, 0, 8, 0, 0, 0, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 7, 8, 0, 0, + 80, 79, 83, 73, 84, 73, + 79, 78, 0, 171, 171, 171, + 80, 67, 83, 71, 140, 0, + 0, 0, 4, 0, 0, 0, + 8, 0, 0, 0, 104, 0, + 0, 0, 0, 0, 0, 0, + 13, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 1, 14, 0, 0, 104, 0, + 0, 0, 1, 0, 0, 0, + 13, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 1, 14, 0, 0, 104, 0, + 0, 0, 2, 0, 0, 0, + 13, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 1, 14, 0, 0, 118, 0, + 0, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 1, 14, 0, 0, 83, 86, + 95, 84, 101, 115, 115, 70, + 97, 99, 116, 111, 114, 0, + 83, 86, 95, 73, 110, 115, + 105, 100, 101, 84, 101, 115, + 115, 70, 97, 99, 116, 111, + 114, 0, 171, 171, 83, 72, + 69, 88, 240, 0, 0, 0, + 80, 0, 3, 0, 60, 0, + 0, 0, 113, 0, 0, 1, + 147, 24, 0, 1, 148, 24, + 0, 1, 149, 16, 0, 1, + 150, 32, 0, 1, 151, 24, + 0, 1, 106, 8, 0, 1, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 9, 0, 0, 0, 115, 0, + 0, 1, 153, 0, 0, 2, + 3, 0, 0, 0, 95, 0, + 0, 2, 0, 112, 1, 0, + 103, 0, 0, 4, 18, 32, + 16, 0, 0, 0, 0, 0, + 17, 0, 0, 0, 103, 0, + 0, 4, 18, 32, 16, 0, + 1, 0, 0, 0, 18, 0, + 0, 0, 103, 0, 0, 4, + 18, 32, 16, 0, 2, 0, + 0, 0, 19, 0, 0, 0, + 104, 0, 0, 2, 1, 0, + 0, 0, 91, 0, 0, 4, + 18, 32, 16, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 54, 0, 0, 4, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 112, 1, 0, 54, 0, + 0, 7, 18, 32, 144, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 42, 128, 32, 0, + 0, 0, 0, 0, 8, 0, + 0, 0, 62, 0, 0, 1, + 115, 0, 0, 1, 103, 0, + 0, 4, 18, 32, 16, 0, + 3, 0, 0, 0, 20, 0, + 0, 0, 54, 0, 0, 6, + 18, 32, 16, 0, 3, 0, + 0, 0, 42, 128, 32, 0, + 0, 0, 0, 0, 8, 0, + 0, 0, 62, 0, 0, 1, + 83, 84, 65, 84, 148, 0, + 0, 0, 5, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 10, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 +}; diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.hlsl.ps.h b/src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.hlsl.ps.h new file mode 100755 index 00000000000..9af20713716 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.hlsl.ps.h @@ -0,0 +1,211 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 +// +// +// fxc /Fhd3d11spikysphere.hlsl.ps.h /Eps /Tps_4_0 d3d11spikysphere.hlsl +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_POSITION 0 xyzw 0 POS float +// OBJPOS 0 xyz 1 NONE float xyz +// OBJNORMAL 0 xyz 2 NONE float xyz +// WORLDNORMAL 0 xyz 3 NONE float xyz +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_TARGET 0 xyzw 0 TARGET float xyzw +// +ps_4_0 +dcl_input_ps linear v1.xyz +dcl_input_ps linear v2.xyz +dcl_input_ps linear v3.xyz +dcl_output o0.xyzw +dcl_temps 2 +dp3 r0.x, v2.xyzx, v2.xyzx +rsq r0.x, r0.x +mul r0.xyz, r0.xxxx, v2.xyzx +dp3 r0.w, v1.xyzx, v1.xyzx +rsq r0.w, r0.w +mul r1.xyz, r0.wwww, v1.xyzx +dp3_sat r0.x, r0.xyzx, r1.xyzx +dp3 r0.y, v3.xyzx, v3.xyzx +rsq r0.y, r0.y +mul r0.yz, r0.yyyy, v3.yyzy +dp2_sat r0.y, l(0.707107, -0.707107, 0.000000, 0.000000), r0.yzyy +mul r0.yzw, r0.yyyy, l(0.000000, 0.600000, 0.600000, 0.400000) +mad o0.xyz, r0.xxxx, l(0.400000, 0.400000, 0.600000, 0.000000), r0.yzwy +mov o0.w, l(1.000000) +ret +// Approximately 15 instruction slots used +#endif + +const BYTE g_ps[] = +{ + 68, 88, 66, 67, 211, 117, + 143, 38, 226, 40, 181, 77, + 39, 255, 33, 137, 74, 241, + 40, 100, 1, 0, 0, 0, + 184, 3, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 140, 0, 0, 0, 40, 1, + 0, 0, 92, 1, 0, 0, + 60, 3, 0, 0, 82, 68, + 69, 70, 80, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 28, 0, 0, 0, 0, 4, + 255, 255, 0, 1, 0, 0, + 28, 0, 0, 0, 77, 105, + 99, 114, 111, 115, 111, 102, + 116, 32, 40, 82, 41, 32, + 72, 76, 83, 76, 32, 83, + 104, 97, 100, 101, 114, 32, + 67, 111, 109, 112, 105, 108, + 101, 114, 32, 57, 46, 50, + 57, 46, 57, 53, 50, 46, + 51, 49, 49, 49, 0, 171, + 171, 171, 73, 83, 71, 78, + 148, 0, 0, 0, 4, 0, + 0, 0, 8, 0, 0, 0, + 104, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 116, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 7, 7, 0, 0, + 123, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 7, 7, 0, 0, + 133, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 7, 7, 0, 0, + 83, 86, 95, 80, 79, 83, + 73, 84, 73, 79, 78, 0, + 79, 66, 74, 80, 79, 83, + 0, 79, 66, 74, 78, 79, + 82, 77, 65, 76, 0, 87, + 79, 82, 76, 68, 78, 79, + 82, 77, 65, 76, 0, 171, + 171, 171, 79, 83, 71, 78, + 44, 0, 0, 0, 1, 0, + 0, 0, 8, 0, 0, 0, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 83, 86, 95, 84, 65, 82, + 71, 69, 84, 0, 171, 171, + 83, 72, 68, 82, 216, 1, + 0, 0, 64, 0, 0, 0, + 118, 0, 0, 0, 98, 16, + 0, 3, 114, 16, 16, 0, + 1, 0, 0, 0, 98, 16, + 0, 3, 114, 16, 16, 0, + 2, 0, 0, 0, 98, 16, + 0, 3, 114, 16, 16, 0, + 3, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 104, 0, + 0, 2, 2, 0, 0, 0, + 16, 0, 0, 7, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 2, 0, + 0, 0, 70, 18, 16, 0, + 2, 0, 0, 0, 68, 0, + 0, 5, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 0, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 2, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 16, 32, 0, 7, + 18, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 16, 0, 0, 7, 34, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 3, 0, + 0, 0, 70, 18, 16, 0, + 3, 0, 0, 0, 68, 0, + 0, 5, 34, 0, 16, 0, + 0, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 98, 0, + 16, 0, 0, 0, 0, 0, + 86, 5, 16, 0, 0, 0, + 0, 0, 86, 22, 16, 0, + 3, 0, 0, 0, 15, 32, + 0, 10, 34, 0, 16, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 243, 4, 53, 63, + 243, 4, 53, 191, 0, 0, + 0, 0, 0, 0, 0, 0, + 150, 5, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 10, + 226, 0, 16, 0, 0, 0, + 0, 0, 86, 5, 16, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 154, 153, 25, 63, 154, 153, + 25, 63, 205, 204, 204, 62, + 50, 0, 0, 12, 114, 32, + 16, 0, 0, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 2, 64, 0, 0, + 205, 204, 204, 62, 205, 204, + 204, 62, 154, 153, 25, 63, + 0, 0, 0, 0, 150, 7, + 16, 0, 0, 0, 0, 0, + 54, 0, 0, 5, 130, 32, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 62, 0, 0, 1, + 83, 84, 65, 84, 116, 0, + 0, 0, 15, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 12, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.hlsl.vs.h b/src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.hlsl.vs.h new file mode 100755 index 00000000000..c71b0c3ae0b --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.hlsl.vs.h @@ -0,0 +1,105 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 +// +// +// fxc /Fhd3d11spikysphere.hlsl.vs.h /Evs /Tvs_4_0 d3d11spikysphere.hlsl +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// POSITION 0 xyz 0 NONE float xyz +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// POSITION 0 xyz 0 NONE float xyz +// +vs_4_0 +dcl_input v0.xyz +dcl_output o0.xyz +mov o0.xyz, v0.xyzx +ret +// Approximately 2 instruction slots used +#endif + +const BYTE g_vs[] = +{ + 68, 88, 66, 67, 71, 140, + 219, 201, 207, 71, 236, 3, + 158, 208, 157, 229, 54, 227, + 221, 132, 1, 0, 0, 0, + 176, 1, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 140, 0, 0, 0, 192, 0, + 0, 0, 244, 0, 0, 0, + 52, 1, 0, 0, 82, 68, + 69, 70, 80, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 28, 0, 0, 0, 0, 4, + 254, 255, 0, 1, 0, 0, + 28, 0, 0, 0, 77, 105, + 99, 114, 111, 115, 111, 102, + 116, 32, 40, 82, 41, 32, + 72, 76, 83, 76, 32, 83, + 104, 97, 100, 101, 114, 32, + 67, 111, 109, 112, 105, 108, + 101, 114, 32, 57, 46, 50, + 57, 46, 57, 53, 50, 46, + 51, 49, 49, 49, 0, 171, + 171, 171, 73, 83, 71, 78, + 44, 0, 0, 0, 1, 0, + 0, 0, 8, 0, 0, 0, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 7, 7, 0, 0, + 80, 79, 83, 73, 84, 73, + 79, 78, 0, 171, 171, 171, + 79, 83, 71, 78, 44, 0, + 0, 0, 1, 0, 0, 0, + 8, 0, 0, 0, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 7, 8, 0, 0, 80, 79, + 83, 73, 84, 73, 79, 78, + 0, 171, 171, 171, 83, 72, + 68, 82, 56, 0, 0, 0, + 64, 0, 1, 0, 14, 0, + 0, 0, 95, 0, 0, 3, + 114, 16, 16, 0, 0, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 114, 32, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 0, 0, 0, 0, 62, 0, + 0, 1, 83, 84, 65, 84, + 116, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 +}; diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.vcxproj b/src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.vcxproj new file mode 100755 index 00000000000..0cf8c709d4e --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.vcxproj @@ -0,0 +1,102 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{64988608-72A3-4125-8A31-45E1EACE8F0A}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>d3d11spikysphere</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(SolutionDir)\d3d11app</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>d3d11.lib;d3dx10.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(SolutionDir)\d3d11app</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalDependencies>d3d11.lib;d3dx10.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\d3d11app\d3d11winmain.cpp" />
+ <ClCompile Include="d3d11spikysphere.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <CustomBuild Include="d3d11spikysphere.hlsl">
+ <FileType>Document</FileType>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(DXSDK_DIR)\Utilities\bin\x86\fxc.exe" /Fh%(Identity).ps.h /Eps /Tps_4_0 %(Identity)
+"$(DXSDK_DIR)\Utilities\bin\x86\fxc.exe" /Fh%(Identity).vs.h /Evs /Tvs_4_0 %(Identity)</Command>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Identity).ps.h;%(Identity).vs.h;%(Outputs)</Outputs>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\d3d11app\d3d11app.h" />
+ <ClInclude Include="d3d11spikysphere.hlsl.ds.h" />
+ <ClInclude Include="d3d11spikysphere.hlsl.hs.h" />
+ <ClInclude Include="d3d11spikysphere.hlsl.ps.h" />
+ <ClInclude Include="d3d11spikysphere.hlsl.vs.h" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11tex/d3d11tex.cpp b/src/gallium/state_trackers/d3d1x/progs/d3d11tex/d3d11tex.cpp new file mode 100755 index 00000000000..19c669be9c8 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11tex/d3d11tex.cpp @@ -0,0 +1,116 @@ +/************************************************************************** + * + * 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 "d3d11app.h" +#include "d3d11u.h" +#include "d3d11tex.hlsl.ps.h" +#include "d3d11tex.hlsl.vs.h" +#include "../data/cornell_box_image.h" +#include "../data/tux_image.h" + +struct d3d11tex : public d3d11_application +{ + ID3D11PixelShader* ps; + ID3D11VertexShader* vs; + mesh* quad; + ID3D11ShaderResourceView* srv[2]; + ID3D11SamplerState* samp[2]; + + virtual bool init(ID3D11Device* dev, int argc, char** argv) + { + ensure(dev->CreatePixelShader(g_ps, sizeof(g_ps), NULL, &ps)); + ensure(dev->CreateVertexShader(g_vs, sizeof(g_vs), NULL, &vs)); + + quad = create_tex_quad(dev, g_vs, sizeof(g_vs)); + + D3D11_TEXTURE2D_DESC texd; + memset(&texd, 0, sizeof(texd)); + texd.BindFlags = D3D11_BIND_SHADER_RESOURCE; + texd.Usage = D3D11_USAGE_IMMUTABLE; + texd.SampleDesc.Count = 1; + texd.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + texd.Width = 32; + texd.Height = 32; + texd.ArraySize = 1; + texd.MipLevels = 1; + + D3D11_SUBRESOURCE_DATA texsd; + texsd.SysMemPitch = 32 * 4; + texsd.SysMemSlicePitch = 32 * 32 * 4; + + ID3D11Texture2D* tex; + + texsd.pSysMem = g_cornell_box_image; + ensure(dev->CreateTexture2D(&texd, &texsd, &tex)); + ensure(dev->CreateShaderResourceView(tex, 0, &srv[0])); + tex->Release(); + + texsd.pSysMem = g_tux_image; + ensure(dev->CreateTexture2D(&texd, &texsd, &tex)); + ensure(dev->CreateShaderResourceView(tex, 0, &srv[1])); + tex->Release(); + + D3D11_SAMPLER_DESC sampd; + memset(&sampd, 0, sizeof(sampd)); + sampd.AddressU = D3D11_TEXTURE_ADDRESS_WRAP; + sampd.AddressV = D3D11_TEXTURE_ADDRESS_WRAP; + sampd.AddressW = D3D11_TEXTURE_ADDRESS_WRAP; + sampd.MinLOD = -FLT_MAX; + sampd.MaxLOD = FLT_MAX; + + sampd.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; + dev->CreateSamplerState(&sampd, &samp[0]); + + sampd.Filter = D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT; + dev->CreateSamplerState(&sampd, &samp[1]); + return true; + } + + virtual void draw(ID3D11DeviceContext* ctx, ID3D11RenderTargetView* rtv, unsigned width, unsigned height, double time) + { + D3D11_VIEWPORT vp; + memset(&vp, 0, sizeof(vp)); + vp.Width = (float)width; + vp.Height = (float)height; + vp.MaxDepth = 1.0f; + + ctx->OMSetRenderTargets(1, &rtv, 0); + ctx->RSSetViewports(1, &vp); + + ctx->VSSetShader(vs, NULL, 0); + ctx->PSSetShader(ps, NULL, 0); + + ctx->PSSetShaderResources(0, 2, srv); + ctx->PSSetSamplers(0, 2, samp); + + quad->bind_and_draw(ctx); + } +}; + +d3d11_application* d3d11_application_create() +{ + return new d3d11tex(); +} diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11tex/d3d11tex.hlsl b/src/gallium/state_trackers/d3d1x/progs/d3d11tex/d3d11tex.hlsl new file mode 100755 index 00000000000..1a6990cc396 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11tex/d3d11tex.hlsl @@ -0,0 +1,66 @@ +/**************************************************************************
+ *
+ * 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.
+ *
+ **************************************************************************/
+
+Texture2D tex0;
+Texture2D tex1;
+sampler samp0;
+sampler samp1;
+
+struct IA2VS
+{
+ float4 position : POSITION;
+ float2 texcoord : TEXCOORD;
+};
+
+struct VS2PS
+{
+ float4 position : SV_POSITION;
+ float2 texcoord : TEXCOORD;
+ float4 factors : FACTORS;
+};
+
+VS2PS vs(IA2VS input)
+{
+ VS2PS result;
+ result.position = input.position;
+ result.texcoord = input.texcoord * 8;
+ result.factors.xy = input.texcoord;
+ result.factors.zw = 1 - input.texcoord;
+ return result;
+}
+
+float4 ps(VS2PS input) : SV_TARGET
+{
+ float4 a0 = tex0.Sample(samp0, input.texcoord);
+ float4 a1 = tex0.Sample(samp1, input.texcoord);
+ float4 a = a0 * input.factors.z + a1 * input.factors.x;
+
+ float4 b0 = tex1.Sample(samp0, input.texcoord);
+ float4 b1 = tex1.Sample(samp1, input.texcoord);
+ float4 b = b0 * input.factors.z + b1 * input.factors.x;
+
+ return a * input.factors.w + b * input.factors.y;
+}
diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11tex/d3d11tex.hlsl.ps.h b/src/gallium/state_trackers/d3d1x/progs/d3d11tex/d3d11tex.hlsl.ps.h new file mode 100755 index 00000000000..29795a99097 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11tex/d3d11tex.hlsl.ps.h @@ -0,0 +1,234 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 +// +// +// fxc /Fhd3d11tex.hlsl.ps.h /Eps /Tps_4_0 d3d11tex.hlsl +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// samp0 sampler NA NA 0 1 +// samp1 sampler NA NA 1 1 +// tex0 texture float4 2d 0 1 +// tex1 texture float4 2d 1 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_POSITION 0 xyzw 0 POS float +// TEXCOORD 0 xy 1 NONE float xy +// FACTORS 0 xyzw 2 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_TARGET 0 xyzw 0 TARGET float xyzw +// +ps_4_0 +dcl_sampler s0, mode_default +dcl_sampler s1, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_resource_texture2d (float,float,float,float) t1 +dcl_input_ps linear v1.xy +dcl_input_ps linear v2.xyzw +dcl_output o0.xyzw +dcl_temps 3 +sample r0.xyzw, v1.xyxx, t1.xyzw, s1 +mul r0.xyzw, r0.xyzw, v2.xxxx +sample r1.xyzw, v1.xyxx, t1.xyzw, s0 +mad r0.xyzw, r1.xyzw, v2.zzzz, r0.xyzw +mul r0.xyzw, r0.xyzw, v2.yyyy +sample r1.xyzw, v1.xyxx, t0.xyzw, s1 +mul r1.xyzw, r1.xyzw, v2.xxxx +sample r2.xyzw, v1.xyxx, t0.xyzw, s0 +mad r1.xyzw, r2.xyzw, v2.zzzz, r1.xyzw +mad o0.xyzw, r1.xyzw, v2.wwww, r0.xyzw +ret +// Approximately 11 instruction slots used +#endif + +const BYTE g_ps[] = +{ + 68, 88, 66, 67, 139, 203, + 114, 37, 104, 101, 201, 12, + 197, 147, 116, 98, 80, 214, + 173, 207, 1, 0, 0, 0, + 16, 4, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 32, 1, 0, 0, 152, 1, + 0, 0, 204, 1, 0, 0, + 148, 3, 0, 0, 82, 68, + 69, 70, 228, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 28, 0, 0, 0, 0, 4, + 255, 255, 0, 1, 0, 0, + 178, 0, 0, 0, 156, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 162, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 168, 0, 0, 0, + 2, 0, 0, 0, 5, 0, + 0, 0, 4, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 1, 0, 0, 0, + 12, 0, 0, 0, 173, 0, + 0, 0, 2, 0, 0, 0, + 5, 0, 0, 0, 4, 0, + 0, 0, 255, 255, 255, 255, + 1, 0, 0, 0, 1, 0, + 0, 0, 12, 0, 0, 0, + 115, 97, 109, 112, 48, 0, + 115, 97, 109, 112, 49, 0, + 116, 101, 120, 48, 0, 116, + 101, 120, 49, 0, 77, 105, + 99, 114, 111, 115, 111, 102, + 116, 32, 40, 82, 41, 32, + 72, 76, 83, 76, 32, 83, + 104, 97, 100, 101, 114, 32, + 67, 111, 109, 112, 105, 108, + 101, 114, 32, 57, 46, 50, + 57, 46, 57, 53, 50, 46, + 51, 49, 49, 49, 0, 171, + 73, 83, 71, 78, 112, 0, + 0, 0, 3, 0, 0, 0, + 8, 0, 0, 0, 80, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 92, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 3, 3, 0, 0, 101, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 15, 15, 0, 0, 83, 86, + 95, 80, 79, 83, 73, 84, + 73, 79, 78, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 70, 65, 67, 84, 79, + 82, 83, 0, 171, 171, 171, + 79, 83, 71, 78, 44, 0, + 0, 0, 1, 0, 0, 0, + 8, 0, 0, 0, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 83, 86, + 95, 84, 65, 82, 71, 69, + 84, 0, 171, 171, 83, 72, + 68, 82, 192, 1, 0, 0, + 64, 0, 0, 0, 112, 0, + 0, 0, 90, 0, 0, 3, + 0, 96, 16, 0, 0, 0, + 0, 0, 90, 0, 0, 3, + 0, 96, 16, 0, 1, 0, + 0, 0, 88, 24, 0, 4, + 0, 112, 16, 0, 0, 0, + 0, 0, 85, 85, 0, 0, + 88, 24, 0, 4, 0, 112, + 16, 0, 1, 0, 0, 0, + 85, 85, 0, 0, 98, 16, + 0, 3, 50, 16, 16, 0, + 1, 0, 0, 0, 98, 16, + 0, 3, 242, 16, 16, 0, + 2, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 104, 0, + 0, 2, 3, 0, 0, 0, + 69, 0, 0, 9, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 16, 16, 0, 1, 0, + 0, 0, 70, 126, 16, 0, + 1, 0, 0, 0, 0, 96, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 7, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 6, 16, 16, 0, + 2, 0, 0, 0, 69, 0, + 0, 9, 242, 0, 16, 0, + 1, 0, 0, 0, 70, 16, + 16, 0, 1, 0, 0, 0, + 70, 126, 16, 0, 1, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 9, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 166, 26, 16, 0, 2, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 86, 21, 16, 0, 2, 0, + 0, 0, 69, 0, 0, 9, + 242, 0, 16, 0, 1, 0, + 0, 0, 70, 16, 16, 0, + 1, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 7, + 242, 0, 16, 0, 1, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 6, 16, + 16, 0, 2, 0, 0, 0, + 69, 0, 0, 9, 242, 0, + 16, 0, 2, 0, 0, 0, + 70, 16, 16, 0, 1, 0, + 0, 0, 70, 126, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 9, 242, 0, + 16, 0, 1, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 166, 26, 16, 0, + 2, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 50, 0, 0, 9, 242, 32, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 246, 31, 16, 0, + 2, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 62, 0, 0, 1, 83, 84, + 65, 84, 116, 0, 0, 0, + 11, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0 +}; diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11tex/d3d11tex.hlsl.vs.h b/src/gallium/state_trackers/d3d1x/progs/d3d11tex/d3d11tex.hlsl.vs.h new file mode 100755 index 00000000000..3aae79441a3 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11tex/d3d11tex.hlsl.vs.h @@ -0,0 +1,153 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 +// +// +// fxc /Fhd3d11tex.hlsl.vs.h /Evs /Tvs_4_0 d3d11tex.hlsl +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// POSITION 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_POSITION 0 xyzw 0 POS float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// FACTORS 0 xyzw 2 NONE float xyzw +// +vs_4_0 +dcl_input v0.xyzw +dcl_input v1.xy +dcl_output_siv o0.xyzw, position +dcl_output o1.xy +dcl_output o2.xyzw +mov o0.xyzw, v0.xyzw +mul o1.xy, v1.xyxx, l(8.000000, 8.000000, 0.000000, 0.000000) +mad o2.xyzw, v1.xyxy, l(1.000000, 1.000000, -1.000000, -1.000000), l(0.000000, 0.000000, 1.000000, 1.000000) +ret +// Approximately 4 instruction slots used +#endif + +const BYTE g_vs[] = +{ + 68, 88, 66, 67, 129, 141, + 49, 0, 46, 132, 26, 20, + 64, 38, 200, 86, 119, 202, + 172, 121, 1, 0, 0, 0, + 160, 2, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 140, 0, 0, 0, 224, 0, + 0, 0, 88, 1, 0, 0, + 36, 2, 0, 0, 82, 68, + 69, 70, 80, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 28, 0, 0, 0, 0, 4, + 254, 255, 0, 1, 0, 0, + 28, 0, 0, 0, 77, 105, + 99, 114, 111, 115, 111, 102, + 116, 32, 40, 82, 41, 32, + 72, 76, 83, 76, 32, 83, + 104, 97, 100, 101, 114, 32, + 67, 111, 109, 112, 105, 108, + 101, 114, 32, 57, 46, 50, + 57, 46, 57, 53, 50, 46, + 51, 49, 49, 49, 0, 171, + 171, 171, 73, 83, 71, 78, + 76, 0, 0, 0, 2, 0, + 0, 0, 8, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 65, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 3, 3, 0, 0, + 80, 79, 83, 73, 84, 73, + 79, 78, 0, 84, 69, 88, + 67, 79, 79, 82, 68, 0, + 171, 171, 79, 83, 71, 78, + 112, 0, 0, 0, 3, 0, + 0, 0, 8, 0, 0, 0, + 80, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 92, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 3, 12, 0, 0, + 101, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 0, 0, 0, + 83, 86, 95, 80, 79, 83, + 73, 84, 73, 79, 78, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 70, 65, 67, + 84, 79, 82, 83, 0, 171, + 171, 171, 83, 72, 68, 82, + 196, 0, 0, 0, 64, 0, + 1, 0, 49, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 0, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 1, 0, 0, 0, + 103, 0, 0, 4, 242, 32, + 16, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 50, 32, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 2, 0, 0, 0, 54, 0, + 0, 5, 242, 32, 16, 0, + 0, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 10, 50, 32, + 16, 0, 1, 0, 0, 0, + 70, 16, 16, 0, 1, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 65, 0, 0, + 0, 65, 0, 0, 0, 0, + 0, 0, 0, 0, 50, 0, + 0, 15, 242, 32, 16, 0, + 2, 0, 0, 0, 70, 20, + 16, 0, 1, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 128, 63, 0, 0, 128, 63, + 0, 0, 128, 191, 0, 0, + 128, 191, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 128, 63, + 0, 0, 128, 63, 62, 0, + 0, 1, 83, 84, 65, 84, + 116, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 5, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 +}; diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11tex/d3d11tex.vcxproj b/src/gallium/state_trackers/d3d1x/progs/d3d11tex/d3d11tex.vcxproj new file mode 100755 index 00000000000..ea6cc038687 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11tex/d3d11tex.vcxproj @@ -0,0 +1,98 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{14F73B97-2DC6-423E-97D9-64E3368713DC}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>d3d11tex</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(SolutionDir)\d3d11app</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>d3d11.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(SolutionDir)\d3d11app</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalDependencies>d3d11.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <CustomBuild Include="d3d11tex.hlsl">
+ <FileType>Document</FileType>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(DXSDK_DIR)\Utilities\bin\x86\fxc.exe" /Fh%(Identity).ps.h /Eps /Tps_4_0 %(Identity)
+"$(DXSDK_DIR)\Utilities\bin\x86\fxc.exe" /Fh%(Identity).vs.h /Evs /Tvs_4_0 %(Identity)</Command>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Identity).ps.h;%(Identity).vs.h;%(Outputs)</Outputs>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\d3d11app\d3d11app.h" />
+ <ClInclude Include="d3d11tex.hlsl.ps.h" />
+ <ClInclude Include="d3d11tex.hlsl.vs.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\d3d11app\d3d11winmain.cpp" />
+ <ClCompile Include="d3d11tex.cpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11tri/d3d11tri.cpp b/src/gallium/state_trackers/d3d1x/progs/d3d11tri/d3d11tri.cpp new file mode 100755 index 00000000000..524b7d1c01c --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11tri/d3d11tri.cpp @@ -0,0 +1,120 @@ +/************************************************************************** + * + * 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 "d3d11app.h" +#include "d3d11tri.hlsl.ps.h" +#include "d3d11tri.hlsl.vs.h" + +struct vertex { + float position[4]; + float color[4]; +}; + +static struct vertex vertices[3] = +{ + { + { 0.0f, 0.9f, 0.5f, 1.0f }, + { 1.0f, 0.0f, 0.0f, 1.0f } + }, + { + { 0.9f, -0.9f, 0.5f, 1.0f }, + { 0.0f, 0.0f, 1.0f, 1.0f } + }, + { + { -0.9f, -0.9f, 0.5f, 1.0f }, + { 0.0f, 1.0f, 0.0f, 1.0f } + }, +}; + +struct d3d11tri : public d3d11_application +{ + ID3D11PixelShader* ps; + ID3D11VertexShader* vs; + ID3D11InputLayout* layout; + ID3D11Buffer* vb; + + virtual bool init(ID3D11Device* dev, int argc, char** argv) + { + ensure(dev->CreatePixelShader(g_ps, sizeof(g_ps), NULL, &ps)); + ensure(dev->CreateVertexShader(g_vs, sizeof(g_vs), NULL, &vs)); + + D3D11_INPUT_ELEMENT_DESC elements[] = + { + // inverse order to make sure the implementation can properly parse the vertex shader signature + {"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, + }; + + ensure(dev->CreateInputLayout(elements, sizeof(elements) / sizeof(elements[0]), g_vs, sizeof(g_vs), &layout)); + D3D11_BUFFER_DESC bufferd; + bufferd.ByteWidth = sizeof(vertices); + bufferd.Usage = D3D11_USAGE_IMMUTABLE; + bufferd.BindFlags = D3D11_BIND_VERTEX_BUFFER; + bufferd.CPUAccessFlags = 0; + bufferd.MiscFlags = 0; + bufferd.StructureByteStride = 0; + + D3D11_SUBRESOURCE_DATA buffersd; + buffersd.pSysMem = vertices; + buffersd.SysMemPitch = sizeof(vertices); + buffersd.SysMemSlicePitch = sizeof(vertices); + + ensure(dev->CreateBuffer(&bufferd, &buffersd, &vb)); + + return true; + } + + virtual void draw(ID3D11DeviceContext* ctx, ID3D11RenderTargetView* rtv, unsigned width, unsigned height, double time) + { + float clear_color[4] = {1, 0, 1, 1}; + D3D11_VIEWPORT vp; + memset(&vp, 0, sizeof(vp)); + vp.Width = (float)width; + vp.Height = (float)height; + vp.MaxDepth = 1.0f; + + ctx->OMSetRenderTargets(1, &rtv, 0); + ctx->RSSetViewports(1, &vp); + + ctx->ClearRenderTargetView(rtv, clear_color); + + ctx->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + ctx->IASetInputLayout(layout); + unsigned stride = 2 * 4 * 4; + unsigned offset = 0; + ctx->IASetVertexBuffers(0, 1, &vb, &stride, &offset); + + ctx->VSSetShader(vs, NULL, 0); + ctx->PSSetShader(ps, NULL, 0); + + ctx->Draw(3, 0); + } +}; + +d3d11_application* d3d11_application_create() +{ + return new d3d11tri(); +} diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11tri/d3d11tri.hlsl b/src/gallium/state_trackers/d3d1x/progs/d3d11tri/d3d11tri.hlsl new file mode 100755 index 00000000000..6bdd448ce0a --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11tri/d3d11tri.hlsl @@ -0,0 +1,50 @@ +/**************************************************************************
+ *
+ * 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.
+ *
+ **************************************************************************/
+
+struct IA2VS
+{
+ float4 position : POSITION;
+ float4 color : COLOR;
+};
+
+struct VS2PS
+{
+ float4 position : SV_POSITION;
+ float4 color : COLOR;
+};
+
+VS2PS vs(IA2VS input)
+{
+ VS2PS result;
+ result.position = input.position;
+ result.color = input.color;
+ return result;
+}
+
+float4 ps(VS2PS input) : SV_TARGET
+{
+ return input.color;
+}
diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11tri/d3d11tri.hlsl.ps.h b/src/gallium/state_trackers/d3d1x/progs/d3d11tri/d3d11tri.hlsl.ps.h new file mode 100755 index 00000000000..68eaee5cb2e --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11tri/d3d11tri.hlsl.ps.h @@ -0,0 +1,112 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 +// +// +// fxc /Fhd3d11tri.hlsl.ps.h /Eps /Tps_4_0 d3d11tri.hlsl +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_POSITION 0 xyzw 0 POS float +// COLOR 0 xyzw 1 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_TARGET 0 xyzw 0 TARGET float xyzw +// +ps_4_0 +dcl_input_ps linear v1.xyzw +dcl_output o0.xyzw +mov o0.xyzw, v1.xyzw +ret +// Approximately 2 instruction slots used +#endif + +const BYTE g_ps[] = +{ + 68, 88, 66, 67, 206, 120, + 117, 238, 118, 127, 10, 87, + 80, 75, 114, 198, 95, 2, + 120, 102, 1, 0, 0, 0, + 208, 1, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 140, 0, 0, 0, 224, 0, + 0, 0, 20, 1, 0, 0, + 84, 1, 0, 0, 82, 68, + 69, 70, 80, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 28, 0, 0, 0, 0, 4, + 255, 255, 0, 1, 0, 0, + 28, 0, 0, 0, 77, 105, + 99, 114, 111, 115, 111, 102, + 116, 32, 40, 82, 41, 32, + 72, 76, 83, 76, 32, 83, + 104, 97, 100, 101, 114, 32, + 67, 111, 109, 112, 105, 108, + 101, 114, 32, 57, 46, 50, + 57, 46, 57, 53, 50, 46, + 51, 49, 49, 49, 0, 171, + 171, 171, 73, 83, 71, 78, + 76, 0, 0, 0, 2, 0, + 0, 0, 8, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 68, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 15, 0, 0, + 83, 86, 95, 80, 79, 83, + 73, 84, 73, 79, 78, 0, + 67, 79, 76, 79, 82, 0, + 171, 171, 79, 83, 71, 78, + 44, 0, 0, 0, 1, 0, + 0, 0, 8, 0, 0, 0, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 83, 86, 95, 84, 65, 82, + 71, 69, 84, 0, 171, 171, + 83, 72, 68, 82, 56, 0, + 0, 0, 64, 0, 0, 0, + 14, 0, 0, 0, 98, 16, + 0, 3, 242, 16, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 242, 32, 16, 0, + 0, 0, 0, 0, 70, 30, + 16, 0, 1, 0, 0, 0, + 62, 0, 0, 1, 83, 84, + 65, 84, 116, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0 +}; diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11tri/d3d11tri.hlsl.vs.h b/src/gallium/state_trackers/d3d1x/progs/d3d11tri/d3d11tri.hlsl.vs.h new file mode 100755 index 00000000000..43e2a18275c --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11tri/d3d11tri.hlsl.vs.h @@ -0,0 +1,128 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 +// +// +// fxc /Fhd3d11tri.hlsl.vs.h /Evs /Tvs_4_0 d3d11tri.hlsl +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// POSITION 0 xyzw 0 NONE float xyzw +// COLOR 0 xyzw 1 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------ ------ +// SV_POSITION 0 xyzw 0 POS float xyzw +// COLOR 0 xyzw 1 NONE float xyzw +// +vs_4_0 +dcl_input v0.xyzw +dcl_input v1.xyzw +dcl_output_siv o0.xyzw, position +dcl_output o1.xyzw +mov o0.xyzw, v0.xyzw +mov o1.xyzw, v1.xyzw +ret +// Approximately 3 instruction slots used +#endif + +const BYTE g_vs[] = +{ + 68, 88, 66, 67, 190, 171, + 186, 20, 44, 105, 95, 129, + 137, 204, 223, 72, 251, 159, + 126, 176, 1, 0, 0, 0, + 28, 2, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 140, 0, 0, 0, 220, 0, + 0, 0, 48, 1, 0, 0, + 160, 1, 0, 0, 82, 68, + 69, 70, 80, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 28, 0, 0, 0, 0, 4, + 254, 255, 0, 1, 0, 0, + 28, 0, 0, 0, 77, 105, + 99, 114, 111, 115, 111, 102, + 116, 32, 40, 82, 41, 32, + 72, 76, 83, 76, 32, 83, + 104, 97, 100, 101, 114, 32, + 67, 111, 109, 112, 105, 108, + 101, 114, 32, 57, 46, 50, + 57, 46, 57, 53, 50, 46, + 51, 49, 49, 49, 0, 171, + 171, 171, 73, 83, 71, 78, + 72, 0, 0, 0, 2, 0, + 0, 0, 8, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 65, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 15, 0, 0, + 80, 79, 83, 73, 84, 73, + 79, 78, 0, 67, 79, 76, + 79, 82, 0, 171, 79, 83, + 71, 78, 76, 0, 0, 0, + 2, 0, 0, 0, 8, 0, + 0, 0, 56, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 68, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 80, + 79, 83, 73, 84, 73, 79, + 78, 0, 67, 79, 76, 79, + 82, 0, 171, 171, 83, 72, + 68, 82, 104, 0, 0, 0, + 64, 0, 1, 0, 26, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 1, 0, + 0, 0, 103, 0, 0, 4, + 242, 32, 16, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 1, 0, 0, 0, + 54, 0, 0, 5, 242, 32, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 242, 32, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 1, 0, 0, 0, 62, 0, + 0, 1, 83, 84, 65, 84, + 116, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 +}; diff --git a/src/gallium/state_trackers/d3d1x/progs/d3d11tri/d3d11tri.vcxproj b/src/gallium/state_trackers/d3d1x/progs/d3d11tri/d3d11tri.vcxproj new file mode 100755 index 00000000000..3ed69fc6f2c --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/d3d11tri/d3d11tri.vcxproj @@ -0,0 +1,99 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{1C11FC42-BFB5-4668-97F6-C5B564754F8F}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>d3d11tri</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(SolutionDir)\d3d11app</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>d3d11.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(SolutionDir)\d3d11app</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalDependencies>d3d11.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <CustomBuild Include="d3d11tri.hlsl">
+ <FileType>Document</FileType>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(DXSDK_DIR)\Utilities\bin\x86\fxc.exe" /Fh%(Identity).ps.h /Eps /Tps_4_0 %(Identity)</Command>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Identity).ps.h;%(Identity).vs.h;%(Outputs)</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(DXSDK_DIR)\Utilities\bin\x86\fxc.exe" /Fh%(Identity).ps.h /Eps /Tps_4_0 %(Identity)</Command>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Identity).ps.h;%(Identity).vs.h;%(Outputs)</Outputs>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\d3d11app\d3d11app.h" />
+ <ClInclude Include="d3d11tri.hlsl.ps.h" />
+ <ClInclude Include="d3d11tri.hlsl.vs.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\d3d11app\d3d11winmain.cpp" />
+ <ClCompile Include="d3d11tri.cpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/src/gallium/state_trackers/d3d1x/progs/data/cornell_box_image.h b/src/gallium/state_trackers/d3d1x/progs/data/cornell_box_image.h new file mode 100755 index 00000000000..007b151f093 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/data/cornell_box_image.h @@ -0,0 +1,1028 @@ +unsigned char g_cornell_box_image[] = +{ + 159, 93, 68, 255, + 171, 158, 120, 255, + 167, 153, 115, 255, + 167, 158, 121, 255, + 166, 161, 122, 255, + 164, 163, 122, 255, + 163, 166, 124, 255, + 165, 166, 125, 255, + 164, 167, 125, 255, + 161, 171, 126, 255, + 161, 170, 126, 255, + 162, 171, 125, 255, + 162, 172, 125, 255, + 160, 172, 125, 255, + 161, 174, 127, 255, + 159, 175, 124, 255, + 158, 175, 124, 255, + 156, 177, 124, 255, + 155, 177, 123, 255, + 154, 178, 122, 255, + 154, 178, 122, 255, + 153, 178, 120, 255, + 151, 180, 120, 255, + 150, 181, 120, 255, + 149, 181, 121, 255, + 146, 181, 118, 255, + 146, 181, 118, 255, + 143, 182, 116, 255, + 141, 183, 114, 255, + 137, 183, 112, 255, + 139, 186, 111, 255, + 89, 176, 70, 255, + 156, 49, 33, 255, + 154, 90, 62, 255, + 172, 149, 110, 255, + 169, 145, 105, 255, + 168, 149, 109, 255, + 166, 153, 112, 255, + 165, 156, 114, 255, + 164, 159, 115, 255, + 164, 162, 117, 255, + 163, 165, 118, 255, + 161, 166, 121, 255, + 160, 169, 122, 255, + 160, 170, 121, 255, + 160, 171, 120, 255, + 158, 173, 119, 255, + 159, 174, 120, 255, + 158, 174, 120, 255, + 154, 177, 119, 255, + 154, 177, 117, 255, + 151, 178, 115, 255, + 151, 179, 115, 255, + 148, 181, 113, 255, + 146, 181, 114, 255, + 142, 182, 113, 255, + 141, 181, 110, 255, + 140, 182, 108, 255, + 136, 183, 106, 255, + 132, 184, 102, 255, + 127, 185, 99, 255, + 132, 187, 101, 255, + 85, 173, 66, 255, + 44, 170, 34, 255, + 173, 59, 45, 255, + 157, 48, 32, 255, + 155, 90, 62, 255, + 171, 148, 108, 255, + 168, 143, 103, 255, + 167, 148, 105, 255, + 166, 151, 108, 255, + 167, 154, 110, 255, + 166, 158, 111, 255, + 164, 161, 113, 255, + 162, 164, 113, 255, + 162, 166, 116, 255, + 162, 168, 118, 255, + 157, 168, 109, 255, + 150, 167, 101, 255, + 150, 169, 102, 255, + 149, 169, 102, 255, + 145, 173, 100, 255, + 150, 177, 107, 255, + 151, 181, 112, 255, + 150, 182, 110, 255, + 149, 183, 108, 255, + 146, 184, 107, 255, + 143, 184, 106, 255, + 139, 185, 104, 255, + 135, 185, 102, 255, + 132, 186, 100, 255, + 128, 186, 97, 255, + 133, 189, 99, 255, + 88, 175, 62, 255, + 42, 171, 33, 255, + 56, 184, 44, 255, + 178, 64, 46, 255, + 175, 62, 45, 255, + 164, 51, 35, 255, + 158, 91, 65, 255, + 173, 148, 109, 255, + 169, 143, 103, 255, + 169, 147, 106, 255, + 167, 151, 106, 255, + 166, 154, 109, 255, + 164, 159, 111, 255, + 165, 162, 111, 255, + 165, 166, 112, 255, + 160, 165, 106, 255, + 200, 203, 172, 255, + 245, 248, 244, 255, + 242, 243, 236, 255, + 241, 243, 236, 255, + 246, 247, 244, 255, + 197, 212, 170, 255, + 155, 184, 101, 255, + 157, 189, 107, 255, + 155, 190, 105, 255, + 152, 191, 103, 255, + 149, 192, 101, 255, + 144, 193, 99, 255, + 140, 191, 95, 255, + 134, 192, 93, 255, + 136, 194, 96, 255, + 91, 179, 65, 255, + 46, 177, 34, 255, + 57, 188, 45, 255, + 59, 193, 45, 255, + 186, 65, 49, 255, + 187, 66, 49, 255, + 191, 66, 51, 255, + 176, 51, 37, 255, + 160, 88, 61, 255, + 172, 148, 108, 255, + 169, 144, 102, 255, + 168, 147, 105, 255, + 167, 151, 106, 255, + 167, 156, 108, 255, + 168, 160, 111, 255, + 167, 165, 110, 255, + 167, 169, 110, 255, + 181, 186, 132, 255, + 217, 220, 190, 255, + 215, 219, 185, 255, + 217, 222, 185, 255, + 220, 227, 187, 255, + 188, 204, 131, 255, + 172, 198, 104, 255, + 172, 202, 105, 255, + 167, 203, 102, 255, + 163, 203, 102, 255, + 157, 202, 99, 255, + 153, 201, 96, 255, + 146, 199, 93, 255, + 148, 199, 96, 255, + 95, 183, 62, 255, + 47, 191, 38, 255, + 62, 201, 51, 255, + 61, 200, 49, 255, + 61, 198, 51, 255, + 192, 66, 51, 255, + 198, 68, 54, 255, + 209, 70, 56, 255, + 207, 70, 55, 255, + 181, 52, 37, 255, + 161, 90, 62, 255, + 172, 146, 106, 255, + 171, 145, 104, 255, + 171, 150, 107, 255, + 171, 155, 109, 255, + 171, 159, 111, 255, + 171, 164, 111, 255, + 171, 168, 113, 255, + 172, 172, 110, 255, + 172, 173, 107, 255, + 172, 180, 106, 255, + 173, 187, 106, 255, + 177, 192, 107, 255, + 181, 198, 109, 255, + 181, 202, 110, 255, + 179, 203, 110, 255, + 175, 204, 105, 255, + 169, 204, 104, 255, + 163, 202, 101, 255, + 153, 202, 97, 255, + 151, 199, 97, 255, + 97, 181, 63, 255, + 51, 190, 38, 255, + 66, 222, 53, 255, + 68, 218, 56, 255, + 64, 209, 53, 255, + 62, 205, 51, 255, + 197, 67, 54, 255, + 205, 71, 58, 255, + 220, 75, 58, 255, + 229, 75, 63, 255, + 211, 71, 54, 255, + 172, 48, 31, 255, + 162, 114, 79, 255, + 160, 148, 102, 255, + 159, 149, 102, 255, + 157, 153, 104, 255, + 158, 154, 107, 255, + 158, 157, 107, 255, + 158, 160, 108, 255, + 160, 161, 112, 255, + 158, 164, 110, 255, + 158, 166, 110, 255, + 158, 167, 108, 255, + 158, 168, 109, 255, + 156, 171, 106, 255, + 153, 170, 104, 255, + 151, 170, 102, 255, + 149, 171, 99, 255, + 145, 171, 99, 255, + 142, 171, 97, 255, + 140, 173, 97, 255, + 111, 173, 78, 255, + 46, 178, 29, 255, + 68, 223, 55, 255, + 72, 242, 62, 255, + 71, 231, 60, 255, + 66, 218, 55, 255, + 64, 208, 54, 255, + 202, 68, 55, 255, + 212, 73, 56, 255, + 229, 77, 61, 255, + 244, 81, 67, 255, + 233, 77, 62, 255, + 194, 59, 41, 255, + 174, 113, 86, 255, + 171, 151, 111, 255, + 172, 155, 115, 255, + 174, 162, 122, 255, + 175, 169, 127, 255, + 179, 175, 132, 255, + 181, 182, 138, 255, + 186, 187, 145, 255, + 186, 192, 148, 255, + 188, 195, 150, 255, + 188, 196, 149, 255, + 184, 197, 146, 255, + 180, 194, 142, 255, + 176, 191, 138, 255, + 167, 189, 128, 255, + 161, 185, 121, 255, + 153, 183, 113, 255, + 148, 182, 111, 255, + 141, 183, 106, 255, + 108, 183, 78, 255, + 54, 202, 43, 255, + 74, 243, 61, 255, + 78, 255, 66, 255, + 73, 241, 63, 255, + 68, 223, 55, 255, + 63, 214, 52, 255, + 203, 70, 56, 255, + 218, 74, 61, 255, + 237, 79, 64, 255, + 253, 85, 68, 255, + 247, 80, 67, 255, + 209, 62, 47, 255, + 184, 121, 95, 255, + 184, 160, 129, 255, + 187, 166, 134, 255, + 190, 176, 142, 255, + 195, 186, 150, 255, + 201, 195, 158, 255, + 206, 204, 166, 255, + 212, 211, 175, 255, + 213, 218, 178, 255, + 215, 221, 181, 255, + 217, 224, 183, 255, + 211, 223, 179, 255, + 207, 220, 173, 255, + 199, 213, 166, 255, + 188, 210, 154, 255, + 180, 205, 145, 255, + 168, 201, 133, 255, + 158, 198, 125, 255, + 151, 197, 119, 255, + 117, 193, 91, 255, + 60, 217, 46, 255, + 78, 255, 66, 255, + 78, 255, 69, 255, + 74, 248, 65, 255, + 68, 228, 58, 255, + 65, 215, 54, 255, + 204, 70, 56, 255, + 219, 74, 62, 255, + 241, 80, 66, 255, + 255, 87, 70, 255, + 255, 82, 71, 255, + 221, 65, 52, 255, + 190, 129, 103, 255, + 192, 169, 139, 255, + 197, 175, 144, 255, + 202, 186, 154, 255, + 209, 198, 163, 255, + 215, 209, 177, 255, + 223, 218, 186, 255, + 228, 228, 192, 255, + 231, 235, 200, 255, + 234, 239, 202, 255, + 234, 241, 200, 255, + 228, 239, 197, 255, + 224, 236, 191, 255, + 215, 228, 182, 255, + 203, 224, 169, 255, + 191, 218, 156, 255, + 179, 213, 145, 255, + 168, 208, 135, 255, + 160, 204, 129, 255, + 123, 201, 96, 255, + 63, 229, 49, 255, + 79, 255, 69, 255, + 80, 255, 70, 255, + 77, 251, 66, 255, + 70, 230, 61, 255, + 66, 216, 55, 255, + 205, 71, 57, 255, + 222, 74, 63, 255, + 243, 81, 67, 255, + 255, 86, 71, 255, + 255, 85, 70, 255, + 227, 66, 52, 255, + 197, 132, 108, 255, + 198, 175, 145, 255, + 205, 183, 153, 255, + 210, 195, 164, 255, + 219, 205, 176, 255, + 225, 217, 185, 255, + 231, 227, 195, 255, + 237, 237, 203, 255, + 244, 242, 209, 255, + 243, 247, 211, 255, + 243, 251, 210, 255, + 238, 249, 206, 255, + 231, 246, 202, 255, + 224, 238, 188, 255, + 211, 232, 176, 255, + 199, 224, 166, 255, + 187, 220, 155, 255, + 175, 215, 144, 255, + 167, 211, 138, 255, + 127, 204, 103, 255, + 64, 237, 51, 255, + 80, 255, 69, 255, + 81, 255, 70, 255, + 76, 251, 66, 255, + 70, 232, 61, 255, + 66, 218, 56, 255, + 205, 70, 57, 255, + 222, 74, 63, 255, + 240, 82, 67, 255, + 255, 86, 71, 255, + 255, 85, 70, 255, + 231, 66, 54, 255, + 200, 136, 111, 255, + 203, 179, 151, 255, + 209, 186, 158, 255, + 215, 197, 169, 255, + 222, 209, 179, 255, + 231, 220, 192, 255, + 235, 230, 200, 255, + 242, 238, 207, 255, + 247, 246, 213, 255, + 245, 251, 216, 255, + 246, 251, 217, 255, + 241, 251, 213, 255, + 234, 249, 206, 255, + 227, 241, 194, 255, + 215, 236, 183, 255, + 202, 229, 172, 255, + 188, 223, 160, 255, + 177, 219, 148, 255, + 169, 215, 144, 255, + 129, 207, 108, 255, + 62, 242, 52, 255, + 80, 255, 68, 255, + 80, 255, 70, 255, + 76, 251, 66, 255, + 69, 232, 61, 255, + 66, 218, 54, 255, + 206, 70, 57, 255, + 221, 75, 63, 255, + 238, 80, 66, 255, + 255, 86, 71, 255, + 255, 84, 70, 255, + 231, 66, 54, 255, + 202, 139, 115, 255, + 205, 181, 155, 255, + 212, 188, 161, 255, + 217, 199, 171, 255, + 224, 209, 181, 255, + 231, 220, 192, 255, + 234, 229, 199, 255, + 242, 236, 207, 255, + 243, 242, 211, 255, + 243, 246, 216, 255, + 243, 249, 210, 255, + 237, 248, 209, 255, + 233, 246, 202, 255, + 227, 241, 179, 255, + 214, 236, 170, 255, + 202, 229, 160, 255, + 191, 226, 150, 255, + 177, 220, 144, 255, + 175, 217, 153, 255, + 129, 210, 110, 255, + 61, 242, 51, 255, + 78, 255, 67, 255, + 79, 255, 69, 255, + 76, 250, 66, 255, + 70, 231, 60, 255, + 66, 218, 54, 255, + 206, 71, 57, 255, + 219, 76, 63, 255, + 235, 79, 65, 255, + 251, 85, 71, 255, + 253, 83, 67, 255, + 231, 66, 53, 255, + 202, 139, 118, 255, + 206, 182, 155, 255, + 211, 188, 161, 255, + 216, 198, 170, 255, + 223, 207, 181, 255, + 228, 217, 189, 255, + 230, 226, 196, 255, + 237, 231, 201, 255, + 237, 236, 206, 255, + 239, 237, 218, 255, + 250, 252, 49, 255, + 250, 253, 59, 255, + 246, 250, 60, 255, + 240, 245, 58, 255, + 229, 238, 55, 255, + 220, 230, 51, 255, + 221, 224, 51, 255, + 77, 197, 0, 255, + 126, 209, 94, 255, + 134, 211, 117, 255, + 61, 241, 50, 255, + 73, 255, 67, 255, + 77, 255, 69, 255, + 74, 247, 64, 255, + 70, 229, 58, 255, + 66, 218, 56, 255, + 205, 71, 56, 255, + 217, 74, 61, 255, + 232, 78, 67, 255, + 245, 83, 70, 255, + 247, 80, 69, 255, + 229, 66, 51, 255, + 202, 139, 118, 255, + 206, 179, 156, 255, + 211, 185, 161, 255, + 215, 194, 170, 255, + 222, 203, 178, 255, + 225, 211, 185, 255, + 227, 219, 191, 255, + 230, 223, 195, 255, + 232, 227, 199, 255, + 233, 228, 210, 255, + 227, 231, 53, 255, + 230, 232, 66, 255, + 225, 230, 65, 255, + 220, 228, 62, 255, + 210, 225, 62, 255, + 204, 220, 60, 255, + 209, 217, 60, 255, + 82, 198, 17, 255, + 119, 208, 87, 255, + 131, 211, 115, 255, + 57, 242, 51, 255, + 69, 255, 63, 255, + 74, 255, 67, 255, + 75, 242, 64, 255, + 69, 227, 58, 255, + 66, 216, 56, 255, + 204, 70, 56, 255, + 215, 74, 60, 255, + 227, 77, 65, 255, + 237, 81, 66, 255, + 240, 79, 67, 255, + 225, 65, 50, 255, + 202, 138, 116, 255, + 204, 178, 154, 255, + 208, 182, 158, 255, + 212, 190, 166, 255, + 216, 197, 172, 255, + 219, 204, 179, 255, + 221, 211, 184, 255, + 225, 215, 188, 255, + 224, 218, 189, 255, + 225, 219, 201, 255, + 211, 216, 48, 255, + 213, 218, 62, 255, + 210, 218, 62, 255, + 207, 217, 60, 255, + 201, 215, 57, 255, + 196, 212, 57, 255, + 200, 210, 55, 255, + 84, 198, 16, 255, + 118, 208, 87, 255, + 133, 210, 116, 255, + 47, 221, 39, 255, + 68, 255, 61, 255, + 73, 253, 65, 255, + 72, 237, 62, 255, + 69, 225, 58, 255, + 66, 215, 56, 255, + 202, 69, 55, 255, + 213, 72, 59, 255, + 222, 76, 62, 255, + 230, 79, 65, 255, + 233, 76, 64, 255, + 221, 64, 49, 255, + 200, 134, 113, 255, + 201, 174, 150, 255, + 204, 178, 155, 255, + 207, 185, 161, 255, + 211, 192, 167, 255, + 213, 197, 172, 255, + 215, 203, 177, 255, + 217, 205, 179, 255, + 216, 209, 180, 255, + 216, 210, 190, 255, + 198, 204, 45, 255, + 199, 207, 55, 255, + 197, 209, 56, 255, + 194, 209, 55, 255, + 193, 206, 55, 255, + 189, 204, 55, 255, + 193, 204, 54, 255, + 85, 197, 17, 255, + 113, 204, 82, 255, + 126, 203, 107, 255, + 34, 180, 27, 255, + 63, 253, 57, 255, + 70, 249, 60, 255, + 70, 234, 61, 255, + 67, 223, 58, 255, + 65, 216, 54, 255, + 200, 69, 56, 255, + 209, 72, 59, 255, + 216, 74, 62, 255, + 223, 76, 64, 255, + 226, 74, 63, 255, + 215, 63, 51, 255, + 200, 132, 111, 255, + 197, 171, 146, 255, + 200, 173, 150, 255, + 204, 180, 156, 255, + 206, 185, 161, 255, + 209, 191, 166, 255, + 209, 195, 169, 255, + 210, 197, 172, 255, + 207, 200, 172, 255, + 209, 202, 182, 255, + 186, 196, 41, 255, + 188, 200, 53, 255, + 188, 202, 53, 255, + 187, 202, 52, 255, + 183, 202, 53, 255, + 180, 200, 51, 255, + 188, 199, 52, 255, + 84, 199, 20, 255, + 92, 190, 53, 255, + 102, 179, 78, 255, + 33, 170, 24, 255, + 51, 221, 45, 255, + 67, 244, 62, 255, + 68, 229, 58, 255, + 67, 220, 58, 255, + 64, 213, 55, 255, + 198, 68, 54, 255, + 204, 71, 58, 255, + 211, 72, 60, 255, + 216, 74, 61, 255, + 219, 71, 61, 255, + 213, 60, 49, 255, + 197, 129, 108, 255, + 195, 166, 143, 255, + 196, 168, 144, 255, + 197, 175, 149, 255, + 200, 179, 154, 255, + 201, 184, 158, 255, + 202, 188, 161, 255, + 202, 190, 163, 255, + 200, 192, 161, 255, + 202, 193, 173, 255, + 176, 190, 40, 255, + 180, 194, 50, 255, + 178, 196, 51, 255, + 178, 196, 51, 255, + 177, 195, 50, 255, + 174, 196, 50, 255, + 182, 195, 52, 255, + 86, 199, 20, 255, + 84, 184, 46, 255, + 89, 167, 62, 255, + 34, 171, 25, 255, + 39, 199, 31, 255, + 65, 238, 59, 255, + 67, 225, 57, 255, + 66, 217, 57, 255, + 64, 212, 54, 255, + 196, 67, 53, 255, + 200, 70, 56, 255, + 205, 70, 58, 255, + 209, 71, 58, 255, + 212, 69, 58, 255, + 208, 59, 47, 255, + 199, 127, 104, 255, + 200, 154, 133, 255, + 199, 156, 133, 255, + 202, 161, 136, 255, + 203, 165, 139, 255, + 204, 171, 143, 255, + 203, 174, 144, 255, + 202, 176, 146, 255, + 199, 180, 145, 255, + 197, 184, 162, 255, + 169, 185, 37, 255, + 170, 190, 48, 255, + 172, 190, 50, 255, + 173, 191, 50, 255, + 172, 191, 50, 255, + 171, 192, 47, 255, + 178, 191, 50, 255, + 86, 198, 21, 255, + 86, 184, 48, 255, + 88, 167, 62, 255, + 35, 173, 27, 255, + 35, 187, 27, 255, + 64, 229, 56, 255, + 66, 221, 57, 255, + 65, 214, 55, 255, + 62, 210, 52, 255, + 194, 68, 52, 255, + 197, 67, 54, 255, + 197, 67, 54, 255, + 201, 66, 55, 255, + 203, 66, 55, 255, + 207, 57, 46, 255, + 142, 121, 104, 255, + 122, 229, 199, 255, + 129, 224, 200, 255, + 123, 231, 211, 255, + 118, 241, 229, 255, + 119, 241, 235, 255, + 120, 244, 238, 255, + 112, 251, 250, 255, + 144, 226, 217, 255, + 174, 192, 170, 255, + 159, 183, 34, 255, + 162, 184, 44, 255, + 164, 187, 46, 255, + 164, 188, 48, 255, + 165, 189, 46, 255, + 165, 189, 47, 255, + 173, 187, 48, 255, + 85, 195, 22, 255, + 86, 185, 48, 255, + 87, 168, 64, 255, + 35, 175, 26, 255, + 32, 183, 23, 255, + 61, 223, 51, 255, + 62, 218, 55, 255, + 63, 210, 52, 255, + 61, 209, 53, 255, + 193, 67, 53, 255, + 193, 67, 52, 255, + 191, 63, 54, 255, + 190, 63, 49, 255, + 196, 63, 51, 255, + 207, 61, 49, 255, + 92, 64, 48, 255, + 46, 154, 127, 255, + 52, 196, 156, 255, + 54, 192, 154, 255, + 49, 186, 143, 255, + 48, 185, 143, 255, + 47, 182, 138, 255, + 43, 176, 129, 255, + 40, 180, 133, 255, + 28, 180, 142, 255, + 152, 182, 35, 255, + 149, 184, 44, 255, + 155, 183, 44, 255, + 158, 185, 45, 255, + 160, 185, 43, 255, + 161, 187, 45, 255, + 167, 186, 49, 255, + 87, 195, 20, 255, + 86, 184, 46, 255, + 87, 168, 65, 255, + 35, 176, 26, 255, + 32, 183, 23, 255, + 60, 217, 49, 255, + 62, 214, 54, 255, + 64, 208, 51, 255, + 61, 206, 51, 255, + 189, 65, 51, 255, + 190, 65, 51, 255, + 183, 60, 52, 255, + 182, 60, 52, 255, + 189, 61, 48, 255, + 202, 59, 47, 255, + 98, 71, 58, 255, + 50, 145, 114, 255, + 52, 184, 142, 255, + 50, 179, 139, 255, + 51, 180, 139, 255, + 52, 181, 138, 255, + 52, 181, 138, 255, + 51, 181, 137, 255, + 51, 181, 135, 255, + 42, 181, 144, 255, + 141, 182, 34, 255, + 141, 180, 44, 255, + 148, 182, 45, 255, + 151, 182, 45, 255, + 152, 184, 47, 255, + 154, 184, 45, 255, + 162, 184, 48, 255, + 87, 194, 21, 255, + 89, 182, 47, 255, + 87, 168, 66, 255, + 35, 176, 27, 255, + 32, 184, 24, 255, + 57, 213, 47, 255, + 61, 210, 52, 255, + 61, 206, 50, 255, + 60, 205, 51, 255, + 186, 65, 49, 255, + 185, 63, 49, 255, + 177, 59, 50, 255, + 175, 57, 48, 255, + 182, 60, 47, 255, + 196, 57, 44, 255, + 95, 71, 58, 255, + 50, 146, 114, 255, + 51, 184, 142, 255, + 50, 180, 139, 255, + 50, 179, 139, 255, + 52, 182, 139, 255, + 51, 181, 137, 255, + 50, 180, 137, 255, + 51, 181, 135, 255, + 41, 179, 141, 255, + 136, 178, 32, 255, + 135, 180, 40, 255, + 139, 181, 41, 255, + 145, 180, 41, 255, + 150, 181, 44, 255, + 152, 179, 43, 255, + 159, 181, 47, 255, + 86, 192, 21, 255, + 92, 181, 47, 255, + 87, 169, 66, 255, + 35, 176, 26, 255, + 33, 184, 24, 255, + 56, 211, 47, 255, + 59, 206, 49, 255, + 59, 203, 48, 255, + 58, 203, 51, 255, + 184, 65, 50, 255, + 183, 61, 49, 255, + 172, 57, 50, 255, + 167, 53, 45, 255, + 178, 57, 48, 255, + 191, 56, 41, 255, + 95, 71, 57, 255, + 51, 145, 116, 255, + 52, 184, 141, 255, + 53, 180, 139, 255, + 53, 180, 139, 255, + 52, 178, 136, 255, + 52, 178, 135, 255, + 52, 178, 136, 255, + 48, 179, 133, 255, + 43, 179, 143, 255, + 133, 176, 32, 255, + 131, 177, 39, 255, + 137, 177, 42, 255, + 141, 177, 43, 255, + 145, 178, 43, 255, + 148, 178, 44, 255, + 154, 178, 46, 255, + 91, 189, 22, 255, + 96, 176, 55, 255, + 85, 167, 64, 255, + 37, 173, 28, 255, + 33, 182, 25, 255, + 55, 207, 47, 255, + 59, 202, 52, 255, + 61, 200, 49, 255, + 60, 200, 49, 255, + 182, 63, 50, 255, + 177, 61, 48, 255, + 170, 56, 48, 255, + 151, 48, 41, 255, + 173, 56, 44, 255, + 182, 44, 33, 255, + 94, 80, 67, 255, + 51, 145, 115, 255, + 52, 181, 140, 255, + 52, 176, 136, 255, + 50, 178, 137, 255, + 51, 178, 136, 255, + 51, 178, 135, 255, + 49, 176, 134, 255, + 49, 177, 132, 255, + 42, 177, 140, 255, + 129, 173, 30, 255, + 129, 174, 38, 255, + 134, 174, 40, 255, + 139, 174, 41, 255, + 142, 176, 39, 255, + 145, 175, 41, 255, + 152, 174, 43, 255, + 91, 187, 22, 255, + 105, 173, 61, 255, + 96, 164, 77, 255, + 31, 169, 23, 255, + 32, 180, 25, 255, + 53, 202, 47, 255, + 57, 199, 48, 255, + 59, 197, 48, 255, + 59, 199, 48, 255, + 181, 62, 50, 255, + 175, 60, 48, 255, + 166, 54, 47, 255, + 130, 44, 35, 255, + 162, 40, 31, 255, + 209, 130, 111, 255, + 105, 125, 103, 255, + 48, 141, 111, 255, + 52, 179, 138, 255, + 52, 174, 136, 255, + 50, 176, 136, 255, + 50, 176, 134, 255, + 50, 176, 133, 255, + 50, 175, 133, 255, + 49, 175, 131, 255, + 42, 175, 138, 255, + 126, 164, 20, 255, + 122, 166, 33, 255, + 129, 169, 35, 255, + 134, 170, 36, 255, + 138, 171, 41, 255, + 142, 171, 43, 255, + 148, 172, 45, 255, + 101, 182, 24, 255, + 89, 162, 53, 255, + 104, 170, 83, 255, + 72, 170, 55, 255, + 29, 172, 24, 255, + 52, 198, 46, 255, + 56, 196, 46, 255, + 57, 195, 48, 255, + 58, 198, 47, 255, + 178, 61, 48, 255, + 171, 58, 48, 255, + 156, 53, 45, 255, + 119, 28, 25, 255, + 193, 119, 102, 255, + 228, 193, 167, 255, + 96, 121, 99, 255, + 47, 142, 110, 255, + 52, 175, 137, 255, + 51, 171, 133, 255, + 50, 172, 134, 255, + 50, 172, 132, 255, + 50, 172, 131, 255, + 49, 171, 131, 255, + 49, 172, 128, 255, + 36, 169, 127, 255, + 172, 197, 99, 255, + 153, 186, 86, 255, + 148, 182, 71, 255, + 143, 176, 58, 255, + 139, 170, 45, 255, + 135, 163, 30, 255, + 139, 163, 27, 255, + 84, 155, 25, 255, + 57, 136, 49, 255, + 71, 151, 54, 255, + 85, 160, 67, 255, + 62, 166, 49, 255, + 42, 189, 34, 255, + 53, 194, 45, 255, + 54, 192, 48, 255, + 58, 196, 48, 255, + 176, 61, 47, 255, + 168, 58, 45, 255, + 140, 39, 34, 255, + 140, 73, 55, 255, + 152, 103, 77, 255, + 141, 78, 59, 255, + 90, 80, 65, 255, + 45, 148, 114, 255, + 50, 173, 134, 255, + 50, 169, 132, 255, + 50, 170, 130, 255, + 48, 170, 129, 255, + 46, 170, 129, 255, + 46, 171, 130, 255, + 44, 171, 128, 255, + 23, 161, 117, 255, + 225, 253, 204, 255, + 211, 244, 195, 255, + 212, 245, 199, 255, + 213, 245, 199, 255, + 215, 243, 193, 255, + 213, 243, 190, 255, + 208, 240, 182, 255, + 193, 235, 176, 255, + 185, 231, 167, 255, + 180, 225, 163, 255, + 172, 223, 156, 255, + 176, 221, 158, 255, + 107, 206, 96, 255, + 39, 183, 33, 255, + 55, 188, 47, 255, + 57, 193, 49, 255, + 173, 60, 45, 255, + 159, 45, 33, 255, + 159, 91, 77, 255, + 157, 108, 85, 255, + 146, 94, 74, 255, + 139, 87, 72, 255, + 134, 71, 56, 255, + 42, 143, 109, 255, + 37, 172, 131, 255, + 39, 167, 128, 255, + 43, 164, 123, 255, + 48, 159, 118, 255, + 52, 155, 115, 255, + 58, 151, 112, 255, + 63, 149, 104, 255, + 73, 149, 104, 255, + 206, 233, 185, 255, + 208, 237, 190, 255, + 207, 237, 188, 255, + 205, 237, 186, 255, + 203, 237, 185, 255, + 199, 237, 179, 255, + 199, 236, 178, 255, + 196, 235, 174, 255, + 192, 233, 170, 255, + 190, 230, 167, 255, + 184, 228, 162, 255, + 178, 227, 158, 255, + 187, 227, 167, 255, + 114, 205, 102, 255, + 38, 181, 33, 255, + 55, 191, 48, 255, + 164, 44, 34, 255, + 178, 112, 95, 255, + 183, 153, 126, 255, + 158, 121, 90, 255, + 151, 117, 88, 255, + 148, 122, 92, 255, + 148, 126, 95, 255, + 140, 136, 102, 255, + 135, 144, 109, 255, + 145, 148, 114, 255, + 151, 157, 121, 255, + 160, 167, 131, 255, + 170, 178, 141, 255, + 178, 190, 149, 255, + 188, 201, 162, 255, + 199, 213, 173, 255, + 199, 220, 181, 255, + 205, 226, 183, 255, + 203, 227, 182, 255, + 204, 228, 182, 255, + 202, 228, 180, 255, + 200, 230, 179, 255, + 199, 229, 178, 255, + 196, 227, 176, 255, + 193, 228, 172, 255, + 189, 226, 168, 255, + 186, 225, 165, 255, + 181, 223, 161, 255, + 177, 223, 155, 255, + 184, 226, 163, 255, + 112, 203, 98, 255, + 39, 183, 34, 255, + 185, 121, 100, 255, + 206, 188, 162, 255, + 196, 177, 149, 255, + 193, 178, 146, 255, + 192, 186, 153, 255, + 198, 192, 161, 255, + 204, 198, 169, 255, + 207, 203, 173, 255, + 210, 206, 175, 255, + 207, 212, 178, 255, + 209, 213, 179, 255, + 208, 216, 181, 255, + 207, 216, 182, 255, + 207, 218, 183, 255, + 206, 217, 179, 255, + 204, 219, 180, 255, + 203, 219, 180, 255, + 203, 220, 178, 255, + 201, 221, 178, 255, + 202, 222, 178, 255, + 201, 222, 176, 255, + 199, 223, 177, 255, + 198, 222, 176, 255, + 195, 222, 173, 255, + 194, 222, 174, 255, + 193, 221, 170, 255, + 191, 220, 167, 255, + 187, 220, 166, 255, + 182, 220, 162, 255, + 180, 218, 158, 255, + 186, 221, 161, 255, + 111, 202, 97, 255, +}; + diff --git a/src/gallium/state_trackers/d3d1x/progs/data/tux_image.h b/src/gallium/state_trackers/d3d1x/progs/data/tux_image.h new file mode 100755 index 00000000000..53aeffa5582 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/data/tux_image.h @@ -0,0 +1,1028 @@ +unsigned char g_tux_image[] = +{ + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 249, 249, 249, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 234, 234, 234, 255, + 23, 23, 25, 255, + 0, 0, 0, 255, + 0, 0, 0, 255, + 0, 0, 0, 255, + 81, 81, 83, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 0, 0, 0, 255, + 0, 0, 0, 255, + 1, 1, 3, 255, + 0, 0, 2, 255, + 8, 7, 9, 255, + 71, 71, 70, 255, + 0, 0, 0, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 106, 106, 107, 255, + 0, 0, 0, 255, + 1, 1, 3, 255, + 2, 2, 4, 255, + 0, 0, 2, 255, + 13, 13, 13, 255, + 46, 46, 46, 255, + 0, 0, 0, 255, + 57, 57, 59, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 33, 33, 35, 255, + 0, 0, 0, 255, + 0, 0, 1, 255, + 1, 1, 3, 255, + 0, 0, 0, 255, + 0, 0, 0, 255, + 0, 0, 0, 255, + 0, 0, 1, 255, + 0, 0, 0, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 10, 10, 13, 255, + 87, 87, 87, 255, + 43, 42, 43, 255, + 0, 0, 0, 255, + 17, 17, 18, 255, + 163, 163, 162, 255, + 71, 70, 70, 255, + 0, 0, 0, 255, + 0, 0, 0, 255, + 213, 213, 213, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 29, 29, 32, 255, + 178, 178, 177, 255, + 210, 212, 215, 255, + 0, 0, 0, 255, + 213, 215, 219, 255, + 112, 112, 112, 255, + 235, 235, 234, 255, + 0, 0, 0, 255, + 0, 0, 0, 255, + 176, 176, 177, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 78, 79, 79, 255, + 43, 47, 59, 255, + 103, 94, 77, 255, + 103, 77, 0, 255, + 168, 156, 123, 255, + 0, 0, 0, 255, + 179, 182, 191, 255, + 1, 1, 3, 255, + 0, 0, 0, 255, + 182, 182, 183, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 31, 35, 45, 255, + 172, 146, 99, 255, + 237, 173, 0, 255, + 248, 208, 9, 255, + 250, 215, 39, 255, + 220, 183, 4, 255, + 223, 201, 120, 255, + 0, 0, 0, 255, + 0, 0, 0, 255, + 151, 151, 152, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 93, 89, 86, 255, + 216, 146, 0, 255, + 245, 193, 9, 255, + 243, 215, 34, 255, + 255, 229, 32, 255, + 228, 193, 8, 255, + 238, 173, 0, 255, + 0, 0, 2, 255, + 0, 0, 0, 255, + 92, 92, 93, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 77, 81, 91, 255, + 120, 94, 41, 255, + 209, 163, 0, 255, + 215, 176, 9, 255, + 189, 133, 0, 255, + 198, 135, 4, 255, + 198, 176, 136, 255, + 0, 0, 0, 255, + 115, 115, 114, 255, + 0, 0, 0, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 0, 0, 0, 255, + 181, 186, 198, 255, + 169, 142, 94, 255, + 174, 119, 18, 255, + 174, 136, 68, 255, + 189, 193, 203, 255, + 255, 255, 255, 255, + 84, 84, 84, 255, + 2, 2, 3, 255, + 0, 0, 0, 255, + 107, 106, 107, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 116, 116, 116, 255, + 35, 35, 36, 255, + 255, 255, 255, 255, + 185, 187, 193, 255, + 182, 186, 197, 255, + 214, 218, 225, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 0, 0, 0, 255, + 0, 0, 1, 255, + 0, 0, 0, 255, + 248, 248, 248, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 198, 198, 199, 255, + 0, 0, 0, 255, + 246, 246, 244, 255, + 255, 255, 255, 255, + 252, 253, 251, 255, + 250, 250, 249, 255, + 255, 255, 255, 255, + 255, 255, 253, 255, + 255, 255, 253, 255, + 255, 255, 255, 255, + 68, 68, 69, 255, + 0, 0, 0, 255, + 0, 0, 0, 255, + 16, 16, 18, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 246, 246, 246, 255, + 0, 0, 0, 255, + 26, 25, 26, 255, + 254, 255, 254, 255, + 255, 255, 253, 255, + 243, 243, 242, 255, + 241, 241, 240, 255, + 253, 253, 251, 255, + 247, 247, 246, 255, + 236, 236, 235, 255, + 236, 235, 235, 255, + 132, 131, 132, 255, + 0, 0, 0, 255, + 0, 0, 1, 255, + 0, 0, 0, 255, + 46, 46, 47, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 67, 67, 69, 255, + 0, 0, 0, 255, + 80, 80, 80, 255, + 243, 243, 242, 255, + 254, 254, 252, 255, + 245, 245, 243, 255, + 252, 252, 251, 255, + 253, 253, 251, 255, + 252, 252, 250, 255, + 235, 235, 233, 255, + 214, 213, 213, 255, + 224, 223, 223, 255, + 31, 31, 32, 255, + 23, 23, 23, 255, + 1, 0, 2, 255, + 0, 0, 0, 255, + 179, 179, 179, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 0, 0, 0, 255, + 0, 0, 0, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 253, 253, 251, 255, + 254, 254, 252, 255, + 253, 253, 251, 255, + 253, 253, 251, 255, + 253, 253, 251, 255, + 255, 255, 253, 255, + 255, 255, 255, 255, + 253, 253, 252, 255, + 184, 184, 184, 255, + 0, 0, 0, 255, + 32, 32, 32, 255, + 0, 0, 0, 255, + 37, 37, 39, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 189, 189, 189, 255, + 0, 0, 0, 255, + 111, 111, 111, 255, + 255, 255, 255, 255, + 253, 253, 251, 255, + 253, 253, 251, 255, + 248, 248, 247, 255, + 253, 253, 251, 255, + 252, 252, 250, 255, + 253, 253, 251, 255, + 252, 252, 251, 255, + 252, 252, 250, 255, + 254, 254, 252, 255, + 255, 255, 255, 255, + 15, 15, 16, 255, + 16, 16, 17, 255, + 12, 11, 13, 255, + 0, 0, 0, 255, + 247, 247, 246, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 51, 51, 52, 255, + 0, 0, 0, 255, + 250, 250, 248, 255, + 255, 255, 255, 255, + 253, 253, 251, 255, + 253, 253, 251, 255, + 240, 240, 239, 255, + 254, 254, 252, 255, + 253, 253, 251, 255, + 252, 252, 250, 255, + 252, 252, 251, 255, + 253, 253, 250, 255, + 253, 253, 251, 255, + 255, 255, 255, 255, + 56, 56, 57, 255, + 0, 0, 0, 255, + 24, 24, 25, 255, + 0, 0, 0, 255, + 152, 152, 153, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 200, 200, 201, 255, + 0, 0, 0, 255, + 19, 19, 20, 255, + 255, 255, 255, 255, + 253, 253, 251, 255, + 253, 253, 251, 255, + 253, 253, 251, 255, + 235, 235, 234, 255, + 254, 254, 252, 255, + 253, 253, 251, 255, + 253, 253, 251, 255, + 253, 253, 251, 255, + 253, 253, 251, 255, + 252, 252, 250, 255, + 255, 255, 255, 255, + 83, 83, 83, 255, + 0, 0, 0, 255, + 18, 18, 18, 255, + 0, 0, 0, 255, + 95, 95, 97, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 34, 35, 39, 255, + 10, 12, 19, 255, + 69, 69, 70, 255, + 255, 255, 255, 255, + 253, 253, 251, 255, + 253, 253, 251, 255, + 252, 252, 250, 255, + 237, 237, 236, 255, + 254, 254, 252, 255, + 252, 252, 250, 255, + 253, 253, 251, 255, + 252, 252, 250, 255, + 253, 253, 251, 255, + 252, 252, 250, 255, + 255, 255, 255, 255, + 91, 91, 92, 255, + 2, 2, 4, 255, + 1, 1, 3, 255, + 0, 0, 0, 255, + 81, 81, 81, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 53, 51, 49, 255, + 49, 33, 0, 255, + 62, 67, 84, 255, + 255, 255, 255, 255, + 253, 253, 251, 255, + 253, 253, 251, 255, + 251, 251, 250, 255, + 240, 240, 239, 255, + 254, 254, 252, 255, + 253, 253, 251, 255, + 252, 252, 250, 255, + 253, 253, 251, 255, + 252, 252, 250, 255, + 253, 254, 253, 255, + 255, 255, 255, 255, + 63, 65, 73, 255, + 9, 9, 10, 255, + 11, 11, 12, 255, + 13, 13, 15, 255, + 104, 105, 114, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 233, 174, 24, 255, + 255, 217, 8, 255, + 107, 77, 0, 255, + 131, 137, 154, 255, + 255, 255, 255, 255, + 254, 254, 252, 255, + 250, 250, 249, 255, + 239, 239, 237, 255, + 254, 254, 252, 255, + 252, 252, 250, 255, + 252, 252, 251, 255, + 253, 253, 251, 255, + 253, 254, 253, 255, + 251, 249, 248, 255, + 255, 205, 14, 255, + 87, 70, 6, 255, + 0, 0, 1, 255, + 0, 0, 0, 255, + 0, 2, 14, 255, + 216, 203, 137, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 230, 207, 159, 255, + 216, 168, 49, 255, + 207, 153, 25, 255, + 239, 180, 4, 255, + 246, 190, 11, 255, + 255, 214, 12, 255, + 25, 13, 0, 255, + 79, 81, 89, 255, + 255, 255, 255, 255, + 255, 255, 254, 255, + 250, 250, 249, 255, + 253, 253, 251, 255, + 253, 253, 251, 255, + 253, 253, 251, 255, + 252, 252, 250, 255, + 255, 255, 255, 255, + 231, 227, 222, 255, + 250, 184, 0, 255, + 101, 71, 5, 255, + 0, 0, 3, 255, + 0, 0, 3, 255, + 112, 83, 2, 255, + 250, 193, 0, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 210, 154, 18, 255, + 247, 187, 0, 255, + 247, 189, 7, 255, + 246, 189, 11, 255, + 245, 189, 12, 255, + 249, 191, 12, 255, + 240, 191, 11, 255, + 0, 0, 0, 255, + 24, 25, 26, 255, + 255, 255, 255, 255, + 255, 255, 253, 255, + 253, 253, 251, 255, + 253, 253, 251, 255, + 252, 252, 251, 255, + 253, 253, 251, 255, + 255, 255, 255, 255, + 188, 186, 184, 255, + 232, 168, 0, 255, + 216, 154, 8, 255, + 158, 108, 7, 255, + 182, 127, 7, 255, + 251, 190, 10, 255, + 243, 181, 0, 255, + 250, 247, 244, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 215, 169, 62, 255, + 245, 186, 4, 255, + 245, 189, 11, 255, + 245, 189, 12, 255, + 245, 189, 12, 255, + 245, 188, 12, 255, + 255, 204, 12, 255, + 125, 99, 7, 255, + 0, 0, 0, 255, + 129, 128, 128, 255, + 255, 255, 255, 255, + 253, 253, 251, 255, + 253, 253, 251, 255, + 252, 252, 250, 255, + 253, 253, 251, 255, + 255, 255, 255, 255, + 181, 178, 176, 255, + 220, 156, 0, 255, + 241, 183, 11, 255, + 232, 173, 9, 255, + 239, 181, 10, 255, + 247, 191, 12, 255, + 245, 188, 8, 255, + 234, 176, 3, 255, + 250, 248, 243, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 216, 173, 80, 255, + 243, 184, 4, 255, + 245, 189, 11, 255, + 245, 188, 12, 255, + 245, 189, 12, 255, + 245, 189, 12, 255, + 246, 188, 12, 255, + 255, 203, 2, 255, + 120, 112, 98, 255, + 255, 255, 255, 255, + 254, 254, 253, 255, + 252, 252, 251, 255, + 253, 253, 251, 255, + 255, 255, 254, 255, + 255, 255, 255, 255, + 213, 214, 216, 255, + 8, 0, 0, 255, + 235, 173, 7, 255, + 248, 192, 12, 255, + 247, 191, 12, 255, + 246, 190, 12, 255, + 245, 189, 12, 255, + 245, 189, 11, 255, + 247, 190, 7, 255, + 238, 169, 0, 255, + 249, 245, 236, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 206, 145, 1, 255, + 249, 191, 9, 255, + 246, 190, 12, 255, + 245, 189, 11, 255, + 245, 189, 11, 255, + 245, 189, 12, 255, + 245, 189, 12, 255, + 247, 191, 9, 255, + 197, 150, 8, 255, + 229, 234, 248, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 104, 104, 104, 255, + 0, 0, 0, 255, + 35, 21, 1, 255, + 236, 174, 10, 255, + 248, 191, 12, 255, + 245, 189, 12, 255, + 245, 189, 11, 255, + 246, 191, 11, 255, + 248, 190, 4, 255, + 234, 168, 0, 255, + 222, 178, 80, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 245, 240, 231, 255, + 193, 121, 0, 255, + 232, 170, 0, 255, + 239, 180, 4, 255, + 248, 191, 12, 255, + 250, 193, 12, 255, + 248, 192, 12, 255, + 246, 190, 12, 255, + 251, 194, 12, 255, + 220, 157, 4, 255, + 9, 0, 0, 255, + 10, 12, 17, 255, + 30, 30, 31, 255, + 0, 0, 2, 255, + 0, 0, 0, 255, + 0, 0, 0, 255, + 0, 0, 0, 255, + 62, 38, 2, 255, + 232, 169, 9, 255, + 250, 194, 12, 255, + 247, 191, 12, 255, + 248, 191, 12, 255, + 229, 164, 0, 255, + 210, 162, 50, 255, + 241, 234, 228, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 237, 231, 222, 255, + 207, 183, 141, 255, + 181, 135, 49, 255, + 158, 97, 0, 255, + 182, 120, 0, 255, + 220, 157, 0, 255, + 243, 183, 11, 255, + 236, 175, 10, 255, + 164, 104, 0, 255, + 26, 11, 0, 255, + 42, 44, 49, 255, + 75, 75, 76, 255, + 75, 75, 76, 255, + 78, 78, 80, 255, + 82, 82, 83, 255, + 38, 41, 49, 255, + 48, 27, 0, 255, + 197, 134, 3, 255, + 237, 178, 11, 255, + 237, 176, 8, 255, + 187, 122, 0, 255, + 214, 191, 154, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 217, 211, 206, 255, + 163, 137, 96, 255, + 112, 63, 0, 255, + 105, 53, 0, 255, + 91, 63, 21, 255, + 248, 251, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 219, 217, 212, 255, + 95, 48, 0, 255, + 143, 84, 0, 255, + 124, 71, 0, 255, + 210, 201, 190, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 231, 232, 234, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 222, 223, 226, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, +}; + diff --git a/src/gallium/state_trackers/d3d1x/progs/progs.sln b/src/gallium/state_trackers/d3d1x/progs/progs.sln new file mode 100755 index 00000000000..13c2d6e581c --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/progs/progs.sln @@ -0,0 +1,49 @@ +
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "d3d11app", "d3d11app", "{77576C4F-7281-41FB-A5C7-D12707AB9ED0}"
+ ProjectSection(SolutionItems) = preProject
+ d3d11app\d3d11blit.hlsl = d3d11app\d3d11blit.hlsl
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "d3d11gears", "d3d11gears\d3d11gears.vcxproj", "{706313AB-8F2C-48D2-9F67-31AA043F48C9}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "d3d11tri", "d3d11tri\d3d11tri.vcxproj", "{1C11FC42-BFB5-4668-97F6-C5B564754F8F}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "d3d11spikysphere", "d3d11spikysphere\d3d11spikysphere.vcxproj", "{64988608-72A3-4125-8A31-45E1EACE8F0A}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "d3d11tex", "d3d11tex\d3d11tex.vcxproj", "{14F73B97-2DC6-423E-97D9-64E3368713DC}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "d3d10tri", "d3d10tri\d3d10tri.vcxproj", "{5366F4FD-0E6C-40CC-B2F2-CE3D350F0729}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {706313AB-8F2C-48D2-9F67-31AA043F48C9}.Debug|Win32.ActiveCfg = Debug|Win32
+ {706313AB-8F2C-48D2-9F67-31AA043F48C9}.Debug|Win32.Build.0 = Debug|Win32
+ {706313AB-8F2C-48D2-9F67-31AA043F48C9}.Release|Win32.ActiveCfg = Release|Win32
+ {706313AB-8F2C-48D2-9F67-31AA043F48C9}.Release|Win32.Build.0 = Release|Win32
+ {1C11FC42-BFB5-4668-97F6-C5B564754F8F}.Debug|Win32.ActiveCfg = Debug|Win32
+ {1C11FC42-BFB5-4668-97F6-C5B564754F8F}.Debug|Win32.Build.0 = Debug|Win32
+ {1C11FC42-BFB5-4668-97F6-C5B564754F8F}.Release|Win32.ActiveCfg = Release|Win32
+ {1C11FC42-BFB5-4668-97F6-C5B564754F8F}.Release|Win32.Build.0 = Release|Win32
+ {64988608-72A3-4125-8A31-45E1EACE8F0A}.Debug|Win32.ActiveCfg = Debug|Win32
+ {64988608-72A3-4125-8A31-45E1EACE8F0A}.Debug|Win32.Build.0 = Debug|Win32
+ {64988608-72A3-4125-8A31-45E1EACE8F0A}.Release|Win32.ActiveCfg = Release|Win32
+ {64988608-72A3-4125-8A31-45E1EACE8F0A}.Release|Win32.Build.0 = Release|Win32
+ {14F73B97-2DC6-423E-97D9-64E3368713DC}.Debug|Win32.ActiveCfg = Debug|Win32
+ {14F73B97-2DC6-423E-97D9-64E3368713DC}.Debug|Win32.Build.0 = Debug|Win32
+ {14F73B97-2DC6-423E-97D9-64E3368713DC}.Release|Win32.ActiveCfg = Release|Win32
+ {14F73B97-2DC6-423E-97D9-64E3368713DC}.Release|Win32.Build.0 = Release|Win32
+ {5366F4FD-0E6C-40CC-B2F2-CE3D350F0729}.Debug|Win32.ActiveCfg = Debug|Win32
+ {5366F4FD-0E6C-40CC-B2F2-CE3D350F0729}.Debug|Win32.Build.0 = Debug|Win32
+ {5366F4FD-0E6C-40CC-B2F2-CE3D350F0729}.Release|Win32.ActiveCfg = Release|Win32
+ {5366F4FD-0E6C-40CC-B2F2-CE3D350F0729}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/src/gallium/state_trackers/d3d1x/tools/fxc b/src/gallium/state_trackers/d3d1x/tools/fxc new file mode 100755 index 00000000000..0cf76a0af6e --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/tools/fxc @@ -0,0 +1,16 @@ +#!/bin/bash +dir="$(dirname "$0")/../mstools" +(cd "$dir"; ./download-mstools) + +arch="$(uname -m)" +if test "$arch" == i386 || test "$arch" == i486 || test "$arch" == i586 || test "$arch" == i686 || test "$arch" == x86_64; then + emu="wine" +else + emu="qemu-i386 wine" +fi +exe="$dir/fxc.exe" +if test "$#" == 0 || test "$1" == "--help"; then + exec $emu "$exe" "/?" +else + exec $emu "$exe" "$@" +fi diff --git a/src/gallium/state_trackers/d3d1x/w32api b/src/gallium/state_trackers/d3d1x/w32api new file mode 120000 index 00000000000..e47a1989e10 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/w32api @@ -0,0 +1 @@ +/usr/include/wine/windows
\ No newline at end of file diff --git a/src/gallium/state_trackers/d3d1x/winedlls/Makefile b/src/gallium/state_trackers/d3d1x/winedlls/Makefile new file mode 100644 index 00000000000..c7e51b2fdda --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/winedlls/Makefile @@ -0,0 +1,11 @@ +SUBDIRS=dxgi d3d10 d3d10_1 d3d11 + +all: + @for dir in $(SUBDIRS) ; do $(MAKE) -C "$$dir" || exit $?; done + +clean: + rm -f `find . -name \*.[oa]` + rm -f `find . -name depend` + +install: + sudo install */*.dll.so /usr/lib/wine diff --git a/src/gallium/state_trackers/d3d1x/winedlls/Makefile.wine b/src/gallium/state_trackers/d3d1x/winedlls/Makefile.wine new file mode 100644 index 00000000000..c9a06876c44 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/winedlls/Makefile.wine @@ -0,0 +1,23 @@ +TOP=../../../../../.. +D3D1X=../.. +include $(TOP)/configs/current +CFLAGS=$(CXXFLAGS) + +all: lib$(LIBNAME).def lib$(LIBNAME).cross.a $(LIBNAME).dll.so + +%.dll.fake: %.spec $(OBJECTS) version.res + wineg++ -m32 -fasynchronous-unwind-tables -shared $^ -o $@ $(LDADD) + +%.dll.so: %.spec $(OBJECTS) version.res + wineg++ -m32 -fasynchronous-unwind-tables -shared $^ -o $@ $(LDADD) + +lib%.def: %.spec + winebuild -w --def -o $@ --export $< + +lib%.cross.a: %.spec + winebuild -m32 -b i586-mingw32msvc -w --implib -o $@ --export $< + +version.res: version.rc + wrc --nostdinc -I. -I. -I../../include -I../../include -D__WINESRC__ -fo$@ $^ + +include ../../../../Makefile.template diff --git a/src/gallium/state_trackers/d3d1x/winedlls/d3d10/Makefile b/src/gallium/state_trackers/d3d1x/winedlls/d3d10/Makefile new file mode 100644 index 00000000000..0ea5ffea0dd --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/winedlls/d3d10/Makefile @@ -0,0 +1,6 @@ +LIBNAME=d3d10 +LIBRARY_INCLUDES=-I$(D3D1X)/gd3dapi -I$(D3D1X)/d3dapi -I$(D3D1X)/w32api +OBJECTS=../../dxgid3d10/libdxgid3d10.a ../../gd3d10/libgd3d10.a ../../gd3d1x/libgd3d1x.a ../../d3d1xshader/libd3d1xshader.a ../../d3d1xstutil/libd3d1xstutil.a ../../../../auxiliary/libgallium.a +LDADD=-L../dxgi -ldxgi -ldl + +include ../Makefile.wine diff --git a/src/gallium/state_trackers/d3d1x/winedlls/d3d10/d3d10.spec b/src/gallium/state_trackers/d3d1x/winedlls/d3d10/d3d10.spec new file mode 100644 index 00000000000..4a68ab58db2 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/winedlls/d3d10/d3d10.spec @@ -0,0 +1,33 @@ +@ stub D3D10CompileEffectFromMemory +@ stub D3D10CompileShader +@ stdcall D3D10CreateBlob(long ptr) +@ stdcall D3D10CreateDevice(ptr long ptr long long ptr) +@ stdcall D3D10CreateDeviceAndSwapChain(ptr long ptr long long ptr ptr ptr) +@ stub D3D10CreateEffectFromMemory +@ stub D3D10CreateEffectPoolFromMemory +@ stub D3D10CreateStateBlock +@ stub D3D10DisassembleEffect +@ stub D3D10DisassembleShader +@ stdcall D3D10GetGeometryShaderProfile(ptr) +@ stdcall D3D10GetInputAndOutputSignatureBlob(ptr long ptr) +@ stdcall D3D10GetInputSignatureBlob(ptr long ptr) +@ stdcall D3D10GetOutputSignatureBlob(ptr long ptr) +@ stdcall D3D10GetPixelShaderProfile(ptr) +@ stub D3D10GetShaderDebugInfo +@ stub D3D10GetVersion +@ stdcall D3D10GetVertexShaderProfile(ptr) +@ stub D3D10PreprocessShader +@ stub D3D10ReflectShader +@ stub D3D10RegisterLayers +@ stub D3D10StateBlockMaskDifference +@ stub D3D10StateBlockMaskDisableAll +@ stub D3D10StateBlockMaskDisableCapture +@ stub D3D10StateBlockMaskEnableAll +@ stub D3D10StateBlockMaskEnableCapture +@ stub D3D10StateBlockMaskGetSetting +@ stub D3D10StateBlockMaskIntersect +@ stub D3D10StateBlockMaskUnion + +@ stdcall D3D10CreateDevice1(ptr long ptr long long long ptr) +@ stdcall D3D10CreateDeviceAndSwapChain1(ptr long ptr long long long ptr ptr ptr) + diff --git a/src/gallium/state_trackers/d3d1x/winedlls/d3d10/version.rc b/src/gallium/state_trackers/d3d1x/winedlls/d3d10/version.rc new file mode 100644 index 00000000000..0575ab8b576 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/winedlls/d3d10/version.rc @@ -0,0 +1,3 @@ +#define FILENAME "d3d10" +#define NAME "D3D10" +#include "../version.rc.h" diff --git a/src/gallium/state_trackers/d3d1x/winedlls/d3d10_1/Makefile b/src/gallium/state_trackers/d3d1x/winedlls/d3d10_1/Makefile new file mode 100644 index 00000000000..60cdca1af9c --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/winedlls/d3d10_1/Makefile @@ -0,0 +1,6 @@ +LIBNAME=d3d10_1 +LIBRARY_INCLUDES= +OBJECTS= +LDADD=-L../d3d10 -ld3d10 + +include ../Makefile.wine diff --git a/src/gallium/state_trackers/d3d1x/winedlls/d3d10_1/d3d10_1.spec b/src/gallium/state_trackers/d3d1x/winedlls/d3d10_1/d3d10_1.spec new file mode 100644 index 00000000000..993e4bbe014 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/winedlls/d3d10_1/d3d10_1.spec @@ -0,0 +1,29 @@ +@ stub D3D10CompileShader +@ stdcall D3D10CreateBlob(long ptr) d3d10.D3D10CreateBlob +@ stdcall D3D10CreateDevice1(ptr long ptr long long long ptr) d3d10.D3D10CreateDevice1 +@ stdcall D3D10CreateDeviceAndSwapChain1(ptr long ptr long long long ptr ptr ptr) d3d10.D3D10CreateDeviceAndSwapChain1 +@ stub D3D10CreateEffectFromMemory +@ stub D3D10CreateEffectPoolFromMemory +@ stub D3D10CreateStateBlock +@ stub D3D10DisassembleEffect +@ stub D3D10DisassembleShader +@ stdcall D3D10GetGeometryShaderProfile(ptr) d3d10.D3D10GetGeometryShaderProfile +@ stdcall D3D10GetInputAndOutputSignatureBlob(ptr long ptr) d3d10.D3D10GetInputAndOutputSignatureBlob +@ stdcall D3D10GetInputSignatureBlob(ptr long ptr) d3d10.D3D10GetInputSignatureBlob +@ stdcall D3D10GetOutputSignatureBlob(ptr long ptr) d3d10.D3D10GetOutputSignatureBlob +@ stdcall D3D10GetPixelShaderProfile(ptr) d3d10.D3D10GetPixelShaderProfile +@ stub D3D10GetShaderDebugInfo +@ stub D3D10GetVersion +@ stdcall D3D10GetVertexShaderProfile(ptr) d3d10.D3D10GetVertexShaderProfile +@ stub D3D10PreprocessShader +@ stub D3D10ReflectShader +@ stub D3D10RegisterLayers +@ stub D3D10StateBlockMaskDifference +@ stub D3D10StateBlockMaskDisableAll +@ stub D3D10StateBlockMaskDisableCapture +@ stub D3D10StateBlockMaskEnableAll +@ stub D3D10StateBlockMaskEnableCapture +@ stub D3D10StateBlockMaskGetSetting +@ stub D3D10StateBlockMaskIntersect +@ stub D3D10StateBlockMaskUnion + diff --git a/src/gallium/state_trackers/d3d1x/winedlls/d3d10_1/version.rc b/src/gallium/state_trackers/d3d1x/winedlls/d3d10_1/version.rc new file mode 100644 index 00000000000..0575ab8b576 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/winedlls/d3d10_1/version.rc @@ -0,0 +1,3 @@ +#define FILENAME "d3d10" +#define NAME "D3D10" +#include "../version.rc.h" diff --git a/src/gallium/state_trackers/d3d1x/winedlls/d3d11/Makefile b/src/gallium/state_trackers/d3d1x/winedlls/d3d11/Makefile new file mode 100644 index 00000000000..b8d992e2437 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/winedlls/d3d11/Makefile @@ -0,0 +1,6 @@ +LIBNAME=d3d11 +LIBRARY_INCLUDES=-I$(D3D1X)/gd3dapi -I$(D3D1X)/d3dapi -I$(D3D1X)/w32api +OBJECTS=../../dxgid3d11/libdxgid3d11.a ../../gd3d11/libgd3d11.a ../../gd3d1x/libgd3d1x.a ../../d3d1xshader/libd3d1xshader.a ../../d3d1xstutil/libd3d1xstutil.a ../../../../auxiliary/libgallium.a +LDADD=-L../dxgi -ldxgi -ldl + +include ../Makefile.wine diff --git a/src/gallium/state_trackers/d3d1x/winedlls/d3d11/d3d11.spec b/src/gallium/state_trackers/d3d1x/winedlls/d3d11/d3d11.spec new file mode 100644 index 00000000000..1d2e0c5b930 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/winedlls/d3d11/d3d11.spec @@ -0,0 +1,6 @@ +@ stub D3D11CoreCreateDevice +@ stub D3D11CoreCreateLayeredDevice +@ stub D3D11CoreGetLayeredDeviceSize +@ stub D3D11CoreRegisterLayers +@ stdcall D3D11CreateDevice(ptr long ptr long ptr long long ptr ptr ptr) +@ stdcall D3D11CreateDeviceAndSwapChain(ptr long ptr long ptr long long ptr ptr ptr ptr ptr) diff --git a/src/gallium/state_trackers/d3d1x/winedlls/d3d11/version.rc b/src/gallium/state_trackers/d3d1x/winedlls/d3d11/version.rc new file mode 100644 index 00000000000..a398678333f --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/winedlls/d3d11/version.rc @@ -0,0 +1,3 @@ +#define FILENAME "d3d11" +#define NAME "D3D11" +#include "../version.rc.h" diff --git a/src/gallium/state_trackers/d3d1x/winedlls/dxgi/Makefile b/src/gallium/state_trackers/d3d1x/winedlls/dxgi/Makefile new file mode 100644 index 00000000000..650bdc84d59 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/winedlls/dxgi/Makefile @@ -0,0 +1,6 @@ +LIBNAME=dxgi +LIBRARY_INCLUDES=-I$(D3D1X)/gd3dapi -I$(D3D1X)/d3dapi -I$(D3D1X)/w32api +OBJECTS=dxgi_dll.o ../../dxgi/libdxgi.a ../../d3d1xstutil/libd3d1xstutil.a ../../../egl/libegl.a ../../../../auxiliary/libgallium.a ../../../../winsys/sw/xlib/libws_xlib.a +LDADD=-lgdi32 -lEGL -lXfixes -lX11 -ldrm -ldl -lXext + +include ../Makefile.wine diff --git a/src/gallium/state_trackers/d3d1x/winedlls/dxgi/dxgi.spec b/src/gallium/state_trackers/d3d1x/winedlls/dxgi/dxgi.spec new file mode 100644 index 00000000000..65a91a45837 --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/winedlls/dxgi/dxgi.spec @@ -0,0 +1,4 @@ +@ stdcall CreateDXGIFactory(ptr ptr) +@ stdcall CreateDXGIFactory1(ptr ptr) +@ stub DXGID3D10CreateDevice +@ stub DXGID3D10RegisterLayers diff --git a/src/gallium/state_trackers/d3d1x/winedlls/dxgi/dxgi_dll.c b/src/gallium/state_trackers/d3d1x/winedlls/dxgi/dxgi_dll.c new file mode 100644 index 00000000000..43e2980afdb --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/winedlls/dxgi/dxgi_dll.c @@ -0,0 +1,264 @@ +/************************************************************************** + * + * 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 <windows.h> +#include <winnt.h> +#include <X11/Xlib.h> +#include <galliumdxgi.h> + +#define DLL_WINE_PREATTACH 8 + +#define X11DRV_ESCAPE 6789 +#define X11DRV_GET_DISPLAY 0 +#define X11DRV_GET_DRAWABLE 1 + +/* Wine works in this way: wineserver stores the all window positions + * in (somewhat fictitious) "screen coordinates", and does not itself + * interact with X11. + * + * Instead, it is the responsibliity of the owner of the X window to + * handle ConfigureNotify and inform wineserver that the window + * moved. + * + * This means that we can freely look at window positions non-atomically, + * since they won't get updated until we return and the application + * processes the Win32 message queue. + * + * Of course, if this thread doesn't own the window, we are screwed. + * + * It might be a good idea to integrate this code in winex11.drv. + */ + +struct WineDXGIBackend +{ + const IGalliumDXGIBackendVtbl *vtbl_IGalliumDXGIBackend; + LONG ref; +}; + +static HRESULT STDMETHODCALLTYPE WineDXGIBackend_BeginPresent( + IGalliumDXGIBackend* This, + HWND hwnd, + void** ppresent_cookie, + void** pwindow, + RECT* prect, + RGNDATA** prgndata, + BOOL* ppreserve_aspect_ratio) +{ + /* this is the parent HWND which actually has an X11 window associated */ + HWND x11_hwnd; + HDC hdc; + RECT client_rect; + POINT x11_hwnd_origin_from_screen; + Drawable drawable; + POINT hwnd_origin_from_screen; + HRGN hrgn; + unsigned code = X11DRV_GET_DRAWABLE; + unsigned rgndata_size; + RGNDATA* rgndata; + RECT rgn_box; + int rgn_box_type; + + hdc = GetDC(hwnd); + GetDCOrgEx(hdc, &hwnd_origin_from_screen); + hrgn = CreateRectRgn(0, 0, 0, 0); + GetRandomRgn(hdc, hrgn, SYSRGN); + rgn_box_type = GetRgnBox(hrgn, &rgn_box); + + /* the coordinate system differs depending on whether Wine is + * pretending to be Win9x or WinNT, so match that behavior. + */ + if (!(GetVersion() & 0x80000000)) + OffsetRgn(hrgn, -hwnd_origin_from_screen.x, -hwnd_origin_from_screen.y); + ReleaseDC(hwnd, hdc); + + if(rgn_box_type == NULLREGION) + { + DeleteObject(hrgn); + return DXGI_STATUS_OCCLUDED; + } + + rgndata_size = GetRegionData(hrgn, 0, NULL); + rgndata = HeapAlloc(GetProcessHeap(), 0, rgndata_size); + GetRegionData(hrgn, rgndata_size, rgndata); + DeleteObject(hrgn); + *prgndata = rgndata; + + x11_hwnd = GetAncestor(hwnd, GA_ROOT); + hdc = GetDC(x11_hwnd); + ExtEscape(hdc, X11DRV_ESCAPE, sizeof(code), (LPSTR)&code, sizeof(drawable), (LPTSTR)&drawable); + + GetDCOrgEx(hdc, &x11_hwnd_origin_from_screen); + ReleaseDC(x11_hwnd, hdc); + + *pwindow = (void*)drawable; + GetClientRect(hwnd, &client_rect); + + prect->left = hwnd_origin_from_screen.x - x11_hwnd_origin_from_screen.x; + prect->top = hwnd_origin_from_screen.y - x11_hwnd_origin_from_screen.y; + + prect->right = prect->left + client_rect.right; + prect->bottom = prect->top + client_rect.bottom; + + // Windows doesn't preserve the aspect ratio + // TODO: maybe let the user turn this on somehow + *ppreserve_aspect_ratio = FALSE; + + *ppresent_cookie = rgndata; + + // TODO: check for errors and return them + return S_OK; +} + +static void STDMETHODCALLTYPE WineDXGIBackend_EndPresent( + IGalliumDXGIBackend* This, + HWND hwnd, + void *present_cookie) +{ + HeapFree(GetProcessHeap(), 0, present_cookie); +} + +static HRESULT STDMETHODCALLTYPE WineDXGIBackend_TestPresent( + IGalliumDXGIBackend* This, + HWND hwnd) +{ + HDC hdc; + HRGN hrgn; + RECT rgn_box; + int rgn_box_type; + + // TODO: is there a simpler way to check this? + hdc = GetDC(hwnd); + hrgn = CreateRectRgn(0, 0, 0, 0); + GetRandomRgn(hdc, hrgn, SYSRGN); + rgn_box_type = GetRgnBox(hrgn, &rgn_box); + DeleteObject(hrgn); + ReleaseDC(hwnd, hdc); + + return rgn_box_type == NULLREGION ? DXGI_STATUS_OCCLUDED : S_OK; +} + +static HRESULT STDMETHODCALLTYPE WineDXGIBackend_GetPresentSize( + IGalliumDXGIBackend* This, + HWND hwnd, + unsigned* width, + unsigned* height) +{ + RECT client_rect; + GetClientRect(hwnd, &client_rect); + *width = client_rect.right - client_rect.left; + *height = client_rect.bottom - client_rect.top; + + // TODO: check for errors and return them + return S_OK; +} + +/* Wine should switch to C++ at least to be able to implement COM interfaces in a sensible way, + * instead of this ridiculous amount of clumsy duplicated code everywhere + * C++ exists exactly to avoid having to write the following code */ +static ULONG STDMETHODCALLTYPE WineDXGIBackend_AddRef(IGalliumDXGIBackend* This) +{ + return InterlockedIncrement(&((struct WineDXGIBackend*)&This)->ref); +} + +static ULONG STDMETHODCALLTYPE WineDXGIBackend_Release(IGalliumDXGIBackend* This) +{ + ULONG v = InterlockedDecrement(&((struct WineDXGIBackend*)&This)->ref); + if(!v) + HeapFree(GetProcessHeap(), 0, This); + return v; +} + +static HRESULT WINAPI WineDXGIBackend_QueryInterface( + IGalliumDXGIBackend* iface, + REFIID riid, + void** ppvObject) +{ + if (IsEqualGUID(riid, &IID_IUnknown) + || IsEqualGUID(riid, &IID_IGalliumDXGIBackend)) + { + WineDXGIBackend_AddRef(iface); + *ppvObject = iface; + return S_OK; + } + + return E_NOINTERFACE; +} + +static IGalliumDXGIBackendVtbl WineDXGIBackend_vtbl = +{ + WineDXGIBackend_QueryInterface, + WineDXGIBackend_AddRef, + WineDXGIBackend_Release, + WineDXGIBackend_BeginPresent, + WineDXGIBackend_EndPresent, + WineDXGIBackend_TestPresent, + WineDXGIBackend_GetPresentSize +}; + +IGalliumDXGIBackend* new_WineDXGIBackend() +{ + struct WineDXGIBackend* backend = HeapAlloc(GetProcessHeap(), 0, sizeof(struct WineDXGIBackend)); + backend->ref = 1; + backend->vtbl_IGalliumDXGIBackend = &WineDXGIBackend_vtbl; + return (IGalliumDXGIBackend*)backend; +} + +static void install_wine_dxgi_backend() +{ + IGalliumDXGIBackend* backend = new_WineDXGIBackend(); + HWND root = GetDesktopWindow(); + unsigned code = X11DRV_GET_DISPLAY; + Display* dpy; + HDC hdc; + + hdc = GetDC(root); + ExtEscape(hdc, X11DRV_ESCAPE, sizeof(code), (LPSTR)&code, sizeof(dpy), (LPTSTR)&dpy); + ReleaseDC(root, hdc); + + GalliumDXGIUseX11Display(dpy, backend); + GalliumDXGIMakeDefault(); + GalliumDXGIUseNothing(); + backend->lpVtbl->Release(backend); +} + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + switch (fdwReason) + { + case DLL_WINE_PREATTACH: + return TRUE; + case DLL_PROCESS_ATTACH: + DisableThreadLibraryCalls(hinstDLL); + install_wine_dxgi_backend(); + break; + case DLL_PROCESS_DETACH: + break; + default: + break; + } + + return TRUE; +} diff --git a/src/gallium/state_trackers/d3d1x/winedlls/dxgi/version.rc b/src/gallium/state_trackers/d3d1x/winedlls/dxgi/version.rc new file mode 100644 index 00000000000..3653281fbcc --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/winedlls/dxgi/version.rc @@ -0,0 +1,3 @@ +#define FILENAME "dxgi" +#define NAME "DXGI" +#include "../version.rc.h" diff --git a/src/gallium/state_trackers/d3d1x/winedlls/version.rc.h b/src/gallium/state_trackers/d3d1x/winedlls/version.rc.h new file mode 100644 index 00000000000..096d119fa3c --- /dev/null +++ b/src/gallium/state_trackers/d3d1x/winedlls/version.rc.h @@ -0,0 +1,30 @@ +1 VERSIONINFO +FILEVERSION 6,0,6000,16386 +PRODUCTVERSION 6,0,6000,16386 +FILEFLAGSMASK 63 +FILEFLAGS 0 +FILEOS 0x00000000L +FILETYPE 0x00000002L +FILESUBTYPE 0x00000000L +{ + BLOCK "StringFileInfo" + { + BLOCK "040904E4" + { + // all Wine DLLs claim to be from Microsoft, maybe it's needed for compatibility + VALUE "CompanyName", "Microsoft Corporation" + VALUE "FileDescription", "GalliumD3D1x " NAME " runtime" + VALUE "FileVersion", "6.0.6000.16386" + VALUE "InternalName", "" + VALUE "LegalCopyright", "Copyright (c) 2010 Luca Barbieri and other contributors" + VALUE "OriginalFilename", FILENAME ".dll" + VALUE "ProductName", "GalliumD3D1x" + VALUE "ProductVersion", "6.0.6000.16386" + } + } + BLOCK "VarFileInfo" + { + VALUE "Translation", 0x0409, 0x04E4 + } +} + |