Signed-off-by: Paul Gofman pgofman@codeweavers.com --- include/Makefile.in | 1 + include/d3d12shader.h | 187 ++++++++++++++++++++++++++++++++++++++++++ include/d3dcommon.idl | 19 +++++ include/d3dcompiler.h | 1 + 4 files changed, 208 insertions(+) create mode 100644 include/d3d12shader.h
diff --git a/include/Makefile.in b/include/Makefile.in index 216adf0d7ae..0c31eb8cc12 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -108,6 +108,7 @@ SOURCES = \ d3d11on12.idl \ d3d11sdklayers.idl \ d3d11shader.h \ + d3d12shader.h \ d3d12.idl \ d3d8.h \ d3d8caps.h \ diff --git a/include/d3d12shader.h b/include/d3d12shader.h new file mode 100644 index 00000000000..a5ef054e806 --- /dev/null +++ b/include/d3d12shader.h @@ -0,0 +1,187 @@ +/* + * Copyright 2020 Paul Gofman 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 __D3D12SHADER_H__ +#define __D3D12SHADER_H__ + +#include "d3dcommon.h" + +typedef struct _D3D12_SHADER_DESC +{ + UINT Version; + const char *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; +} D3D12_SHADER_DESC; + +typedef struct _D3D12_SHADER_VARIABLE_DESC +{ + const char *Name; + UINT StartOffset; + UINT Size; + UINT uFlags; + void *DefaultValue; + UINT StartTexture; + UINT TextureSize; + UINT StartSampler; + UINT SamplerSize; +} D3D12_SHADER_VARIABLE_DESC; + +typedef struct _D3D12_SHADER_TYPE_DESC +{ + D3D_SHADER_VARIABLE_CLASS Class; + D3D_SHADER_VARIABLE_TYPE Type; + UINT Rows; + UINT Columns; + UINT Elements; + UINT Members; + UINT Offset; + const char *Name; +} D3D12_SHADER_TYPE_DESC; + +typedef struct _D3D12_SHADER_BUFFER_DESC +{ + const char *Name; + D3D_CBUFFER_TYPE Type; + UINT Variables; + UINT Size; + UINT uFlags; +} D3D12_SHADER_BUFFER_DESC; + +typedef struct _D3D12_SHADER_INPUT_BIND_DESC +{ + const char *Name; + D3D_SHADER_INPUT_TYPE Type; + UINT BindPoint; + UINT BindCount; + UINT uFlags; + D3D_RESOURCE_RETURN_TYPE ReturnType; + D3D_SRV_DIMENSION Dimension; + UINT NumSamples; + UINT Space; + UINT uID; +} D3D12_SHADER_INPUT_BIND_DESC; + +typedef struct _D3D12_SIGNATURE_PARAMETER_DESC +{ + const char *SemanticName; + UINT SemanticIndex; + UINT Register; + D3D_NAME SystemValueType; + D3D_REGISTER_COMPONENT_TYPE ComponentType; + BYTE Mask; + BYTE ReadWriteMask; + UINT Stream; + D3D_MIN_PRECISION MinPrecision; +} D3D12_SIGNATURE_PARAMETER_DESC; + +typedef struct _D3D12_PARAMETER_DESC +{ + const char *Name; + const char *SemanticName; + D3D_SHADER_VARIABLE_TYPE Type; + D3D_SHADER_VARIABLE_CLASS Class; + UINT Rows; + UINT Columns; + D3D_INTERPOLATION_MODE InterpolationMode; + D3D_PARAMETER_FLAGS Flags; + UINT FirstInRegister; + UINT FirstInComponent; + UINT FirstOutRegister; + UINT FirstOutComponent; +} D3D12_PARAMETER_DESC; + +typedef struct _D3D12_FUNCTION_DESC +{ + UINT Version; + const char *Creator; + UINT Flags; + UINT ConstantBuffers; + UINT BoundResources; + 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 MovInstructionCount; + UINT MovcInstructionCount; + UINT ConversionInstructionCount; + UINT BitwiseInstructionCount; + D3D_FEATURE_LEVEL MinFeatureLevel; + UINT64 RequiredFeatureFlags; + const char *Name; + INT FunctionParameterCount; + BOOL HasReturn; + BOOL Has10Level9VertexShader; + BOOL Has10Level9PixelShader; +} D3D12_FUNCTION_DESC; + +typedef struct _D3D12_LIBRARY_DESC +{ + const char *Creator; + UINT Flags; + UINT FunctionCount; +} D3D12_LIBRARY_DESC; + +#endif diff --git a/include/d3dcommon.idl b/include/d3dcommon.idl index 29404efd69d..b0c3fe2b693 100644 --- a/include/d3dcommon.idl +++ b/include/d3dcommon.idl @@ -686,4 +686,23 @@ typedef enum _D3D_SHADER_CBUFFER_FLAGS D3D_CBF_FORCE_DWORD = 0x7fffffff } D3D_SHADER_CBUFFER_FLAGS;
+typedef enum _D3D_PARAMETER_FLAGS +{ + D3D_PF_NONE, + D3D_PF_IN, + D3D_PF_OUT, + D3D_PF_FORCE_DWORD, +} D3D_PARAMETER_FLAGS; + +typedef enum _D3D_INTERPOLATION_MODE { + D3D_INTERPOLATION_UNDEFINED, + D3D_INTERPOLATION_CONSTANT, + D3D_INTERPOLATION_LINEAR, + D3D_INTERPOLATION_LINEAR_CENTROID, + D3D_INTERPOLATION_LINEAR_NOPERSPECTIVE, + D3D_INTERPOLATION_LINEAR_NOPERSPECTIVE_CENTROID, + D3D_INTERPOLATION_LINEAR_SAMPLE, + D3D_INTERPOLATION_LINEAR_NOPERSPECTIVE_SAMPLE, +} D3D_INTERPOLATION_MODE; + cpp_quote("DEFINE_GUID(WKPDID_D3DDebugObjectName,0x429b8c22,0x9188,0x4b0c,0x87,0x42,0xac,0xb0,0xbf,0x85,0xc2,0x00);") diff --git a/include/d3dcompiler.h b/include/d3dcompiler.h index bd1b3d1d44d..f11251e9dbf 100644 --- a/include/d3dcompiler.h +++ b/include/d3dcompiler.h @@ -20,6 +20,7 @@ #define __D3DCOMPILER_H__
#include "d3d11shader.h" +#include "d3d12shader.h"
#ifdef __cplusplus extern "C" {
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- include/d3d12shader.h | 111 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+)
diff --git a/include/d3d12shader.h b/include/d3d12shader.h index a5ef054e806..7179c33790b 100644 --- a/include/d3d12shader.h +++ b/include/d3d12shader.h @@ -184,4 +184,115 @@ typedef struct _D3D12_LIBRARY_DESC UINT FunctionCount; } D3D12_LIBRARY_DESC;
+DEFINE_GUID(IID_ID3D12ShaderReflectionType, 0xe913c351, 0x783d, 0x48ca, 0xa1, 0xd1, 0x4f, 0x30, 0x62, 0x84, 0xad, 0x56); + +#define INTERFACE ID3D12ShaderReflectionType +DECLARE_INTERFACE(ID3D12ShaderReflectionType) +{ + STDMETHOD(GetDesc)(THIS_ D3D12_SHADER_TYPE_DESC *desc) PURE; + STDMETHOD_(struct ID3D12ShaderReflectionType *, GetMemberTypeByIndex)(THIS_ UINT index) PURE; + STDMETHOD_(struct ID3D12ShaderReflectionType *, GetMemberTypeByName)(THIS_ const char *name) PURE; + STDMETHOD_(const char *, GetMemberTypeName)(THIS_ UINT index) PURE; + STDMETHOD(IsEqual)(THIS_ struct ID3D12ShaderReflectionType *type) PURE; + STDMETHOD_(struct ID3D12ShaderReflectionType *, GetSubType)(THIS) PURE; + STDMETHOD_(struct ID3D12ShaderReflectionType *, GetBaseClass)(THIS) PURE; + STDMETHOD_(UINT, GetNumInterfaces)(THIS) PURE; + STDMETHOD_(struct ID3D12ShaderReflectionType *, GetInterfaceByIndex)(THIS_ UINT index) PURE; + STDMETHOD(IsOfType)(THIS_ struct ID3D12ShaderReflectionType *type) PURE; + STDMETHOD(ImplementsInterface)(THIS_ struct ID3D12ShaderReflectionType *base) PURE; +}; +#undef INTERFACE + +DEFINE_GUID(IID_ID3D12ShaderReflectionVariable, 0x8337a8a6, 0xa216, 0x444a, 0xb2, 0xf4, 0x31, 0x47, 0x33, 0xa7, 0x3a, 0xea); + +#define INTERFACE ID3D12ShaderReflectionVariable +DECLARE_INTERFACE(ID3D12ShaderReflectionVariable) +{ + STDMETHOD(GetDesc)(THIS_ D3D12_SHADER_VARIABLE_DESC *desc) PURE; + STDMETHOD_(struct ID3D12ShaderReflectionType *, GetType)(THIS) PURE; + STDMETHOD_(struct ID3D12ShaderReflectionConstantBuffer *, GetBuffer)(THIS) PURE; + STDMETHOD_(UINT, GetInterfaceSlot)(THIS_ UINT index) PURE; +}; +#undef INTERFACE + +DEFINE_GUID(IID_ID3D12ShaderReflectionConstantBuffer, 0xc59598b4, 0x48b3, 0x4869, 0xb9, 0xb1, 0xb1, 0x61, 0x8b, 0x14, 0xa8, 0xb7); + +#define INTERFACE ID3D12ShaderReflectionConstantBuffer +DECLARE_INTERFACE(ID3D12ShaderReflectionConstantBuffer) +{ + STDMETHOD(GetDesc)(THIS_ D3D12_SHADER_BUFFER_DESC *desc) PURE; + STDMETHOD_(struct ID3D12ShaderReflectionVariable *, GetVariableByIndex)(THIS_ UINT index) PURE; + STDMETHOD_(struct ID3D12ShaderReflectionVariable *, GetVariableByName)(THIS_ const char *name) PURE; +}; +#undef INTERFACE + +DEFINE_GUID(IID_ID3D12ShaderReflection, 0x5a58797d, 0xa72c, 0x478d, 0x8b, 0xa2, 0xef, 0xc6, 0xb0, 0xef, 0xe8, 0x8e); + +#define INTERFACE ID3D12ShaderReflection +DECLARE_INTERFACE_(ID3D12ShaderReflection, IUnknown) +{ + /* IUnknown methods */ + STDMETHOD(QueryInterface)(THIS_ REFIID iid, void **out) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + /* ID3D12ShaderReflection methods */ + STDMETHOD(GetDesc)(THIS_ D3D12_SHADER_DESC *desc) PURE; + STDMETHOD_(struct ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByIndex)(THIS_ UINT index) PURE; + STDMETHOD_(struct ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByName)(THIS_ const char *name) PURE; + STDMETHOD(GetResourceBindingDesc)(THIS_ UINT index, D3D12_SHADER_INPUT_BIND_DESC *desc) PURE; + STDMETHOD(GetInputParameterDesc)(THIS_ UINT index, D3D12_SIGNATURE_PARAMETER_DESC *desc) PURE; + STDMETHOD(GetOutputParameterDesc)(THIS_ UINT index, D3D12_SIGNATURE_PARAMETER_DESC *desc) PURE; + STDMETHOD(GetPatchConstantParameterDesc)(THIS_ UINT index, D3D12_SIGNATURE_PARAMETER_DESC *desc) PURE; + STDMETHOD_(struct ID3D12ShaderReflectionVariable *, GetVariableByName)(THIS_ const char *name) PURE; + STDMETHOD(GetResourceBindingDescByName)(THIS_ const char *name, D3D12_SHADER_INPUT_BIND_DESC *desc) PURE; + STDMETHOD_(UINT, GetMovInstructionCount)(THIS) PURE; + STDMETHOD_(UINT, GetMovcInstructionCount)(THIS) PURE; + STDMETHOD_(UINT, GetConversionInstructionCount)(THIS) PURE; + STDMETHOD_(UINT, GetBitwiseInstructionCount)(THIS) PURE; + STDMETHOD_(D3D_PRIMITIVE, GetGSInputPrimitive)(THIS) PURE; + STDMETHOD_(BOOL, IsSampleFrequencyShader)(THIS) PURE; + STDMETHOD_(UINT, GetNumInterfaceSlots)(THIS) PURE; + STDMETHOD(GetMinFeatureLevel)(THIS_ enum D3D_FEATURE_LEVEL *level) PURE; + STDMETHOD_(UINT, GetThreadGroupSize)(THIS_ UINT *sizex, UINT *sizey, UINT *sizez) PURE; + STDMETHOD_(UINT64, GetRequiresFlags)(THIS) PURE; +}; +#undef INTERFACE + +DEFINE_GUID(IID_ID3D12FunctionParameterReflection, 0xec25f42d, 0x7006, 0x4f2b, 0xb3, 0x3e, 0x2, 0xcc, 0x33, 0x75, 0x73, 0x3f); + +#define INTERFACE ID3D12FunctionParameterReflection +DECLARE_INTERFACE(ID3D12FunctionParameterReflection) +{ + STDMETHOD(GetDesc)(THIS_ D3D12_PARAMETER_DESC *desc) PURE; +}; +#undef INTERFACE + +DEFINE_GUID(IID_ID3D12FunctionReflection, 0x1108795c, 0x2772, 0x4ba9, 0xb2, 0xa8, 0xd4, 0x64, 0xdc, 0x7e, 0x27, 0x99); + +#define INTERFACE ID3D12FunctionReflection +DECLARE_INTERFACE(ID3D12FunctionReflection) +{ + STDMETHOD(GetDesc)(THIS_ D3D12_FUNCTION_DESC *desc) PURE; + STDMETHOD_(struct ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByIndex)(THIS_ UINT index) PURE; + STDMETHOD_(struct ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByName)(THIS_ const char *name) PURE; + STDMETHOD(GetResourceBindingDesc)(THIS_ UINT index, D3D12_SHADER_INPUT_BIND_DESC *desc) PURE; + STDMETHOD_(struct ID3D12ShaderReflectionVariable *, GetVariableByName)(THIS_ const char *name) PURE; + STDMETHOD(GetResourceBindingDescByName)(THIS_ const char *name, D3D12_SHADER_INPUT_BIND_DESC *desc) PURE; + STDMETHOD_(struct ID3D12FunctionParameterReflection *, GetFunctionParameter)(THIS_ INT index) PURE; +}; +#undef INTERFACE + +DEFINE_GUID(IID_ID3D12LibraryReflection, 0x8e349d19, 0x54db, 0x4a56, 0x9d, 0xc9, 0x11, 0x9d, 0x87, 0xbd, 0xb8, 0x4); + +#define INTERFACE ID3D12LibraryReflection +DECLARE_INTERFACE_(ID3D12LibraryReflection, IUnknown) +{ + STDMETHOD(QueryInterface)(THIS_ REFIID iid, void **out) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3D12_LIBRARY_DESC *desc) PURE; + STDMETHOD_(struct ID3D12FunctionReflection *, GetFunctionByIndex)(THIS_ INT index) PURE; +}; +#undef INTERFACE + #endif
On Thu, 6 Aug 2020 at 19:36, Paul Gofman pgofman@codeweavers.com wrote:
Signed-off-by: Paul Gofman pgofman@codeweavers.com
include/d3d12shader.h | 111 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+)
It seems tempting to convert this to IDL. The main issue with that may be that we'd get C interfaces that aren't present in the SDK headers, but perhaps we don't care?
On Thu, 6 Aug 2020 at 19:36, Paul Gofman pgofman@codeweavers.com wrote:
+typedef enum _D3D_PARAMETER_FLAGS +{
- D3D_PF_NONE,
- D3D_PF_IN,
- D3D_PF_OUT,
- D3D_PF_FORCE_DWORD,
+} D3D_PARAMETER_FLAGS;
+typedef enum _D3D_INTERPOLATION_MODE {
Inconsistent style.