summaryrefslogtreecommitdiff
path: root/sample/d3d11/Effects11/Binary
diff options
context:
space:
mode:
authorJason Maskell <[email protected]>2016-05-09 10:39:54 +0200
committerJason Maskell <[email protected]>2016-05-09 10:39:54 +0200
commit79b3462799c28af8ba586349bd671b1b56e72353 (patch)
tree3b06e36c390254c0dc7f3733a0d32af213d87293 /sample/d3d11/Effects11/Binary
downloadwaveworks_archive-79b3462799c28af8ba586349bd671b1b56e72353.tar.xz
waveworks_archive-79b3462799c28af8ba586349bd671b1b56e72353.zip
Initial commit with PS4 and XBone stuff trimmed.
Diffstat (limited to 'sample/d3d11/Effects11/Binary')
-rw-r--r--sample/d3d11/Effects11/Binary/EffectBinaryFormat.h666
-rw-r--r--sample/d3d11/Effects11/Binary/EffectStateBase11.h49
-rw-r--r--sample/d3d11/Effects11/Binary/EffectStates11.h236
-rw-r--r--sample/d3d11/Effects11/Binary/SOParser.h311
4 files changed, 1262 insertions, 0 deletions
diff --git a/sample/d3d11/Effects11/Binary/EffectBinaryFormat.h b/sample/d3d11/Effects11/Binary/EffectBinaryFormat.h
new file mode 100644
index 0000000..50c5ce3
--- /dev/null
+++ b/sample/d3d11/Effects11/Binary/EffectBinaryFormat.h
@@ -0,0 +1,666 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (C) Microsoft Corporation. All Rights Reserved.
+//
+// File: Effect.h
+// Content: D3DX11 Effects Binary Format
+// This is the binary file interface shared between the Effects
+// compiler and runtime.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#pragma once
+
+namespace D3DX11Effects
+{
+
+
+//////////////////////////////////////////////////////////////////////////
+// Version Control
+//////////////////////////////////////////////////////////////////////////
+
+#define D3D10_FXL_VERSION(_Major,_Minor) (('F' << 24) | ('X' << 16) | ((_Major) << 8) | (_Minor))
+
+struct EVersionTag
+{
+ const char* m_pName;
+ DWORD m_Version;
+ UINT m_Tag;
+};
+
+// versions must be listed in ascending order
+static CONST EVersionTag g_EffectVersions[] =
+{
+ { "fx_4_0", D3D10_FXL_VERSION(4,0), 0xFEFF1001 },
+ { "fx_4_1", D3D10_FXL_VERSION(4,1), 0xFEFF1011 },
+ { "fx_5_0", D3D10_FXL_VERSION(5,0), 0xFEFF2001 },
+};
+#define NUM_EFFECT10_VERSIONS ( sizeof(g_EffectVersions) / sizeof(EVersionTag) )
+
+
+//////////////////////////////////////////////////////////////////////////
+// Reflection & Type structures
+//////////////////////////////////////////////////////////////////////////
+
+// Enumeration of the possible left-hand side values of an assignment,
+// divided up categorically by the type of block they may appear in
+enum ELhsType
+{
+ ELHS_Invalid,
+
+ // Pass block assignment types
+
+ ELHS_PixelShaderBlock, // SBlock *pValue points to the block to apply
+ ELHS_VertexShaderBlock,
+ ELHS_GeometryShaderBlock,
+ ELHS_RenderTargetView,
+ ELHS_DepthStencilView,
+
+ ELHS_RasterizerBlock,
+ ELHS_DepthStencilBlock,
+ ELHS_BlendBlock,
+
+ ELHS_GenerateMips, // This is really a call to D3D::GenerateMips
+
+ // Various SAssignment.Value.*
+
+ ELHS_DS_StencilRef, // SAssignment.Value.pdValue
+ ELHS_B_BlendFactor, // D3D10_BLEND_CONFIG.BlendFactor, points to a float4
+ ELHS_B_SampleMask, // D3D10_BLEND_CONFIG.SampleMask
+
+ ELHS_GeometryShaderSO, // When setting SO assignments, GeometryShaderSO precedes the actual GeometryShader assn
+
+ ELHS_ComputeShaderBlock,
+ ELHS_HullShaderBlock,
+ ELHS_DomainShaderBlock,
+
+ // Rasterizer
+
+ ELHS_FillMode = 0x20000,
+ ELHS_CullMode,
+ ELHS_FrontCC,
+ ELHS_DepthBias,
+ ELHS_DepthBiasClamp,
+ ELHS_SlopeScaledDepthBias,
+ ELHS_DepthClipEnable,
+ ELHS_ScissorEnable,
+ ELHS_MultisampleEnable,
+ ELHS_AntialiasedLineEnable,
+
+ // Sampler
+
+ ELHS_Filter = 0x30000,
+ ELHS_AddressU,
+ ELHS_AddressV,
+ ELHS_AddressW,
+ ELHS_MipLODBias,
+ ELHS_MaxAnisotropy,
+ ELHS_ComparisonFunc,
+ ELHS_BorderColor,
+ ELHS_MinLOD,
+ ELHS_MaxLOD,
+ ELHS_Texture,
+
+ // DepthStencil
+
+ ELHS_DepthEnable = 0x40000,
+ ELHS_DepthWriteMask,
+ ELHS_DepthFunc,
+ ELHS_StencilEnable,
+ ELHS_StencilReadMask,
+ ELHS_StencilWriteMask,
+ ELHS_FrontFaceStencilFailOp,
+ ELHS_FrontFaceStencilDepthFailOp,
+ ELHS_FrontFaceStencilPassOp,
+ ELHS_FrontFaceStencilFunc,
+ ELHS_BackFaceStencilFailOp,
+ ELHS_BackFaceStencilDepthFailOp,
+ ELHS_BackFaceStencilPassOp,
+ ELHS_BackFaceStencilFunc,
+
+ // BlendState
+
+ ELHS_AlphaToCoverage = 0x50000,
+ ELHS_BlendEnable,
+ ELHS_SrcBlend,
+ ELHS_DestBlend,
+ ELHS_BlendOp,
+ ELHS_SrcBlendAlpha,
+ ELHS_DestBlendAlpha,
+ ELHS_BlendOpAlpha,
+ ELHS_RenderTargetWriteMask,
+};
+
+
+
+enum EBlockType
+{
+ EBT_Invalid,
+ EBT_DepthStencil,
+ EBT_Blend,
+ EBT_Rasterizer,
+ EBT_Sampler,
+ EBT_Pass
+};
+
+enum EVarType
+{
+ EVT_Invalid,
+ EVT_Numeric,
+ EVT_Object,
+ EVT_Struct,
+ EVT_Interface,
+};
+
+enum EScalarType
+{
+ EST_Invalid,
+ EST_Float,
+ EST_Int,
+ EST_UInt,
+ EST_Bool,
+ EST_Count
+};
+
+enum ENumericLayout
+{
+ ENL_Invalid,
+ ENL_Scalar,
+ ENL_Vector,
+ ENL_Matrix,
+ ENL_Count
+};
+
+enum EObjectType
+{
+ EOT_Invalid,
+ EOT_String,
+ EOT_Blend,
+ EOT_DepthStencil,
+ EOT_Rasterizer,
+ EOT_PixelShader,
+ EOT_VertexShader,
+ EOT_GeometryShader, // Regular geometry shader
+ EOT_GeometryShaderSO, // Geometry shader with a attached StreamOut decl
+ EOT_Texture,
+ EOT_Texture1D,
+ EOT_Texture1DArray,
+ EOT_Texture2D,
+ EOT_Texture2DArray,
+ EOT_Texture2DMS,
+ EOT_Texture2DMSArray,
+ EOT_Texture3D,
+ EOT_TextureCube,
+ EOT_ConstantBuffer,
+ EOT_RenderTargetView,
+ EOT_DepthStencilView,
+ EOT_Sampler,
+ EOT_Buffer,
+ EOT_TextureCubeArray,
+ EOT_Count,
+ EOT_PixelShader5,
+ EOT_VertexShader5,
+ EOT_GeometryShader5,
+ EOT_ComputeShader5,
+ EOT_HullShader5,
+ EOT_DomainShader5,
+ EOT_RWTexture1D,
+ EOT_RWTexture1DArray,
+ EOT_RWTexture2D,
+ EOT_RWTexture2DArray,
+ EOT_RWTexture3D,
+ EOT_RWBuffer,
+ EOT_ByteAddressBuffer,
+ EOT_RWByteAddressBuffer,
+ EOT_StructuredBuffer,
+ EOT_RWStructuredBuffer,
+ EOT_RWStructuredBufferAlloc,
+ EOT_RWStructuredBufferConsume,
+ EOT_AppendStructuredBuffer,
+ EOT_ConsumeStructuredBuffer,
+};
+
+D3DX11INLINE BOOL IsObjectTypeHelper(EVarType InVarType,
+ EObjectType InObjType,
+ EObjectType TargetObjType)
+{
+ return (InVarType == EVT_Object) && (InObjType == TargetObjType);
+}
+
+D3DX11INLINE BOOL IsSamplerHelper(EVarType InVarType,
+ EObjectType InObjType)
+{
+ return (InVarType == EVT_Object) && (InObjType == EOT_Sampler);
+}
+
+D3DX11INLINE BOOL IsStateBlockObjectHelper(EVarType InVarType,
+ EObjectType InObjType)
+{
+ return (InVarType == EVT_Object) && ((InObjType == EOT_Blend) || (InObjType == EOT_DepthStencil) || (InObjType == EOT_Rasterizer) || IsSamplerHelper(InVarType, InObjType));
+}
+
+D3DX11INLINE BOOL IsShaderHelper(EVarType InVarType,
+ EObjectType InObjType)
+{
+ return (InVarType == EVT_Object) && ((InObjType == EOT_VertexShader) ||
+ (InObjType == EOT_VertexShader5) ||
+ (InObjType == EOT_HullShader5) ||
+ (InObjType == EOT_DomainShader5) ||
+ (InObjType == EOT_ComputeShader5) ||
+ (InObjType == EOT_GeometryShader) ||
+ (InObjType == EOT_GeometryShaderSO) ||
+ (InObjType == EOT_GeometryShader5) ||
+ (InObjType == EOT_PixelShader) ||
+ (InObjType == EOT_PixelShader5));
+}
+
+D3DX11INLINE BOOL IsShader5Helper(EVarType InVarType,
+ EObjectType InObjType)
+{
+ return (InVarType == EVT_Object) && ((InObjType == EOT_VertexShader5) ||
+ (InObjType == EOT_HullShader5) ||
+ (InObjType == EOT_DomainShader5) ||
+ (InObjType == EOT_ComputeShader5) ||
+ (InObjType == EOT_GeometryShader5) ||
+ (InObjType == EOT_PixelShader5));
+}
+
+D3DX11INLINE BOOL IsInterfaceHelper(EVarType InVarType,
+ EObjectType InObjType)
+{
+ return (InVarType == EVT_Interface);
+}
+
+D3DX11INLINE BOOL IsShaderResourceHelper(EVarType InVarType,
+ EObjectType InObjType)
+{
+ return (InVarType == EVT_Object) && ((InObjType == EOT_Texture) ||
+ (InObjType == EOT_Texture1D) ||
+ (InObjType == EOT_Texture1DArray) ||
+ (InObjType == EOT_Texture2D) ||
+ (InObjType == EOT_Texture2DArray) ||
+ (InObjType == EOT_Texture2DMS) ||
+ (InObjType == EOT_Texture2DMSArray) ||
+ (InObjType == EOT_Texture3D) ||
+ (InObjType == EOT_TextureCube) ||
+ (InObjType == EOT_TextureCubeArray) ||
+ (InObjType == EOT_Buffer) ||
+ (InObjType == EOT_StructuredBuffer) ||
+ (InObjType == EOT_ByteAddressBuffer));
+}
+
+D3DX11INLINE BOOL IsUnorderedAccessViewHelper(EVarType InVarType,
+ EObjectType InObjType)
+{
+ return (InVarType == EVT_Object) &&
+ ((InObjType == EOT_RWTexture1D) ||
+ (InObjType == EOT_RWTexture1DArray) ||
+ (InObjType == EOT_RWTexture2D) ||
+ (InObjType == EOT_RWTexture2DArray) ||
+ (InObjType == EOT_RWTexture3D) ||
+ (InObjType == EOT_RWBuffer) ||
+ (InObjType == EOT_RWByteAddressBuffer) ||
+ (InObjType == EOT_RWStructuredBuffer) ||
+ (InObjType == EOT_RWStructuredBufferAlloc) ||
+ (InObjType == EOT_RWStructuredBufferConsume) ||
+ (InObjType == EOT_AppendStructuredBuffer) ||
+ (InObjType == EOT_ConsumeStructuredBuffer));
+}
+
+D3DX11INLINE BOOL IsRenderTargetViewHelper(EVarType InVarType,
+ EObjectType InObjType)
+{
+ return (InVarType == EVT_Object) && (InObjType == EOT_RenderTargetView);
+}
+
+D3DX11INLINE BOOL IsDepthStencilViewHelper(EVarType InVarType,
+ EObjectType InObjType)
+{
+ return (InVarType == EVT_Object) && (InObjType == EOT_DepthStencilView);
+}
+
+D3DX11INLINE BOOL IsObjectAssignmentHelper(ELhsType LhsType)
+{
+ switch(LhsType)
+ {
+ case ELHS_VertexShaderBlock:
+ case ELHS_HullShaderBlock:
+ case ELHS_DepthStencilView:
+ case ELHS_GeometryShaderBlock:
+ case ELHS_PixelShaderBlock:
+ case ELHS_ComputeShaderBlock:
+ case ELHS_DepthStencilBlock:
+ case ELHS_RasterizerBlock:
+ case ELHS_BlendBlock:
+ case ELHS_Texture:
+ case ELHS_RenderTargetView:
+ case ELHS_DomainShaderBlock:
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+
+
+// Effect file format structures /////////////////////////////////////////////
+// File format:
+// File header (SBinaryHeader Header)
+// Unstructured data block (BYTE[Header.cbUnstructured))
+// Structured data block
+// ConstantBuffer (SBinaryConstantBuffer CB) * Header.Effect.cCBs
+// UINT NumAnnotations
+// Annotation data (SBinaryAnnotation) * (NumAnnotations) *this structure is variable sized
+// Variable data (SBinaryNumericVariable Var) * (CB.cVariables)
+// UINT NumAnnotations
+// Annotation data (SBinaryAnnotation) * (NumAnnotations) *this structure is variable sized
+// Object variables (SBinaryObjectVariable Var) * (Header.cObjectVariables) *this structure is variable sized
+// UINT NumAnnotations
+// Annotation data (SBinaryAnnotation) * (NumAnnotations) *this structure is variable sized
+// Interface variables (SBinaryInterfaceVariable Var) * (Header.cInterfaceVariables) *this structure is variable sized
+// UINT NumAnnotations
+// Annotation data (SBinaryAnnotation) * (NumAnnotations) *this structure is variable sized
+// Groups (SBinaryGroup Group) * Header.cGroups
+// UINT NumAnnotations
+// Annotation data (SBinaryAnnotation) * (NumAnnotations) *this structure is variable sized
+// Techniques (SBinaryTechnique Technique) * Group.cTechniques
+// UINT NumAnnotations
+// Annotation data (SBinaryAnnotation) * (NumAnnotations) *this structure is variable sized
+// Pass (SBinaryPass Pass) * Technique.cPasses
+// UINT NumAnnotations
+// Annotation data (SBinaryAnnotation) * (NumAnnotations) *this structure is variable sized
+// Pass assignments (SBinaryAssignment) * Pass.cAssignments
+
+struct SBinaryHeader
+{
+ struct SVarCounts
+ {
+ UINT cCBs;
+ UINT cNumericVariables;
+ UINT cObjectVariables;
+ };
+
+ UINT Tag; // should be equal to c_EffectFileTag
+ // this is used to identify ASCII vs Binary files
+
+ SVarCounts Effect;
+ SVarCounts Pool;
+
+ UINT cTechniques;
+ UINT cbUnstructured;
+
+ UINT cStrings;
+ UINT cShaderResources;
+
+ UINT cDepthStencilBlocks;
+ UINT cBlendStateBlocks;
+ UINT cRasterizerStateBlocks;
+ UINT cSamplers;
+ UINT cRenderTargetViews;
+ UINT cDepthStencilViews;
+
+ UINT cTotalShaders;
+ UINT cInlineShaders; // of the aforementioned shaders, the number that are defined inline within pass blocks
+
+ D3DX11INLINE bool RequiresPool() const
+ {
+ return (Pool.cCBs != 0) ||
+ (Pool.cNumericVariables != 0) ||
+ (Pool.cObjectVariables != 0);
+ }
+};
+
+struct SBinaryHeader5 : public SBinaryHeader
+{
+ UINT cGroups;
+ UINT cUnorderedAccessViews;
+ UINT cInterfaceVariables;
+ UINT cInterfaceVariableElements;
+ UINT cClassInstanceElements;
+};
+
+// Constant buffer definition
+struct SBinaryConstantBuffer
+{
+ // private flags
+ static const UINT c_IsTBuffer = (1 << 0);
+ static const UINT c_IsSingle = (1 << 1);
+
+ UINT oName; // Offset to constant buffer name
+ UINT Size; // Size, in bytes
+ UINT Flags;
+ UINT cVariables; // # of variables inside this buffer
+ UINT ExplicitBindPoint; // Defined if the effect file specifies a bind point using the register keyword
+ // otherwise, -1
+};
+
+struct SBinaryAnnotation
+{
+ UINT oName; // Offset to variable name
+ UINT oType; // Offset to type information (SBinaryType)
+
+ // For numeric annotations:
+ // UINT oDefaultValue; // Offset to default initializer value
+ //
+ // For string annotations:
+ // UINT oStringOffsets[Elements]; // Elements comes from the type data at oType
+};
+
+struct SBinaryNumericVariable
+{
+ UINT oName; // Offset to variable name
+ UINT oType; // Offset to type information (SBinaryType)
+ UINT oSemantic; // Offset to semantic information
+ UINT Offset; // Offset in parent constant buffer
+ UINT oDefaultValue; // Offset to default initializer value
+ UINT Flags; // Explicit bind point
+};
+
+struct SBinaryInterfaceVariable
+{
+ UINT oName; // Offset to variable name
+ UINT oType; // Offset to type information (SBinaryType)
+ UINT oDefaultValue; // Offset to default initializer array (SBinaryInterfaceInitializer[Elements])
+ UINT Flags;
+};
+
+struct SBinaryInterfaceInitializer
+{
+ UINT oInstanceName;
+ UINT ArrayIndex;
+};
+
+struct SBinaryObjectVariable
+{
+ UINT oName; // Offset to variable name
+ UINT oType; // Offset to type information (SBinaryType)
+ UINT oSemantic; // Offset to semantic information
+ UINT ExplicitBindPoint; // Used when a variable has been explicitly bound (register(XX)). -1 if not
+
+ // Initializer data:
+ //
+ // The type structure pointed to by oType gives you Elements,
+ // VarType (must be EVT_Object), and ObjectType
+ //
+ // For ObjectType == EOT_Blend, EOT_DepthStencil, EOT_Rasterizer, EOT_Sampler
+ // struct
+ // {
+ // UINT cAssignments;
+ // SBinaryAssignment Assignments[cAssignments];
+ // } Blocks[Elements]
+ //
+ // For EObjectType == EOT_Texture*, EOT_Buffer
+ // <nothing>
+ //
+ // For EObjectType == EOT_*Shader, EOT_String
+ // UINT oData[Elements]; // offsets to a shader data block or a NULL-terminated string
+ //
+ // For EObjectType == EOT_GeometryShaderSO
+ // SBinaryGSSOInitializer[Elements]
+ //
+ // For EObjectType == EOT_*Shader5
+ // SBinaryShaderData5[Elements]
+};
+
+struct SBinaryGSSOInitializer
+{
+ UINT oShader; // Offset to shader bytecode data block
+ UINT oSODecl; // Offset to StreamOutput decl string
+};
+
+struct SBinaryShaderData5
+{
+ UINT oShader; // Offset to shader bytecode data block
+ UINT oSODecls[4]; // Offset to StreamOutput decl strings
+ UINT cSODecls; // Count of valid oSODecls entries.
+ UINT RasterizedStream; // Which stream is used for rasterization
+ UINT cInterfaceBindings; // Count of interface bindings.
+ UINT oInterfaceBindings; // Offset to SBinaryInterfaceInitializer[cInterfaceBindings].
+};
+
+struct SBinaryType
+{
+ UINT oTypeName; // Offset to friendly type name ("float4", "VS_OUTPUT")
+ EVarType VarType; // Numeric, Object, or Struct
+ UINT Elements; // # of array elements (0 for non-arrays)
+ UINT TotalSize; // Size in bytes; not necessarily Stride * Elements for arrays
+ // because of possible gap left in final register
+ UINT Stride; // If an array, this is the spacing between elements.
+ // For unpacked arrays, always divisible by 16-bytes (1 register).
+ // No support for packed arrays
+ UINT PackedSize; // Size, in bytes, of this data typed when fully packed
+
+ struct SBinaryMember
+ {
+ UINT oName; // Offset to structure member name ("m_pFoo")
+ UINT oSemantic; // Offset to semantic ("POSITION0")
+ UINT Offset; // Offset, in bytes, relative to start of parent structure
+ UINT oType; // Offset to member's type descriptor
+ };
+
+ // the data that follows depends on the VarType:
+ // Numeric: SType::SNumericType
+ // Object: EObjectType
+ // Struct:
+ // struct
+ // {
+ // UINT cMembers;
+ // SBinaryMembers Members[cMembers];
+ // } MemberInfo
+ // struct
+ // {
+ // UINT oBaseClassType; // Offset to type information (SBinaryType)
+ // UINT cInterfaces;
+ // UINT oInterfaceTypes[cInterfaces];
+ // } SBinaryTypeInheritance
+ // Interface: (nothing)
+};
+
+struct SBinaryNumericType
+{
+ ENumericLayout NumericLayout : 3; // scalar (1x1), vector (1xN), matrix (NxN)
+ EScalarType ScalarType : 5; // float32, int32, int8, etc.
+ UINT Rows : 3; // 1 <= Rows <= 4
+ UINT Columns : 3; // 1 <= Columns <= 4
+ UINT IsColumnMajor : 1; // applies only to matrices
+ UINT IsPackedArray : 1; // if this is an array, indicates whether elements should be greedily packed
+};
+
+struct SBinaryTypeInheritance
+{
+ UINT oBaseClass; // Offset to base class type info or 0 if no base class.
+ UINT cInterfaces;
+
+ // Followed by UINT[cInterfaces] with offsets to the type
+ // info of each interface.
+};
+
+struct SBinaryGroup
+{
+ UINT oName;
+ UINT cTechniques;
+};
+
+struct SBinaryTechnique
+{
+ UINT oName;
+ UINT cPasses;
+};
+
+struct SBinaryPass
+{
+ UINT oName;
+ UINT cAssignments;
+};
+
+enum ECompilerAssignmentType
+{
+ ECAT_Invalid, // Assignment-specific data (always in the unstructured blob)
+ ECAT_Constant, // -N SConstant structures
+ ECAT_Variable, // -NULL terminated string with variable name ("foo")
+ ECAT_ConstIndex, // -SConstantIndex structure
+ ECAT_VariableIndex, // -SVariableIndex structure
+ ECAT_ExpressionIndex, // -SIndexedObjectExpression structure
+ ECAT_Expression, // -Data block containing FXLVM code
+ ECAT_InlineShader, // -Data block containing shader
+ ECAT_InlineShader5, // -Data block containing shader with extended 5.0 data (SBinaryShaderData5)
+};
+
+struct SBinaryAssignment
+{
+ UINT iState; // index into g_lvGeneral
+ UINT Index; // the particular index to assign to (see g_lvGeneral to find the # of valid indices)
+ ECompilerAssignmentType AssignmentType;
+ UINT oInitializer; // Offset of assignment-specific data
+
+ //struct SConstantAssignment
+ //{
+ // UINT NumConstants; // number of constants to follow
+ // SCompilerConstant Constants[NumConstants];
+ //};
+
+ struct SConstantIndex
+ {
+ UINT oArrayName;
+ UINT Index;
+ };
+
+ struct SVariableIndex
+ {
+ UINT oArrayName;
+ UINT oIndexVarName;
+ };
+
+ struct SIndexedObjectExpression
+ {
+ UINT oArrayName;
+ UINT oCode;
+ };
+
+ struct SInlineShader
+ {
+ UINT oShader;
+ UINT oSODecl;
+ };
+
+ //struct SExpression or SInlineShader
+ //{
+ // UINT DataSize;
+ // BYTE Data[DataSize];
+ //}
+
+};
+
+struct SBinaryConstant
+{
+ EScalarType Type;
+ union
+ {
+ BOOL bValue;
+ INT iValue;
+ float fValue;
+ };
+};
+
+
+} // end namespace D3DX11Effects
diff --git a/sample/d3d11/Effects11/Binary/EffectStateBase11.h b/sample/d3d11/Effects11/Binary/EffectStateBase11.h
new file mode 100644
index 0000000..3727da2
--- /dev/null
+++ b/sample/d3d11/Effects11/Binary/EffectStateBase11.h
@@ -0,0 +1,49 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (C) Microsoft Corporation. All Rights Reserved.
+//
+// File: EffectStateBase11.h
+// Content: D3DX11 Effects States Header
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#pragma once
+
+namespace D3DX11Effects
+{
+
+//////////////////////////////////////////////////////////////////////////
+// Effect HLSL states and late resolve lists
+//////////////////////////////////////////////////////////////////////////
+
+struct RValue
+{
+ const char *m_pName;
+ UINT m_Value;
+};
+
+#define RVALUE_END() { NULL, 0U }
+#define RVALUE_ENTRY(prefix, x) { #x, (UINT)prefix##x }
+
+enum ELhsType;
+
+struct LValue
+{
+ const char *m_pName; // name of the LHS side of expression
+ EBlockType m_BlockType; // type of block it can appear in
+ D3D10_SHADER_VARIABLE_TYPE m_Type; // data type allows
+ UINT m_Cols; // number of [m_Type]'s required (1 for a scalar, 4 for a vector)
+ UINT m_Indices; // max index allowable (if LHS is an array; otherwise this is 1)
+ BOOL m_VectorScalar; // can be both vector and scalar (setting as a scalar sets all m_Indices values simultaneously)
+ CONST RValue *m_pRValue; // pointer to table of allowable RHS "late resolve" values
+ ELhsType m_LhsType; // ELHS_* enum value that corresponds to this entry
+ UINT m_Offset; // offset into the given block type where this value should be written
+ UINT m_Stride; // for vectors, byte stride between two consecutive values. if 0, m_Type's size is used
+};
+
+#define LVALUE_END() { NULL, D3D10_SVT_UINT, 0, 0, 0, NULL }
+
+extern CONST LValue g_lvGeneral[];
+extern CONST UINT g_lvGeneralCount;
+
+} // end namespace D3DX11Effects
diff --git a/sample/d3d11/Effects11/Binary/EffectStates11.h b/sample/d3d11/Effects11/Binary/EffectStates11.h
new file mode 100644
index 0000000..3bb3087
--- /dev/null
+++ b/sample/d3d11/Effects11/Binary/EffectStates11.h
@@ -0,0 +1,236 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (C) Microsoft Corporation. All Rights Reserved.
+//
+// File: EffectStates11.h
+// Content: D3DX11 Effects States Header
+// This file defines properties of states which can appear in
+// state blocks and pass blocks.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#pragma once
+
+#include <EffectStateBase11.h>
+
+namespace D3DX11Effects
+{
+
+//////////////////////////////////////////////////////////////////////////
+// Effect HLSL late resolve lists (state values)
+//////////////////////////////////////////////////////////////////////////
+
+static CONST RValue g_rvNULL[] =
+{
+ { "NULL", 0 },
+ RVALUE_END()
+};
+
+
+static CONST RValue g_rvBOOL[] =
+{
+ { "FALSE", 0 },
+ { "TRUE", 1 },
+ RVALUE_END()
+};
+
+static CONST RValue g_rvDEPTH_WRITE_MASK[] =
+{
+ { "ZERO", D3D10_DEPTH_WRITE_MASK_ZERO },
+ { "ALL", D3D10_DEPTH_WRITE_MASK_ALL },
+ RVALUE_END()
+};
+
+static CONST RValue g_rvFILL[] =
+{
+ { "WIREFRAME", D3D10_FILL_WIREFRAME },
+ { "SOLID", D3D10_FILL_SOLID },
+ RVALUE_END()
+};
+
+static CONST RValue g_rvFILTER[] =
+{
+ RVALUE_ENTRY(D3D10_FILTER_, MIN_MAG_MIP_POINT ),
+ RVALUE_ENTRY(D3D10_FILTER_, MIN_MAG_POINT_MIP_LINEAR ),
+ RVALUE_ENTRY(D3D10_FILTER_, MIN_POINT_MAG_LINEAR_MIP_POINT ),
+ RVALUE_ENTRY(D3D10_FILTER_, MIN_POINT_MAG_MIP_LINEAR ),
+ RVALUE_ENTRY(D3D10_FILTER_, MIN_LINEAR_MAG_MIP_POINT ),
+ RVALUE_ENTRY(D3D10_FILTER_, MIN_LINEAR_MAG_POINT_MIP_LINEAR ),
+ RVALUE_ENTRY(D3D10_FILTER_, MIN_MAG_LINEAR_MIP_POINT ),
+ RVALUE_ENTRY(D3D10_FILTER_, MIN_MAG_MIP_LINEAR ),
+ RVALUE_ENTRY(D3D10_FILTER_, ANISOTROPIC ),
+ RVALUE_ENTRY(D3D10_FILTER_, COMPARISON_MIN_MAG_MIP_POINT ),
+ RVALUE_ENTRY(D3D10_FILTER_, COMPARISON_MIN_MAG_POINT_MIP_LINEAR ),
+ RVALUE_ENTRY(D3D10_FILTER_, COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT ),
+ RVALUE_ENTRY(D3D10_FILTER_, COMPARISON_MIN_POINT_MAG_MIP_LINEAR ),
+ RVALUE_ENTRY(D3D10_FILTER_, COMPARISON_MIN_LINEAR_MAG_MIP_POINT ),
+ RVALUE_ENTRY(D3D10_FILTER_, COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR ),
+ RVALUE_ENTRY(D3D10_FILTER_, COMPARISON_MIN_MAG_LINEAR_MIP_POINT ),
+ RVALUE_ENTRY(D3D10_FILTER_, COMPARISON_MIN_MAG_MIP_LINEAR ),
+ RVALUE_ENTRY(D3D10_FILTER_, COMPARISON_ANISOTROPIC ),
+ RVALUE_ENTRY(D3D10_FILTER_, TEXT_1BIT ),
+ RVALUE_END()
+};
+
+static CONST RValue g_rvBLEND[] =
+{
+ { "ZERO", D3D10_BLEND_ZERO },
+ { "ONE", D3D10_BLEND_ONE },
+ { "SRC_COLOR", D3D10_BLEND_SRC_COLOR },
+ { "INV_SRC_COLOR", D3D10_BLEND_INV_SRC_COLOR },
+ { "SRC_ALPHA", D3D10_BLEND_SRC_ALPHA },
+ { "INV_SRC_ALPHA", D3D10_BLEND_INV_SRC_ALPHA },
+ { "DEST_ALPHA", D3D10_BLEND_DEST_ALPHA },
+ { "INV_DEST_ALPHA", D3D10_BLEND_INV_DEST_ALPHA },
+ { "DEST_COLOR", D3D10_BLEND_DEST_COLOR },
+ { "INV_DEST_COLOR", D3D10_BLEND_INV_DEST_COLOR },
+ { "SRC_ALPHA_SAT", D3D10_BLEND_SRC_ALPHA_SAT },
+ { "BLEND_FACTOR", D3D10_BLEND_BLEND_FACTOR },
+ { "INV_BLEND_FACTOR", D3D10_BLEND_INV_BLEND_FACTOR },
+ { "SRC1_COLOR", D3D10_BLEND_SRC1_COLOR },
+ { "INV_SRC1_COLOR", D3D10_BLEND_INV_SRC1_COLOR },
+ { "SRC1_ALPHA", D3D10_BLEND_SRC1_ALPHA },
+ { "INV_SRC1_ALPHA", D3D10_BLEND_INV_SRC1_ALPHA },
+
+ RVALUE_END()
+};
+
+static CONST RValue g_rvTADDRESS[] =
+{
+ { "CLAMP", D3D10_TEXTURE_ADDRESS_CLAMP },
+ { "WRAP", D3D10_TEXTURE_ADDRESS_WRAP },
+ { "MIRROR", D3D10_TEXTURE_ADDRESS_MIRROR },
+ { "BORDER", D3D10_TEXTURE_ADDRESS_BORDER },
+ { "MIRROR_ONCE", D3D10_TEXTURE_ADDRESS_MIRROR_ONCE },
+ RVALUE_END()
+};
+
+static CONST RValue g_rvCULL[] =
+{
+ { "NONE", D3D10_CULL_NONE },
+ { "FRONT", D3D10_CULL_FRONT },
+ { "BACK", D3D10_CULL_BACK },
+ RVALUE_END()
+};
+
+static CONST RValue g_rvCMP[] =
+{
+ { "NEVER", D3D10_COMPARISON_NEVER },
+ { "LESS", D3D10_COMPARISON_LESS },
+ { "EQUAL", D3D10_COMPARISON_EQUAL },
+ { "LESS_EQUAL", D3D10_COMPARISON_LESS_EQUAL },
+ { "GREATER", D3D10_COMPARISON_GREATER },
+ { "NOT_EQUAL", D3D10_COMPARISON_NOT_EQUAL },
+ { "GREATER_EQUAL", D3D10_COMPARISON_GREATER_EQUAL },
+ { "ALWAYS", D3D10_COMPARISON_ALWAYS },
+ RVALUE_END()
+};
+
+static CONST RValue g_rvSTENCILOP[] =
+{
+ { "KEEP", D3D10_STENCIL_OP_KEEP },
+ { "ZERO", D3D10_STENCIL_OP_ZERO },
+ { "REPLACE", D3D10_STENCIL_OP_REPLACE },
+ { "INCR_SAT", D3D10_STENCIL_OP_INCR_SAT },
+ { "DECR_SAT", D3D10_STENCIL_OP_DECR_SAT },
+ { "INVERT", D3D10_STENCIL_OP_INVERT },
+ { "INCR", D3D10_STENCIL_OP_INCR },
+ { "DECR", D3D10_STENCIL_OP_DECR },
+ RVALUE_END()
+};
+
+static CONST RValue g_rvBLENDOP[] =
+{
+ { "ADD", D3D10_BLEND_OP_ADD },
+ { "SUBTRACT", D3D10_BLEND_OP_SUBTRACT },
+ { "REV_SUBTRACT", D3D10_BLEND_OP_REV_SUBTRACT },
+ { "MIN", D3D10_BLEND_OP_MIN },
+ { "MAX", D3D10_BLEND_OP_MAX },
+ RVALUE_END()
+};
+
+
+//////////////////////////////////////////////////////////////////////////
+// Effect HLSL states
+//////////////////////////////////////////////////////////////////////////
+
+#define strideof( s, m ) offsetof_fx(s,m[1]) - offsetof_fx(s,m[0])
+
+CONST LValue g_lvGeneral[] =
+{
+ // RObjects
+ { "RasterizerState", EBT_Pass, D3D10_SVT_RASTERIZER, 1, 1, FALSE, NULL, ELHS_RasterizerBlock, offsetof_fx(SPassBlock, BackingStore.pRasterizerBlock), 0 },
+ { "DepthStencilState", EBT_Pass, D3D10_SVT_DEPTHSTENCIL, 1, 1, FALSE, NULL, ELHS_DepthStencilBlock, offsetof_fx(SPassBlock, BackingStore.pDepthStencilBlock), 0 },
+ { "BlendState", EBT_Pass, D3D10_SVT_BLEND, 1, 1, FALSE, NULL, ELHS_BlendBlock, offsetof_fx(SPassBlock, BackingStore.pBlendBlock), 0 },
+ { "RenderTargetView", EBT_Pass, D3D10_SVT_RENDERTARGETVIEW, 1, 8, FALSE, NULL, ELHS_RenderTargetView, offsetof_fx(SPassBlock, BackingStore.pRenderTargetViews), 0 },
+ { "DepthStencilView", EBT_Pass, D3D10_SVT_DEPTHSTENCILVIEW, 1, 8, FALSE, NULL, ELHS_DepthStencilView, offsetof_fx(SPassBlock, BackingStore.pDepthStencilView), 0 },
+ { "GenerateMips", EBT_Pass, D3D10_SVT_TEXTURE, 1, 1, FALSE, NULL, ELHS_GenerateMips, 0, 0 },
+ // Shaders
+ { "VertexShader", EBT_Pass, D3D10_SVT_VERTEXSHADER, 1, 1, FALSE, g_rvNULL, ELHS_VertexShaderBlock, offsetof_fx(SPassBlock, BackingStore.pVertexShaderBlock), 0 },
+ { "PixelShader", EBT_Pass, D3D10_SVT_PIXELSHADER, 1, 1, FALSE, g_rvNULL, ELHS_PixelShaderBlock, offsetof_fx(SPassBlock, BackingStore.pPixelShaderBlock), 0 },
+ { "GeometryShader", EBT_Pass, D3D10_SVT_GEOMETRYSHADER, 1, 1, FALSE, g_rvNULL, ELHS_GeometryShaderBlock, offsetof_fx(SPassBlock, BackingStore.pGeometryShaderBlock), 0 },
+ // RObject config assignments
+ { "DS_StencilRef", EBT_Pass, D3D10_SVT_UINT, 1, 1, FALSE, NULL, ELHS_DS_StencilRef, offsetof_fx(SPassBlock, BackingStore.StencilRef), 0 },
+ { "AB_BlendFactor", EBT_Pass, D3D10_SVT_FLOAT, 4, 1, FALSE, NULL, ELHS_B_BlendFactor, offsetof_fx(SPassBlock, BackingStore.BlendFactor), 0 },
+ { "AB_SampleMask", EBT_Pass, D3D10_SVT_UINT, 1, 1, FALSE, NULL, ELHS_B_SampleMask, offsetof_fx(SPassBlock, BackingStore.SampleMask), 0 },
+
+ { "FillMode", EBT_Rasterizer, D3D10_SVT_UINT, 1, 1, FALSE, g_rvFILL, ELHS_FillMode, offsetof_fx(SRasterizerBlock, BackingStore.FillMode), 0 },
+ { "CullMode", EBT_Rasterizer, D3D10_SVT_UINT, 1, 1, FALSE, g_rvCULL, ELHS_CullMode, offsetof_fx(SRasterizerBlock, BackingStore.CullMode), 0 },
+ { "FrontCounterClockwise", EBT_Rasterizer, D3D10_SVT_BOOL, 1, 1, FALSE, g_rvBOOL, ELHS_FrontCC, offsetof_fx(SRasterizerBlock, BackingStore.FrontCounterClockwise), 0 },
+ { "DepthBias", EBT_Rasterizer, D3D10_SVT_UINT, 1, 1, FALSE, NULL, ELHS_DepthBias, offsetof_fx(SRasterizerBlock, BackingStore.DepthBias), 0 },
+ { "DepthBiasClamp", EBT_Rasterizer, D3D10_SVT_FLOAT, 1, 1, FALSE, NULL, ELHS_DepthBiasClamp, offsetof_fx(SRasterizerBlock, BackingStore.DepthBiasClamp), 0 },
+ { "SlopeScaledDepthBias", EBT_Rasterizer, D3D10_SVT_FLOAT, 1, 1, FALSE, NULL, ELHS_SlopeScaledDepthBias, offsetof_fx(SRasterizerBlock, BackingStore.SlopeScaledDepthBias), 0 },
+ { "DepthClipEnable", EBT_Rasterizer, D3D10_SVT_BOOL, 1, 1, FALSE, g_rvBOOL, ELHS_DepthClipEnable, offsetof_fx(SRasterizerBlock, BackingStore.DepthClipEnable), 0 },
+ { "ScissorEnable", EBT_Rasterizer, D3D10_SVT_BOOL, 1, 1, FALSE, g_rvBOOL, ELHS_ScissorEnable, offsetof_fx(SRasterizerBlock, BackingStore.ScissorEnable), 0 },
+ { "MultisampleEnable", EBT_Rasterizer, D3D10_SVT_BOOL, 1, 1, FALSE, g_rvBOOL, ELHS_MultisampleEnable, offsetof_fx(SRasterizerBlock, BackingStore.MultisampleEnable), 0 },
+ { "AntialiasedLineEnable", EBT_Rasterizer, D3D10_SVT_BOOL, 1, 1, FALSE, g_rvBOOL, ELHS_AntialiasedLineEnable, offsetof_fx(SRasterizerBlock, BackingStore.AntialiasedLineEnable), 0 },
+
+ { "DepthEnable", EBT_DepthStencil, D3D10_SVT_BOOL, 1, 1, FALSE, g_rvBOOL, ELHS_DepthEnable, offsetof_fx(SDepthStencilBlock, BackingStore.DepthEnable), 0 },
+ { "DepthWriteMask", EBT_DepthStencil, D3D10_SVT_UINT, 1, 1, FALSE, g_rvDEPTH_WRITE_MASK, ELHS_DepthWriteMask, offsetof_fx(SDepthStencilBlock, BackingStore.DepthWriteMask), 0 },
+ { "DepthFunc", EBT_DepthStencil, D3D10_SVT_UINT, 1, 1, FALSE, g_rvCMP, ELHS_DepthFunc, offsetof_fx(SDepthStencilBlock, BackingStore.DepthFunc), 0 },
+ { "StencilEnable", EBT_DepthStencil, D3D10_SVT_BOOL, 1, 1, FALSE, g_rvBOOL, ELHS_StencilEnable, offsetof_fx(SDepthStencilBlock, BackingStore.StencilEnable), 0 },
+ { "StencilReadMask", EBT_DepthStencil, D3D10_SVT_UINT8, 1, 1, FALSE, NULL, ELHS_StencilReadMask, offsetof_fx(SDepthStencilBlock, BackingStore.StencilReadMask), 0 },
+ { "StencilWriteMask", EBT_DepthStencil, D3D10_SVT_UINT8, 1, 1, FALSE, NULL, ELHS_StencilWriteMask, offsetof_fx(SDepthStencilBlock, BackingStore.StencilWriteMask), 0 },
+ { "FrontFaceStencilFail", EBT_DepthStencil, D3D10_SVT_UINT, 1, 1, FALSE, g_rvSTENCILOP, ELHS_FrontFaceStencilFailOp, offsetof_fx(SDepthStencilBlock, BackingStore.FrontFace.StencilFailOp), 0 },
+ { "FrontFaceStencilDepthFail", EBT_DepthStencil, D3D10_SVT_UINT, 1, 1, FALSE, g_rvSTENCILOP, ELHS_FrontFaceStencilDepthFailOp,offsetof_fx(SDepthStencilBlock, BackingStore.FrontFace.StencilDepthFailOp), 0 },
+ { "FrontFaceStencilPass", EBT_DepthStencil, D3D10_SVT_UINT, 1, 1, FALSE, g_rvSTENCILOP, ELHS_FrontFaceStencilPassOp, offsetof_fx(SDepthStencilBlock, BackingStore.FrontFace.StencilPassOp), 0 },
+ { "FrontFaceStencilFunc", EBT_DepthStencil, D3D10_SVT_UINT, 1, 1, FALSE, g_rvCMP, ELHS_FrontFaceStencilFunc, offsetof_fx(SDepthStencilBlock, BackingStore.FrontFace.StencilFunc), 0 },
+ { "BackFaceStencilFail", EBT_DepthStencil, D3D10_SVT_UINT, 1, 1, FALSE, g_rvSTENCILOP, ELHS_BackFaceStencilFailOp, offsetof_fx(SDepthStencilBlock, BackingStore.BackFace.StencilFailOp), 0 },
+ { "BackFaceStencilDepthFail", EBT_DepthStencil, D3D10_SVT_UINT, 1, 1, FALSE, g_rvSTENCILOP, ELHS_BackFaceStencilDepthFailOp,offsetof_fx(SDepthStencilBlock, BackingStore.BackFace.StencilDepthFailOp), 0 },
+ { "BackFaceStencilPass", EBT_DepthStencil, D3D10_SVT_UINT, 1, 1, FALSE, g_rvSTENCILOP, ELHS_BackFaceStencilPassOp, offsetof_fx(SDepthStencilBlock, BackingStore.BackFace.StencilPassOp), 0 },
+ { "BackFaceStencilFunc", EBT_DepthStencil, D3D10_SVT_UINT, 1, 1, FALSE, g_rvCMP, ELHS_BackFaceStencilFunc, offsetof_fx(SDepthStencilBlock, BackingStore.BackFace.StencilFunc), 0 },
+
+ { "AlphaToCoverageEnable", EBT_Blend, D3D10_SVT_BOOL, 1, 1, FALSE, g_rvBOOL, ELHS_AlphaToCoverage, offsetof_fx(SBlendBlock, BackingStore.AlphaToCoverageEnable), 0 },
+ { "BlendEnable", EBT_Blend, D3D10_SVT_BOOL, 1, 8, FALSE, g_rvBOOL, ELHS_BlendEnable, offsetof_fx(SBlendBlock, BackingStore.RenderTarget[0].BlendEnable), strideof(SBlendBlock, BackingStore.RenderTarget) },
+ { "SrcBlend", EBT_Blend, D3D10_SVT_UINT, 1, 8, TRUE, g_rvBLEND, ELHS_SrcBlend, offsetof_fx(SBlendBlock, BackingStore.RenderTarget[0].SrcBlend), strideof(SBlendBlock, BackingStore.RenderTarget) },
+ { "DestBlend", EBT_Blend, D3D10_SVT_UINT, 1, 8, TRUE, g_rvBLEND, ELHS_DestBlend, offsetof_fx(SBlendBlock, BackingStore.RenderTarget[0].DestBlend), strideof(SBlendBlock, BackingStore.RenderTarget) },
+ { "BlendOp", EBT_Blend, D3D10_SVT_UINT, 1, 8, TRUE, g_rvBLENDOP, ELHS_BlendOp, offsetof_fx(SBlendBlock, BackingStore.RenderTarget[0].BlendOp), strideof(SBlendBlock, BackingStore.RenderTarget) },
+ { "SrcBlendAlpha", EBT_Blend, D3D10_SVT_UINT, 1, 8, TRUE, g_rvBLEND, ELHS_SrcBlendAlpha, offsetof_fx(SBlendBlock, BackingStore.RenderTarget[0].SrcBlendAlpha), strideof(SBlendBlock, BackingStore.RenderTarget) },
+ { "DestBlendAlpha", EBT_Blend, D3D10_SVT_UINT, 1, 8, TRUE, g_rvBLEND, ELHS_DestBlendAlpha, offsetof_fx(SBlendBlock, BackingStore.RenderTarget[0].DestBlendAlpha), strideof(SBlendBlock, BackingStore.RenderTarget) },
+ { "BlendOpAlpha", EBT_Blend, D3D10_SVT_UINT, 1, 8, TRUE, g_rvBLENDOP, ELHS_BlendOpAlpha, offsetof_fx(SBlendBlock, BackingStore.RenderTarget[0].BlendOpAlpha), strideof(SBlendBlock, BackingStore.RenderTarget) },
+ { "RenderTargetWriteMask", EBT_Blend, D3D10_SVT_UINT8, 1, 8, FALSE, NULL, ELHS_RenderTargetWriteMask, offsetof_fx(SBlendBlock, BackingStore.RenderTarget[0].RenderTargetWriteMask), strideof(SBlendBlock, BackingStore.RenderTarget) },
+
+ { "Filter", EBT_Sampler, D3D10_SVT_UINT, 1, 1, FALSE, g_rvFILTER, ELHS_Filter, offsetof_fx(SSamplerBlock, BackingStore.SamplerDesc.Filter), 0 },
+ { "AddressU", EBT_Sampler, D3D10_SVT_UINT, 1, 1, FALSE, g_rvTADDRESS, ELHS_AddressU, offsetof_fx(SSamplerBlock, BackingStore.SamplerDesc.AddressU), 0 },
+ { "AddressV", EBT_Sampler, D3D10_SVT_UINT, 1, 1, FALSE, g_rvTADDRESS, ELHS_AddressV, offsetof_fx(SSamplerBlock, BackingStore.SamplerDesc.AddressV), 0 },
+ { "AddressW", EBT_Sampler, D3D10_SVT_UINT, 1, 1, FALSE, g_rvTADDRESS, ELHS_AddressW, offsetof_fx(SSamplerBlock, BackingStore.SamplerDesc.AddressW), 0 },
+ { "MipLODBias", EBT_Sampler, D3D10_SVT_FLOAT, 1, 1, FALSE, NULL, ELHS_MipLODBias, offsetof_fx(SSamplerBlock, BackingStore.SamplerDesc.MipLODBias), 0 },
+ { "MaxAnisotropy", EBT_Sampler, D3D10_SVT_UINT, 1, 1, FALSE, NULL, ELHS_MaxAnisotropy, offsetof_fx(SSamplerBlock, BackingStore.SamplerDesc.MaxAnisotropy), 0 },
+ { "ComparisonFunc", EBT_Sampler, D3D10_SVT_UINT, 1, 1, FALSE, g_rvCMP, ELHS_ComparisonFunc, offsetof_fx(SSamplerBlock, BackingStore.SamplerDesc.ComparisonFunc), 0 },
+ { "BorderColor", EBT_Sampler, D3D10_SVT_FLOAT, 4, 1, FALSE, NULL, ELHS_BorderColor, offsetof_fx(SSamplerBlock, BackingStore.SamplerDesc.BorderColor), 0 },
+ { "MinLOD", EBT_Sampler, D3D10_SVT_FLOAT, 1, 1, FALSE, NULL, ELHS_MinLOD, offsetof_fx(SSamplerBlock, BackingStore.SamplerDesc.MinLOD), 0 },
+ { "MaxLOD", EBT_Sampler, D3D10_SVT_FLOAT, 1, 1, FALSE, NULL, ELHS_MaxLOD, offsetof_fx(SSamplerBlock, BackingStore.SamplerDesc.MaxLOD), 0 },
+ { "Texture", EBT_Sampler, D3D10_SVT_TEXTURE, 1, 1, FALSE, g_rvNULL, ELHS_Texture, offsetof_fx(SSamplerBlock, BackingStore.pTexture), 0 },
+
+ // D3D11
+ { "HullShader", EBT_Pass, D3D11_SVT_HULLSHADER, 1, 1, FALSE, g_rvNULL, ELHS_HullShaderBlock, offsetof_fx(SPassBlock, BackingStore.pHullShaderBlock), 0 },
+ { "DomainShader", EBT_Pass, D3D11_SVT_DOMAINSHADER, 1, 1, FALSE, g_rvNULL, ELHS_DomainShaderBlock, offsetof_fx(SPassBlock, BackingStore.pDomainShaderBlock), 0 },
+ { "ComputeShader", EBT_Pass, D3D11_SVT_COMPUTESHADER, 1, 1, FALSE, g_rvNULL, ELHS_ComputeShaderBlock, offsetof_fx(SPassBlock, BackingStore.pComputeShaderBlock), 0 },
+};
+
+#define NUM_STATES (sizeof(g_lvGeneral) / sizeof(LValue))
+#define MAX_VECTOR_SCALAR_INDEX 8
+
+CONST UINT g_lvGeneralCount = NUM_STATES;
+
+} // end namespace D3DX11Effects
diff --git a/sample/d3d11/Effects11/Binary/SOParser.h b/sample/d3d11/Effects11/Binary/SOParser.h
new file mode 100644
index 0000000..1fb95a9
--- /dev/null
+++ b/sample/d3d11/Effects11/Binary/SOParser.h
@@ -0,0 +1,311 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (C) Microsoft Corporation. All Rights Reserved.
+//
+// File: SOParser.h
+// Content: D3DX11 Effects Stream Out Decl Parser
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#pragma once
+
+namespace D3DX11Effects
+{
+
+
+//////////////////////////////////////////////////////////////////////////
+// CSOParser
+//////////////////////////////////////////////////////////////////////////
+
+class CSOParser
+{
+
+ CEffectVector<D3D11_SO_DECLARATION_ENTRY> m_vDecls; // Set of parsed decl entries
+ D3D11_SO_DECLARATION_ENTRY m_newEntry; // Currently parsing entry
+ LPSTR m_SemanticString[D3D11_SO_BUFFER_SLOT_COUNT]; // Copy of strings
+
+ static const UINT MAX_ERROR_SIZE = 254;
+ char m_pError[ MAX_ERROR_SIZE + 1 ]; // Error buffer
+
+public:
+ CSOParser()
+ {
+ ZeroMemory(&m_newEntry, sizeof(m_newEntry));
+ ZeroMemory(m_SemanticString, sizeof(m_SemanticString));
+ m_pError[0] = 0;
+ }
+
+ ~CSOParser()
+ {
+ for( UINT Stream = 0; Stream < D3D11_SO_STREAM_COUNT; Stream++ )
+ {
+ SAFE_DELETE_ARRAY( m_SemanticString[Stream] );
+ }
+ }
+
+ // Parse a single string, assuming stream 0
+ HRESULT Parse( __in_z LPCSTR pString )
+ {
+ m_vDecls.Clear();
+ return Parse( 0, pString );
+ }
+
+ // Parse all 4 streams
+ HRESULT Parse( __in_z LPSTR pStreams[D3D11_SO_STREAM_COUNT] )
+ {
+ HRESULT hr = S_OK;
+ m_vDecls.Clear();
+ for( UINT iDecl=0; iDecl < D3D11_SO_STREAM_COUNT; ++iDecl )
+ {
+ hr = Parse( iDecl, pStreams[iDecl] );
+ if( FAILED(hr) )
+ {
+ char pStream[16];
+ StringCchPrintfA( pStream, 16, " in stream %d.", iDecl );
+ pStream[15] = 0;
+ StringCchCatA( m_pError, MAX_ERROR_SIZE, pStream );
+ return hr;
+ }
+ }
+ return hr;
+ }
+
+ // Return resulting declarations
+ D3D11_SO_DECLARATION_ENTRY *GetDeclArray()
+ {
+ return &m_vDecls[0];
+ }
+
+ char* GetErrorString()
+ {
+ return m_pError;
+ }
+
+ UINT GetDeclCount() const
+ {
+ return m_vDecls.GetSize();
+ }
+
+ // Return resulting buffer strides
+ void GetStrides( UINT strides[4] )
+ {
+ UINT len = GetDeclCount();
+ strides[0] = strides[1] = strides[2] = strides[3] = 0;
+
+ for( UINT i=0; i < len; i++ )
+ {
+ strides[m_vDecls[i].OutputSlot] += m_vDecls[i].ComponentCount * sizeof(float);
+ }
+ }
+
+protected:
+
+ // Parse a single string "[<slot> :] <semantic>[<index>][.<mask>]; [[<slot> :] <semantic>[<index>][.<mask>][;]]"
+ HRESULT Parse( UINT Stream, __in_z LPCSTR pString )
+ {
+ HRESULT hr = S_OK;
+
+ m_pError[0] = 0;
+
+ if( pString == NULL )
+ return S_OK;
+
+ UINT len = (UINT)strlen( pString );
+ if( len == 0 )
+ return S_OK;
+
+ SAFE_DELETE_ARRAY( m_SemanticString[Stream] );
+ VN( m_SemanticString[Stream] = NEW char[len + 1] );
+ StringCchCopyA( m_SemanticString[Stream], len + 1, pString );
+
+ LPSTR pSemantic = m_SemanticString[Stream];
+
+ while( TRUE )
+ {
+ // Each decl entry is delimited by a semi-colon
+ LPSTR pSemi = strchr( pSemantic, ';' );
+
+ // strip leading and trailing spaces
+ LPSTR pEnd;
+ if( pSemi != NULL )
+ {
+ *pSemi = '\0';
+ pEnd = pSemi - 1;
+ }
+ else
+ {
+ pEnd = pSemantic + strlen( pSemantic );
+ }
+ while( isspace( (unsigned char)*pSemantic ) )
+ pSemantic++;
+ while( pEnd > pSemantic && isspace( (unsigned char)*pEnd ) )
+ {
+ *pEnd = '\0';
+ pEnd--;
+ }
+
+ if( *pSemantic != '\0' )
+ {
+ VH( AddSemantic( pSemantic ) );
+ m_newEntry.Stream = Stream;
+
+ VH( m_vDecls.Add( m_newEntry ) );
+ }
+ if( pSemi == NULL )
+ break;
+ pSemantic = pSemi + 1;
+ }
+
+lExit:
+ return hr;
+ }
+
+ // Parse a single decl "[<slot> :] <semantic>[<index>][.<mask>]"
+ HRESULT AddSemantic( __inout_z LPSTR pSemantic )
+ {
+ HRESULT hr = S_OK;
+
+ D3DXASSERT( pSemantic );
+
+ ZeroMemory( &m_newEntry, sizeof(m_newEntry) );
+ VH( ConsumeOutputSlot( &pSemantic ) );
+ VH( ConsumeRegisterMask( pSemantic ) );
+ VH( ConsumeSemanticIndex( pSemantic ) );
+
+ // pSenantic now contains only the SemanticName (all other fields were consumed)
+ if( strcmp( "$SKIP", pSemantic ) != 0 )
+ {
+ m_newEntry.SemanticName = pSemantic;
+ }
+
+lExit:
+ return hr;
+ }
+
+ // Parse optional mask "[.<mask>]"
+ HRESULT ConsumeRegisterMask( __inout_z LPSTR pSemantic )
+ {
+ HRESULT hr = S_OK;
+ const char *pFullMask1 = "xyzw";
+ const char *pFullMask2 = "rgba";
+ SIZE_T stringLength;
+ SIZE_T startComponent = 0;
+ LPCSTR p;
+
+ D3DXASSERT( pSemantic );
+
+ pSemantic = strchr( pSemantic, '.' );
+
+ if( pSemantic == NULL )
+ {
+ m_newEntry.ComponentCount = 4;
+ return S_OK;
+ }
+
+ *pSemantic = '\0';
+ pSemantic++;
+
+ stringLength = strlen( pSemantic );
+ p = strstr(pFullMask1, pSemantic );
+ if( p )
+ {
+ startComponent = (UINT)( p - pFullMask1 );
+ }
+ else
+ {
+ p = strstr( pFullMask2, pSemantic );
+ if( p )
+ startComponent = (UINT)( p - pFullMask2 );
+ else
+ {
+ StringCchPrintfA( m_pError, MAX_ERROR_SIZE, "ID3D11Effect::ParseSODecl - invalid mask declaration '%s'", pSemantic );
+ VH( E_FAIL );
+ }
+
+ }
+
+ if( stringLength == 0 )
+ stringLength = 4;
+
+ m_newEntry.StartComponent = (BYTE)startComponent;
+ m_newEntry.ComponentCount = (BYTE)stringLength;
+
+lExit:
+ return hr;
+ }
+
+ // Parse optional output slot "[<slot> :]"
+ HRESULT ConsumeOutputSlot( __deref_inout_z LPSTR* ppSemantic )
+ {
+ D3DXASSERT( ppSemantic && *ppSemantic );
+
+ HRESULT hr = S_OK;
+ LPSTR pColon = strchr( *ppSemantic, ':' );
+
+ if( pColon == NULL )
+ return S_OK;
+
+ if( pColon == *ppSemantic )
+ {
+ StringCchCopyA( m_pError, MAX_ERROR_SIZE,
+ "ID3D11Effect::ParseSODecl - Invalid output slot" );
+ VH( E_FAIL );
+ }
+
+ *pColon = '\0';
+ int outputSlot = atoi( *ppSemantic );
+ if( outputSlot < 0 || outputSlot > 255 )
+ {
+ StringCchCopyA( m_pError, MAX_ERROR_SIZE,
+ "ID3D11Effect::ParseSODecl - Invalid output slot" );
+ VH( E_FAIL );
+ }
+ m_newEntry.OutputSlot = (BYTE)outputSlot;
+
+ while( *ppSemantic < pColon )
+ {
+ if( !isdigit( (unsigned char)**ppSemantic ) )
+ {
+ StringCchPrintfA( m_pError, MAX_ERROR_SIZE, "ID3D11Effect::ParseSODecl - Non-digit '%c' in output slot", **ppSemantic );
+ VH( E_FAIL );
+ }
+ (*ppSemantic)++;
+ }
+
+ // skip the colon (which is now '\0')
+ (*ppSemantic)++;
+
+ while( isspace( (unsigned char)**ppSemantic ) )
+ (*ppSemantic)++;
+
+lExit:
+ return hr;
+ }
+
+ // Parse optional index "[<index>]"
+ HRESULT ConsumeSemanticIndex( __inout_z LPSTR pSemantic )
+ {
+ D3DXASSERT( pSemantic );
+
+ UINT uLen = (UINT)strlen( pSemantic );
+
+ // Grab semantic index
+ while( uLen > 0 && isdigit( (unsigned char)pSemantic[uLen - 1] ) )
+ uLen--;
+
+ if( isdigit( (unsigned char)pSemantic[uLen] ) )
+ {
+ m_newEntry.SemanticIndex = atoi( pSemantic + uLen );
+ pSemantic[uLen] = '\0';
+ }
+ else
+ {
+ m_newEntry.SemanticIndex = 0;
+ }
+
+ return S_OK;
+ }
+};
+
+
+} // end namespace D3DX11Effects