/**************************************************************************
 *
 * 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
	);
};

