d3d1x: Remove.

Unused/unmaintained.

Reviewed-by: Christoph Bumiller <e0425955@student.tuwien.ac.at>
This commit is contained in:
José Fonseca 2013-03-11 10:13:47 +00:00
parent 7db60f049f
commit 44a8e51354
137 changed files with 1 additions and 27307 deletions

View File

@ -590,13 +590,6 @@ AC_ARG_ENABLE([xa],
[enable build of the XA X Acceleration API @<:@default=no@:>@])],
[enable_xa="$enableval"],
[enable_xa=no])
dnl Broken, unmaintained. Don't want to see bug reports about it without patches.
enable_d3d1x=no
dnl AC_ARG_ENABLE([d3d1x],
dnl [AS_HELP_STRING([--enable-d3d1x],
dnl [enable support for Direct3D 10 & 11 low-level API @<:@default=no@:>@])],
dnl [enable_d3d1x="$enableval"],
dnl [enable_d3d1x=no])
AC_ARG_ENABLE([gbm],
[AS_HELP_STRING([--enable-gbm],
[enable gbm library @<:@default=auto@:>@])],
@ -678,7 +671,6 @@ if test "x$enable_opengl" = xno -a \
"x$enable_openvg" = xno -a \
"x$enable_xorg" = xno -a \
"x$enable_xa" = xno -a \
"x$enable_d3d1x" = xno -a \
"x$enable_xvmc" = xno -a \
"x$enable_vdpau" = xno -a \
"x$enable_opencl" = xno; then
@ -1356,19 +1348,6 @@ if test "x$enable_openvg" = xyes; then
fi
AM_CONDITIONAL(HAVE_OPENVG, test "x$enable_openvg" = xyes)
dnl
dnl D3D1X configuration
dnl
if test "x$enable_d3d1x" = xyes; then
if test "x$with_gallium_drivers" = x; then
AC_MSG_ERROR([cannot enable D3D1X without Gallium])
fi
GALLIUM_STATE_TRACKERS_DIRS="d3d1x $GALLIUM_STATE_TRACKERS_DIRS"
HAVE_ST_D3D1X=yes
fi
dnl
dnl Gallium G3DVL configuration
dnl

View File

@ -290,7 +290,7 @@ Queries
^^^^^^^
Queries gather some statistic from the 3D pipeline over one or more
draws. Queries may be nested, though only d3d1x currently exercises this.
draws. Queries may be nested, though not all state trackers exercise this.
Queries can be created with ``create_query`` and deleted with
``destroy_query``. To start a query, use ``begin_query``, and when finished,

View File

@ -1,20 +0,0 @@
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

View File

@ -1,11 +0,0 @@
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:

View File

@ -1,19 +0,0 @@
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 $@ $<

View File

@ -1,16 +0,0 @@
LIBNAME=d3d1xshader
CPP_SOURCES=$(wildcard src/*.cpp) src/sm4_text.cpp
LIBRARY_INCLUDES=-Iinclude -I../d3dapi -I../w32api
PROGS=tools/fxdis
PROGS_DEPS=libd3d1xshader.a
LIBS=$(PROGS_DEPS)
include ../Makefile.inc
include/sm4.h: include/sm4_defs.h
include/sm4_defs.h: $(wildcard defs/*.txt)
./gen-header.sh $^ > $@
src/sm4_text.cpp: $(wildcard defs/*.txt)
./gen-text.sh $^ > $@

View File

@ -1,41 +0,0 @@
temp
input
output
indexable_temp
immediate32
immediate64
sampler
resource
constant_buffer
immediate_constant_buffer
label
input_primitiveid
output_depth
null
rasterizer
output_coverage_mask
stream
function_body
function_table
interface
function_input
function_output
output_control_point_id
input_fork_instance_id
input_join_instance_id
input_control_point
output_control_point
input_patch_constant
input_domain_point
this_pointer
unordered_access_view
thread_group_shared_memory
input_thread_id
input_thread_group_id
input_thread_id_in_group
input_coverage_mask
input_thread_id_in_group_flattened
input_gs_instance_id
output_depth_greater_equal
output_depth_less_equal
cycle_counter

View File

@ -1,8 +0,0 @@
undefined
constant
linear
linear centroid
linear noperspective
linear noperspective centroid
linear sample
linear noperspective sample

View File

@ -1,207 +0,0 @@
add
and
break
breakc
call
callc
case
continue
continuec
cut
default
deriv_rtx
deriv_rty
discard
div
dp2
dp3
dp4
else
emit
emitthencut
endif
endloop
endswitch
eq
exp
frc
ftoi
ftou
ge
iadd
if
ieq
ige
ilt
imad
imax
imin
imul
ine
ineg
ishl
ishr
itof
label
ld
ld_ms
log
loop
lt
mad
min
max
customdata
mov
movc
mul
ne
nop
not
or
resinfo
ret
retc
round_ne
round_ni
round_pi
round_z
rsq
sample
sample_c
sample_c_lz
sample_l
sample_d
sample_b
sqrt
switch
sincos
udiv
ult
uge
umul
umad
umax
umin
ushr
utof
xor
dcl_resource
dcl_constant_buffer
dcl_sampler
dcl_index_range
dcl_gs_output_primitive_topology
dcl_gs_input_primitive
dcl_max_output_vertex_count
dcl_input
dcl_input_sgv
dcl_input_siv
dcl_input_ps
dcl_input_ps_sgv
dcl_input_ps_siv
dcl_output
dcl_output_sgv
dcl_output_siv
dcl_temps
dcl_indexable_temp
dcl_global_flags
d3d10_count
lod
gather4
sample_pos
sample_info
d3d10_1_count
hs_decls
hs_control_point_phase
hs_fork_phase
hs_join_phase
emit_stream
cut_stream
emitthencut_stream
interface_call
bufinfo
deriv_rtx_coarse
deriv_rtx_fine
deriv_rty_coarse
deriv_rty_fine
gather4_c
gather4_po
gather4_po_c
rcp
f32tof16
f16tof32
uaddc
usubb
countbits
firstbit_hi
firstbit_lo
firstbit_shi
ubfe
ibfe
bfi
bfrev
swapc
dcl_stream
dcl_function_body
dcl_function_table
dcl_interface
dcl_input_control_point_count
dcl_output_control_point_count
dcl_tess_domain
dcl_tess_partitioning
dcl_tess_output_primitive
dcl_hs_max_tessfactor
dcl_hs_fork_phase_instance_count
dcl_hs_join_phase_instance_count
dcl_thread_group
dcl_unordered_access_view_typed
dcl_unordered_access_view_raw
dcl_unordered_access_view_structured
dcl_thread_group_shared_memory_raw
dcl_thread_group_shared_memory_structured
dcl_resource_raw
dcl_resource_structured
ld_uav_typed
store_uav_typed
ld_raw
store_raw
ld_structured
store_structured
atomic_and
atomic_or
atomic_xor
atomic_cmp_store
atomic_iadd
atomic_imax
atomic_imin
atomic_umax
atomic_umin
imm_atomic_alloc
imm_atomic_consume
imm_atomic_iadd
imm_atomic_and
imm_atomic_or
imm_atomic_xor
imm_atomic_exch
imm_atomic_cmp_exch
imm_atomic_imax
imm_atomic_imin
imm_atomic_umax
imm_atomic_umin
sync
dadd
dmax
dmin
dmul
deq
dge
dlt
dne
dmov
dmovc
dtof
ftod
eval_snapped
eval_sample_index
eval_centroid
dcl_gs_instance_count

View File

@ -1,5 +0,0 @@
imm32
imm64
reg
reg_imm32
reg_imm64

View File

@ -1,4 +0,0 @@
mask
swizzle
scalar

View File

@ -1,41 +0,0 @@
r
v
o
x
l
d
sampler
resource
cb
icb
label
vPrim
oDepth
null
rasterizer
oMask
stream
function_body
function_table
interface
function_input
function_output
vOutputControlPointID
vForkInstanceID
vJoinInstanceID
vicp
vocp
input_patch_constant
vDomain
this
u
g
vThreadID
vThreadGrouID
vThreadIDInGroup
vCoverage
vThreadIDInGroupFlattened
vGSInstanceID
oDepthGE
oDepthLE
vCycleCounter

View File

@ -1,23 +0,0 @@
undefined
position
clip_distance
cull_distance
render_target_array_index
viewport_array_index
vertex_id
primitive_id
instance_id
is_front_face
sample_index
final_quad_u_eq_0_edge_tessfactor
final_quad_v_eq_0_edge_tessfactor
final_quad_u_eq_1_edge_tessfactor
final_quad_v_eq_1_edge_tessfactor
final_quad_u_inside_tessfactor
final_quad_v_inside_tessfactor
final_tri_u_eq_0_edge_tessfactor
final_tri_v_eq_0_edge_tessfactor
final_tri_w_eq_0_edge_tessfactor
final_tri_inside_tessfactor
final_line_detail_tessfactor
final_line_density_tessfactor

View File

@ -1,13 +0,0 @@
unknown
buffer
texture1d
texture2d
texture2dms
texture3d
texturecube
texture1darray
texture2darray
texture2dmsarray
texturecubearray
raw_buffer
structured_buffer

View File

@ -1,4 +0,0 @@
empty
sample_controls
resource_dim
resource_return_type

View File

@ -1,13 +0,0 @@
#!/bin/bash
for i in "$@"; do
n=$(basename "$i" .txt|sed -e 's/s$//')
if test "$n" == "shortfile"; then continue; fi
echo "enum sm4_$n"
echo "{"
while read j; do
echo $'\t'"SM4_${n}_$j",
done < "$i" |tr '[a-z]' '[A-Z]'|tr ' ' '_'
echo $'\t'"SM4_${n}_COUNT"|tr '[a-z]' '[A-Z]'
echo "};"
echo
done

View File

@ -1,11 +0,0 @@
#!/bin/bash
for i in "$@"; do
n=$(basename "$i" .txt|sed -e 's/s$//')
echo "const char* sm4_${n}_names[] ="
echo "{"
while read j; do
echo $'\t'"\"$j\"",
done < "$i"
echo "};"
echo
done

View File

@ -1,125 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#ifndef DXBC_H_
#define DXBC_H_
#include <stdint.h>
#include <vector>
#include <map>
#include <iostream>
#include "le32.h"
#define FOURCC(a, b, c, d) ((uint32_t)(uint8_t)(a) | ((uint32_t)(uint8_t)(b) << 8) | ((uint32_t)(uint8_t)(c) << 16) | ((uint32_t)(uint8_t)(d) << 24 ))
#define FOURCC_DXBC FOURCC('D', 'X', 'B', 'C')
#define FOURCC_RDEF FOURCC('R', 'D', 'E', 'F')
#define FOURCC_ISGN FOURCC('I', 'S', 'G', 'N')
#define FOURCC_OSGN FOURCC('O', 'S', 'G', 'N')
#define FOURCC_SHDR FOURCC('S', 'H', 'D', 'R')
#define FOURCC_SHEX FOURCC('S', 'H', 'E', 'X')
#define FOURCC_STAT FOURCC('S', 'T', 'A', 'T')
#define FOURCC_PCSG FOURCC('P', 'C', 'S', 'G')
/* this is always little-endian! */
struct dxbc_chunk_header
{
unsigned fourcc;
unsigned size;
};
/* this is always little-endian! */
struct dxbc_chunk_signature : public dxbc_chunk_header
{
uint32_t count;
uint32_t unk;
struct
{
uint32_t name_offset;
uint32_t semantic_index;
uint32_t system_value_type;
uint32_t component_type;
uint32_t register_num;
uint8_t mask;
uint8_t read_write_mask;
uint8_t stream; /* TODO: guess! */
uint8_t unused;
} elements[];
};
struct dxbc_container
{
const void* data;
std::vector<dxbc_chunk_header*> chunks;
std::map<unsigned, unsigned> chunk_map;
};
struct dxbc_container_header
{
unsigned fourcc;
uint32_t unk[4];
uint32_t one;
uint32_t total_size;
uint32_t chunk_count;
};
dxbc_container* dxbc_parse(const void* data, int size);
std::ostream& operator <<(std::ostream& out, const dxbc_container& container);
dxbc_chunk_header* dxbc_find_chunk(const void* data, int size, unsigned fourcc);
static inline dxbc_chunk_header* dxbc_find_shader_bytecode(const void* data, int size)
{
dxbc_chunk_header* chunk;
chunk = dxbc_find_chunk(data, size, FOURCC_SHDR);
if(!chunk)
chunk = dxbc_find_chunk(data, size, FOURCC_SHEX);
return chunk;
}
#define DXBC_FIND_INPUT_SIGNATURE 0
#define DXBC_FIND_OUTPUT_SIGNATURE 1
#define DXBC_FIND_PATCH_SIGNATURE 2
static inline dxbc_chunk_signature* dxbc_find_signature(const void* data, int size, unsigned kind)
{
unsigned fourcc;
switch(kind) {
case DXBC_FIND_INPUT_SIGNATURE: fourcc = FOURCC_ISGN; break;
case DXBC_FIND_OUTPUT_SIGNATURE: fourcc = FOURCC_OSGN; break;
case DXBC_FIND_PATCH_SIGNATURE: fourcc = FOURCC_PCSG; break;
default:
return NULL;
}
return (dxbc_chunk_signature*)dxbc_find_chunk(data, size, fourcc);
}
struct _D3D11_SIGNATURE_PARAMETER_DESC;
typedef struct _D3D11_SIGNATURE_PARAMETER_DESC D3D11_SIGNATURE_PARAMETER_DESC;
int dxbc_parse_signature(dxbc_chunk_signature* sig, D3D11_SIGNATURE_PARAMETER_DESC** params);
std::pair<void*, size_t> dxbc_assemble(struct dxbc_chunk_header** chunks, unsigned num_chunks);
#endif /* DXBC_H_ */

View File

@ -1,45 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#ifndef LE32_H_
#define LE32_H_
#include <stdint.h>
#include <assert.h>
#ifdef WORDS_BIGENDIAN
static inline uint32_t bswap_le32(uint32_t v)
{
return ((v & 0xff) << 24) | ((v & 0xff00) << 8) | ((v & 0xff0000) >> 8) | ((v & 0xff000000) >> 24);
}
#else
static inline uint32_t bswap_le32(uint32_t v)
{
return v;
}
#endif
#endif /* LE32_H_ */

View File

@ -1,416 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
/* Header for Shader Model 4.0, 4.1 and 5.0 */
#ifndef SM4_H_
#define SM4_H_
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <memory>
#include <vector>
#include <map>
#include <iostream>
#include "le32.h"
#include "sm4_defs.h"
extern const char* sm4_opcode_names[];
extern const char* sm4_file_names[];
extern const char* sm4_shortfile_names[];
extern const char* sm4_target_names[];
extern const char* sm4_interpolation_names[];
extern const char* sm4_sv_names[];
struct sm4_token_version
{
unsigned minor : 4;
unsigned major : 4;
unsigned format : 8;
unsigned type : 16;
};
struct sm4_token_instruction
{
// we don't make it an union directly because unions can't be inherited from
union
{
// length and extended are always present, but they are only here to reduce duplication
struct
{
unsigned opcode : 11;
unsigned _11_23 : 13;
unsigned length : 7;
unsigned extended : 1;
};
struct
{
unsigned opcode : 11;
unsigned resinfo_return_type : 2;
unsigned sat : 1;
unsigned _14_17 : 4;
unsigned test_nz : 1; // bit 18
unsigned precise_mask : 4;
unsigned _23 : 1;
unsigned length : 7;
unsigned extended : 1;
} insn;
struct
{
unsigned opcode : 11;
unsigned threads_in_group : 1;
unsigned shared_memory : 1;
unsigned uav_group : 1;
unsigned uav_global : 1;
unsigned _15_17 : 3;
} sync;
struct
{
unsigned opcode : 11;
unsigned allow_refactoring : 1;
unsigned fp64 : 1;
unsigned early_depth_stencil : 1;
unsigned enable_raw_and_structured_in_non_cs : 1;
} dcl_global_flags;
struct
{
unsigned opcode : 11;
unsigned target : 5;
unsigned nr_samples : 7;
} dcl_resource;
struct
{
unsigned opcode : 11;
unsigned shadow : 1;
unsigned mono : 1;
} dcl_sampler;
struct
{
unsigned opcode : 11;
unsigned interpolation : 5;
} dcl_input_ps;
struct
{
unsigned opcode : 11;
unsigned dynamic : 1;
} dcl_constant_buffer;
struct
{
unsigned opcode : 11;
unsigned primitive : 6;
} dcl_gs_input_primitive;
struct
{
unsigned opcode : 11;
unsigned primitive_topology : 7;
} dcl_gs_output_primitive_topology;
struct
{
unsigned opcode : 11;
unsigned control_points : 6;
} dcl_input_control_point_count;
struct
{
unsigned opcode : 11;
unsigned control_points : 6;
} dcl_output_control_point_count;
struct
{
unsigned opcode : 11;
unsigned domain : 3; /* D3D_TESSELLATOR_DOMAIN */
} dcl_tess_domain;
struct
{
unsigned opcode : 11;
unsigned partitioning : 3; /* D3D_TESSELLATOR_PARTITIONING */
} dcl_tess_partitioning;
struct
{
unsigned opcode : 11;
unsigned primitive : 3; /* D3D_TESSELLATOR_OUTPUT_PRIMITIVE */
} dcl_tess_output_primitive;
};
};
union sm4_token_instruction_extended
{
struct
{
unsigned type : 6;
unsigned _6_30 : 25;
unsigned extended :1;
};
struct
{
unsigned type : 6;
unsigned _6_8 : 3;
int offset_u : 4;
int offset_v : 4;
int offset_w : 4;
} sample_controls;
struct
{
unsigned type : 6;
unsigned target : 5;
} resource_target;
struct
{
unsigned type : 6;
unsigned x : 4;
unsigned y : 4;
unsigned z : 4;
unsigned w : 4;
} resource_return_type;
};
struct sm4_token_resource_return_type
{
unsigned x : 4;
unsigned y : 4;
unsigned z : 4;
unsigned w : 4;
};
struct sm4_token_operand
{
unsigned comps_enum : 2; /* sm4_operands_comps */
unsigned mode : 2; /* sm4_operand_mode */
unsigned sel : 8;
unsigned file : 8; /* sm4_file */
unsigned num_indices : 2;
unsigned index0_repr : 3; /* sm4_operand_index_repr */
unsigned index1_repr : 3; /* sm4_operand_index_repr */
unsigned index2_repr : 3; /* sm4_operand_index_repr */
unsigned extended : 1;
};
#define SM4_OPERAND_SEL_MASK(sel) ((sel) & 0xf)
#define SM4_OPERAND_SEL_SWZ(sel, i) (((sel) >> ((i) * 2)) & 3)
#define SM4_OPERAND_SEL_SCALAR(sel) ((sel) & 3)
struct sm4_token_operand_extended
{
unsigned type : 6;
unsigned neg : 1;
unsigned abs : 1;
};
union sm4_any
{
double f64;
float f32;
int64_t i64;
int32_t i32;
uint64_t u64;
int64_t u32;
};
struct sm4_op;
struct sm4_insn;
struct sm4_dcl;
struct sm4_program;
std::ostream& operator <<(std::ostream& out, const sm4_op& op);
std::ostream& operator <<(std::ostream& out, const sm4_insn& op);
std::ostream& operator <<(std::ostream& out, const sm4_dcl& op);
std::ostream& operator <<(std::ostream& out, const sm4_program& op);
struct sm4_op
{
uint8_t mode;
uint8_t comps;
uint8_t mask;
uint8_t num_indices;
uint8_t swizzle[4];
sm4_file file;
sm4_any imm_values[4];
bool neg;
bool abs;
struct
{
int64_t disp;
std::auto_ptr<sm4_op> reg;
} indices[3];
bool is_index_simple(unsigned i) const
{
return !indices[i].reg.get() && indices[i].disp >= 0 && (int64_t)(int32_t)indices[i].disp == indices[i].disp;
}
bool has_simple_index() const
{
return num_indices == 1 && is_index_simple(0);
}
sm4_op()
{
memset(this, 0, sizeof(*this));
}
void dump();
private:
sm4_op(const sm4_op& op)
{}
};
/* for sample_d */
#define SM4_MAX_OPS 6
struct sm4_insn : public sm4_token_instruction
{
int8_t sample_offset[3];
uint8_t resource_target;
uint8_t resource_return_type[4];
unsigned num;
unsigned num_ops;
std::auto_ptr<sm4_op> ops[SM4_MAX_OPS];
sm4_insn()
{
memset(this, 0, sizeof(*this));
}
void dump();
private:
sm4_insn(const sm4_insn& op)
{}
};
struct sm4_dcl : public sm4_token_instruction
{
std::auto_ptr<sm4_op> op;
union
{
unsigned num;
float f32;
sm4_sv sv;
struct
{
unsigned id;
unsigned expected_function_table_length;
unsigned table_length;
unsigned array_length;
} intf;
unsigned thread_group_size[3];
sm4_token_resource_return_type rrt;
struct
{
unsigned num;
unsigned comps;
} indexable_temp;
struct
{
unsigned stride;
unsigned count;
} structured;
};
void* data;
sm4_dcl()
{
memset(this, 0, sizeof(*this));
}
~sm4_dcl()
{
free(data);
}
void dump();
private:
sm4_dcl(const sm4_dcl& op)
{}
};
struct _D3D11_SIGNATURE_PARAMETER_DESC;
struct sm4_program
{
sm4_token_version version;
std::vector<sm4_dcl*> dcls;
std::vector<sm4_insn*> insns;
_D3D11_SIGNATURE_PARAMETER_DESC* params_in;
_D3D11_SIGNATURE_PARAMETER_DESC* params_out;
_D3D11_SIGNATURE_PARAMETER_DESC* params_patch;
unsigned num_params_in;
unsigned num_params_out;
unsigned num_params_patch;
/* for ifs, the insn number of the else or endif if there is no else
* for elses, the insn number of the endif
* for endifs, the insn number of the if
* for loops, the insn number of the endloop
* for endloops, the insn number of the loop
* for all others, -1
*/
std::vector<int> cf_insn_linked;
bool labels_found;
std::vector<int> label_to_insn_num;
sm4_program()
{
memset(&version, 0, sizeof(version));
labels_found = false;
num_params_in = num_params_out = num_params_patch = 0;
}
~sm4_program()
{
for(std::vector<sm4_dcl*>::iterator i = dcls.begin(), e = dcls.end(); i != e; ++i)
delete *i;
for(std::vector<sm4_insn*>::iterator i = insns.begin(), e = insns.end(); i != e; ++i)
delete *i;
if(num_params_in)
free(params_in);
if(num_params_out)
free(params_out);
if(num_params_patch)
free(params_patch);
}
void dump();
private:
sm4_program(const sm4_dcl& op)
{}
};
sm4_program* sm4_parse(void* tokens, int size);
bool sm4_link_cf_insns(sm4_program& program);
bool sm4_find_labels(sm4_program& program);
#endif /* SM4_H_ */

View File

@ -1,59 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include <stdlib.h>
#include <string.h>
#include "dxbc.h"
std::pair<void*, size_t> dxbc_assemble(struct dxbc_chunk_header** chunks, unsigned num_chunks)
{
size_t data_size = 0;
for(unsigned i = 0; i < num_chunks; ++i)
data_size += sizeof(uint32_t) + sizeof(dxbc_chunk_header) + bswap_le32(chunks[i]->size);
size_t total_size = sizeof(dxbc_container_header) + data_size;
dxbc_container_header* header = (dxbc_container_header*)malloc(total_size);
if(!header)
return std::make_pair((void*)0, 0);
header->fourcc = bswap_le32(FOURCC_DXBC);
memset(header->unk, 0, sizeof(header->unk));
header->one = bswap_le32(1);
header->total_size = bswap_le32(total_size);
header->chunk_count = num_chunks;
uint32_t* chunk_offsets = (uint32_t*)(header + 1);
uint32_t off = sizeof(struct dxbc_container_header) + num_chunks * sizeof(uint32_t);
for(unsigned i = 0; i < num_chunks; ++i)
{
chunk_offsets[i] = bswap_le32(off);
unsigned chunk_full_size = sizeof(dxbc_chunk_header) + bswap_le32(chunks[i]->size);
memcpy((char*)header + off, chunks[i], chunk_full_size);
off += chunk_full_size;
}
return std::make_pair((void*)header, total_size);
}

View File

@ -1,43 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include <memory>
#include <string.h>
#include <iomanip>
#include "dxbc.h"
std::ostream& operator <<(std::ostream& out, const dxbc_container& container)
{
for(unsigned i = 0; i < container.chunks.size(); ++i)
{
struct dxbc_chunk_header* chunk = container.chunks[i];
char fourcc_str[5];
memcpy(fourcc_str, &chunk->fourcc, 4);
fourcc_str[4] = 0;
out << "# DXBC chunk " << std::setw(2) << i << ": " << fourcc_str << " offset " << ((char*)chunk - (char*)container.data) << " size " << bswap_le32(chunk->size) << "\n";
}
return out;
}

View File

@ -1,87 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include <memory>
#include "dxbc.h"
#include <d3d11shader.h>
#include <d3dcommon.h>
dxbc_container* dxbc_parse(const void* data, int size)
{
std::auto_ptr<dxbc_container> container(new dxbc_container());
container->data = data;
dxbc_container_header* header = (dxbc_container_header*)data;
uint32_t* chunk_offsets = (uint32_t*)(header + 1);
if(bswap_le32(header->fourcc) != FOURCC_DXBC)
return 0;
unsigned num_chunks = bswap_le32(header->chunk_count);
for(unsigned i = 0; i < num_chunks; ++i)
{
unsigned offset = bswap_le32(chunk_offsets[i]);
dxbc_chunk_header* chunk = (dxbc_chunk_header*)((char*)data + offset);
unsigned fourcc = bswap_le32(chunk->fourcc);
container->chunk_map[fourcc] = i;
container->chunks.push_back(chunk);
}
return container.release();
}
dxbc_chunk_header* dxbc_find_chunk(const void* data, int size, unsigned fourcc)
{
dxbc_container_header* header = (dxbc_container_header*)data;
uint32_t* chunk_offsets = (uint32_t*)(header + 1);
if(bswap_le32(header->fourcc) != FOURCC_DXBC)
return 0;
unsigned num_chunks = bswap_le32(header->chunk_count);
for(unsigned i = 0; i < num_chunks; ++i)
{
unsigned offset = bswap_le32(chunk_offsets[i]);
dxbc_chunk_header* chunk = (dxbc_chunk_header*)((char*)data + offset);
if(bswap_le32(chunk->fourcc) == fourcc)
return chunk;
}
return 0;
}
int dxbc_parse_signature(dxbc_chunk_signature* sig, D3D11_SIGNATURE_PARAMETER_DESC** params)
{
unsigned count = bswap_le32(sig->count);
*params = (D3D11_SIGNATURE_PARAMETER_DESC*)malloc(sizeof(D3D11_SIGNATURE_PARAMETER_DESC) * count);
for (unsigned i = 0; i < count; ++i)
{
D3D11_SIGNATURE_PARAMETER_DESC& param = (*params)[i];
param.SemanticName = (char*)&sig->count + bswap_le32(sig->elements[i].name_offset);
param.SemanticIndex = bswap_le32(sig->elements[i].semantic_index);
param.SystemValueType = (D3D_NAME)bswap_le32(sig->elements[i].system_value_type);
param.ComponentType = (D3D_REGISTER_COMPONENT_TYPE)bswap_le32(sig->elements[i].component_type);
param.Register = bswap_le32(sig->elements[i].register_num);
param.Mask = sig->elements[i].mask;
param.ReadWriteMask = sig->elements[i].read_write_mask;
param.Stream = sig->elements[i].stream;
}
return count;
}

View File

@ -1,122 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include <vector>
#include <set>
#include "sm4.h"
#define check(x) do {if(!(x)) return false;} while(0)
bool sm4_link_cf_insns(sm4_program& program)
{
if(program.cf_insn_linked.size())
return true;
std::vector<int> cf_insn_linked;
cf_insn_linked.resize(program.insns.size());
memset(&cf_insn_linked[0], 0xff, cf_insn_linked.size() * sizeof(int));
std::vector<unsigned> cf_stack;
for(unsigned insn_num = 0; insn_num < program.insns.size(); ++insn_num)
{
unsigned v;
switch(program.insns[insn_num]->opcode)
{
case SM4_OPCODE_LOOP:
cf_stack.push_back(insn_num);
break;
case SM4_OPCODE_ENDLOOP:
check(!cf_stack.empty());
v = cf_stack.back();
check(program.insns[v]->opcode == SM4_OPCODE_LOOP);
cf_insn_linked[v] = insn_num;
cf_insn_linked[insn_num] = v;
cf_stack.pop_back();
break;
case SM4_OPCODE_IF:
case SM4_OPCODE_SWITCH:
cf_insn_linked[insn_num] = insn_num; // later changed
cf_stack.push_back(insn_num);
break;
case SM4_OPCODE_ELSE:
case SM4_OPCODE_CASE:
check(!cf_stack.empty());
v = cf_stack.back();
if(program.insns[insn_num]->opcode == SM4_OPCODE_ELSE)
check(program.insns[v]->opcode == SM4_OPCODE_IF);
else
check(program.insns[v]->opcode == SM4_OPCODE_SWITCH || program.insns[v]->opcode == SM4_OPCODE_CASE);
cf_insn_linked[insn_num] = cf_insn_linked[v]; // later changed
cf_insn_linked[v] = insn_num;
cf_stack.back() = insn_num;
break;
case SM4_OPCODE_ENDSWITCH:
case SM4_OPCODE_ENDIF:
check(!cf_stack.empty());
v = cf_stack.back();
if(program.insns[insn_num]->opcode == SM4_OPCODE_ENDIF)
check(program.insns[v]->opcode == SM4_OPCODE_IF || program.insns[v]->opcode == SM4_OPCODE_ELSE);
else
check(program.insns[v]->opcode == SM4_OPCODE_SWITCH || program.insns[v]->opcode == SM4_OPCODE_CASE);
cf_insn_linked[insn_num] = cf_insn_linked[v];
cf_insn_linked[v] = insn_num;
cf_stack.pop_back();
break;
}
}
check(cf_stack.empty());
program.cf_insn_linked.swap(cf_insn_linked);
return true;
}
bool sm4_find_labels(sm4_program& program)
{
if(program.labels_found)
return true;
std::vector<int> labels;
for(unsigned insn_num = 0; insn_num < program.insns.size(); ++insn_num)
{
switch(program.insns[insn_num]->opcode)
{
case SM4_OPCODE_LABEL:
if(program.insns[insn_num]->num_ops > 0)
{
sm4_op& op = *program.insns[insn_num]->ops[0];
if(op.file == SM4_FILE_LABEL && op.has_simple_index())
{
unsigned idx = (unsigned)op.indices[0].disp;
if(idx >= labels.size())
labels.resize(idx + 1);
labels[idx] = insn_num;
}
}
break;
}
}
program.label_to_insn_num.swap(labels);
program.labels_found = true;
return true;
}

View File

@ -1,222 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include "sm4.h"
// TODO: we should fix this to output the same syntax as fxc, if sm4_dump_short_syntax is set
bool sm4_dump_short_syntax = true;
std::ostream& operator <<(std::ostream& out, const sm4_op& op)
{
if(op.neg)
out << '-';
if(op.abs)
out << '|';
if(op.file == SM4_FILE_IMMEDIATE32)
{
out << "l(";
for(unsigned i = 0; i < op.comps; ++i)
{
if(i)
out << ", ";
out << op.imm_values[i].f32;
}
out << ")";
}
else if(op.file == SM4_FILE_IMMEDIATE64)
{
out << "d(";
for(unsigned i = 0; i < op.comps; ++i)
{
if(i)
out << ", ";
out << op.imm_values[i].f64;
}
out << ")";
return out;
}
else
{
bool naked = false;
if(sm4_dump_short_syntax)
{
switch(op.file)
{
case SM4_FILE_TEMP:
case SM4_FILE_INPUT:
case SM4_FILE_OUTPUT:
case SM4_FILE_CONSTANT_BUFFER:
case SM4_FILE_INDEXABLE_TEMP:
case SM4_FILE_UNORDERED_ACCESS_VIEW:
case SM4_FILE_THREAD_GROUP_SHARED_MEMORY:
naked = true;
break;
default:
naked = false;
break;
}
}
out << (sm4_dump_short_syntax ? sm4_shortfile_names : sm4_file_names)[op.file];
if(op.indices[0].reg.get())
naked = false;
for(unsigned i = 0; i < op.num_indices; ++i)
{
if(!naked || i)
out << '[';
if(op.indices[i].reg.get())
{
out << *op.indices[i].reg;
if(op.indices[i].disp)
out << '+' << op.indices[i].disp;
}
else
out << op.indices[i].disp;
if(!naked || i)
out << ']';
}
if(op.comps)
{
switch(op.mode)
{
case SM4_OPERAND_MODE_MASK:
out << (sm4_dump_short_syntax ? '.' : '!');
for(unsigned i = 0; i < op.comps; ++i)
{
if(op.mask & (1 << i))
out << "xyzw"[i];
}
break;
case SM4_OPERAND_MODE_SWIZZLE:
out << '.';
for(unsigned i = 0; i < op.comps; ++i)
out << "xyzw"[op.swizzle[i]];
break;
case SM4_OPERAND_MODE_SCALAR:
out << (sm4_dump_short_syntax ? '.' : ':');
out << "xyzw"[op.swizzle[0]];
break;
}
}
}
if(op.abs)
out << '|';
return out;
}
std::ostream& operator <<(std::ostream& out, const sm4_dcl& dcl)
{
out << sm4_opcode_names[dcl.opcode];
switch(dcl.opcode)
{
case SM4_OPCODE_DCL_GLOBAL_FLAGS:
if(dcl.dcl_global_flags.allow_refactoring)
out << " refactoringAllowed";
if(dcl.dcl_global_flags.early_depth_stencil)
out << " forceEarlyDepthStencil";
if(dcl.dcl_global_flags.fp64)
out << " enableDoublePrecisionFloatOps";
if(dcl.dcl_global_flags.enable_raw_and_structured_in_non_cs)
out << " enableRawAndStructuredBuffers";
break;
case SM4_OPCODE_DCL_INPUT_PS:
case SM4_OPCODE_DCL_INPUT_PS_SIV:
case SM4_OPCODE_DCL_INPUT_PS_SGV:
out << ' ' << sm4_interpolation_names[dcl.dcl_input_ps.interpolation];
break;
case SM4_OPCODE_DCL_TEMPS:
out << ' ' << dcl.num;
break;
default:
break;
}
if(dcl.op.get())
out << ' ' << *dcl.op;
switch(dcl.opcode)
{
case SM4_OPCODE_DCL_CONSTANT_BUFFER:
out << ", " << (dcl.dcl_constant_buffer.dynamic ? "dynamicIndexed" : "immediateIndexed");
break;
case SM4_OPCODE_DCL_INPUT_SIV:
case SM4_OPCODE_DCL_INPUT_SGV:
case SM4_OPCODE_DCL_OUTPUT_SIV:
case SM4_OPCODE_DCL_OUTPUT_SGV:
case SM4_OPCODE_DCL_INPUT_PS_SIV:
case SM4_OPCODE_DCL_INPUT_PS_SGV:
out << ", " << sm4_sv_names[dcl.num];
break;
}
return out;
}
std::ostream& operator <<(std::ostream& out, const sm4_insn& insn)
{
out << sm4_opcode_names[insn.opcode];
if(insn.insn.sat)
out << "_sat";
for(unsigned i = 0; i < insn.num_ops; ++i)
{
if(i)
out << ',';
out << ' ' << *insn.ops[i];
}
return out;
}
std::ostream& operator <<(std::ostream& out, const sm4_program& program)
{
out << "pvghdc"[program.version.type] << "s_" << program.version.major << "_" << program.version.minor << "\n";
for(unsigned i = 0; i < program.dcls.size(); ++i)
out << *program.dcls[i] << "\n";
for(unsigned i = 0; i < program.insns.size(); ++i)
out << *program.insns[i] << "\n";
return out;
}
void sm4_op::dump()
{
std::cout << *this;
}
void sm4_insn::dump()
{
std::cout << *this;
}
void sm4_dcl::dump()
{
std::cout << *this;
}
void sm4_program::dump()
{
std::cout << *this;
}

View File

@ -1,445 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include "sm4.h"
#include "utils.h"
#if 1
#define check(x) assert(x)
#define fail(x) assert(0 && (x))
#else
#define check(x) do {if(!(x)) throw(#x);} while(0)
#define fail(x) throw(x)
#endif
struct sm4_parser
{
unsigned* tokens;
unsigned* tokens_end;
sm4_program& program;
sm4_parser(sm4_program& program, void* p_tokens, unsigned size)
: program(program)
{
tokens = (unsigned*)p_tokens;
tokens_end = (unsigned*)((char*)p_tokens + size);
}
/* TODO: byteswap if machine is big endian */
uint32_t read32()
{
check(tokens < tokens_end);
return bswap_le32(*tokens++);
}
template<typename T>
void read_token(T* tok)
{
*(unsigned*)tok = read32();
}
uint64_t read64()
{
unsigned a = read32();
unsigned b = read32();
return (uint64_t)a | ((uint64_t)b << 32);
}
void skip(unsigned toskip)
{
tokens += toskip;
}
void read_op(sm4_op* pop)
{
sm4_op& op = *pop;
sm4_token_operand optok;
read_token(&optok);
assert(optok.file < SM4_FILE_COUNT);
op.swizzle[0] = 0;
op.swizzle[1] = 1;
op.swizzle[2] = 2;
op.swizzle[3] = 3;
op.mask = 0xf;
switch(optok.comps_enum)
{
case SM4_OPERAND_COMPNUM_0:
op.comps = 0;
break;
case SM4_OPERAND_COMPNUM_1:
op.comps = 1;
op.swizzle[1] = op.swizzle[2] = op.swizzle[3] = 0;
break;
case SM4_OPERAND_COMPNUM_4:
op.comps = 4;
op.mode = optok.mode;
switch(optok.mode)
{
case SM4_OPERAND_MODE_MASK:
op.mask = SM4_OPERAND_SEL_MASK(optok.sel);
break;
case SM4_OPERAND_MODE_SWIZZLE:
op.swizzle[0] = SM4_OPERAND_SEL_SWZ(optok.sel, 0);
op.swizzle[1] = SM4_OPERAND_SEL_SWZ(optok.sel, 1);
op.swizzle[2] = SM4_OPERAND_SEL_SWZ(optok.sel, 2);
op.swizzle[3] = SM4_OPERAND_SEL_SWZ(optok.sel, 3);
break;
case SM4_OPERAND_MODE_SCALAR:
op.swizzle[0] = op.swizzle[1] = op.swizzle[2] = op.swizzle[3] = SM4_OPERAND_SEL_SCALAR(optok.sel);
break;
}
break;
case SM4_OPERAND_COMPNUM_N:
fail("Unhandled operand component type");
}
op.file = (sm4_file)optok.file;
op.num_indices = optok.num_indices;
if(optok.extended)
{
sm4_token_operand_extended optokext;
read_token(&optokext);
if(optokext.type == 0)
{}
else if(optokext.type == 1)
{
op.neg = optokext.neg;
op.abs= optokext.abs;
}
else
fail("Unhandled extended operand token type");
}
for(unsigned i = 0; i < op.num_indices; ++i)
{
unsigned repr;
if(i == 0)
repr = optok.index0_repr;
else if(i == 1)
repr = optok.index1_repr;
else if(i == 2)
repr = optok.index2_repr;
else
fail("Unhandled operand index representation");
op.indices[i].disp = 0;
// TODO: is disp supposed to be signed here??
switch(repr)
{
case SM4_OPERAND_INDEX_REPR_IMM32:
op.indices[i].disp = (int32_t)read32();
break;
case SM4_OPERAND_INDEX_REPR_IMM64:
op.indices[i].disp = read64();
break;
case SM4_OPERAND_INDEX_REPR_REG:
relative:
op.indices[i].reg.reset(new sm4_op());
read_op(&*op.indices[i].reg);
break;
case SM4_OPERAND_INDEX_REPR_REG_IMM32:
op.indices[i].disp = (int32_t)read32();
goto relative;
case SM4_OPERAND_INDEX_REPR_REG_IMM64:
op.indices[i].disp = read64();
goto relative;
}
}
if(op.file == SM4_FILE_IMMEDIATE32)
{
for(unsigned i = 0; i < op.comps; ++i)
op.imm_values[i].i32 = read32();
}
else if(op.file == SM4_FILE_IMMEDIATE64)
{
for(unsigned i = 0; i < op.comps; ++i)
op.imm_values[i].i64 = read64();
}
}
void do_parse()
{
read_token(&program.version);
unsigned lentok = read32();
tokens_end = tokens - 2 + lentok;
while(tokens != tokens_end)
{
sm4_token_instruction insntok;
read_token(&insntok);
unsigned* insn_end = tokens - 1 + insntok.length;
sm4_opcode opcode = (sm4_opcode)insntok.opcode;
check(opcode < SM4_OPCODE_COUNT);
if(opcode == SM4_OPCODE_CUSTOMDATA)
{
// immediate constant buffer data
unsigned customlen = read32() - 2;
sm4_dcl& dcl = *new sm4_dcl;
program.dcls.push_back(&dcl);
dcl.opcode = SM4_OPCODE_CUSTOMDATA;
dcl.num = customlen;
dcl.data = malloc(customlen * sizeof(tokens[0]));
memcpy(dcl.data, &tokens[0], customlen * sizeof(tokens[0]));
skip(customlen);
continue;
}
if(opcode == SM4_OPCODE_HS_FORK_PHASE || opcode == SM4_OPCODE_HS_JOIN_PHASE)
{
// need to interleave these with the declarations or we cannot
// assign fork/join phase instance counts to phases
sm4_dcl& dcl = *new sm4_dcl;
program.dcls.push_back(&dcl);
dcl.opcode = opcode;
}
if((opcode >= SM4_OPCODE_DCL_RESOURCE && opcode <= SM4_OPCODE_DCL_GLOBAL_FLAGS)
|| (opcode >= SM4_OPCODE_DCL_STREAM && opcode <= SM4_OPCODE_DCL_RESOURCE_STRUCTURED))
{
sm4_dcl& dcl = *new sm4_dcl;
program.dcls.push_back(&dcl);
(sm4_token_instruction&)dcl = insntok;
sm4_token_instruction_extended exttok;
memcpy(&exttok, &insntok, sizeof(exttok));
while(exttok.extended)
{
read_token(&exttok);
}
#define READ_OP_ANY dcl.op.reset(new sm4_op()); read_op(&*dcl.op);
#define READ_OP(FILE) READ_OP_ANY
//check(dcl.op->file == SM4_FILE_##FILE);
switch(opcode)
{
case SM4_OPCODE_DCL_GLOBAL_FLAGS:
break;
case SM4_OPCODE_DCL_RESOURCE:
READ_OP(RESOURCE);
read_token(&dcl.rrt);
break;
case SM4_OPCODE_DCL_SAMPLER:
READ_OP(SAMPLER);
break;
case SM4_OPCODE_DCL_INPUT:
case SM4_OPCODE_DCL_INPUT_PS:
READ_OP(INPUT);
break;
case SM4_OPCODE_DCL_INPUT_SIV:
case SM4_OPCODE_DCL_INPUT_SGV:
case SM4_OPCODE_DCL_INPUT_PS_SIV:
case SM4_OPCODE_DCL_INPUT_PS_SGV:
READ_OP(INPUT);
dcl.sv = (sm4_sv)(uint16_t)read32();
break;
case SM4_OPCODE_DCL_OUTPUT:
READ_OP(OUTPUT);
break;
case SM4_OPCODE_DCL_OUTPUT_SIV:
case SM4_OPCODE_DCL_OUTPUT_SGV:
READ_OP(OUTPUT);
dcl.sv = (sm4_sv)(uint16_t)read32();
break;
case SM4_OPCODE_DCL_INDEX_RANGE:
READ_OP_ANY;
check(dcl.op->file == SM4_FILE_INPUT || dcl.op->file == SM4_FILE_OUTPUT);
dcl.num = read32();
break;
case SM4_OPCODE_DCL_TEMPS:
dcl.num = read32();
break;
case SM4_OPCODE_DCL_INDEXABLE_TEMP:
READ_OP(INDEXABLE_TEMP);
dcl.indexable_temp.num = read32();
dcl.indexable_temp.comps = read32();
break;
case SM4_OPCODE_DCL_CONSTANT_BUFFER:
READ_OP(CONSTANT_BUFFER);
break;
case SM4_OPCODE_DCL_GS_INPUT_PRIMITIVE:
case SM4_OPCODE_DCL_GS_OUTPUT_PRIMITIVE_TOPOLOGY:
break;
case SM4_OPCODE_DCL_MAX_OUTPUT_VERTEX_COUNT:
dcl.num = read32();
break;
case SM4_OPCODE_DCL_GS_INSTANCE_COUNT:
dcl.num = read32();
break;
case SM4_OPCODE_DCL_INPUT_CONTROL_POINT_COUNT:
case SM4_OPCODE_DCL_OUTPUT_CONTROL_POINT_COUNT:
case SM4_OPCODE_DCL_TESS_DOMAIN:
case SM4_OPCODE_DCL_TESS_PARTITIONING:
case SM4_OPCODE_DCL_TESS_OUTPUT_PRIMITIVE:
break;
case SM4_OPCODE_DCL_HS_MAX_TESSFACTOR:
dcl.f32 = read32();
break;
case SM4_OPCODE_DCL_HS_FORK_PHASE_INSTANCE_COUNT:
dcl.num = read32();
break;
case SM4_OPCODE_DCL_FUNCTION_BODY:
dcl.num = read32();
break;
case SM4_OPCODE_DCL_FUNCTION_TABLE:
dcl.num = read32();
dcl.data = malloc(dcl.num * sizeof(uint32_t));
for(unsigned i = 0; i < dcl.num; ++i)
((uint32_t*)dcl.data)[i] = read32();
break;
case SM4_OPCODE_DCL_INTERFACE:
dcl.intf.id = read32();
dcl.intf.expected_function_table_length = read32();
{
uint32_t v = read32();
dcl.intf.table_length = v & 0xffff;
dcl.intf.array_length = v >> 16;
}
dcl.data = malloc(dcl.intf.table_length * sizeof(uint32_t));
for(unsigned i = 0; i < dcl.intf.table_length; ++i)
((uint32_t*)dcl.data)[i] = read32();
break;
case SM4_OPCODE_DCL_THREAD_GROUP:
dcl.thread_group_size[0] = read32();
dcl.thread_group_size[1] = read32();
dcl.thread_group_size[2] = read32();
break;
case SM4_OPCODE_DCL_UNORDERED_ACCESS_VIEW_TYPED:
READ_OP(UNORDERED_ACCESS_VIEW);
read_token(&dcl.rrt);
break;
case SM4_OPCODE_DCL_UNORDERED_ACCESS_VIEW_RAW:
READ_OP(UNORDERED_ACCESS_VIEW);
break;
case SM4_OPCODE_DCL_UNORDERED_ACCESS_VIEW_STRUCTURED:
READ_OP(UNORDERED_ACCESS_VIEW);
dcl.structured.stride = read32();
break;
case SM4_OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_RAW:
READ_OP(THREAD_GROUP_SHARED_MEMORY);
dcl.num = read32();
break;
case SM4_OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_STRUCTURED:
READ_OP(THREAD_GROUP_SHARED_MEMORY);
dcl.structured.stride = read32();
dcl.structured.count = read32();
break;
case SM4_OPCODE_DCL_RESOURCE_RAW:
READ_OP(RESOURCE);
break;
case SM4_OPCODE_DCL_RESOURCE_STRUCTURED:
READ_OP(RESOURCE);
dcl.structured.stride = read32();
break;
case SM4_OPCODE_DCL_STREAM:
/* TODO: dcl_stream is undocumented: what is it? */
fail("Unhandled dcl_stream since it's undocumented");
default:
fail("Unhandled declaration");
}
check(tokens == insn_end);
}
else
{
sm4_insn& insn = *new sm4_insn;
program.insns.push_back(&insn);
(sm4_token_instruction&)insn = insntok;
sm4_token_instruction_extended exttok;
memcpy(&exttok, &insntok, sizeof(exttok));
while(exttok.extended)
{
read_token(&exttok);
if(exttok.type == SM4_TOKEN_INSTRUCTION_EXTENDED_TYPE_SAMPLE_CONTROLS)
{
insn.sample_offset[0] = exttok.sample_controls.offset_u;
insn.sample_offset[1] = exttok.sample_controls.offset_v;
insn.sample_offset[2] = exttok.sample_controls.offset_w;
}
else if(exttok.type == SM4_TOKEN_INSTRUCTION_EXTENDED_TYPE_RESOURCE_DIM)
insn.resource_target = exttok.resource_target.target;
else if(exttok.type == SM4_TOKEN_INSTRUCTION_EXTENDED_TYPE_RESOURCE_RETURN_TYPE)
{
insn.resource_return_type[0] = exttok.resource_return_type.x;
insn.resource_return_type[1] = exttok.resource_return_type.y;
insn.resource_return_type[2] = exttok.resource_return_type.z;
insn.resource_return_type[3] = exttok.resource_return_type.w;
}
}
switch(opcode)
{
case SM4_OPCODE_INTERFACE_CALL:
insn.num = read32();
break;
default:
break;
}
unsigned op_num = 0;
while(tokens != insn_end)
{
check(tokens < insn_end);
check(op_num < SM4_MAX_OPS);
insn.ops[op_num].reset(new sm4_op);
read_op(&*insn.ops[op_num]);
++op_num;
}
insn.num_ops = op_num;
}
}
}
const char* parse()
{
try
{
do_parse();
return 0;
}
catch(const char* error)
{
return error;
}
}
};
sm4_program* sm4_parse(void* tokens, int size)
{
sm4_program* program = new sm4_program;
sm4_parser parser(*program, tokens, size);
if(!parser.parse())
return program;
delete program;
return 0;
}

View File

@ -1,45 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#ifndef BYTESWAP_H_
#define BYTESWAP_H_
#include <stdint.h>
#include <assert.h>
#ifdef WORDS_BIGENDIAN
static inline uint32_t le32_to_cpu(uint32_t v)
{
return ((v & 0xff) << 24) | ((v & 0xff00) << 8) | ((v & 0xff0000) >> 8) | ((v & 0xff000000) >> 24);
}
#else
static inline uint32_t le32_to_cpu(uint32_t v)
{
return v;
}
#endif
#endif /* BYTESWAP_H_ */

View File

@ -1,75 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include "dxbc.h"
#include "sm4.h"
#include <iostream>
#include <fstream>
void usage()
{
std::cerr << "Gallium Direct3D10/11 Shader Disassembler\n";
std::cerr << "This program is free software, released under a MIT-like license\n";
std::cerr << "Not affiliated with or endorsed by Microsoft in any way\n";
std::cerr << "Latest version available from http://cgit.freedesktop.org/mesa/mesa/\n";
std::cerr << "\n";
std::cerr << "Usage: fxdis FILE\n";
std::cerr << std::endl;
}
int main(int argc, char** argv)
{
if(argc < 2)
{
usage();
return 1;
}
std::vector<char> data;
std::ifstream in(argv[1]);
char c;
in >> std::noskipws;
while(in >> c)
data.push_back(c);
in.close();
dxbc_container* dxbc = dxbc_parse(&data[0], data.size());
if(dxbc)
{
std::cout << *dxbc;
dxbc_chunk_header* sm4_chunk = dxbc_find_shader_bytecode(&data[0], data.size());
if(sm4_chunk)
{
sm4_program* sm4 = sm4_parse(sm4_chunk + 1, bswap_le32(sm4_chunk->size));
if(sm4)
{
std::cout << *sm4;
delete sm4;
}
}
delete dxbc;
}
}

View File

@ -1,5 +0,0 @@
LIBNAME=d3d1xstutil
CPP_SOURCES=$(wildcard src/*.cpp)
LIBRARY_INCLUDES=-Iinclude -I../gd3dapi -I../d3dapi -I../w32api -I../../../include -I../../../auxiliary
include ../Makefile.inc

View File

@ -1,42 +0,0 @@
#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,
};

View File

@ -1,165 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include <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_UINT, /* TYPELESS */
PIPE_FORMAT_R32G32B32A32_FLOAT,
PIPE_FORMAT_R32G32B32A32_UINT,
PIPE_FORMAT_R32G32B32A32_SINT,
PIPE_FORMAT_R32G32B32_UINT, /* TYPELESS */
PIPE_FORMAT_R32G32B32_FLOAT,
PIPE_FORMAT_R32G32B32_UINT,
PIPE_FORMAT_R32G32B32_SINT,
PIPE_FORMAT_R16G16B16A16_UINT, /* TYPELESS */
PIPE_FORMAT_R16G16B16A16_FLOAT,
PIPE_FORMAT_R16G16B16A16_UNORM,
PIPE_FORMAT_R16G16B16A16_UINT,
PIPE_FORMAT_R16G16B16A16_SNORM,
PIPE_FORMAT_R16G16B16A16_SINT,
PIPE_FORMAT_R32G32_UINT, /* TYPELESS */
PIPE_FORMAT_R32G32_FLOAT,
PIPE_FORMAT_R32G32_UINT,
PIPE_FORMAT_R32G32_SINT,
PIPE_FORMAT_Z32_FLOAT_S8X24_UINT, /* PIPE_FORMAT_R32_G8X24_TYPELESS */
PIPE_FORMAT_Z32_FLOAT_S8X24_UINT,
PIPE_FORMAT_Z32_FLOAT_S8X24_UINT, /* PIPE_FORMAT_R32_X8X24_FLOAT */
PIPE_FORMAT_Z32_FLOAT_S8X24_UINT, /* PIPE_FORMAT_X32_G8X24_UINT */
PIPE_FORMAT_R10G10B10A2_UNORM, /* TYPELESS */
PIPE_FORMAT_R10G10B10A2_UNORM,
PIPE_FORMAT_NONE, /* PIPE_FORMAT_R10G10B10A2_UINT */
PIPE_FORMAT_R11G11B10_FLOAT,
PIPE_FORMAT_R8G8B8A8_UINT, /* TYPELESS */
PIPE_FORMAT_R8G8B8A8_UNORM,
PIPE_FORMAT_R8G8B8A8_SRGB,
PIPE_FORMAT_R8G8B8A8_UINT,
PIPE_FORMAT_R8G8B8A8_SNORM,
PIPE_FORMAT_R8G8B8A8_SINT,
PIPE_FORMAT_R16G16_UINT, /* TYPELESS */
PIPE_FORMAT_R16G16_FLOAT,
PIPE_FORMAT_R16G16_UNORM,
PIPE_FORMAT_R16G16_UINT,
PIPE_FORMAT_R16G16_SNORM,
PIPE_FORMAT_R16G16_SINT,
PIPE_FORMAT_R32_UINT, /* TYPELESS */
PIPE_FORMAT_Z32_FLOAT,
PIPE_FORMAT_R32_FLOAT,
PIPE_FORMAT_R32_UINT,
PIPE_FORMAT_R32_SINT,
PIPE_FORMAT_Z24_UNORM_S8_UINT, /* PIPE_FORMAT_R24G8_TYPELESS */
PIPE_FORMAT_Z24_UNORM_S8_UINT,
PIPE_FORMAT_Z24X8_UNORM, /* PIPE_FORMAT_R24X8_UNORM */
PIPE_FORMAT_Z24_UNORM_S8_UINT, /* PIPE_FORMAT_X24G8_UINT */
PIPE_FORMAT_R8G8_UINT, /* TYPELESS */
PIPE_FORMAT_R8G8_UNORM,
PIPE_FORMAT_R8G8_UINT,
PIPE_FORMAT_R8G8_SNORM,
PIPE_FORMAT_R8G8_SINT,
PIPE_FORMAT_R16_UINT, /* TYPELESS */
PIPE_FORMAT_R16_FLOAT,
PIPE_FORMAT_Z16_UNORM,
PIPE_FORMAT_R16_UNORM,
PIPE_FORMAT_R16_UINT,
PIPE_FORMAT_R16_SNORM,
PIPE_FORMAT_R16_SINT,
PIPE_FORMAT_R8_UINT, /* TYPELESS */
PIPE_FORMAT_R8_UNORM,
PIPE_FORMAT_R8_UINT,
PIPE_FORMAT_R8_SNORM,
PIPE_FORMAT_R8_SINT,
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 */
PIPE_FORMAT_A8R8G8B8_UNORM, /* PIPE_FORMAT_AYUV */
PIPE_FORMAT_NONE, /* PIPE_FORMAT_Y410 */
PIPE_FORMAT_NONE, /* PIPE_FORMAT_Y416 */
PIPE_FORMAT_NV12,
PIPE_FORMAT_NONE, /* PIPE_FORMAT_P010 */
PIPE_FORMAT_NONE, /* PIPE_FORMAT_P016 */
PIPE_FORMAT_NONE, /* PIPE_FORMAT_420_OPAQUE */
PIPE_FORMAT_NONE, /* PIPE_FORMAT_YUV2 */
PIPE_FORMAT_NONE, /* PIPE_FORMAT_Y210 */
PIPE_FORMAT_NONE, /* PIPE_FORMAT_Y216 */
PIPE_FORMAT_NONE, /* PIPE_FORMAT_NV11 */
PIPE_FORMAT_NONE, /* PIPE_FORMAT_AI44 (palettized) */
PIPE_FORMAT_NONE, /* PIPE_FORMAT_IA44 (palettized) */
PIPE_FORMAT_NONE, /* PIPE_FORMAT_P8 (palettized) */
PIPE_FORMAT_NONE, /* PIPE_FORMAT_A8P8 (palettized) */
PIPE_FORMAT_B4G4R4A4_UNORM,
};
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[PIPE_FORMAT_Z32_FLOAT_S8X24_UINT] = DXGI_FORMAT_D32_FLOAT_S8X24_UINT;
pipe_to_dxgi_format[PIPE_FORMAT_Z24_UNORM_S8_UINT] = DXGI_FORMAT_D24_UNORM_S8_UINT;
pipe_to_dxgi_format_initialized = 1;
}
}

View File

@ -1,6 +0,0 @@
#define INITGUID
#include "d3d1xstutil.h"
#include <galliumd3d11.h>
#include <galliumd3d10_1.h>
#include <galliumdxgi.h>
#include <galliumcom.h>

View File

@ -1,4 +0,0 @@
all: idl
include ../Makefile.inc

File diff suppressed because it is too large Load Diff

View File

@ -1,191 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
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
);

View File

@ -1,47 +0,0 @@
/*
* 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__ */

View File

@ -1,269 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
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);

File diff suppressed because it is too large Load Diff

View File

@ -1,287 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
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
);
};

View File

@ -1,704 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
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;

View File

@ -1,470 +0,0 @@
/*
* 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);

View File

@ -1,129 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
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;

View File

@ -1,84 +0,0 @@
/*
* 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;

View File

@ -1,5 +0,0 @@
all: module_dependencies.svg module_dependencies.pdf
.IGNORE: module_dependencies.svg module_dependencies.pdf
include ../Makefile.inc

View File

@ -1,84 +0,0 @@
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.

View File

@ -1,25 +0,0 @@
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
};

View File

@ -1,17 +0,0 @@
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

View File

@ -1,17 +0,0 @@
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

View File

@ -1,206 +0,0 @@
/*
* 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 <olv@lunarg.com>
*/
#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;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,49 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#ifndef 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_ */

View File

@ -1,4 +0,0 @@
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

View File

@ -1,149 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "software"), to deal in the software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the software, and to
* permit persons to whom the software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include "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);
}

View File

@ -1,4 +0,0 @@
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

View File

@ -1,135 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "software"), to deal in the software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the software, and to
* permit persons to whom the software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include "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;
}

View File

@ -1,20 +0,0 @@
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) $< > $@

View File

@ -1,12 +0,0 @@
#!/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 $_;
}

View File

@ -1,6 +0,0 @@
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

View File

@ -1,241 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include "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

File diff suppressed because it is too large Load Diff

View File

@ -1,92 +0,0 @@
#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, DXBC_FIND_INPUT_SIGNATURE);
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, DXBC_FIND_OUTPUT_SIGNATURE);
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, DXBC_FIND_INPUT_SIGNATURE);
if(!sigs[0])
return E_FAIL;
sigs[1] = dxbc_find_signature(shader_bytecode, bytecode_length, DXBC_FIND_OUTPUT_SIGNATURE);
if(!sigs[1])
return E_FAIL;
return dxbc_assemble_as_blob((dxbc_chunk_header**)&sigs, 2, signature_blob);
}
#endif

View File

@ -1,737 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
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();
}
virtual ~GalliumD3D11DeviceChild()
{
if(device)
device->Release();
}
/* 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()
{
return GalliumPrivateDataComObject<Base, dual_refcnt_t>::add_ref();
}
inline ULONG 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
{
GalliumD3D11RasterizerState(GalliumD3D11Screen* device, void* object, const D3D11_RASTERIZER_DESC& desc)
: GalliumD3D11RasterizerStateBase(device, object, desc)
{}
};
template<typename Base = ID3D11DeviceChild>
struct GalliumD3D11Shader : public GalliumD3D11Object<Base>
{
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 GalliumD3D11Texture1DBase GalliumD3D11Texture1D;
typedef GalliumD3D11Texture2DBase GalliumD3D11Texture2D;
typedef GalliumD3D11Texture3DBase GalliumD3D11Texture3D;
struct GalliumD3D11Buffer : public GalliumD3D11BufferBase
{
struct pipe_stream_output_target* so_target;
GalliumD3D11Buffer(GalliumD3D11Screen* device, struct pipe_resource* resource, const D3D11_BUFFER_DESC& desc, unsigned dxgi_usage)
: GalliumD3D11BufferBase(device, resource, desc, dxgi_usage), so_target(0)
{
}
~GalliumD3D11Buffer()
{
if(so_target)
pipe_so_target_reference(&so_target, NULL);
}
};
#else
struct GalliumD3D10Buffer : public GalliumD3D10BufferBase
{
struct pipe_stream_output_target *so_target;
GalliumD3D10Buffer(GalliumD3D10Screen* device, struct pipe_resource* resource, const D3D10_BUFFER_DESC& desc, unsigned dxgi_usage)
: GalliumD3D10BufferBase(device, resource, desc, dxgi_usage)
{
}
~GalliumD3D10Buffer()
{
if(so_target)
pipe_so_target_reference(&so_target, NULL);
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;
}
};

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +0,0 @@
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

View File

@ -1,97 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#ifndef 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 D3D10_BLEND_COUNT 20
#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 D3D10_STENCIL_OP_COUNT 9
#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_ */

View File

@ -1,123 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include "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_TIMESTAMP,
PIPE_QUERY_TIMESTAMP_DISJOINT,
PIPE_QUERY_PIPELINE_STATISTICS,
PIPE_QUERY_OCCLUSION_PREDICATE,
PIPE_QUERY_SO_STATISTICS,
PIPE_QUERY_SO_OVERFLOW_PREDICATE,
/* per-stream SO queries */
PIPE_QUERY_TYPES,
PIPE_QUERY_TYPES,
PIPE_QUERY_TYPES,
PIPE_QUERY_TYPES,
PIPE_QUERY_TYPES,
PIPE_QUERY_TYPES,
PIPE_QUERY_TYPES,
PIPE_QUERY_TYPES,
};
unsigned d3d11_query_size[D3D11_QUERY_COUNT] =
{
sizeof(BOOL),
sizeof(UINT64),
sizeof(UINT64),
sizeof(D3D11_QUERY_DATA_TIMESTAMP_DISJOINT),
sizeof(D3D11_QUERY_DATA_PIPELINE_STATISTICS),
sizeof(BOOL),
sizeof(D3D11_QUERY_DATA_SO_STATISTICS),
sizeof(BOOL),
0,
0,
0,
0,
0,
0,
0,
0
};

View File

@ -1,856 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include <d3d11shader.h>
#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> resources;
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;
}
unsigned tex_target(unsigned resource, unsigned sampler)
{
unsigned shadow = sampler_modes[sampler];
unsigned target = shadow ? targets[resource].second : targets[resource].first;
check(target);
return target;
}
enum pipe_type res_return_type(unsigned type)
{
switch(type)
{
case D3D_RETURN_TYPE_UNORM: return PIPE_TYPE_UNORM;
case D3D_RETURN_TYPE_SNORM: return PIPE_TYPE_SNORM;
case D3D_RETURN_TYPE_SINT: return PIPE_TYPE_SINT;
case D3D_RETURN_TYPE_UINT: return PIPE_TYPE_UINT;
case D3D_RETURN_TYPE_FLOAT: return PIPE_TYPE_FLOAT;
default:
fail("invalid resource return type");
return PIPE_TYPE_FLOAT;
}
}
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:
// TODO: return type
ureg_SVIEWINFO(ureg, _dst(), _src(1), resources[_idx(SM4_FILE_RESOURCE, 2)]);
break;
// TODO: sample index, texture offset
case SM4_OPCODE_LD: // dst, coord_int, res; mipmap level in last coord_int arg
ureg_LOAD(ureg, _dst(), _src(1), resources[_idx(SM4_FILE_RESOURCE, 2)]);
break;
case SM4_OPCODE_LD_MS:
ureg_LOAD_MS(ureg, _dst(), _src(1), resources[_idx(SM4_FILE_RESOURCE, 2)]);
break;
case SM4_OPCODE_SAMPLE: // dst, coord, res, samp
ureg_SAMPLE(ureg, _dst(), _src(1), resources[_idx(SM4_FILE_RESOURCE, 2)], samplers[_idx(SM4_FILE_SAMPLER, 3)]);
break;
case SM4_OPCODE_SAMPLE_B: // dst, coord, res, samp, bias.x
ureg_SAMPLE_B(ureg, _dst(), _src(1), resources[_idx(SM4_FILE_RESOURCE, 2)], samplers[_idx(SM4_FILE_SAMPLER, 3)], _src(4));
break;
case SM4_OPCODE_SAMPLE_C: // dst, coord, res, samp, comp.x
ureg_SAMPLE_C(ureg, _dst(), _src(1), resources[_idx(SM4_FILE_RESOURCE, 2)], samplers[_idx(SM4_FILE_SAMPLER, 3)], _src(4));
break;
case SM4_OPCODE_SAMPLE_C_LZ: // dst, coord, res, samp, comp.x
ureg_SAMPLE_C_LZ(ureg, _dst(), _src(1), resources[_idx(SM4_FILE_RESOURCE, 2)], samplers[_idx(SM4_FILE_SAMPLER, 3)], _src(4));
break;
case SM4_OPCODE_SAMPLE_D: // dst, coord, res, samp, ddx, ddy
ureg_SAMPLE_D(ureg, _dst(), _src(1), resources[_idx(SM4_FILE_RESOURCE, 2)], samplers[_idx(SM4_FILE_SAMPLER, 3)], _src(4), _src(5));
break;
case SM4_OPCODE_SAMPLE_L: // dst, coord, res, samp, lod.x
ureg_SAMPLE_L(ureg, _dst(), _src(1), resources[_idx(SM4_FILE_RESOURCE, 2)], samplers[_idx(SM4_FILE_SAMPLER, 3)], _src(4));
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");
ureg = ureg_create(processor);
in_sub = false;
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_TEXTURE1DARRAY:
targets[idx].first = TGSI_TEXTURE_1D_ARRAY;
targets[idx].second = TGSI_TEXTURE_SHADOW1D_ARRAY;
break;
case SM4_TARGET_TEXTURE2D:
targets[idx].first = TGSI_TEXTURE_2D;
targets[idx].second = TGSI_TEXTURE_SHADOW2D;
break;
case SM4_TARGET_TEXTURE2DARRAY:
targets[idx].first = TGSI_TEXTURE_2D_ARRAY;
targets[idx].second = TGSI_TEXTURE_SHADOW2D_ARRAY;
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;
}
if(resources.size() <= (unsigned)idx)
resources.resize(idx + 1);
resources[idx] = ureg_DECL_sampler_view(
ureg, idx, targets[idx].first,
res_return_type(dcl.rrt.x),
res_return_type(dcl.rrt.y),
res_return_type(dcl.rrt.z),
res_return_type(dcl.rrt.w));
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;
if(samplers.size() <= (unsigned)idx)
samplers.resize(idx + 1);
samplers[idx] = ureg_DECL_sampler(ureg, idx);
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();
}
void* sm4_to_tgsi_linkage_only(struct sm4_program& prog)
{
struct ureg_program* ureg = ureg_create(TGSI_PROCESSOR_GEOMETRY);
uint64_t already = 0;
for(unsigned n = 0, i = 0; i < prog.num_params_out; ++i)
{
unsigned sn, si;
if(already & (1ULL << prog.params_out[i].Register))
continue;
already |= 1ULL << prog.params_out[i].Register;
switch(prog.params_out[i].SystemValueType)
{
case D3D_NAME_UNDEFINED:
sn = TGSI_SEMANTIC_GENERIC;
si = n++;
break;
case D3D_NAME_CULL_DISTANCE:
case D3D_NAME_CLIP_DISTANCE:
// FIXME
sn = 0;
si = prog.params_out[i].SemanticIndex;
assert(0);
break;
default:
continue;
}
ureg_DECL_output(ureg, sn, si);
}
const struct tgsi_token* tokens = ureg_get_tokens(ureg, 0);
ureg_destroy(ureg);
return (void*)tokens;
}

View File

@ -1,35 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#ifndef SM4_TO_TGSI_H_
#define SM4_TO_TGSI_H_
#include "sm4.h"
void* sm4_to_tgsi(struct sm4_program& program);
void* sm4_to_tgsi_linkage_only(struct sm4_program& program);
#endif /* SM4_TO_TGSI_H_ */

View File

@ -1,82 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include "dxbc.h"
#include "sm4.h"
#include "../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;
}
}

View File

@ -1,4 +0,0 @@
all: idl
include ../Makefile.inc

View File

@ -1,76 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
/* Header for 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();
};

View File

@ -1,35 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
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);

View File

@ -1,36 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
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);

View File

@ -1,134 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
/* Header for 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();

View File

@ -1,73 +0,0 @@
#!/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" .

View File

@ -1,46 +0,0 @@
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)

View File

@ -1,51 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#ifndef 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

View File

@ -1,188 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#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;
}

View File

@ -1,154 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include "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;
}

View File

@ -1,118 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include "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();
}

View File

@ -1,50 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
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;
}

View File

@ -1,112 +0,0 @@
#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
};

View File

@ -1,128 +0,0 @@
#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
};

View File

@ -1,98 +0,0 @@
<?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>

View File

@ -1,51 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#ifndef 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

View File

@ -1,53 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
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);
}

View File

@ -1,142 +0,0 @@
#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
};

View File

@ -1,130 +0,0 @@
#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
};

View File

@ -1,424 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include <vector>
#include "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;
}

View File

@ -1,172 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#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;
}

View File

@ -1,114 +0,0 @@
#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;
}

View File

@ -1,573 +0,0 @@
/*
* 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();
}

View File

@ -1,75 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
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;
}

View File

@ -1,309 +0,0 @@
#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
};

View File

@ -1,308 +0,0 @@
#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
};

View File

@ -1,100 +0,0 @@
<?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>

View File

@ -1,227 +0,0 @@
/**************************************************************************
*
* Copyright 2010 Luca Barbieri
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#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();
}

Some files were not shown because too many files have changed in this diff Show More