From 765a08c8468197476d3e5a8399130f77d6852976 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Tue, 7 Jul 2020 14:18:46 +0300 Subject: [PATCH] merge gfx updates from sm64-port --- Makefile | 5 +- include/dxsdk/d3d12shader.h | 459 ----- include/dxsdk/d3dcompiler.h | 586 ------ include/dxsdk/dxgi.h | 2958 ---------------------------- include/dxsdk/dxgi1_4.h | 1494 -------------- src/pc/gfx/gfx_cc.c | 41 + src/pc/gfx/gfx_cc.h | 32 + src/pc/gfx/gfx_direct3d11.cpp | 940 ++------- src/pc/gfx/gfx_direct3d11.h | 8 +- src/pc/gfx/gfx_direct3d12.cpp | 744 ++----- src/pc/gfx/gfx_direct3d12.h | 8 +- src/pc/gfx/gfx_direct3d12_guids.h | 62 + src/pc/gfx/gfx_direct3d_common.cpp | 208 +- src/pc/gfx/gfx_direct3d_common.h | 23 +- src/pc/gfx/gfx_dxgi.cpp | 641 ++++++ src/pc/gfx/gfx_dxgi.h | 16 + src/pc/gfx/gfx_opengl.c | 12 + src/pc/gfx/gfx_opengl_legacy.c | 15 + src/pc/gfx/gfx_pc.c | 31 +- src/pc/gfx/gfx_pc.h | 9 + src/pc/gfx/gfx_rendering_api.h | 5 +- src/pc/pc_main.c | 7 +- src/pc/pc_main.h | 8 + 23 files changed, 1405 insertions(+), 6907 deletions(-) delete mode 100644 include/dxsdk/d3d12shader.h delete mode 100644 include/dxsdk/d3dcompiler.h delete mode 100644 include/dxsdk/dxgi.h delete mode 100644 include/dxsdk/dxgi1_4.h create mode 100644 src/pc/gfx/gfx_cc.c create mode 100644 src/pc/gfx/gfx_direct3d12_guids.h create mode 100644 src/pc/gfx/gfx_dxgi.cpp create mode 100644 src/pc/gfx/gfx_dxgi.h diff --git a/Makefile b/Makefile index 09bbba36..b78192ca 100644 --- a/Makefile +++ b/Makefile @@ -487,10 +487,7 @@ SDL2_USED := 0 # for now, it's either SDL+GL or DXGI+DirectX, so choose based on WAPI ifeq ($(WINDOW_API),DXGI) DXBITS := `cat $(ENDIAN_BITWIDTH) | tr ' ' '\n' | tail -1` - ifeq ($(RENDER_API),D3D11) - BACKEND_LDFLAGS += -ld3d11 - else ifeq ($(RENDER_API),D3D12) - BACKEND_LDFLAGS += -ld3d12 + ifeq ($(RENDER_API),D3D12) BACKEND_CFLAGS += -Iinclude/dxsdk endif BACKEND_LDFLAGS += -ld3dcompiler -ldxgi -ldxguid diff --git a/include/dxsdk/d3d12shader.h b/include/dxsdk/d3d12shader.h deleted file mode 100644 index fbeb7633..00000000 --- a/include/dxsdk/d3d12shader.h +++ /dev/null @@ -1,459 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// File: D3D12Shader.h -// Content: D3D12 Shader Types and APIs -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef __D3D12SHADER_H__ -#define __D3D12SHADER_H__ - -#include "d3dcommon.h" - -typedef enum D3D12_SHADER_VERSION_TYPE -{ - D3D12_SHVER_PIXEL_SHADER = 0, - D3D12_SHVER_VERTEX_SHADER = 1, - D3D12_SHVER_GEOMETRY_SHADER = 2, - - // D3D11 Shaders - D3D12_SHVER_HULL_SHADER = 3, - D3D12_SHVER_DOMAIN_SHADER = 4, - D3D12_SHVER_COMPUTE_SHADER = 5, - - D3D12_SHVER_RESERVED0 = 0xFFF0, -} D3D12_SHADER_VERSION_TYPE; - -#define D3D12_SHVER_GET_TYPE(_Version) \ - (((_Version) >> 16) & 0xffff) -#define D3D12_SHVER_GET_MAJOR(_Version) \ - (((_Version) >> 4) & 0xf) -#define D3D12_SHVER_GET_MINOR(_Version) \ - (((_Version) >> 0) & 0xf) - -// Slot ID for library function return -#define D3D_RETURN_PARAMETER_INDEX (-1) - -typedef D3D_RESOURCE_RETURN_TYPE D3D12_RESOURCE_RETURN_TYPE; - -typedef D3D_CBUFFER_TYPE D3D12_CBUFFER_TYPE; - - -typedef struct _D3D12_SIGNATURE_PARAMETER_DESC -{ - LPCSTR SemanticName; // Name of the semantic - UINT SemanticIndex; // Index of the semantic - UINT Register; // Number of member variables - D3D_NAME SystemValueType;// A predefined system value, or D3D_NAME_UNDEFINED if not applicable - D3D_REGISTER_COMPONENT_TYPE ComponentType; // Scalar type (e.g. uint, float, etc.) - BYTE Mask; // Mask to indicate which components of the register - // are used (combination of D3D10_COMPONENT_MASK values) - BYTE ReadWriteMask; // Mask to indicate whether a given component is - // never written (if this is an output signature) or - // always read (if this is an input signature). - // (combination of D3D_MASK_* values) - UINT Stream; // Stream index - D3D_MIN_PRECISION MinPrecision; // Minimum desired interpolation precision -} D3D12_SIGNATURE_PARAMETER_DESC; - -typedef struct _D3D12_SHADER_BUFFER_DESC -{ - LPCSTR Name; // Name of the constant buffer - D3D_CBUFFER_TYPE Type; // Indicates type of buffer content - UINT Variables; // Number of member variables - UINT Size; // Size of CB (in bytes) - UINT uFlags; // Buffer description flags -} D3D12_SHADER_BUFFER_DESC; - -typedef struct _D3D12_SHADER_VARIABLE_DESC -{ - LPCSTR Name; // Name of the variable - UINT StartOffset; // Offset in constant buffer's backing store - UINT Size; // Size of variable (in bytes) - UINT uFlags; // Variable flags - LPVOID DefaultValue; // Raw pointer to default value - UINT StartTexture; // First texture index (or -1 if no textures used) - UINT TextureSize; // Number of texture slots possibly used. - UINT StartSampler; // First sampler index (or -1 if no textures used) - UINT SamplerSize; // Number of sampler slots possibly used. -} D3D12_SHADER_VARIABLE_DESC; - -typedef struct _D3D12_SHADER_TYPE_DESC -{ - D3D_SHADER_VARIABLE_CLASS Class; // Variable class (e.g. object, matrix, etc.) - D3D_SHADER_VARIABLE_TYPE Type; // Variable type (e.g. float, sampler, etc.) - UINT Rows; // Number of rows (for matrices, 1 for other numeric, 0 if not applicable) - UINT Columns; // Number of columns (for vectors & matrices, 1 for other numeric, 0 if not applicable) - UINT Elements; // Number of elements (0 if not an array) - UINT Members; // Number of members (0 if not a structure) - UINT Offset; // Offset from the start of structure (0 if not a structure member) - LPCSTR Name; // Name of type, can be NULL -} D3D12_SHADER_TYPE_DESC; - -typedef D3D_TESSELLATOR_DOMAIN D3D12_TESSELLATOR_DOMAIN; - -typedef D3D_TESSELLATOR_PARTITIONING D3D12_TESSELLATOR_PARTITIONING; - -typedef D3D_TESSELLATOR_OUTPUT_PRIMITIVE D3D12_TESSELLATOR_OUTPUT_PRIMITIVE; - -typedef struct _D3D12_SHADER_DESC -{ - UINT Version; // Shader version - LPCSTR Creator; // Creator string - UINT Flags; // Shader compilation/parse flags - - UINT ConstantBuffers; // Number of constant buffers - UINT BoundResources; // Number of bound resources - UINT InputParameters; // Number of parameters in the input signature - UINT OutputParameters; // Number of parameters in the output signature - - UINT InstructionCount; // Number of emitted instructions - UINT TempRegisterCount; // Number of temporary registers used - UINT TempArrayCount; // Number of temporary arrays used - UINT DefCount; // Number of constant defines - UINT DclCount; // Number of declarations (input + output) - UINT TextureNormalInstructions; // Number of non-categorized texture instructions - UINT TextureLoadInstructions; // Number of texture load instructions - UINT TextureCompInstructions; // Number of texture comparison instructions - UINT TextureBiasInstructions; // Number of texture bias instructions - UINT TextureGradientInstructions; // Number of texture gradient instructions - UINT FloatInstructionCount; // Number of floating point arithmetic instructions used - UINT IntInstructionCount; // Number of signed integer arithmetic instructions used - UINT UintInstructionCount; // Number of unsigned integer arithmetic instructions used - UINT StaticFlowControlCount; // Number of static flow control instructions used - UINT DynamicFlowControlCount; // Number of dynamic flow control instructions used - UINT MacroInstructionCount; // Number of macro instructions used - UINT ArrayInstructionCount; // Number of array instructions used - UINT CutInstructionCount; // Number of cut instructions used - UINT EmitInstructionCount; // Number of emit instructions used - D3D_PRIMITIVE_TOPOLOGY GSOutputTopology; // Geometry shader output topology - UINT GSMaxOutputVertexCount; // Geometry shader maximum output vertex count - D3D_PRIMITIVE InputPrimitive; // GS/HS input primitive - UINT PatchConstantParameters; // Number of parameters in the patch constant signature - UINT cGSInstanceCount; // Number of Geometry shader instances - UINT cControlPoints; // Number of control points in the HS->DS stage - D3D_TESSELLATOR_OUTPUT_PRIMITIVE HSOutputPrimitive; // Primitive output by the tessellator - D3D_TESSELLATOR_PARTITIONING HSPartitioning; // Partitioning mode of the tessellator - D3D_TESSELLATOR_DOMAIN TessellatorDomain; // Domain of the tessellator (quad, tri, isoline) - // instruction counts - UINT cBarrierInstructions; // Number of barrier instructions in a compute shader - UINT cInterlockedInstructions; // Number of interlocked instructions - UINT cTextureStoreInstructions; // Number of texture writes -} D3D12_SHADER_DESC; - -typedef struct _D3D12_SHADER_INPUT_BIND_DESC -{ - LPCSTR Name; // Name of the resource - D3D_SHADER_INPUT_TYPE Type; // Type of resource (e.g. texture, cbuffer, etc.) - UINT BindPoint; // Starting bind point - UINT BindCount; // Number of contiguous bind points (for arrays) - - UINT uFlags; // Input binding flags - D3D_RESOURCE_RETURN_TYPE ReturnType; // Return type (if texture) - D3D_SRV_DIMENSION Dimension; // Dimension (if texture) - UINT NumSamples; // Number of samples (0 if not MS texture) - UINT Space; // Register space - UINT uID; // Range ID in the bytecode -} D3D12_SHADER_INPUT_BIND_DESC; - -#define D3D_SHADER_REQUIRES_DOUBLES 0x00000001 -#define D3D_SHADER_REQUIRES_EARLY_DEPTH_STENCIL 0x00000002 -#define D3D_SHADER_REQUIRES_UAVS_AT_EVERY_STAGE 0x00000004 -#define D3D_SHADER_REQUIRES_64_UAVS 0x00000008 -#define D3D_SHADER_REQUIRES_MINIMUM_PRECISION 0x00000010 -#define D3D_SHADER_REQUIRES_11_1_DOUBLE_EXTENSIONS 0x00000020 -#define D3D_SHADER_REQUIRES_11_1_SHADER_EXTENSIONS 0x00000040 -#define D3D_SHADER_REQUIRES_LEVEL_9_COMPARISON_FILTERING 0x00000080 -#define D3D_SHADER_REQUIRES_TILED_RESOURCES 0x00000100 -#define D3D_SHADER_REQUIRES_STENCIL_REF 0x00000200 -#define D3D_SHADER_REQUIRES_INNER_COVERAGE 0x00000400 -#define D3D_SHADER_REQUIRES_TYPED_UAV_LOAD_ADDITIONAL_FORMATS 0x00000800 -#define D3D_SHADER_REQUIRES_ROVS 0x00001000 -#define D3D_SHADER_REQUIRES_VIEWPORT_AND_RT_ARRAY_INDEX_FROM_ANY_SHADER_FEEDING_RASTERIZER 0x00002000 - - -typedef struct _D3D12_LIBRARY_DESC -{ - LPCSTR Creator; // The name of the originator of the library. - UINT Flags; // Compilation flags. - UINT FunctionCount; // Number of functions exported from the library. -} D3D12_LIBRARY_DESC; - -typedef struct _D3D12_FUNCTION_DESC -{ - UINT Version; // Shader version - LPCSTR Creator; // Creator string - UINT Flags; // Shader compilation/parse flags - - UINT ConstantBuffers; // Number of constant buffers - UINT BoundResources; // Number of bound resources - - UINT InstructionCount; // Number of emitted instructions - UINT TempRegisterCount; // Number of temporary registers used - UINT TempArrayCount; // Number of temporary arrays used - UINT DefCount; // Number of constant defines - UINT DclCount; // Number of declarations (input + output) - UINT TextureNormalInstructions; // Number of non-categorized texture instructions - UINT TextureLoadInstructions; // Number of texture load instructions - UINT TextureCompInstructions; // Number of texture comparison instructions - UINT TextureBiasInstructions; // Number of texture bias instructions - UINT TextureGradientInstructions; // Number of texture gradient instructions - UINT FloatInstructionCount; // Number of floating point arithmetic instructions used - UINT IntInstructionCount; // Number of signed integer arithmetic instructions used - UINT UintInstructionCount; // Number of unsigned integer arithmetic instructions used - UINT StaticFlowControlCount; // Number of static flow control instructions used - UINT DynamicFlowControlCount; // Number of dynamic flow control instructions used - UINT MacroInstructionCount; // Number of macro instructions used - UINT ArrayInstructionCount; // Number of array instructions used - UINT MovInstructionCount; // Number of mov instructions used - UINT MovcInstructionCount; // Number of movc instructions used - UINT ConversionInstructionCount; // Number of type conversion instructions used - UINT BitwiseInstructionCount; // Number of bitwise arithmetic instructions used - D3D_FEATURE_LEVEL MinFeatureLevel; // Min target of the function byte code - UINT64 RequiredFeatureFlags; // Required feature flags - - LPCSTR Name; // Function name - INT FunctionParameterCount; // Number of logical parameters in the function signature (not including return) - BOOL HasReturn; // TRUE, if function returns a value, false - it is a subroutine - BOOL Has10Level9VertexShader; // TRUE, if there is a 10L9 VS blob - BOOL Has10Level9PixelShader; // TRUE, if there is a 10L9 PS blob -} D3D12_FUNCTION_DESC; - -typedef struct _D3D12_PARAMETER_DESC -{ - LPCSTR Name; // Parameter name. - LPCSTR SemanticName; // Parameter semantic name (+index). - D3D_SHADER_VARIABLE_TYPE Type; // Element type. - D3D_SHADER_VARIABLE_CLASS Class; // Scalar/Vector/Matrix. - UINT Rows; // Rows are for matrix parameters. - UINT Columns; // Components or Columns in matrix. - D3D_INTERPOLATION_MODE InterpolationMode; // Interpolation mode. - D3D_PARAMETER_FLAGS Flags; // Parameter modifiers. - - UINT FirstInRegister; // The first input register for this parameter. - UINT FirstInComponent; // The first input register component for this parameter. - UINT FirstOutRegister; // The first output register for this parameter. - UINT FirstOutComponent; // The first output register component for this parameter. -} D3D12_PARAMETER_DESC; - - -////////////////////////////////////////////////////////////////////////////// -// Interfaces //////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3D12ShaderReflectionType ID3D12ShaderReflectionType; -typedef interface ID3D12ShaderReflectionType *LPD3D12SHADERREFLECTIONTYPE; - -typedef interface ID3D12ShaderReflectionVariable ID3D12ShaderReflectionVariable; -typedef interface ID3D12ShaderReflectionVariable *LPD3D12SHADERREFLECTIONVARIABLE; - -typedef interface ID3D12ShaderReflectionConstantBuffer ID3D12ShaderReflectionConstantBuffer; -typedef interface ID3D12ShaderReflectionConstantBuffer *LPD3D12SHADERREFLECTIONCONSTANTBUFFER; - -typedef interface ID3D12ShaderReflection ID3D12ShaderReflection; -typedef interface ID3D12ShaderReflection *LPD3D12SHADERREFLECTION; - -typedef interface ID3D12LibraryReflection ID3D12LibraryReflection; -typedef interface ID3D12LibraryReflection *LPD3D12LIBRARYREFLECTION; - -typedef interface ID3D12FunctionReflection ID3D12FunctionReflection; -typedef interface ID3D12FunctionReflection *LPD3D12FUNCTIONREFLECTION; - -typedef interface ID3D12FunctionParameterReflection ID3D12FunctionParameterReflection; -typedef interface ID3D12FunctionParameterReflection *LPD3D12FUNCTIONPARAMETERREFLECTION; - - -// {E913C351-783D-48CA-A1D1-4F306284AD56} -interface DECLSPEC_UUID("E913C351-783D-48CA-A1D1-4F306284AD56") ID3D12ShaderReflectionType; -DEFINE_GUID(IID_ID3D12ShaderReflectionType, -0xe913c351, 0x783d, 0x48ca, 0xa1, 0xd1, 0x4f, 0x30, 0x62, 0x84, 0xad, 0x56); - -#undef INTERFACE -#define INTERFACE ID3D12ShaderReflectionType - -DECLARE_INTERFACE(ID3D12ShaderReflectionType) -{ - STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_SHADER_TYPE_DESC *pDesc) PURE; - - STDMETHOD_(ID3D12ShaderReflectionType*, GetMemberTypeByIndex)(THIS_ _In_ UINT Index) PURE; - STDMETHOD_(ID3D12ShaderReflectionType*, GetMemberTypeByName)(THIS_ _In_ LPCSTR Name) PURE; - STDMETHOD_(LPCSTR, GetMemberTypeName)(THIS_ _In_ UINT Index) PURE; - - STDMETHOD(IsEqual)(THIS_ _In_ ID3D12ShaderReflectionType* pType) PURE; - STDMETHOD_(ID3D12ShaderReflectionType*, GetSubType)(THIS) PURE; - STDMETHOD_(ID3D12ShaderReflectionType*, GetBaseClass)(THIS) PURE; - STDMETHOD_(UINT, GetNumInterfaces)(THIS) PURE; - STDMETHOD_(ID3D12ShaderReflectionType*, GetInterfaceByIndex)(THIS_ _In_ UINT uIndex) PURE; - STDMETHOD(IsOfType)(THIS_ _In_ ID3D12ShaderReflectionType* pType) PURE; - STDMETHOD(ImplementsInterface)(THIS_ _In_ ID3D12ShaderReflectionType* pBase) PURE; -}; - -// {8337A8A6-A216-444A-B2F4-314733A73AEA} -interface DECLSPEC_UUID("8337A8A6-A216-444A-B2F4-314733A73AEA") ID3D12ShaderReflectionVariable; -DEFINE_GUID(IID_ID3D12ShaderReflectionVariable, -0x8337a8a6, 0xa216, 0x444a, 0xb2, 0xf4, 0x31, 0x47, 0x33, 0xa7, 0x3a, 0xea); - -#undef INTERFACE -#define INTERFACE ID3D12ShaderReflectionVariable - -DECLARE_INTERFACE(ID3D12ShaderReflectionVariable) -{ - STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_SHADER_VARIABLE_DESC *pDesc) PURE; - - STDMETHOD_(ID3D12ShaderReflectionType*, GetType)(THIS) PURE; - STDMETHOD_(ID3D12ShaderReflectionConstantBuffer*, GetBuffer)(THIS) PURE; - - STDMETHOD_(UINT, GetInterfaceSlot)(THIS_ _In_ UINT uArrayIndex) PURE; -}; - -// {C59598B4-48B3-4869-B9B1-B1618B14A8B7} -interface DECLSPEC_UUID("C59598B4-48B3-4869-B9B1-B1618B14A8B7") ID3D12ShaderReflectionConstantBuffer; -DEFINE_GUID(IID_ID3D12ShaderReflectionConstantBuffer, -0xc59598b4, 0x48b3, 0x4869, 0xb9, 0xb1, 0xb1, 0x61, 0x8b, 0x14, 0xa8, 0xb7); - -#undef INTERFACE -#define INTERFACE ID3D12ShaderReflectionConstantBuffer - -DECLARE_INTERFACE(ID3D12ShaderReflectionConstantBuffer) -{ - STDMETHOD(GetDesc)(THIS_ D3D12_SHADER_BUFFER_DESC *pDesc) PURE; - - STDMETHOD_(ID3D12ShaderReflectionVariable*, GetVariableByIndex)(THIS_ _In_ UINT Index) PURE; - STDMETHOD_(ID3D12ShaderReflectionVariable*, GetVariableByName)(THIS_ _In_ LPCSTR Name) PURE; -}; - -// The ID3D12ShaderReflection IID may change from SDK version to SDK version -// if the reflection API changes. This prevents new code with the new API -// from working with an old binary. Recompiling with the new header -// will pick up the new IID. - -// {5A58797D-A72C-478D-8BA2-EFC6B0EFE88E} -interface DECLSPEC_UUID("5A58797D-A72C-478D-8BA2-EFC6B0EFE88E") ID3D12ShaderReflection; -DEFINE_GUID(IID_ID3D12ShaderReflection, -0x5a58797d, 0xa72c, 0x478d, 0x8b, 0xa2, 0xef, 0xc6, 0xb0, 0xef, 0xe8, 0x8e); - -#undef INTERFACE -#define INTERFACE ID3D12ShaderReflection - -DECLARE_INTERFACE_(ID3D12ShaderReflection, IUnknown) -{ - STDMETHOD(QueryInterface)(THIS_ _In_ REFIID iid, - _Out_ LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_SHADER_DESC *pDesc) PURE; - - STDMETHOD_(ID3D12ShaderReflectionConstantBuffer*, GetConstantBufferByIndex)(THIS_ _In_ UINT Index) PURE; - STDMETHOD_(ID3D12ShaderReflectionConstantBuffer*, GetConstantBufferByName)(THIS_ _In_ LPCSTR Name) PURE; - - STDMETHOD(GetResourceBindingDesc)(THIS_ _In_ UINT ResourceIndex, - _Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc) PURE; - - STDMETHOD(GetInputParameterDesc)(THIS_ _In_ UINT ParameterIndex, - _Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) PURE; - STDMETHOD(GetOutputParameterDesc)(THIS_ _In_ UINT ParameterIndex, - _Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) PURE; - STDMETHOD(GetPatchConstantParameterDesc)(THIS_ _In_ UINT ParameterIndex, - _Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) PURE; - - STDMETHOD_(ID3D12ShaderReflectionVariable*, GetVariableByName)(THIS_ _In_ LPCSTR Name) PURE; - - STDMETHOD(GetResourceBindingDescByName)(THIS_ _In_ LPCSTR Name, - _Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc) 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_ _Out_ enum D3D_FEATURE_LEVEL* pLevel) PURE; - - STDMETHOD_(UINT, GetThreadGroupSize)(THIS_ - _Out_opt_ UINT* pSizeX, - _Out_opt_ UINT* pSizeY, - _Out_opt_ UINT* pSizeZ) PURE; - - STDMETHOD_(UINT64, GetRequiresFlags)(THIS) PURE; -}; - -// {8E349D19-54DB-4A56-9DC9-119D87BDB804} -interface DECLSPEC_UUID("8E349D19-54DB-4A56-9DC9-119D87BDB804") ID3D12LibraryReflection; -DEFINE_GUID(IID_ID3D12LibraryReflection, -0x8e349d19, 0x54db, 0x4a56, 0x9d, 0xc9, 0x11, 0x9d, 0x87, 0xbd, 0xb8, 0x4); - -#undef INTERFACE -#define INTERFACE ID3D12LibraryReflection - -DECLARE_INTERFACE_(ID3D12LibraryReflection, IUnknown) -{ - STDMETHOD(QueryInterface)(THIS_ _In_ REFIID iid, _Out_ LPVOID * ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_LIBRARY_DESC * pDesc) PURE; - - STDMETHOD_(ID3D12FunctionReflection *, GetFunctionByIndex)(THIS_ _In_ INT FunctionIndex) PURE; -}; - -// {1108795C-2772-4BA9-B2A8-D464DC7E2799} -interface DECLSPEC_UUID("1108795C-2772-4BA9-B2A8-D464DC7E2799") ID3D12FunctionReflection; -DEFINE_GUID(IID_ID3D12FunctionReflection, -0x1108795c, 0x2772, 0x4ba9, 0xb2, 0xa8, 0xd4, 0x64, 0xdc, 0x7e, 0x27, 0x99); - -#undef INTERFACE -#define INTERFACE ID3D12FunctionReflection - -DECLARE_INTERFACE(ID3D12FunctionReflection) -{ - STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_FUNCTION_DESC * pDesc) PURE; - - STDMETHOD_(ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByIndex)(THIS_ _In_ UINT BufferIndex) PURE; - STDMETHOD_(ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByName)(THIS_ _In_ LPCSTR Name) PURE; - - STDMETHOD(GetResourceBindingDesc)(THIS_ _In_ UINT ResourceIndex, - _Out_ D3D12_SHADER_INPUT_BIND_DESC * pDesc) PURE; - - STDMETHOD_(ID3D12ShaderReflectionVariable *, GetVariableByName)(THIS_ _In_ LPCSTR Name) PURE; - - STDMETHOD(GetResourceBindingDescByName)(THIS_ _In_ LPCSTR Name, - _Out_ D3D12_SHADER_INPUT_BIND_DESC * pDesc) PURE; - - // Use D3D_RETURN_PARAMETER_INDEX to get description of the return value. - STDMETHOD_(ID3D12FunctionParameterReflection *, GetFunctionParameter)(THIS_ _In_ INT ParameterIndex) PURE; -}; - -// {EC25F42D-7006-4F2B-B33E-02CC3375733F} -interface DECLSPEC_UUID("EC25F42D-7006-4F2B-B33E-02CC3375733F") ID3D12FunctionParameterReflection; -DEFINE_GUID(IID_ID3D12FunctionParameterReflection, -0xec25f42d, 0x7006, 0x4f2b, 0xb3, 0x3e, 0x2, 0xcc, 0x33, 0x75, 0x73, 0x3f); - -#undef INTERFACE -#define INTERFACE ID3D12FunctionParameterReflection - -DECLARE_INTERFACE(ID3D12FunctionParameterReflection) -{ - STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_PARAMETER_DESC * pDesc) PURE; -}; - - -////////////////////////////////////////////////////////////////////////////// -// APIs ////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3D12SHADER_H__ - diff --git a/include/dxsdk/d3dcompiler.h b/include/dxsdk/d3dcompiler.h deleted file mode 100644 index 58767216..00000000 --- a/include/dxsdk/d3dcompiler.h +++ /dev/null @@ -1,586 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// File: D3DCompiler.h -// Content: D3D Compilation Types and APIs -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef __D3DCOMPILER_H__ -#define __D3DCOMPILER_H__ - -#include - -// Current name of the DLL shipped in the same SDK as this header. - - - -#define D3DCOMPILER_DLL_W L"d3dcompiler_47.dll" -#define D3DCOMPILER_DLL_A "d3dcompiler_47.dll" - -// Current HLSL compiler version. - -#define D3D_COMPILER_VERSION 47 - -#ifdef UNICODE - #define D3DCOMPILER_DLL D3DCOMPILER_DLL_W -#else - #define D3DCOMPILER_DLL D3DCOMPILER_DLL_A -#endif - -#include "d3d11shader.h" -#include "d3d12shader.h" - -////////////////////////////////////////////////////////////////////////////// -// APIs ////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - -#pragma region Application Family -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_GAMES) - -//---------------------------------------------------------------------------- -// D3DReadFileToBlob: -// ----------------- -// Simple helper routine to read a file on disk into memory -// for passing to other routines in this API. -//---------------------------------------------------------------------------- - -HRESULT WINAPI -D3DReadFileToBlob(_In_ LPCWSTR pFileName, - _Out_ ID3DBlob** ppContents); - -//---------------------------------------------------------------------------- -// D3DWriteBlobToFile: -// ------------------ -// Simple helper routine to write a memory blob to a file on disk. -//---------------------------------------------------------------------------- - -HRESULT WINAPI -D3DWriteBlobToFile(_In_ ID3DBlob* pBlob, - _In_ LPCWSTR pFileName, - _In_ BOOL bOverwrite); - -//---------------------------------------------------------------------------- -// D3DCOMPILE flags: -// ----------------- -// D3DCOMPILE_DEBUG -// Insert debug file/line/type/symbol information. -// -// D3DCOMPILE_SKIP_VALIDATION -// Do not validate the generated code against known capabilities and -// constraints. This option is only recommended when compiling shaders -// you KNOW will work. (ie. have compiled before without this option.) -// Shaders are always validated by D3D before they are set to the device. -// -// D3DCOMPILE_SKIP_OPTIMIZATION -// Instructs the compiler to skip optimization steps during code generation. -// Unless you are trying to isolate a problem in your code using this option -// is not recommended. -// -// D3DCOMPILE_PACK_MATRIX_ROW_MAJOR -// Unless explicitly specified, matrices will be packed in row-major order -// on input and output from the shader. -// -// D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR -// Unless explicitly specified, matrices will be packed in column-major -// order on input and output from the shader. This is generally more -// efficient, since it allows vector-matrix multiplication to be performed -// using a series of dot-products. -// -// D3DCOMPILE_PARTIAL_PRECISION -// Force all computations in resulting shader to occur at partial precision. -// This may result in faster evaluation of shaders on some hardware. -// -// D3DCOMPILE_FORCE_VS_SOFTWARE_NO_OPT -// Force compiler to compile against the next highest available software -// target for vertex shaders. This flag also turns optimizations off, -// and debugging on. -// -// D3DCOMPILE_FORCE_PS_SOFTWARE_NO_OPT -// Force compiler to compile against the next highest available software -// target for pixel shaders. This flag also turns optimizations off, -// and debugging on. -// -// D3DCOMPILE_NO_PRESHADER -// Disables Preshaders. Using this flag will cause the compiler to not -// pull out static expression for evaluation on the host cpu -// -// D3DCOMPILE_AVOID_FLOW_CONTROL -// Hint compiler to avoid flow-control constructs where possible. -// -// D3DCOMPILE_PREFER_FLOW_CONTROL -// Hint compiler to prefer flow-control constructs where possible. -// -// D3DCOMPILE_ENABLE_STRICTNESS -// By default, the HLSL/Effect compilers are not strict on deprecated syntax. -// Specifying this flag enables the strict mode. Deprecated syntax may be -// removed in a future release, and enabling syntax is a good way to make -// sure your shaders comply to the latest spec. -// -// D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY -// This enables older shaders to compile to 4_0 targets. -// -// D3DCOMPILE_DEBUG_NAME_FOR_SOURCE -// This enables a debug name to be generated based on source information. -// It requires D3DCOMPILE_DEBUG to be set, and is exclusive with -// D3DCOMPILE_DEBUG_NAME_FOR_BINARY. -// -// D3DCOMPILE_DEBUG_NAME_FOR_BINARY -// This enables a debug name to be generated based on compiled information. -// It requires D3DCOMPILE_DEBUG to be set, and is exclusive with -// D3DCOMPILE_DEBUG_NAME_FOR_SOURCE. -// -//---------------------------------------------------------------------------- - -#define D3DCOMPILE_DEBUG (1 << 0) -#define D3DCOMPILE_SKIP_VALIDATION (1 << 1) -#define D3DCOMPILE_SKIP_OPTIMIZATION (1 << 2) -#define D3DCOMPILE_PACK_MATRIX_ROW_MAJOR (1 << 3) -#define D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR (1 << 4) -#define D3DCOMPILE_PARTIAL_PRECISION (1 << 5) -#define D3DCOMPILE_FORCE_VS_SOFTWARE_NO_OPT (1 << 6) -#define D3DCOMPILE_FORCE_PS_SOFTWARE_NO_OPT (1 << 7) -#define D3DCOMPILE_NO_PRESHADER (1 << 8) -#define D3DCOMPILE_AVOID_FLOW_CONTROL (1 << 9) -#define D3DCOMPILE_PREFER_FLOW_CONTROL (1 << 10) -#define D3DCOMPILE_ENABLE_STRICTNESS (1 << 11) -#define D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY (1 << 12) -#define D3DCOMPILE_IEEE_STRICTNESS (1 << 13) -#define D3DCOMPILE_OPTIMIZATION_LEVEL0 (1 << 14) -#define D3DCOMPILE_OPTIMIZATION_LEVEL1 0 -#define D3DCOMPILE_OPTIMIZATION_LEVEL2 ((1 << 14) | (1 << 15)) -#define D3DCOMPILE_OPTIMIZATION_LEVEL3 (1 << 15) -#define D3DCOMPILE_RESERVED16 (1 << 16) -#define D3DCOMPILE_RESERVED17 (1 << 17) -#define D3DCOMPILE_WARNINGS_ARE_ERRORS (1 << 18) -#define D3DCOMPILE_RESOURCES_MAY_ALIAS (1 << 19) -#define D3DCOMPILE_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES (1 << 20) -#define D3DCOMPILE_ALL_RESOURCES_BOUND (1 << 21) -#define D3DCOMPILE_DEBUG_NAME_FOR_SOURCE (1 << 22) -#define D3DCOMPILE_DEBUG_NAME_FOR_BINARY (1 << 23) - -//---------------------------------------------------------------------------- -// D3DCOMPILE_EFFECT flags: -// ------------------------------------- -// These flags are passed in when creating an effect, and affect -// either compilation behavior or runtime effect behavior -// -// D3DCOMPILE_EFFECT_CHILD_EFFECT -// Compile this .fx file to a child effect. Child effects have no -// initializers for any shared values as these are initialied in the -// master effect (pool). -// -// D3DCOMPILE_EFFECT_ALLOW_SLOW_OPS -// By default, performance mode is enabled. Performance mode -// disallows mutable state objects by preventing non-literal -// expressions from appearing in state object definitions. -// Specifying this flag will disable the mode and allow for mutable -// state objects. -// -//---------------------------------------------------------------------------- - -#define D3DCOMPILE_EFFECT_CHILD_EFFECT (1 << 0) -#define D3DCOMPILE_EFFECT_ALLOW_SLOW_OPS (1 << 1) - -//---------------------------------------------------------------------------- -// D3DCOMPILE Flags2: -// ----------------- -// Root signature flags. (passed in Flags2) -#define D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_LATEST 0 -#define D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_1_0 (1 << 4) -#define D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_1_1 (1 << 5) - -//---------------------------------------------------------------------------- -// D3DCompile: -// ---------- -// Compile source text into bytecode appropriate for the given target. -//---------------------------------------------------------------------------- - -// D3D_COMPILE_STANDARD_FILE_INCLUDE can be passed for pInclude in any -// API and indicates that a simple default include handler should be -// used. The include handler will include files relative to the -// current directory and files relative to the directory of the initial source -// file. When used with APIs like D3DCompile pSourceName must be a -// file name and the initial relative directory will be derived from it. -#define D3D_COMPILE_STANDARD_FILE_INCLUDE ((ID3DInclude*)(UINT_PTR)1) - -HRESULT WINAPI -D3DCompile(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData, - _In_ SIZE_T SrcDataSize, - _In_opt_ LPCSTR pSourceName, - _In_reads_opt_(_Inexpressible_(pDefines->Name != NULL)) CONST D3D_SHADER_MACRO* pDefines, - _In_opt_ ID3DInclude* pInclude, - _In_opt_ LPCSTR pEntrypoint, - _In_ LPCSTR pTarget, - _In_ UINT Flags1, - _In_ UINT Flags2, - _Out_ ID3DBlob** ppCode, - _Always_(_Outptr_opt_result_maybenull_) ID3DBlob** ppErrorMsgs); - -typedef HRESULT (WINAPI *pD3DCompile) - (LPCVOID pSrcData, - SIZE_T SrcDataSize, - LPCSTR pFileName, - CONST D3D_SHADER_MACRO* pDefines, - ID3DInclude* pInclude, - LPCSTR pEntrypoint, - LPCSTR pTarget, - UINT Flags1, - UINT Flags2, - ID3DBlob** ppCode, - ID3DBlob** ppErrorMsgs); - -#define D3DCOMPILE_SECDATA_MERGE_UAV_SLOTS 0x00000001 -#define D3DCOMPILE_SECDATA_PRESERVE_TEMPLATE_SLOTS 0x00000002 -#define D3DCOMPILE_SECDATA_REQUIRE_TEMPLATE_MATCH 0x00000004 - -HRESULT WINAPI -D3DCompile2(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData, - _In_ SIZE_T SrcDataSize, - _In_opt_ LPCSTR pSourceName, - _In_reads_opt_(_Inexpressible_(pDefines->Name != NULL)) CONST D3D_SHADER_MACRO* pDefines, - _In_opt_ ID3DInclude* pInclude, - _In_ LPCSTR pEntrypoint, - _In_ LPCSTR pTarget, - _In_ UINT Flags1, - _In_ UINT Flags2, - _In_ UINT SecondaryDataFlags, - _In_reads_bytes_opt_(SecondaryDataSize) LPCVOID pSecondaryData, - _In_ SIZE_T SecondaryDataSize, - _Out_ ID3DBlob** ppCode, - _Always_(_Outptr_opt_result_maybenull_) ID3DBlob** ppErrorMsgs); - -HRESULT WINAPI -D3DCompileFromFile(_In_ LPCWSTR pFileName, - _In_reads_opt_(_Inexpressible_(pDefines->Name != NULL)) CONST D3D_SHADER_MACRO* pDefines, - _In_opt_ ID3DInclude* pInclude, - _In_ LPCSTR pEntrypoint, - _In_ LPCSTR pTarget, - _In_ UINT Flags1, - _In_ UINT Flags2, - _Out_ ID3DBlob** ppCode, - _Always_(_Outptr_opt_result_maybenull_) ID3DBlob** ppErrorMsgs); - -//---------------------------------------------------------------------------- -// D3DPreprocess: -// ------------- -// Process source text with the compiler's preprocessor and return -// the resulting text. -//---------------------------------------------------------------------------- - -HRESULT WINAPI -D3DPreprocess(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData, - _In_ SIZE_T SrcDataSize, - _In_opt_ LPCSTR pSourceName, - _In_opt_ CONST D3D_SHADER_MACRO* pDefines, - _In_opt_ ID3DInclude* pInclude, - _Out_ ID3DBlob** ppCodeText, - _Always_(_Outptr_opt_result_maybenull_) ID3DBlob** ppErrorMsgs); - -typedef HRESULT (WINAPI *pD3DPreprocess) - (LPCVOID pSrcData, - SIZE_T SrcDataSize, - LPCSTR pFileName, - CONST D3D_SHADER_MACRO* pDefines, - ID3DInclude* pInclude, - ID3DBlob** ppCodeText, - ID3DBlob** ppErrorMsgs); - -//---------------------------------------------------------------------------- -// D3DGetDebugInfo: -// ----------------------- -// Gets shader debug info. Debug info is generated by D3DCompile and is -// embedded in the body of the shader. -//---------------------------------------------------------------------------- - -HRESULT WINAPI -D3DGetDebugInfo(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData, - _In_ SIZE_T SrcDataSize, - _Out_ ID3DBlob** ppDebugInfo); - -//---------------------------------------------------------------------------- -// D3DReflect: -// ---------- -// Shader code contains metadata that can be inspected via the -// reflection APIs. -//---------------------------------------------------------------------------- - -HRESULT WINAPI -D3DReflect(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData, - _In_ SIZE_T SrcDataSize, - _In_ REFIID pInterface, - _Out_ void** ppReflector); - -//---------------------------------------------------------------------------- -// D3DReflectLibrary: -// ---------- -// Library code contains metadata that can be inspected via the library -// reflection APIs. -//---------------------------------------------------------------------------- - -HRESULT WINAPI -D3DReflectLibrary(__in_bcount(SrcDataSize) LPCVOID pSrcData, - __in SIZE_T SrcDataSize, - __in REFIID riid, - __out LPVOID * ppReflector); - -//---------------------------------------------------------------------------- -// D3DDisassemble: -// ---------------------- -// Takes a binary shader and returns a buffer containing text assembly. -//---------------------------------------------------------------------------- - -#define D3D_DISASM_ENABLE_COLOR_CODE 0x00000001 -#define D3D_DISASM_ENABLE_DEFAULT_VALUE_PRINTS 0x00000002 -#define D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING 0x00000004 -#define D3D_DISASM_ENABLE_INSTRUCTION_CYCLE 0x00000008 -#define D3D_DISASM_DISABLE_DEBUG_INFO 0x00000010 -#define D3D_DISASM_ENABLE_INSTRUCTION_OFFSET 0x00000020 -#define D3D_DISASM_INSTRUCTION_ONLY 0x00000040 -#define D3D_DISASM_PRINT_HEX_LITERALS 0x00000080 - -HRESULT WINAPI -D3DDisassemble(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData, - _In_ SIZE_T SrcDataSize, - _In_ UINT Flags, - _In_opt_ LPCSTR szComments, - _Out_ ID3DBlob** ppDisassembly); - -typedef HRESULT (WINAPI *pD3DDisassemble) - (_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData, - _In_ SIZE_T SrcDataSize, - _In_ UINT Flags, - _In_opt_ LPCSTR szComments, - _Out_ ID3DBlob** ppDisassembly); - -HRESULT WINAPI -D3DDisassembleRegion(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData, - _In_ SIZE_T SrcDataSize, - _In_ UINT Flags, - _In_opt_ LPCSTR szComments, - _In_ SIZE_T StartByteOffset, - _In_ SIZE_T NumInsts, - _Out_opt_ SIZE_T* pFinishByteOffset, - _Out_ ID3DBlob** ppDisassembly); - -//---------------------------------------------------------------------------- -// Shader linking and Function Linking Graph (FLG) APIs -//---------------------------------------------------------------------------- -HRESULT WINAPI -D3DCreateLinker(__out interface ID3D11Linker ** ppLinker); - -HRESULT WINAPI -D3DLoadModule(_In_ LPCVOID pSrcData, - _In_ SIZE_T cbSrcDataSize, - _Out_ interface ID3D11Module ** ppModule); - -HRESULT WINAPI -D3DCreateFunctionLinkingGraph(_In_ UINT uFlags, - _Out_ interface ID3D11FunctionLinkingGraph ** ppFunctionLinkingGraph); - -//---------------------------------------------------------------------------- -// D3DGetTraceInstructionOffsets: -// ----------------------- -// Determines byte offsets for instructions within a shader blob. -// This information is useful for going between trace instruction -// indices and byte offsets that are used in debug information. -//---------------------------------------------------------------------------- - -#define D3D_GET_INST_OFFSETS_INCLUDE_NON_EXECUTABLE 0x00000001 - -HRESULT WINAPI -D3DGetTraceInstructionOffsets(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData, - _In_ SIZE_T SrcDataSize, - _In_ UINT Flags, - _In_ SIZE_T StartInstIndex, - _In_ SIZE_T NumInsts, - _Out_writes_to_opt_(NumInsts, min(NumInsts, *pTotalInsts)) SIZE_T* pOffsets, - _Out_opt_ SIZE_T* pTotalInsts); - -//---------------------------------------------------------------------------- -// D3DGetInputSignatureBlob: -// ----------------------- -// Retrieve the input signature from a compilation result. -//---------------------------------------------------------------------------- - -HRESULT WINAPI -D3DGetInputSignatureBlob(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData, - _In_ SIZE_T SrcDataSize, - _Out_ ID3DBlob** ppSignatureBlob); - -//---------------------------------------------------------------------------- -// D3DGetOutputSignatureBlob: -// ----------------------- -// Retrieve the output signature from a compilation result. -//---------------------------------------------------------------------------- - -HRESULT WINAPI -D3DGetOutputSignatureBlob(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData, - _In_ SIZE_T SrcDataSize, - _Out_ ID3DBlob** ppSignatureBlob); - -//---------------------------------------------------------------------------- -// D3DGetInputAndOutputSignatureBlob: -// ----------------------- -// Retrieve the input and output signatures from a compilation result. -//---------------------------------------------------------------------------- - -HRESULT WINAPI -D3DGetInputAndOutputSignatureBlob(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData, - _In_ SIZE_T SrcDataSize, - _Out_ ID3DBlob** ppSignatureBlob); - -//---------------------------------------------------------------------------- -// D3DStripShader: -// ----------------------- -// Removes unwanted blobs from a compilation result -//---------------------------------------------------------------------------- - -typedef enum D3DCOMPILER_STRIP_FLAGS -{ - D3DCOMPILER_STRIP_REFLECTION_DATA = 0x00000001, - D3DCOMPILER_STRIP_DEBUG_INFO = 0x00000002, - D3DCOMPILER_STRIP_TEST_BLOBS = 0x00000004, - D3DCOMPILER_STRIP_PRIVATE_DATA = 0x00000008, - D3DCOMPILER_STRIP_ROOT_SIGNATURE = 0x00000010, - D3DCOMPILER_STRIP_FORCE_DWORD = 0x7fffffff, -} D3DCOMPILER_STRIP_FLAGS; - -HRESULT WINAPI -D3DStripShader(_In_reads_bytes_(BytecodeLength) LPCVOID pShaderBytecode, - _In_ SIZE_T BytecodeLength, - _In_ UINT uStripFlags, - _Out_ ID3DBlob** ppStrippedBlob); - -//---------------------------------------------------------------------------- -// D3DGetBlobPart: -// ----------------------- -// Extracts information from a compilation result. -//---------------------------------------------------------------------------- - -typedef enum D3D_BLOB_PART -{ - D3D_BLOB_INPUT_SIGNATURE_BLOB, - D3D_BLOB_OUTPUT_SIGNATURE_BLOB, - D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB, - D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB, - D3D_BLOB_ALL_SIGNATURE_BLOB, - D3D_BLOB_DEBUG_INFO, - D3D_BLOB_LEGACY_SHADER, - D3D_BLOB_XNA_PREPASS_SHADER, - D3D_BLOB_XNA_SHADER, - D3D_BLOB_PDB, - D3D_BLOB_PRIVATE_DATA, - D3D_BLOB_ROOT_SIGNATURE, - D3D_BLOB_DEBUG_NAME, - - // Test parts are only produced by special compiler versions and so - // are usually not present in shaders. - D3D_BLOB_TEST_ALTERNATE_SHADER = 0x8000, - D3D_BLOB_TEST_COMPILE_DETAILS, - D3D_BLOB_TEST_COMPILE_PERF, - D3D_BLOB_TEST_COMPILE_REPORT, -} D3D_BLOB_PART; - -HRESULT WINAPI -D3DGetBlobPart(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData, - _In_ SIZE_T SrcDataSize, - _In_ D3D_BLOB_PART Part, - _In_ UINT Flags, - _Out_ ID3DBlob** ppPart); - -//---------------------------------------------------------------------------- -// D3DSetBlobPart: -// ----------------------- -// Update information in a compilation result. -//---------------------------------------------------------------------------- - -HRESULT WINAPI -D3DSetBlobPart(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData, - _In_ SIZE_T SrcDataSize, - _In_ D3D_BLOB_PART Part, - _In_ UINT Flags, - _In_reads_bytes_(PartSize) LPCVOID pPart, - _In_ SIZE_T PartSize, - _Out_ ID3DBlob** ppNewShader); - -//---------------------------------------------------------------------------- -// D3DCreateBlob: -// ----------------------- -// Create an ID3DBlob instance. -//---------------------------------------------------------------------------- - -HRESULT WINAPI -D3DCreateBlob(_In_ SIZE_T Size, - _Out_ ID3DBlob** ppBlob); - -//---------------------------------------------------------------------------- -// D3DCompressShaders: -// ----------------------- -// Compresses a set of shaders into a more compact form. -//---------------------------------------------------------------------------- - -typedef struct _D3D_SHADER_DATA -{ - LPCVOID pBytecode; - SIZE_T BytecodeLength; -} D3D_SHADER_DATA; - -#define D3D_COMPRESS_SHADER_KEEP_ALL_PARTS 0x00000001 - -HRESULT WINAPI -D3DCompressShaders(_In_ UINT uNumShaders, - _In_reads_(uNumShaders) D3D_SHADER_DATA* pShaderData, - _In_ UINT uFlags, - _Out_ ID3DBlob** ppCompressedData); - -//---------------------------------------------------------------------------- -// D3DDecompressShaders: -// ----------------------- -// Decompresses one or more shaders from a compressed set. -//---------------------------------------------------------------------------- - -HRESULT WINAPI -D3DDecompressShaders(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData, - _In_ SIZE_T SrcDataSize, - _In_ UINT uNumShaders, - _In_ UINT uStartIndex, - _In_reads_opt_(uNumShaders) UINT* pIndices, - _In_ UINT uFlags, - _Out_writes_(uNumShaders) ID3DBlob** ppShaders, - _Out_opt_ UINT* pTotalShaders); - -#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_GAMES) */ -#pragma endregion - - -#pragma region Desktop Family -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) - -//---------------------------------------------------------------------------- -// D3DDisassemble10Effect: -// ----------------------- -// Takes a D3D10 effect interface and returns a -// buffer containing text assembly. -//---------------------------------------------------------------------------- - -HRESULT WINAPI -D3DDisassemble10Effect(_In_ interface ID3D10Effect *pEffect, - _In_ UINT Flags, - _Out_ ID3DBlob** ppDisassembly); - -#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */ -#pragma endregion - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif // #ifndef __D3DCOMPILER_H__ diff --git a/include/dxsdk/dxgi.h b/include/dxsdk/dxgi.h deleted file mode 100644 index d8c8ce9d..00000000 --- a/include/dxsdk/dxgi.h +++ /dev/null @@ -1,2958 +0,0 @@ - - -/* this ALWAYS GENERATED file contains the definitions for the interfaces */ - - - /* File created by MIDL compiler version 8.01.0622 */ -/* @@MIDL_FILE_HEADING( ) */ - - - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCNDR_H_VERSION__ -#define __REQUIRED_RPCNDR_H_VERSION__ 500 -#endif - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCSAL_H_VERSION__ -#define __REQUIRED_RPCSAL_H_VERSION__ 100 -#endif - -#include "rpc.h" -#include "rpcndr.h" - -#ifndef __RPCNDR_H_VERSION__ -#error this stub requires an updated version of -#endif /* __RPCNDR_H_VERSION__ */ - -#ifndef COM_NO_WINDOWS_H -#include "windows.h" -#include "ole2.h" -#endif /*COM_NO_WINDOWS_H*/ - -#ifndef __dxgi_h__ -#define __dxgi_h__ - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -#pragma once -#endif - -/* Forward Declarations */ - -#ifndef __IDXGIObject_FWD_DEFINED__ -#define __IDXGIObject_FWD_DEFINED__ -typedef interface IDXGIObject IDXGIObject; - -#endif /* __IDXGIObject_FWD_DEFINED__ */ - - -#ifndef __IDXGIDeviceSubObject_FWD_DEFINED__ -#define __IDXGIDeviceSubObject_FWD_DEFINED__ -typedef interface IDXGIDeviceSubObject IDXGIDeviceSubObject; - -#endif /* __IDXGIDeviceSubObject_FWD_DEFINED__ */ - - -#ifndef __IDXGIResource_FWD_DEFINED__ -#define __IDXGIResource_FWD_DEFINED__ -typedef interface IDXGIResource IDXGIResource; - -#endif /* __IDXGIResource_FWD_DEFINED__ */ - - -#ifndef __IDXGIKeyedMutex_FWD_DEFINED__ -#define __IDXGIKeyedMutex_FWD_DEFINED__ -typedef interface IDXGIKeyedMutex IDXGIKeyedMutex; - -#endif /* __IDXGIKeyedMutex_FWD_DEFINED__ */ - - -#ifndef __IDXGISurface_FWD_DEFINED__ -#define __IDXGISurface_FWD_DEFINED__ -typedef interface IDXGISurface IDXGISurface; - -#endif /* __IDXGISurface_FWD_DEFINED__ */ - - -#ifndef __IDXGISurface1_FWD_DEFINED__ -#define __IDXGISurface1_FWD_DEFINED__ -typedef interface IDXGISurface1 IDXGISurface1; - -#endif /* __IDXGISurface1_FWD_DEFINED__ */ - - -#ifndef __IDXGIAdapter_FWD_DEFINED__ -#define __IDXGIAdapter_FWD_DEFINED__ -typedef interface IDXGIAdapter IDXGIAdapter; - -#endif /* __IDXGIAdapter_FWD_DEFINED__ */ - - -#ifndef __IDXGIOutput_FWD_DEFINED__ -#define __IDXGIOutput_FWD_DEFINED__ -typedef interface IDXGIOutput IDXGIOutput; - -#endif /* __IDXGIOutput_FWD_DEFINED__ */ - - -#ifndef __IDXGISwapChain_FWD_DEFINED__ -#define __IDXGISwapChain_FWD_DEFINED__ -typedef interface IDXGISwapChain IDXGISwapChain; - -#endif /* __IDXGISwapChain_FWD_DEFINED__ */ - - -#ifndef __IDXGIFactory_FWD_DEFINED__ -#define __IDXGIFactory_FWD_DEFINED__ -typedef interface IDXGIFactory IDXGIFactory; - -#endif /* __IDXGIFactory_FWD_DEFINED__ */ - - -#ifndef __IDXGIDevice_FWD_DEFINED__ -#define __IDXGIDevice_FWD_DEFINED__ -typedef interface IDXGIDevice IDXGIDevice; - -#endif /* __IDXGIDevice_FWD_DEFINED__ */ - - -#ifndef __IDXGIFactory1_FWD_DEFINED__ -#define __IDXGIFactory1_FWD_DEFINED__ -typedef interface IDXGIFactory1 IDXGIFactory1; - -#endif /* __IDXGIFactory1_FWD_DEFINED__ */ - - -#ifndef __IDXGIAdapter1_FWD_DEFINED__ -#define __IDXGIAdapter1_FWD_DEFINED__ -typedef interface IDXGIAdapter1 IDXGIAdapter1; - -#endif /* __IDXGIAdapter1_FWD_DEFINED__ */ - - -#ifndef __IDXGIDevice1_FWD_DEFINED__ -#define __IDXGIDevice1_FWD_DEFINED__ -typedef interface IDXGIDevice1 IDXGIDevice1; - -#endif /* __IDXGIDevice1_FWD_DEFINED__ */ - - -/* header files for imported files */ -#include "oaidl.h" -#include "ocidl.h" -#include "dxgicommon.h" -#include "dxgitype.h" - -#ifdef __cplusplus -extern "C"{ -#endif - - -/* interface __MIDL_itf_dxgi_0000_0000 */ -/* [local] */ - -#include -#define DXGI_CPU_ACCESS_NONE ( 0 ) -#define DXGI_CPU_ACCESS_DYNAMIC ( 1 ) -#define DXGI_CPU_ACCESS_READ_WRITE ( 2 ) -#define DXGI_CPU_ACCESS_SCRATCH ( 3 ) -#define DXGI_CPU_ACCESS_FIELD 15 -#define DXGI_USAGE_SHADER_INPUT 0x00000010UL -#define DXGI_USAGE_RENDER_TARGET_OUTPUT 0x00000020UL -#define DXGI_USAGE_BACK_BUFFER 0x00000040UL -#define DXGI_USAGE_SHARED 0x00000080UL -#define DXGI_USAGE_READ_ONLY 0x00000100UL -#define DXGI_USAGE_DISCARD_ON_PRESENT 0x00000200UL -#define DXGI_USAGE_UNORDERED_ACCESS 0x00000400UL -typedef UINT DXGI_USAGE; - -typedef struct DXGI_FRAME_STATISTICS - { - UINT PresentCount; - UINT PresentRefreshCount; - UINT SyncRefreshCount; - LARGE_INTEGER SyncQPCTime; - LARGE_INTEGER SyncGPUTime; - } DXGI_FRAME_STATISTICS; - -typedef struct DXGI_MAPPED_RECT - { - INT Pitch; - BYTE *pBits; - } DXGI_MAPPED_RECT; - -#ifdef __midl -#ifndef LUID_DEFINED -#define LUID_DEFINED 1 -typedef struct _LUID - { - DWORD LowPart; - LONG HighPart; - } LUID; - -typedef struct _LUID *PLUID; - -#endif -#endif -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; - -#if !defined(HMONITOR_DECLARED) && !defined(HMONITOR) && (WINVER < 0x0500) -#define HMONITOR_DECLARED -#if 0 -typedef HANDLE HMONITOR; - -#endif -DECLARE_HANDLE(HMONITOR); -#endif -typedef struct DXGI_OUTPUT_DESC - { - WCHAR DeviceName[ 32 ]; - RECT DesktopCoordinates; - BOOL AttachedToDesktop; - DXGI_MODE_ROTATION Rotation; - HMONITOR Monitor; - } DXGI_OUTPUT_DESC; - -typedef struct DXGI_SHARED_RESOURCE - { - HANDLE Handle; - } DXGI_SHARED_RESOURCE; - -#define DXGI_RESOURCE_PRIORITY_MINIMUM ( 0x28000000 ) - -#define DXGI_RESOURCE_PRIORITY_LOW ( 0x50000000 ) - -#define DXGI_RESOURCE_PRIORITY_NORMAL ( 0x78000000 ) - -#define DXGI_RESOURCE_PRIORITY_HIGH ( 0xa0000000 ) - -#define DXGI_RESOURCE_PRIORITY_MAXIMUM ( 0xc8000000 ) - -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 -enum DXGI_SWAP_EFFECT - { - DXGI_SWAP_EFFECT_DISCARD = 0, - DXGI_SWAP_EFFECT_SEQUENTIAL = 1, - DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL = 3, - DXGI_SWAP_EFFECT_FLIP_DISCARD = 4 - } DXGI_SWAP_EFFECT; - -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_RESTRICTED_CONTENT = 8, - DXGI_SWAP_CHAIN_FLAG_RESTRICT_SHARED_RESOURCE_DRIVER = 16, - DXGI_SWAP_CHAIN_FLAG_DISPLAY_ONLY = 32, - DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT = 64, - DXGI_SWAP_CHAIN_FLAG_FOREGROUND_LAYER = 128, - DXGI_SWAP_CHAIN_FLAG_FULLSCREEN_VIDEO = 256, - DXGI_SWAP_CHAIN_FLAG_YUV_VIDEO = 512, - DXGI_SWAP_CHAIN_FLAG_HW_PROTECTED = 1024, - DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING = 2048, - DXGI_SWAP_CHAIN_FLAG_RESTRICTED_TO_ALL_HOLOGRAPHIC_DISPLAYS = 4096 - } DXGI_SWAP_CHAIN_FLAG; - -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; - - - -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0000_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0000_v0_0_s_ifspec; - -#ifndef __IDXGIObject_INTERFACE_DEFINED__ -#define __IDXGIObject_INTERFACE_DEFINED__ - -/* interface IDXGIObject */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGIObject; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("aec22fb8-76f3-4639-9be0-28eb43a67a2e") - IDXGIObject : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE SetPrivateData( - /* [annotation][in] */ - _In_ REFGUID Name, - /* [in] */ UINT DataSize, - /* [annotation][in] */ - _In_reads_bytes_(DataSize) const void *pData) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][in] */ - _In_opt_ const IUnknown *pUnknown) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetPrivateData( - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][out][in] */ - _Inout_ UINT *pDataSize, - /* [annotation][out] */ - _Out_writes_bytes_(*pDataSize) void *pData) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetParent( - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppParent) = 0; - - }; - - -#else /* C style interface */ - - typedef struct IDXGIObjectVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGIObject * This, - /* [in] */ REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGIObject * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGIObject * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGIObject * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [in] */ UINT DataSize, - /* [annotation][in] */ - _In_reads_bytes_(DataSize) const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGIObject * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][in] */ - _In_opt_ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGIObject * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][out][in] */ - _Inout_ UINT *pDataSize, - /* [annotation][out] */ - _Out_writes_bytes_(*pDataSize) void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGIObject * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppParent); - - END_INTERFACE - } IDXGIObjectVtbl; - - interface IDXGIObject - { - CONST_VTBL struct IDXGIObjectVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGIObject_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGIObject_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGIObject_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGIObject_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGIObject_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGIObject_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGIObject_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGIObject_INTERFACE_DEFINED__ */ - - -#ifndef __IDXGIDeviceSubObject_INTERFACE_DEFINED__ -#define __IDXGIDeviceSubObject_INTERFACE_DEFINED__ - -/* interface IDXGIDeviceSubObject */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGIDeviceSubObject; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("3d3e0379-f9de-4d58-bb6c-18d62992f1a6") - IDXGIDeviceSubObject : public IDXGIObject - { - public: - virtual HRESULT STDMETHODCALLTYPE GetDevice( - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppDevice) = 0; - - }; - - -#else /* C style interface */ - - typedef struct IDXGIDeviceSubObjectVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGIDeviceSubObject * This, - /* [in] */ REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGIDeviceSubObject * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGIDeviceSubObject * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGIDeviceSubObject * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [in] */ UINT DataSize, - /* [annotation][in] */ - _In_reads_bytes_(DataSize) const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGIDeviceSubObject * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][in] */ - _In_opt_ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGIDeviceSubObject * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][out][in] */ - _Inout_ UINT *pDataSize, - /* [annotation][out] */ - _Out_writes_bytes_(*pDataSize) void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGIDeviceSubObject * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *GetDevice )( - IDXGIDeviceSubObject * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppDevice); - - END_INTERFACE - } IDXGIDeviceSubObjectVtbl; - - interface IDXGIDeviceSubObject - { - CONST_VTBL struct IDXGIDeviceSubObjectVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGIDeviceSubObject_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGIDeviceSubObject_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGIDeviceSubObject_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGIDeviceSubObject_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGIDeviceSubObject_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGIDeviceSubObject_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGIDeviceSubObject_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGIDeviceSubObject_GetDevice(This,riid,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,riid,ppDevice) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGIDeviceSubObject_INTERFACE_DEFINED__ */ - - -#ifndef __IDXGIResource_INTERFACE_DEFINED__ -#define __IDXGIResource_INTERFACE_DEFINED__ - -/* interface IDXGIResource */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGIResource; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("035f3ab4-482e-4e50-b41f-8a7f8bd8960b") - IDXGIResource : public IDXGIDeviceSubObject - { - public: - virtual HRESULT STDMETHODCALLTYPE GetSharedHandle( - /* [annotation][out] */ - _Out_ HANDLE *pSharedHandle) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetUsage( - /* [out] */ DXGI_USAGE *pUsage) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetEvictionPriority( - /* [in] */ UINT EvictionPriority) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetEvictionPriority( - /* [annotation][retval][out] */ - _Out_ UINT *pEvictionPriority) = 0; - - }; - - -#else /* C style interface */ - - typedef struct IDXGIResourceVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGIResource * This, - /* [in] */ REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGIResource * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGIResource * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGIResource * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [in] */ UINT DataSize, - /* [annotation][in] */ - _In_reads_bytes_(DataSize) const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGIResource * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][in] */ - _In_opt_ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGIResource * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][out][in] */ - _Inout_ UINT *pDataSize, - /* [annotation][out] */ - _Out_writes_bytes_(*pDataSize) void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGIResource * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *GetDevice )( - IDXGIResource * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetSharedHandle )( - IDXGIResource * This, - /* [annotation][out] */ - _Out_ HANDLE *pSharedHandle); - - HRESULT ( STDMETHODCALLTYPE *GetUsage )( - IDXGIResource * This, - /* [out] */ DXGI_USAGE *pUsage); - - HRESULT ( STDMETHODCALLTYPE *SetEvictionPriority )( - IDXGIResource * This, - /* [in] */ UINT EvictionPriority); - - HRESULT ( STDMETHODCALLTYPE *GetEvictionPriority )( - IDXGIResource * This, - /* [annotation][retval][out] */ - _Out_ UINT *pEvictionPriority); - - END_INTERFACE - } IDXGIResourceVtbl; - - interface IDXGIResource - { - CONST_VTBL struct IDXGIResourceVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGIResource_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGIResource_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGIResource_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGIResource_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGIResource_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGIResource_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGIResource_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGIResource_GetDevice(This,riid,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,riid,ppDevice) ) - - -#define IDXGIResource_GetSharedHandle(This,pSharedHandle) \ - ( (This)->lpVtbl -> GetSharedHandle(This,pSharedHandle) ) - -#define IDXGIResource_GetUsage(This,pUsage) \ - ( (This)->lpVtbl -> GetUsage(This,pUsage) ) - -#define IDXGIResource_SetEvictionPriority(This,EvictionPriority) \ - ( (This)->lpVtbl -> SetEvictionPriority(This,EvictionPriority) ) - -#define IDXGIResource_GetEvictionPriority(This,pEvictionPriority) \ - ( (This)->lpVtbl -> GetEvictionPriority(This,pEvictionPriority) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGIResource_INTERFACE_DEFINED__ */ - - -#ifndef __IDXGIKeyedMutex_INTERFACE_DEFINED__ -#define __IDXGIKeyedMutex_INTERFACE_DEFINED__ - -/* interface IDXGIKeyedMutex */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGIKeyedMutex; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("9d8e1289-d7b3-465f-8126-250e349af85d") - IDXGIKeyedMutex : public IDXGIDeviceSubObject - { - public: - virtual HRESULT STDMETHODCALLTYPE AcquireSync( - /* [in] */ UINT64 Key, - /* [in] */ DWORD dwMilliseconds) = 0; - - virtual HRESULT STDMETHODCALLTYPE ReleaseSync( - /* [in] */ UINT64 Key) = 0; - - }; - - -#else /* C style interface */ - - typedef struct IDXGIKeyedMutexVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGIKeyedMutex * This, - /* [in] */ REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGIKeyedMutex * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGIKeyedMutex * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGIKeyedMutex * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [in] */ UINT DataSize, - /* [annotation][in] */ - _In_reads_bytes_(DataSize) const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGIKeyedMutex * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][in] */ - _In_opt_ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGIKeyedMutex * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][out][in] */ - _Inout_ UINT *pDataSize, - /* [annotation][out] */ - _Out_writes_bytes_(*pDataSize) void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGIKeyedMutex * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *GetDevice )( - IDXGIKeyedMutex * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *AcquireSync )( - IDXGIKeyedMutex * This, - /* [in] */ UINT64 Key, - /* [in] */ DWORD dwMilliseconds); - - HRESULT ( STDMETHODCALLTYPE *ReleaseSync )( - IDXGIKeyedMutex * This, - /* [in] */ UINT64 Key); - - END_INTERFACE - } IDXGIKeyedMutexVtbl; - - interface IDXGIKeyedMutex - { - CONST_VTBL struct IDXGIKeyedMutexVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGIKeyedMutex_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGIKeyedMutex_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGIKeyedMutex_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGIKeyedMutex_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGIKeyedMutex_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGIKeyedMutex_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGIKeyedMutex_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGIKeyedMutex_GetDevice(This,riid,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,riid,ppDevice) ) - - -#define IDXGIKeyedMutex_AcquireSync(This,Key,dwMilliseconds) \ - ( (This)->lpVtbl -> AcquireSync(This,Key,dwMilliseconds) ) - -#define IDXGIKeyedMutex_ReleaseSync(This,Key) \ - ( (This)->lpVtbl -> ReleaseSync(This,Key) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGIKeyedMutex_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxgi_0000_0004 */ -/* [local] */ - -#define DXGI_MAP_READ ( 1UL ) - -#define DXGI_MAP_WRITE ( 2UL ) - -#define DXGI_MAP_DISCARD ( 4UL ) - - - -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0004_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0004_v0_0_s_ifspec; - -#ifndef __IDXGISurface_INTERFACE_DEFINED__ -#define __IDXGISurface_INTERFACE_DEFINED__ - -/* interface IDXGISurface */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGISurface; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("cafcb56c-6ac3-4889-bf47-9e23bbd260ec") - IDXGISurface : public IDXGIDeviceSubObject - { - public: - virtual HRESULT STDMETHODCALLTYPE GetDesc( - /* [annotation][out] */ - _Out_ DXGI_SURFACE_DESC *pDesc) = 0; - - virtual HRESULT STDMETHODCALLTYPE Map( - /* [annotation][out] */ - _Out_ DXGI_MAPPED_RECT *pLockedRect, - /* [in] */ UINT MapFlags) = 0; - - virtual HRESULT STDMETHODCALLTYPE Unmap( void) = 0; - - }; - - -#else /* C style interface */ - - typedef struct IDXGISurfaceVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGISurface * This, - /* [in] */ REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGISurface * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGISurface * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGISurface * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [in] */ UINT DataSize, - /* [annotation][in] */ - _In_reads_bytes_(DataSize) const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGISurface * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][in] */ - _In_opt_ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGISurface * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][out][in] */ - _Inout_ UINT *pDataSize, - /* [annotation][out] */ - _Out_writes_bytes_(*pDataSize) void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGISurface * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *GetDevice )( - IDXGISurface * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetDesc )( - IDXGISurface * This, - /* [annotation][out] */ - _Out_ DXGI_SURFACE_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *Map )( - IDXGISurface * This, - /* [annotation][out] */ - _Out_ DXGI_MAPPED_RECT *pLockedRect, - /* [in] */ UINT MapFlags); - - HRESULT ( STDMETHODCALLTYPE *Unmap )( - IDXGISurface * This); - - END_INTERFACE - } IDXGISurfaceVtbl; - - interface IDXGISurface - { - CONST_VTBL struct IDXGISurfaceVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGISurface_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGISurface_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGISurface_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGISurface_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGISurface_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGISurface_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGISurface_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGISurface_GetDevice(This,riid,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,riid,ppDevice) ) - - -#define IDXGISurface_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#define IDXGISurface_Map(This,pLockedRect,MapFlags) \ - ( (This)->lpVtbl -> Map(This,pLockedRect,MapFlags) ) - -#define IDXGISurface_Unmap(This) \ - ( (This)->lpVtbl -> Unmap(This) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGISurface_INTERFACE_DEFINED__ */ - - -#ifndef __IDXGISurface1_INTERFACE_DEFINED__ -#define __IDXGISurface1_INTERFACE_DEFINED__ - -/* interface IDXGISurface1 */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGISurface1; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("4AE63092-6327-4c1b-80AE-BFE12EA32B86") - IDXGISurface1 : public IDXGISurface - { - public: - virtual HRESULT STDMETHODCALLTYPE GetDC( - /* [in] */ BOOL Discard, - /* [annotation][out] */ - _Out_ HDC *phdc) = 0; - - virtual HRESULT STDMETHODCALLTYPE ReleaseDC( - /* [annotation][in] */ - _In_opt_ RECT *pDirtyRect) = 0; - - }; - - -#else /* C style interface */ - - typedef struct IDXGISurface1Vtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGISurface1 * This, - /* [in] */ REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGISurface1 * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGISurface1 * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGISurface1 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [in] */ UINT DataSize, - /* [annotation][in] */ - _In_reads_bytes_(DataSize) const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGISurface1 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][in] */ - _In_opt_ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGISurface1 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][out][in] */ - _Inout_ UINT *pDataSize, - /* [annotation][out] */ - _Out_writes_bytes_(*pDataSize) void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGISurface1 * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *GetDevice )( - IDXGISurface1 * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *GetDesc )( - IDXGISurface1 * This, - /* [annotation][out] */ - _Out_ DXGI_SURFACE_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *Map )( - IDXGISurface1 * This, - /* [annotation][out] */ - _Out_ DXGI_MAPPED_RECT *pLockedRect, - /* [in] */ UINT MapFlags); - - HRESULT ( STDMETHODCALLTYPE *Unmap )( - IDXGISurface1 * This); - - HRESULT ( STDMETHODCALLTYPE *GetDC )( - IDXGISurface1 * This, - /* [in] */ BOOL Discard, - /* [annotation][out] */ - _Out_ HDC *phdc); - - HRESULT ( STDMETHODCALLTYPE *ReleaseDC )( - IDXGISurface1 * This, - /* [annotation][in] */ - _In_opt_ RECT *pDirtyRect); - - END_INTERFACE - } IDXGISurface1Vtbl; - - interface IDXGISurface1 - { - CONST_VTBL struct IDXGISurface1Vtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGISurface1_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGISurface1_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGISurface1_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGISurface1_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGISurface1_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGISurface1_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGISurface1_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGISurface1_GetDevice(This,riid,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,riid,ppDevice) ) - - -#define IDXGISurface1_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#define IDXGISurface1_Map(This,pLockedRect,MapFlags) \ - ( (This)->lpVtbl -> Map(This,pLockedRect,MapFlags) ) - -#define IDXGISurface1_Unmap(This) \ - ( (This)->lpVtbl -> Unmap(This) ) - - -#define IDXGISurface1_GetDC(This,Discard,phdc) \ - ( (This)->lpVtbl -> GetDC(This,Discard,phdc) ) - -#define IDXGISurface1_ReleaseDC(This,pDirtyRect) \ - ( (This)->lpVtbl -> ReleaseDC(This,pDirtyRect) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGISurface1_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxgi_0000_0006 */ -/* [local] */ - - - - -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0006_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0006_v0_0_s_ifspec; - -#ifndef __IDXGIAdapter_INTERFACE_DEFINED__ -#define __IDXGIAdapter_INTERFACE_DEFINED__ - -/* interface IDXGIAdapter */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGIAdapter; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("2411e7e1-12ac-4ccf-bd14-9798e8534dc0") - IDXGIAdapter : public IDXGIObject - { - public: - virtual HRESULT STDMETHODCALLTYPE EnumOutputs( - /* [in] */ UINT Output, - /* [annotation][out][in] */ - _COM_Outptr_ IDXGIOutput **ppOutput) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetDesc( - /* [annotation][out] */ - _Out_ DXGI_ADAPTER_DESC *pDesc) = 0; - - virtual HRESULT STDMETHODCALLTYPE CheckInterfaceSupport( - /* [annotation][in] */ - _In_ REFGUID InterfaceName, - /* [annotation][out] */ - _Out_ LARGE_INTEGER *pUMDVersion) = 0; - - }; - - -#else /* C style interface */ - - typedef struct IDXGIAdapterVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGIAdapter * This, - /* [in] */ REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGIAdapter * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGIAdapter * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGIAdapter * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [in] */ UINT DataSize, - /* [annotation][in] */ - _In_reads_bytes_(DataSize) const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGIAdapter * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][in] */ - _In_opt_ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGIAdapter * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][out][in] */ - _Inout_ UINT *pDataSize, - /* [annotation][out] */ - _Out_writes_bytes_(*pDataSize) void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGIAdapter * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *EnumOutputs )( - IDXGIAdapter * This, - /* [in] */ UINT Output, - /* [annotation][out][in] */ - _COM_Outptr_ IDXGIOutput **ppOutput); - - HRESULT ( STDMETHODCALLTYPE *GetDesc )( - IDXGIAdapter * This, - /* [annotation][out] */ - _Out_ DXGI_ADAPTER_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *CheckInterfaceSupport )( - IDXGIAdapter * This, - /* [annotation][in] */ - _In_ REFGUID InterfaceName, - /* [annotation][out] */ - _Out_ LARGE_INTEGER *pUMDVersion); - - END_INTERFACE - } IDXGIAdapterVtbl; - - interface IDXGIAdapter - { - CONST_VTBL struct IDXGIAdapterVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGIAdapter_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGIAdapter_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGIAdapter_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGIAdapter_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGIAdapter_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGIAdapter_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGIAdapter_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGIAdapter_EnumOutputs(This,Output,ppOutput) \ - ( (This)->lpVtbl -> EnumOutputs(This,Output,ppOutput) ) - -#define IDXGIAdapter_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#define IDXGIAdapter_CheckInterfaceSupport(This,InterfaceName,pUMDVersion) \ - ( (This)->lpVtbl -> CheckInterfaceSupport(This,InterfaceName,pUMDVersion) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGIAdapter_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxgi_0000_0007 */ -/* [local] */ - -#define DXGI_ENUM_MODES_INTERLACED ( 1UL ) - -#define DXGI_ENUM_MODES_SCALING ( 2UL ) - - - -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0007_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0007_v0_0_s_ifspec; - -#ifndef __IDXGIOutput_INTERFACE_DEFINED__ -#define __IDXGIOutput_INTERFACE_DEFINED__ - -/* interface IDXGIOutput */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGIOutput; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("ae02eedb-c735-4690-8d52-5a8dc20213aa") - IDXGIOutput : public IDXGIObject - { - public: - virtual HRESULT STDMETHODCALLTYPE GetDesc( - /* [annotation][out] */ - _Out_ DXGI_OUTPUT_DESC *pDesc) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetDisplayModeList( - /* [in] */ DXGI_FORMAT EnumFormat, - /* [in] */ UINT Flags, - /* [annotation][out][in] */ - _Inout_ UINT *pNumModes, - /* [annotation][out] */ - _Out_writes_to_opt_(*pNumModes,*pNumModes) DXGI_MODE_DESC *pDesc) = 0; - - virtual HRESULT STDMETHODCALLTYPE FindClosestMatchingMode( - /* [annotation][in] */ - _In_ const DXGI_MODE_DESC *pModeToMatch, - /* [annotation][out] */ - _Out_ DXGI_MODE_DESC *pClosestMatch, - /* [annotation][in] */ - _In_opt_ IUnknown *pConcernedDevice) = 0; - - virtual HRESULT STDMETHODCALLTYPE WaitForVBlank( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE TakeOwnership( - /* [annotation][in] */ - _In_ IUnknown *pDevice, - BOOL Exclusive) = 0; - - virtual void STDMETHODCALLTYPE ReleaseOwnership( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetGammaControlCapabilities( - /* [annotation][out] */ - _Out_ DXGI_GAMMA_CONTROL_CAPABILITIES *pGammaCaps) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetGammaControl( - /* [annotation][in] */ - _In_ const DXGI_GAMMA_CONTROL *pArray) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetGammaControl( - /* [annotation][out] */ - _Out_ DXGI_GAMMA_CONTROL *pArray) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetDisplaySurface( - /* [annotation][in] */ - _In_ IDXGISurface *pScanoutSurface) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetDisplaySurfaceData( - /* [annotation][in] */ - _In_ IDXGISurface *pDestination) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetFrameStatistics( - /* [annotation][out] */ - _Out_ DXGI_FRAME_STATISTICS *pStats) = 0; - - }; - - -#else /* C style interface */ - - typedef struct IDXGIOutputVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGIOutput * This, - /* [in] */ REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGIOutput * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGIOutput * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGIOutput * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [in] */ UINT DataSize, - /* [annotation][in] */ - _In_reads_bytes_(DataSize) const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGIOutput * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][in] */ - _In_opt_ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGIOutput * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][out][in] */ - _Inout_ UINT *pDataSize, - /* [annotation][out] */ - _Out_writes_bytes_(*pDataSize) void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGIOutput * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *GetDesc )( - IDXGIOutput * This, - /* [annotation][out] */ - _Out_ DXGI_OUTPUT_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *GetDisplayModeList )( - IDXGIOutput * This, - /* [in] */ DXGI_FORMAT EnumFormat, - /* [in] */ UINT Flags, - /* [annotation][out][in] */ - _Inout_ UINT *pNumModes, - /* [annotation][out] */ - _Out_writes_to_opt_(*pNumModes,*pNumModes) DXGI_MODE_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *FindClosestMatchingMode )( - IDXGIOutput * This, - /* [annotation][in] */ - _In_ const DXGI_MODE_DESC *pModeToMatch, - /* [annotation][out] */ - _Out_ DXGI_MODE_DESC *pClosestMatch, - /* [annotation][in] */ - _In_opt_ IUnknown *pConcernedDevice); - - HRESULT ( STDMETHODCALLTYPE *WaitForVBlank )( - IDXGIOutput * This); - - HRESULT ( STDMETHODCALLTYPE *TakeOwnership )( - IDXGIOutput * This, - /* [annotation][in] */ - _In_ IUnknown *pDevice, - BOOL Exclusive); - - void ( STDMETHODCALLTYPE *ReleaseOwnership )( - IDXGIOutput * This); - - HRESULT ( STDMETHODCALLTYPE *GetGammaControlCapabilities )( - IDXGIOutput * This, - /* [annotation][out] */ - _Out_ DXGI_GAMMA_CONTROL_CAPABILITIES *pGammaCaps); - - HRESULT ( STDMETHODCALLTYPE *SetGammaControl )( - IDXGIOutput * This, - /* [annotation][in] */ - _In_ const DXGI_GAMMA_CONTROL *pArray); - - HRESULT ( STDMETHODCALLTYPE *GetGammaControl )( - IDXGIOutput * This, - /* [annotation][out] */ - _Out_ DXGI_GAMMA_CONTROL *pArray); - - HRESULT ( STDMETHODCALLTYPE *SetDisplaySurface )( - IDXGIOutput * This, - /* [annotation][in] */ - _In_ IDXGISurface *pScanoutSurface); - - HRESULT ( STDMETHODCALLTYPE *GetDisplaySurfaceData )( - IDXGIOutput * This, - /* [annotation][in] */ - _In_ IDXGISurface *pDestination); - - HRESULT ( STDMETHODCALLTYPE *GetFrameStatistics )( - IDXGIOutput * This, - /* [annotation][out] */ - _Out_ DXGI_FRAME_STATISTICS *pStats); - - END_INTERFACE - } IDXGIOutputVtbl; - - interface IDXGIOutput - { - CONST_VTBL struct IDXGIOutputVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGIOutput_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGIOutput_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGIOutput_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGIOutput_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGIOutput_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGIOutput_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGIOutput_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGIOutput_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#define IDXGIOutput_GetDisplayModeList(This,EnumFormat,Flags,pNumModes,pDesc) \ - ( (This)->lpVtbl -> GetDisplayModeList(This,EnumFormat,Flags,pNumModes,pDesc) ) - -#define IDXGIOutput_FindClosestMatchingMode(This,pModeToMatch,pClosestMatch,pConcernedDevice) \ - ( (This)->lpVtbl -> FindClosestMatchingMode(This,pModeToMatch,pClosestMatch,pConcernedDevice) ) - -#define IDXGIOutput_WaitForVBlank(This) \ - ( (This)->lpVtbl -> WaitForVBlank(This) ) - -#define IDXGIOutput_TakeOwnership(This,pDevice,Exclusive) \ - ( (This)->lpVtbl -> TakeOwnership(This,pDevice,Exclusive) ) - -#define IDXGIOutput_ReleaseOwnership(This) \ - ( (This)->lpVtbl -> ReleaseOwnership(This) ) - -#define IDXGIOutput_GetGammaControlCapabilities(This,pGammaCaps) \ - ( (This)->lpVtbl -> GetGammaControlCapabilities(This,pGammaCaps) ) - -#define IDXGIOutput_SetGammaControl(This,pArray) \ - ( (This)->lpVtbl -> SetGammaControl(This,pArray) ) - -#define IDXGIOutput_GetGammaControl(This,pArray) \ - ( (This)->lpVtbl -> GetGammaControl(This,pArray) ) - -#define IDXGIOutput_SetDisplaySurface(This,pScanoutSurface) \ - ( (This)->lpVtbl -> SetDisplaySurface(This,pScanoutSurface) ) - -#define IDXGIOutput_GetDisplaySurfaceData(This,pDestination) \ - ( (This)->lpVtbl -> GetDisplaySurfaceData(This,pDestination) ) - -#define IDXGIOutput_GetFrameStatistics(This,pStats) \ - ( (This)->lpVtbl -> GetFrameStatistics(This,pStats) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGIOutput_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxgi_0000_0008 */ -/* [local] */ - -#define DXGI_MAX_SWAP_CHAIN_BUFFERS ( 16 ) -#define DXGI_PRESENT_TEST 0x00000001UL -#define DXGI_PRESENT_DO_NOT_SEQUENCE 0x00000002UL -#define DXGI_PRESENT_RESTART 0x00000004UL -#define DXGI_PRESENT_DO_NOT_WAIT 0x00000008UL -#define DXGI_PRESENT_STEREO_PREFER_RIGHT 0x00000010UL -#define DXGI_PRESENT_STEREO_TEMPORARY_MONO 0x00000020UL -#define DXGI_PRESENT_RESTRICT_TO_OUTPUT 0x00000040UL -#define DXGI_PRESENT_USE_DURATION 0x00000100UL -#define DXGI_PRESENT_ALLOW_TEARING 0x00000200UL - - -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0008_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0008_v0_0_s_ifspec; - -#ifndef __IDXGISwapChain_INTERFACE_DEFINED__ -#define __IDXGISwapChain_INTERFACE_DEFINED__ - -/* interface IDXGISwapChain */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGISwapChain; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("310d36a0-d2e7-4c0a-aa04-6a9d23b8886a") - IDXGISwapChain : public IDXGIDeviceSubObject - { - public: - virtual HRESULT STDMETHODCALLTYPE Present( - /* [in] */ UINT SyncInterval, - /* [in] */ UINT Flags) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetBuffer( - /* [in] */ UINT Buffer, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][out][in] */ - _COM_Outptr_ void **ppSurface) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetFullscreenState( - /* [in] */ BOOL Fullscreen, - /* [annotation][in] */ - _In_opt_ IDXGIOutput *pTarget) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetFullscreenState( - /* [annotation][out] */ - _Out_opt_ BOOL *pFullscreen, - /* [annotation][out] */ - _COM_Outptr_opt_result_maybenull_ IDXGIOutput **ppTarget) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetDesc( - /* [annotation][out] */ - _Out_ DXGI_SWAP_CHAIN_DESC *pDesc) = 0; - - virtual HRESULT STDMETHODCALLTYPE ResizeBuffers( - /* [in] */ UINT BufferCount, - /* [in] */ UINT Width, - /* [in] */ UINT Height, - /* [in] */ DXGI_FORMAT NewFormat, - /* [in] */ UINT SwapChainFlags) = 0; - - virtual HRESULT STDMETHODCALLTYPE ResizeTarget( - /* [annotation][in] */ - _In_ const DXGI_MODE_DESC *pNewTargetParameters) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetContainingOutput( - /* [annotation][out] */ - _COM_Outptr_ IDXGIOutput **ppOutput) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetFrameStatistics( - /* [annotation][out] */ - _Out_ DXGI_FRAME_STATISTICS *pStats) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetLastPresentCount( - /* [annotation][out] */ - _Out_ UINT *pLastPresentCount) = 0; - - }; - - -#else /* C style interface */ - - typedef struct IDXGISwapChainVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGISwapChain * This, - /* [in] */ REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGISwapChain * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGISwapChain * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGISwapChain * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [in] */ UINT DataSize, - /* [annotation][in] */ - _In_reads_bytes_(DataSize) const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGISwapChain * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][in] */ - _In_opt_ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGISwapChain * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][out][in] */ - _Inout_ UINT *pDataSize, - /* [annotation][out] */ - _Out_writes_bytes_(*pDataSize) void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGISwapChain * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *GetDevice )( - IDXGISwapChain * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *Present )( - IDXGISwapChain * This, - /* [in] */ UINT SyncInterval, - /* [in] */ UINT Flags); - - HRESULT ( STDMETHODCALLTYPE *GetBuffer )( - IDXGISwapChain * This, - /* [in] */ UINT Buffer, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][out][in] */ - _COM_Outptr_ void **ppSurface); - - HRESULT ( STDMETHODCALLTYPE *SetFullscreenState )( - IDXGISwapChain * This, - /* [in] */ BOOL Fullscreen, - /* [annotation][in] */ - _In_opt_ IDXGIOutput *pTarget); - - HRESULT ( STDMETHODCALLTYPE *GetFullscreenState )( - IDXGISwapChain * This, - /* [annotation][out] */ - _Out_opt_ BOOL *pFullscreen, - /* [annotation][out] */ - _COM_Outptr_opt_result_maybenull_ IDXGIOutput **ppTarget); - - HRESULT ( STDMETHODCALLTYPE *GetDesc )( - IDXGISwapChain * This, - /* [annotation][out] */ - _Out_ DXGI_SWAP_CHAIN_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *ResizeBuffers )( - IDXGISwapChain * This, - /* [in] */ UINT BufferCount, - /* [in] */ UINT Width, - /* [in] */ UINT Height, - /* [in] */ DXGI_FORMAT NewFormat, - /* [in] */ UINT SwapChainFlags); - - HRESULT ( STDMETHODCALLTYPE *ResizeTarget )( - IDXGISwapChain * This, - /* [annotation][in] */ - _In_ const DXGI_MODE_DESC *pNewTargetParameters); - - HRESULT ( STDMETHODCALLTYPE *GetContainingOutput )( - IDXGISwapChain * This, - /* [annotation][out] */ - _COM_Outptr_ IDXGIOutput **ppOutput); - - HRESULT ( STDMETHODCALLTYPE *GetFrameStatistics )( - IDXGISwapChain * This, - /* [annotation][out] */ - _Out_ DXGI_FRAME_STATISTICS *pStats); - - HRESULT ( STDMETHODCALLTYPE *GetLastPresentCount )( - IDXGISwapChain * This, - /* [annotation][out] */ - _Out_ UINT *pLastPresentCount); - - END_INTERFACE - } IDXGISwapChainVtbl; - - interface IDXGISwapChain - { - CONST_VTBL struct IDXGISwapChainVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGISwapChain_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGISwapChain_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGISwapChain_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGISwapChain_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGISwapChain_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGISwapChain_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGISwapChain_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGISwapChain_GetDevice(This,riid,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,riid,ppDevice) ) - - -#define IDXGISwapChain_Present(This,SyncInterval,Flags) \ - ( (This)->lpVtbl -> Present(This,SyncInterval,Flags) ) - -#define IDXGISwapChain_GetBuffer(This,Buffer,riid,ppSurface) \ - ( (This)->lpVtbl -> GetBuffer(This,Buffer,riid,ppSurface) ) - -#define IDXGISwapChain_SetFullscreenState(This,Fullscreen,pTarget) \ - ( (This)->lpVtbl -> SetFullscreenState(This,Fullscreen,pTarget) ) - -#define IDXGISwapChain_GetFullscreenState(This,pFullscreen,ppTarget) \ - ( (This)->lpVtbl -> GetFullscreenState(This,pFullscreen,ppTarget) ) - -#define IDXGISwapChain_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#define IDXGISwapChain_ResizeBuffers(This,BufferCount,Width,Height,NewFormat,SwapChainFlags) \ - ( (This)->lpVtbl -> ResizeBuffers(This,BufferCount,Width,Height,NewFormat,SwapChainFlags) ) - -#define IDXGISwapChain_ResizeTarget(This,pNewTargetParameters) \ - ( (This)->lpVtbl -> ResizeTarget(This,pNewTargetParameters) ) - -#define IDXGISwapChain_GetContainingOutput(This,ppOutput) \ - ( (This)->lpVtbl -> GetContainingOutput(This,ppOutput) ) - -#define IDXGISwapChain_GetFrameStatistics(This,pStats) \ - ( (This)->lpVtbl -> GetFrameStatistics(This,pStats) ) - -#define IDXGISwapChain_GetLastPresentCount(This,pLastPresentCount) \ - ( (This)->lpVtbl -> GetLastPresentCount(This,pLastPresentCount) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGISwapChain_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxgi_0000_0009 */ -/* [local] */ - -#define DXGI_MWA_NO_WINDOW_CHANGES ( 1 << 0 ) -#define DXGI_MWA_NO_ALT_ENTER ( 1 << 1 ) -#define DXGI_MWA_NO_PRINT_SCREEN ( 1 << 2 ) -#define DXGI_MWA_VALID ( 0x7 ) - - -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0009_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0009_v0_0_s_ifspec; - -#ifndef __IDXGIFactory_INTERFACE_DEFINED__ -#define __IDXGIFactory_INTERFACE_DEFINED__ - -/* interface IDXGIFactory */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGIFactory; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("7b7166ec-21c7-44ae-b21a-c9ae321ae369") - IDXGIFactory : public IDXGIObject - { - public: - virtual HRESULT STDMETHODCALLTYPE EnumAdapters( - /* [in] */ UINT Adapter, - /* [annotation][out] */ - _COM_Outptr_ IDXGIAdapter **ppAdapter) = 0; - - virtual HRESULT STDMETHODCALLTYPE MakeWindowAssociation( - HWND WindowHandle, - UINT Flags) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetWindowAssociation( - /* [annotation][out] */ - _Out_ HWND *pWindowHandle) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateSwapChain( - /* [annotation][in] */ - _In_ IUnknown *pDevice, - /* [annotation][in] */ - _In_ DXGI_SWAP_CHAIN_DESC *pDesc, - /* [annotation][out] */ - _COM_Outptr_ IDXGISwapChain **ppSwapChain) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateSoftwareAdapter( - /* [in] */ HMODULE Module, - /* [annotation][out] */ - _COM_Outptr_ IDXGIAdapter **ppAdapter) = 0; - - }; - - -#else /* C style interface */ - - typedef struct IDXGIFactoryVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGIFactory * This, - /* [in] */ REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGIFactory * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGIFactory * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGIFactory * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [in] */ UINT DataSize, - /* [annotation][in] */ - _In_reads_bytes_(DataSize) const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGIFactory * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][in] */ - _In_opt_ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGIFactory * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][out][in] */ - _Inout_ UINT *pDataSize, - /* [annotation][out] */ - _Out_writes_bytes_(*pDataSize) void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGIFactory * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *EnumAdapters )( - IDXGIFactory * This, - /* [in] */ UINT Adapter, - /* [annotation][out] */ - _COM_Outptr_ IDXGIAdapter **ppAdapter); - - HRESULT ( STDMETHODCALLTYPE *MakeWindowAssociation )( - IDXGIFactory * This, - HWND WindowHandle, - UINT Flags); - - HRESULT ( STDMETHODCALLTYPE *GetWindowAssociation )( - IDXGIFactory * This, - /* [annotation][out] */ - _Out_ HWND *pWindowHandle); - - HRESULT ( STDMETHODCALLTYPE *CreateSwapChain )( - IDXGIFactory * This, - /* [annotation][in] */ - _In_ IUnknown *pDevice, - /* [annotation][in] */ - _In_ DXGI_SWAP_CHAIN_DESC *pDesc, - /* [annotation][out] */ - _COM_Outptr_ IDXGISwapChain **ppSwapChain); - - HRESULT ( STDMETHODCALLTYPE *CreateSoftwareAdapter )( - IDXGIFactory * This, - /* [in] */ HMODULE Module, - /* [annotation][out] */ - _COM_Outptr_ IDXGIAdapter **ppAdapter); - - END_INTERFACE - } IDXGIFactoryVtbl; - - interface IDXGIFactory - { - CONST_VTBL struct IDXGIFactoryVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGIFactory_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGIFactory_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGIFactory_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGIFactory_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGIFactory_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGIFactory_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGIFactory_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGIFactory_EnumAdapters(This,Adapter,ppAdapter) \ - ( (This)->lpVtbl -> EnumAdapters(This,Adapter,ppAdapter) ) - -#define IDXGIFactory_MakeWindowAssociation(This,WindowHandle,Flags) \ - ( (This)->lpVtbl -> MakeWindowAssociation(This,WindowHandle,Flags) ) - -#define IDXGIFactory_GetWindowAssociation(This,pWindowHandle) \ - ( (This)->lpVtbl -> GetWindowAssociation(This,pWindowHandle) ) - -#define IDXGIFactory_CreateSwapChain(This,pDevice,pDesc,ppSwapChain) \ - ( (This)->lpVtbl -> CreateSwapChain(This,pDevice,pDesc,ppSwapChain) ) - -#define IDXGIFactory_CreateSoftwareAdapter(This,Module,ppAdapter) \ - ( (This)->lpVtbl -> CreateSoftwareAdapter(This,Module,ppAdapter) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGIFactory_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxgi_0000_0010 */ -/* [local] */ - -#pragma region Desktop Family -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) -HRESULT WINAPI CreateDXGIFactory(REFIID riid, _COM_Outptr_ void **ppFactory); -#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */ -#pragma endregion -HRESULT WINAPI CreateDXGIFactory1(REFIID riid, _COM_Outptr_ void **ppFactory); - - -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0010_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0010_v0_0_s_ifspec; - -#ifndef __IDXGIDevice_INTERFACE_DEFINED__ -#define __IDXGIDevice_INTERFACE_DEFINED__ - -/* interface IDXGIDevice */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGIDevice; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("54ec77fa-1377-44e6-8c32-88fd5f44c84c") - IDXGIDevice : public IDXGIObject - { - public: - virtual HRESULT STDMETHODCALLTYPE GetAdapter( - /* [annotation][out] */ - _COM_Outptr_ IDXGIAdapter **pAdapter) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateSurface( - /* [annotation][in] */ - _In_ const DXGI_SURFACE_DESC *pDesc, - /* [in] */ UINT NumSurfaces, - /* [in] */ DXGI_USAGE Usage, - /* [annotation][in] */ - _In_opt_ const DXGI_SHARED_RESOURCE *pSharedResource, - /* [annotation][out] */ - _COM_Outptr_ IDXGISurface **ppSurface) = 0; - - virtual HRESULT STDMETHODCALLTYPE QueryResourceResidency( - /* [annotation][size_is][in] */ - _In_reads_(NumResources) IUnknown *const *ppResources, - /* [annotation][size_is][out] */ - _Out_writes_(NumResources) DXGI_RESIDENCY *pResidencyStatus, - /* [in] */ UINT NumResources) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetGPUThreadPriority( - /* [in] */ INT Priority) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetGPUThreadPriority( - /* [annotation][retval][out] */ - _Out_ INT *pPriority) = 0; - - }; - - -#else /* C style interface */ - - typedef struct IDXGIDeviceVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGIDevice * This, - /* [in] */ REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGIDevice * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGIDevice * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGIDevice * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [in] */ UINT DataSize, - /* [annotation][in] */ - _In_reads_bytes_(DataSize) const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGIDevice * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][in] */ - _In_opt_ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGIDevice * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][out][in] */ - _Inout_ UINT *pDataSize, - /* [annotation][out] */ - _Out_writes_bytes_(*pDataSize) void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGIDevice * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *GetAdapter )( - IDXGIDevice * This, - /* [annotation][out] */ - _COM_Outptr_ IDXGIAdapter **pAdapter); - - HRESULT ( STDMETHODCALLTYPE *CreateSurface )( - IDXGIDevice * This, - /* [annotation][in] */ - _In_ const DXGI_SURFACE_DESC *pDesc, - /* [in] */ UINT NumSurfaces, - /* [in] */ DXGI_USAGE Usage, - /* [annotation][in] */ - _In_opt_ const DXGI_SHARED_RESOURCE *pSharedResource, - /* [annotation][out] */ - _COM_Outptr_ IDXGISurface **ppSurface); - - HRESULT ( STDMETHODCALLTYPE *QueryResourceResidency )( - IDXGIDevice * This, - /* [annotation][size_is][in] */ - _In_reads_(NumResources) IUnknown *const *ppResources, - /* [annotation][size_is][out] */ - _Out_writes_(NumResources) DXGI_RESIDENCY *pResidencyStatus, - /* [in] */ UINT NumResources); - - HRESULT ( STDMETHODCALLTYPE *SetGPUThreadPriority )( - IDXGIDevice * This, - /* [in] */ INT Priority); - - HRESULT ( STDMETHODCALLTYPE *GetGPUThreadPriority )( - IDXGIDevice * This, - /* [annotation][retval][out] */ - _Out_ INT *pPriority); - - END_INTERFACE - } IDXGIDeviceVtbl; - - interface IDXGIDevice - { - CONST_VTBL struct IDXGIDeviceVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGIDevice_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGIDevice_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGIDevice_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGIDevice_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGIDevice_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGIDevice_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGIDevice_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGIDevice_GetAdapter(This,pAdapter) \ - ( (This)->lpVtbl -> GetAdapter(This,pAdapter) ) - -#define IDXGIDevice_CreateSurface(This,pDesc,NumSurfaces,Usage,pSharedResource,ppSurface) \ - ( (This)->lpVtbl -> CreateSurface(This,pDesc,NumSurfaces,Usage,pSharedResource,ppSurface) ) - -#define IDXGIDevice_QueryResourceResidency(This,ppResources,pResidencyStatus,NumResources) \ - ( (This)->lpVtbl -> QueryResourceResidency(This,ppResources,pResidencyStatus,NumResources) ) - -#define IDXGIDevice_SetGPUThreadPriority(This,Priority) \ - ( (This)->lpVtbl -> SetGPUThreadPriority(This,Priority) ) - -#define IDXGIDevice_GetGPUThreadPriority(This,pPriority) \ - ( (This)->lpVtbl -> GetGPUThreadPriority(This,pPriority) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGIDevice_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxgi_0000_0011 */ -/* [local] */ - -typedef -enum DXGI_ADAPTER_FLAG - { - DXGI_ADAPTER_FLAG_NONE = 0, - DXGI_ADAPTER_FLAG_REMOTE = 1, - DXGI_ADAPTER_FLAG_SOFTWARE = 2, - DXGI_ADAPTER_FLAG_FORCE_DWORD = 0xffffffff - } DXGI_ADAPTER_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; - -typedef struct DXGI_DISPLAY_COLOR_SPACE - { - FLOAT PrimaryCoordinates[ 8 ][ 2 ]; - FLOAT WhitePoints[ 16 ][ 2 ]; - } DXGI_DISPLAY_COLOR_SPACE; - - - - -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0011_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0011_v0_0_s_ifspec; - -#ifndef __IDXGIFactory1_INTERFACE_DEFINED__ -#define __IDXGIFactory1_INTERFACE_DEFINED__ - -/* interface IDXGIFactory1 */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGIFactory1; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("770aae78-f26f-4dba-a829-253c83d1b387") - IDXGIFactory1 : public IDXGIFactory - { - public: - virtual HRESULT STDMETHODCALLTYPE EnumAdapters1( - /* [in] */ UINT Adapter, - /* [annotation][out] */ - _COM_Outptr_ IDXGIAdapter1 **ppAdapter) = 0; - - virtual BOOL STDMETHODCALLTYPE IsCurrent( void) = 0; - - }; - - -#else /* C style interface */ - - typedef struct IDXGIFactory1Vtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGIFactory1 * This, - /* [in] */ REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGIFactory1 * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGIFactory1 * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGIFactory1 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [in] */ UINT DataSize, - /* [annotation][in] */ - _In_reads_bytes_(DataSize) const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGIFactory1 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][in] */ - _In_opt_ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGIFactory1 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][out][in] */ - _Inout_ UINT *pDataSize, - /* [annotation][out] */ - _Out_writes_bytes_(*pDataSize) void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGIFactory1 * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *EnumAdapters )( - IDXGIFactory1 * This, - /* [in] */ UINT Adapter, - /* [annotation][out] */ - _COM_Outptr_ IDXGIAdapter **ppAdapter); - - HRESULT ( STDMETHODCALLTYPE *MakeWindowAssociation )( - IDXGIFactory1 * This, - HWND WindowHandle, - UINT Flags); - - HRESULT ( STDMETHODCALLTYPE *GetWindowAssociation )( - IDXGIFactory1 * This, - /* [annotation][out] */ - _Out_ HWND *pWindowHandle); - - HRESULT ( STDMETHODCALLTYPE *CreateSwapChain )( - IDXGIFactory1 * This, - /* [annotation][in] */ - _In_ IUnknown *pDevice, - /* [annotation][in] */ - _In_ DXGI_SWAP_CHAIN_DESC *pDesc, - /* [annotation][out] */ - _COM_Outptr_ IDXGISwapChain **ppSwapChain); - - HRESULT ( STDMETHODCALLTYPE *CreateSoftwareAdapter )( - IDXGIFactory1 * This, - /* [in] */ HMODULE Module, - /* [annotation][out] */ - _COM_Outptr_ IDXGIAdapter **ppAdapter); - - HRESULT ( STDMETHODCALLTYPE *EnumAdapters1 )( - IDXGIFactory1 * This, - /* [in] */ UINT Adapter, - /* [annotation][out] */ - _COM_Outptr_ IDXGIAdapter1 **ppAdapter); - - BOOL ( STDMETHODCALLTYPE *IsCurrent )( - IDXGIFactory1 * This); - - END_INTERFACE - } IDXGIFactory1Vtbl; - - interface IDXGIFactory1 - { - CONST_VTBL struct IDXGIFactory1Vtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGIFactory1_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGIFactory1_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGIFactory1_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGIFactory1_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGIFactory1_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGIFactory1_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGIFactory1_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGIFactory1_EnumAdapters(This,Adapter,ppAdapter) \ - ( (This)->lpVtbl -> EnumAdapters(This,Adapter,ppAdapter) ) - -#define IDXGIFactory1_MakeWindowAssociation(This,WindowHandle,Flags) \ - ( (This)->lpVtbl -> MakeWindowAssociation(This,WindowHandle,Flags) ) - -#define IDXGIFactory1_GetWindowAssociation(This,pWindowHandle) \ - ( (This)->lpVtbl -> GetWindowAssociation(This,pWindowHandle) ) - -#define IDXGIFactory1_CreateSwapChain(This,pDevice,pDesc,ppSwapChain) \ - ( (This)->lpVtbl -> CreateSwapChain(This,pDevice,pDesc,ppSwapChain) ) - -#define IDXGIFactory1_CreateSoftwareAdapter(This,Module,ppAdapter) \ - ( (This)->lpVtbl -> CreateSoftwareAdapter(This,Module,ppAdapter) ) - - -#define IDXGIFactory1_EnumAdapters1(This,Adapter,ppAdapter) \ - ( (This)->lpVtbl -> EnumAdapters1(This,Adapter,ppAdapter) ) - -#define IDXGIFactory1_IsCurrent(This) \ - ( (This)->lpVtbl -> IsCurrent(This) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGIFactory1_INTERFACE_DEFINED__ */ - - -#ifndef __IDXGIAdapter1_INTERFACE_DEFINED__ -#define __IDXGIAdapter1_INTERFACE_DEFINED__ - -/* interface IDXGIAdapter1 */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGIAdapter1; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("29038f61-3839-4626-91fd-086879011a05") - IDXGIAdapter1 : public IDXGIAdapter - { - public: - virtual HRESULT STDMETHODCALLTYPE GetDesc1( - /* [annotation][out] */ - _Out_ DXGI_ADAPTER_DESC1 *pDesc) = 0; - - }; - - -#else /* C style interface */ - - typedef struct IDXGIAdapter1Vtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGIAdapter1 * This, - /* [in] */ REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGIAdapter1 * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGIAdapter1 * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGIAdapter1 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [in] */ UINT DataSize, - /* [annotation][in] */ - _In_reads_bytes_(DataSize) const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGIAdapter1 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][in] */ - _In_opt_ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGIAdapter1 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][out][in] */ - _Inout_ UINT *pDataSize, - /* [annotation][out] */ - _Out_writes_bytes_(*pDataSize) void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGIAdapter1 * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *EnumOutputs )( - IDXGIAdapter1 * This, - /* [in] */ UINT Output, - /* [annotation][out][in] */ - _COM_Outptr_ IDXGIOutput **ppOutput); - - HRESULT ( STDMETHODCALLTYPE *GetDesc )( - IDXGIAdapter1 * This, - /* [annotation][out] */ - _Out_ DXGI_ADAPTER_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *CheckInterfaceSupport )( - IDXGIAdapter1 * This, - /* [annotation][in] */ - _In_ REFGUID InterfaceName, - /* [annotation][out] */ - _Out_ LARGE_INTEGER *pUMDVersion); - - HRESULT ( STDMETHODCALLTYPE *GetDesc1 )( - IDXGIAdapter1 * This, - /* [annotation][out] */ - _Out_ DXGI_ADAPTER_DESC1 *pDesc); - - END_INTERFACE - } IDXGIAdapter1Vtbl; - - interface IDXGIAdapter1 - { - CONST_VTBL struct IDXGIAdapter1Vtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGIAdapter1_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGIAdapter1_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGIAdapter1_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGIAdapter1_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGIAdapter1_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGIAdapter1_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGIAdapter1_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGIAdapter1_EnumOutputs(This,Output,ppOutput) \ - ( (This)->lpVtbl -> EnumOutputs(This,Output,ppOutput) ) - -#define IDXGIAdapter1_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#define IDXGIAdapter1_CheckInterfaceSupport(This,InterfaceName,pUMDVersion) \ - ( (This)->lpVtbl -> CheckInterfaceSupport(This,InterfaceName,pUMDVersion) ) - - -#define IDXGIAdapter1_GetDesc1(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc1(This,pDesc) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGIAdapter1_INTERFACE_DEFINED__ */ - - -#ifndef __IDXGIDevice1_INTERFACE_DEFINED__ -#define __IDXGIDevice1_INTERFACE_DEFINED__ - -/* interface IDXGIDevice1 */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGIDevice1; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("77db970f-6276-48ba-ba28-070143b4392c") - IDXGIDevice1 : public IDXGIDevice - { - public: - virtual HRESULT STDMETHODCALLTYPE SetMaximumFrameLatency( - /* [in] */ UINT MaxLatency) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetMaximumFrameLatency( - /* [annotation][out] */ - _Out_ UINT *pMaxLatency) = 0; - - }; - - -#else /* C style interface */ - - typedef struct IDXGIDevice1Vtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGIDevice1 * This, - /* [in] */ REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGIDevice1 * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGIDevice1 * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGIDevice1 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [in] */ UINT DataSize, - /* [annotation][in] */ - _In_reads_bytes_(DataSize) const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGIDevice1 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][in] */ - _In_opt_ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGIDevice1 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][out][in] */ - _Inout_ UINT *pDataSize, - /* [annotation][out] */ - _Out_writes_bytes_(*pDataSize) void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGIDevice1 * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *GetAdapter )( - IDXGIDevice1 * This, - /* [annotation][out] */ - _COM_Outptr_ IDXGIAdapter **pAdapter); - - HRESULT ( STDMETHODCALLTYPE *CreateSurface )( - IDXGIDevice1 * This, - /* [annotation][in] */ - _In_ const DXGI_SURFACE_DESC *pDesc, - /* [in] */ UINT NumSurfaces, - /* [in] */ DXGI_USAGE Usage, - /* [annotation][in] */ - _In_opt_ const DXGI_SHARED_RESOURCE *pSharedResource, - /* [annotation][out] */ - _COM_Outptr_ IDXGISurface **ppSurface); - - HRESULT ( STDMETHODCALLTYPE *QueryResourceResidency )( - IDXGIDevice1 * This, - /* [annotation][size_is][in] */ - _In_reads_(NumResources) IUnknown *const *ppResources, - /* [annotation][size_is][out] */ - _Out_writes_(NumResources) DXGI_RESIDENCY *pResidencyStatus, - /* [in] */ UINT NumResources); - - HRESULT ( STDMETHODCALLTYPE *SetGPUThreadPriority )( - IDXGIDevice1 * This, - /* [in] */ INT Priority); - - HRESULT ( STDMETHODCALLTYPE *GetGPUThreadPriority )( - IDXGIDevice1 * This, - /* [annotation][retval][out] */ - _Out_ INT *pPriority); - - HRESULT ( STDMETHODCALLTYPE *SetMaximumFrameLatency )( - IDXGIDevice1 * This, - /* [in] */ UINT MaxLatency); - - HRESULT ( STDMETHODCALLTYPE *GetMaximumFrameLatency )( - IDXGIDevice1 * This, - /* [annotation][out] */ - _Out_ UINT *pMaxLatency); - - END_INTERFACE - } IDXGIDevice1Vtbl; - - interface IDXGIDevice1 - { - CONST_VTBL struct IDXGIDevice1Vtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGIDevice1_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGIDevice1_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGIDevice1_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGIDevice1_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGIDevice1_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGIDevice1_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGIDevice1_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGIDevice1_GetAdapter(This,pAdapter) \ - ( (This)->lpVtbl -> GetAdapter(This,pAdapter) ) - -#define IDXGIDevice1_CreateSurface(This,pDesc,NumSurfaces,Usage,pSharedResource,ppSurface) \ - ( (This)->lpVtbl -> CreateSurface(This,pDesc,NumSurfaces,Usage,pSharedResource,ppSurface) ) - -#define IDXGIDevice1_QueryResourceResidency(This,ppResources,pResidencyStatus,NumResources) \ - ( (This)->lpVtbl -> QueryResourceResidency(This,ppResources,pResidencyStatus,NumResources) ) - -#define IDXGIDevice1_SetGPUThreadPriority(This,Priority) \ - ( (This)->lpVtbl -> SetGPUThreadPriority(This,Priority) ) - -#define IDXGIDevice1_GetGPUThreadPriority(This,pPriority) \ - ( (This)->lpVtbl -> GetGPUThreadPriority(This,pPriority) ) - - -#define IDXGIDevice1_SetMaximumFrameLatency(This,MaxLatency) \ - ( (This)->lpVtbl -> SetMaximumFrameLatency(This,MaxLatency) ) - -#define IDXGIDevice1_GetMaximumFrameLatency(This,pMaxLatency) \ - ( (This)->lpVtbl -> GetMaximumFrameLatency(This,pMaxLatency) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGIDevice1_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxgi_0000_0014 */ -/* [local] */ - -#ifdef __cplusplus -#endif /*__cplusplus*/ -DEFINE_GUID(IID_IDXGIObject,0xaec22fb8,0x76f3,0x4639,0x9b,0xe0,0x28,0xeb,0x43,0xa6,0x7a,0x2e); -DEFINE_GUID(IID_IDXGIDeviceSubObject,0x3d3e0379,0xf9de,0x4d58,0xbb,0x6c,0x18,0xd6,0x29,0x92,0xf1,0xa6); -DEFINE_GUID(IID_IDXGIResource,0x035f3ab4,0x482e,0x4e50,0xb4,0x1f,0x8a,0x7f,0x8b,0xd8,0x96,0x0b); -DEFINE_GUID(IID_IDXGIKeyedMutex,0x9d8e1289,0xd7b3,0x465f,0x81,0x26,0x25,0x0e,0x34,0x9a,0xf8,0x5d); -DEFINE_GUID(IID_IDXGISurface,0xcafcb56c,0x6ac3,0x4889,0xbf,0x47,0x9e,0x23,0xbb,0xd2,0x60,0xec); -DEFINE_GUID(IID_IDXGISurface1,0x4AE63092,0x6327,0x4c1b,0x80,0xAE,0xBF,0xE1,0x2E,0xA3,0x2B,0x86); -DEFINE_GUID(IID_IDXGIAdapter,0x2411e7e1,0x12ac,0x4ccf,0xbd,0x14,0x97,0x98,0xe8,0x53,0x4d,0xc0); -DEFINE_GUID(IID_IDXGIOutput,0xae02eedb,0xc735,0x4690,0x8d,0x52,0x5a,0x8d,0xc2,0x02,0x13,0xaa); -DEFINE_GUID(IID_IDXGISwapChain,0x310d36a0,0xd2e7,0x4c0a,0xaa,0x04,0x6a,0x9d,0x23,0xb8,0x88,0x6a); -DEFINE_GUID(IID_IDXGIFactory,0x7b7166ec,0x21c7,0x44ae,0xb2,0x1a,0xc9,0xae,0x32,0x1a,0xe3,0x69); -DEFINE_GUID(IID_IDXGIDevice,0x54ec77fa,0x1377,0x44e6,0x8c,0x32,0x88,0xfd,0x5f,0x44,0xc8,0x4c); -DEFINE_GUID(IID_IDXGIFactory1,0x770aae78,0xf26f,0x4dba,0xa8,0x29,0x25,0x3c,0x83,0xd1,0xb3,0x87); -DEFINE_GUID(IID_IDXGIAdapter1,0x29038f61,0x3839,0x4626,0x91,0xfd,0x08,0x68,0x79,0x01,0x1a,0x05); -DEFINE_GUID(IID_IDXGIDevice1,0x77db970f,0x6276,0x48ba,0xba,0x28,0x07,0x01,0x43,0xb4,0x39,0x2c); - - -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0014_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0014_v0_0_s_ifspec; - -/* Additional Prototypes for ALL interfaces */ - -/* end of Additional Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/include/dxsdk/dxgi1_4.h b/include/dxsdk/dxgi1_4.h deleted file mode 100644 index ce48d9c7..00000000 --- a/include/dxsdk/dxgi1_4.h +++ /dev/null @@ -1,1494 +0,0 @@ - - -/* this ALWAYS GENERATED file contains the definitions for the interfaces */ - - - /* File created by MIDL compiler version 8.01.0622 */ -/* @@MIDL_FILE_HEADING( ) */ - - - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCNDR_H_VERSION__ -#define __REQUIRED_RPCNDR_H_VERSION__ 500 -#endif - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCSAL_H_VERSION__ -#define __REQUIRED_RPCSAL_H_VERSION__ 100 -#endif - -#include "rpc.h" -#include "rpcndr.h" - -#ifndef __RPCNDR_H_VERSION__ -#error this stub requires an updated version of -#endif /* __RPCNDR_H_VERSION__ */ - -#ifndef COM_NO_WINDOWS_H -#include "windows.h" -#include "ole2.h" -#endif /*COM_NO_WINDOWS_H*/ - -#ifndef __dxgi1_4_h__ -#define __dxgi1_4_h__ - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -#pragma once -#endif - -/* Forward Declarations */ - -#ifndef __IDXGISwapChain3_FWD_DEFINED__ -#define __IDXGISwapChain3_FWD_DEFINED__ -typedef interface IDXGISwapChain3 IDXGISwapChain3; - -#endif /* __IDXGISwapChain3_FWD_DEFINED__ */ - - -#ifndef __IDXGIOutput4_FWD_DEFINED__ -#define __IDXGIOutput4_FWD_DEFINED__ -typedef interface IDXGIOutput4 IDXGIOutput4; - -#endif /* __IDXGIOutput4_FWD_DEFINED__ */ - - -#ifndef __IDXGIFactory4_FWD_DEFINED__ -#define __IDXGIFactory4_FWD_DEFINED__ -typedef interface IDXGIFactory4 IDXGIFactory4; - -#endif /* __IDXGIFactory4_FWD_DEFINED__ */ - - -#ifndef __IDXGIAdapter3_FWD_DEFINED__ -#define __IDXGIAdapter3_FWD_DEFINED__ -typedef interface IDXGIAdapter3 IDXGIAdapter3; - -#endif /* __IDXGIAdapter3_FWD_DEFINED__ */ - - -/* header files for imported files */ -#include "dxgi1_3.h" - -#ifdef __cplusplus -extern "C"{ -#endif - - -/* interface __MIDL_itf_dxgi1_4_0000_0000 */ -/* [local] */ - -#include -#pragma region App Family -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_GAMES) -typedef -enum DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG - { - DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG_PRESENT = 0x1, - DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG_OVERLAY_PRESENT = 0x2 - } DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG; - - - -extern RPC_IF_HANDLE __MIDL_itf_dxgi1_4_0000_0000_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxgi1_4_0000_0000_v0_0_s_ifspec; - -#ifndef __IDXGISwapChain3_INTERFACE_DEFINED__ -#define __IDXGISwapChain3_INTERFACE_DEFINED__ - -/* interface IDXGISwapChain3 */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGISwapChain3; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("94d99bdb-f1f8-4ab0-b236-7da0170edab1") - IDXGISwapChain3 : public IDXGISwapChain2 - { - public: - virtual UINT STDMETHODCALLTYPE GetCurrentBackBufferIndex( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE CheckColorSpaceSupport( - /* [annotation][in] */ - _In_ DXGI_COLOR_SPACE_TYPE ColorSpace, - /* [annotation][out] */ - _Out_ UINT *pColorSpaceSupport) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetColorSpace1( - /* [annotation][in] */ - _In_ DXGI_COLOR_SPACE_TYPE ColorSpace) = 0; - - virtual HRESULT STDMETHODCALLTYPE ResizeBuffers1( - /* [annotation][in] */ - _In_ UINT BufferCount, - /* [annotation][in] */ - _In_ UINT Width, - /* [annotation][in] */ - _In_ UINT Height, - /* [annotation][in] */ - _In_ DXGI_FORMAT Format, - /* [annotation][in] */ - _In_ UINT SwapChainFlags, - /* [annotation][in] */ - _In_reads_(BufferCount) const UINT *pCreationNodeMask, - /* [annotation][in] */ - _In_reads_(BufferCount) IUnknown *const *ppPresentQueue) = 0; - - }; - - -#else /* C style interface */ - - typedef struct IDXGISwapChain3Vtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGISwapChain3 * This, - /* [in] */ REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGISwapChain3 * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGISwapChain3 * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGISwapChain3 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [in] */ UINT DataSize, - /* [annotation][in] */ - _In_reads_bytes_(DataSize) const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGISwapChain3 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][in] */ - _In_opt_ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGISwapChain3 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][out][in] */ - _Inout_ UINT *pDataSize, - /* [annotation][out] */ - _Out_writes_bytes_(*pDataSize) void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGISwapChain3 * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *GetDevice )( - IDXGISwapChain3 * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppDevice); - - HRESULT ( STDMETHODCALLTYPE *Present )( - IDXGISwapChain3 * This, - /* [in] */ UINT SyncInterval, - /* [in] */ UINT Flags); - - HRESULT ( STDMETHODCALLTYPE *GetBuffer )( - IDXGISwapChain3 * This, - /* [in] */ UINT Buffer, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][out][in] */ - _COM_Outptr_ void **ppSurface); - - HRESULT ( STDMETHODCALLTYPE *SetFullscreenState )( - IDXGISwapChain3 * This, - /* [in] */ BOOL Fullscreen, - /* [annotation][in] */ - _In_opt_ IDXGIOutput *pTarget); - - HRESULT ( STDMETHODCALLTYPE *GetFullscreenState )( - IDXGISwapChain3 * This, - /* [annotation][out] */ - _Out_opt_ BOOL *pFullscreen, - /* [annotation][out] */ - _COM_Outptr_opt_result_maybenull_ IDXGIOutput **ppTarget); - - HRESULT ( STDMETHODCALLTYPE *GetDesc )( - IDXGISwapChain3 * This, - /* [annotation][out] */ - _Out_ DXGI_SWAP_CHAIN_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *ResizeBuffers )( - IDXGISwapChain3 * This, - /* [in] */ UINT BufferCount, - /* [in] */ UINT Width, - /* [in] */ UINT Height, - /* [in] */ DXGI_FORMAT NewFormat, - /* [in] */ UINT SwapChainFlags); - - HRESULT ( STDMETHODCALLTYPE *ResizeTarget )( - IDXGISwapChain3 * This, - /* [annotation][in] */ - _In_ const DXGI_MODE_DESC *pNewTargetParameters); - - HRESULT ( STDMETHODCALLTYPE *GetContainingOutput )( - IDXGISwapChain3 * This, - /* [annotation][out] */ - _COM_Outptr_ IDXGIOutput **ppOutput); - - HRESULT ( STDMETHODCALLTYPE *GetFrameStatistics )( - IDXGISwapChain3 * This, - /* [annotation][out] */ - _Out_ DXGI_FRAME_STATISTICS *pStats); - - HRESULT ( STDMETHODCALLTYPE *GetLastPresentCount )( - IDXGISwapChain3 * This, - /* [annotation][out] */ - _Out_ UINT *pLastPresentCount); - - HRESULT ( STDMETHODCALLTYPE *GetDesc1 )( - IDXGISwapChain3 * This, - /* [annotation][out] */ - _Out_ DXGI_SWAP_CHAIN_DESC1 *pDesc); - - HRESULT ( STDMETHODCALLTYPE *GetFullscreenDesc )( - IDXGISwapChain3 * This, - /* [annotation][out] */ - _Out_ DXGI_SWAP_CHAIN_FULLSCREEN_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *GetHwnd )( - IDXGISwapChain3 * This, - /* [annotation][out] */ - _Out_ HWND *pHwnd); - - HRESULT ( STDMETHODCALLTYPE *GetCoreWindow )( - IDXGISwapChain3 * This, - /* [annotation][in] */ - _In_ REFIID refiid, - /* [annotation][out] */ - _COM_Outptr_ void **ppUnk); - - HRESULT ( STDMETHODCALLTYPE *Present1 )( - IDXGISwapChain3 * This, - /* [in] */ UINT SyncInterval, - /* [in] */ UINT PresentFlags, - /* [annotation][in] */ - _In_ const DXGI_PRESENT_PARAMETERS *pPresentParameters); - - BOOL ( STDMETHODCALLTYPE *IsTemporaryMonoSupported )( - IDXGISwapChain3 * This); - - HRESULT ( STDMETHODCALLTYPE *GetRestrictToOutput )( - IDXGISwapChain3 * This, - /* [annotation][out] */ - _Out_ IDXGIOutput **ppRestrictToOutput); - - HRESULT ( STDMETHODCALLTYPE *SetBackgroundColor )( - IDXGISwapChain3 * This, - /* [annotation][in] */ - _In_ const DXGI_RGBA *pColor); - - HRESULT ( STDMETHODCALLTYPE *GetBackgroundColor )( - IDXGISwapChain3 * This, - /* [annotation][out] */ - _Out_ DXGI_RGBA *pColor); - - HRESULT ( STDMETHODCALLTYPE *SetRotation )( - IDXGISwapChain3 * This, - /* [annotation][in] */ - _In_ DXGI_MODE_ROTATION Rotation); - - HRESULT ( STDMETHODCALLTYPE *GetRotation )( - IDXGISwapChain3 * This, - /* [annotation][out] */ - _Out_ DXGI_MODE_ROTATION *pRotation); - - HRESULT ( STDMETHODCALLTYPE *SetSourceSize )( - IDXGISwapChain3 * This, - UINT Width, - UINT Height); - - HRESULT ( STDMETHODCALLTYPE *GetSourceSize )( - IDXGISwapChain3 * This, - /* [annotation][out] */ - _Out_ UINT *pWidth, - /* [annotation][out] */ - _Out_ UINT *pHeight); - - HRESULT ( STDMETHODCALLTYPE *SetMaximumFrameLatency )( - IDXGISwapChain3 * This, - UINT MaxLatency); - - HRESULT ( STDMETHODCALLTYPE *GetMaximumFrameLatency )( - IDXGISwapChain3 * This, - /* [annotation][out] */ - _Out_ UINT *pMaxLatency); - - HANDLE ( STDMETHODCALLTYPE *GetFrameLatencyWaitableObject )( - IDXGISwapChain3 * This); - - HRESULT ( STDMETHODCALLTYPE *SetMatrixTransform )( - IDXGISwapChain3 * This, - const DXGI_MATRIX_3X2_F *pMatrix); - - HRESULT ( STDMETHODCALLTYPE *GetMatrixTransform )( - IDXGISwapChain3 * This, - /* [annotation][out] */ - _Out_ DXGI_MATRIX_3X2_F *pMatrix); - - UINT ( STDMETHODCALLTYPE *GetCurrentBackBufferIndex )( - IDXGISwapChain3 * This); - - HRESULT ( STDMETHODCALLTYPE *CheckColorSpaceSupport )( - IDXGISwapChain3 * This, - /* [annotation][in] */ - _In_ DXGI_COLOR_SPACE_TYPE ColorSpace, - /* [annotation][out] */ - _Out_ UINT *pColorSpaceSupport); - - HRESULT ( STDMETHODCALLTYPE *SetColorSpace1 )( - IDXGISwapChain3 * This, - /* [annotation][in] */ - _In_ DXGI_COLOR_SPACE_TYPE ColorSpace); - - HRESULT ( STDMETHODCALLTYPE *ResizeBuffers1 )( - IDXGISwapChain3 * This, - /* [annotation][in] */ - _In_ UINT BufferCount, - /* [annotation][in] */ - _In_ UINT Width, - /* [annotation][in] */ - _In_ UINT Height, - /* [annotation][in] */ - _In_ DXGI_FORMAT Format, - /* [annotation][in] */ - _In_ UINT SwapChainFlags, - /* [annotation][in] */ - _In_reads_(BufferCount) const UINT *pCreationNodeMask, - /* [annotation][in] */ - _In_reads_(BufferCount) IUnknown *const *ppPresentQueue); - - END_INTERFACE - } IDXGISwapChain3Vtbl; - - interface IDXGISwapChain3 - { - CONST_VTBL struct IDXGISwapChain3Vtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGISwapChain3_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGISwapChain3_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGISwapChain3_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGISwapChain3_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGISwapChain3_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGISwapChain3_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGISwapChain3_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGISwapChain3_GetDevice(This,riid,ppDevice) \ - ( (This)->lpVtbl -> GetDevice(This,riid,ppDevice) ) - - -#define IDXGISwapChain3_Present(This,SyncInterval,Flags) \ - ( (This)->lpVtbl -> Present(This,SyncInterval,Flags) ) - -#define IDXGISwapChain3_GetBuffer(This,Buffer,riid,ppSurface) \ - ( (This)->lpVtbl -> GetBuffer(This,Buffer,riid,ppSurface) ) - -#define IDXGISwapChain3_SetFullscreenState(This,Fullscreen,pTarget) \ - ( (This)->lpVtbl -> SetFullscreenState(This,Fullscreen,pTarget) ) - -#define IDXGISwapChain3_GetFullscreenState(This,pFullscreen,ppTarget) \ - ( (This)->lpVtbl -> GetFullscreenState(This,pFullscreen,ppTarget) ) - -#define IDXGISwapChain3_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#define IDXGISwapChain3_ResizeBuffers(This,BufferCount,Width,Height,NewFormat,SwapChainFlags) \ - ( (This)->lpVtbl -> ResizeBuffers(This,BufferCount,Width,Height,NewFormat,SwapChainFlags) ) - -#define IDXGISwapChain3_ResizeTarget(This,pNewTargetParameters) \ - ( (This)->lpVtbl -> ResizeTarget(This,pNewTargetParameters) ) - -#define IDXGISwapChain3_GetContainingOutput(This,ppOutput) \ - ( (This)->lpVtbl -> GetContainingOutput(This,ppOutput) ) - -#define IDXGISwapChain3_GetFrameStatistics(This,pStats) \ - ( (This)->lpVtbl -> GetFrameStatistics(This,pStats) ) - -#define IDXGISwapChain3_GetLastPresentCount(This,pLastPresentCount) \ - ( (This)->lpVtbl -> GetLastPresentCount(This,pLastPresentCount) ) - - -#define IDXGISwapChain3_GetDesc1(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc1(This,pDesc) ) - -#define IDXGISwapChain3_GetFullscreenDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetFullscreenDesc(This,pDesc) ) - -#define IDXGISwapChain3_GetHwnd(This,pHwnd) \ - ( (This)->lpVtbl -> GetHwnd(This,pHwnd) ) - -#define IDXGISwapChain3_GetCoreWindow(This,refiid,ppUnk) \ - ( (This)->lpVtbl -> GetCoreWindow(This,refiid,ppUnk) ) - -#define IDXGISwapChain3_Present1(This,SyncInterval,PresentFlags,pPresentParameters) \ - ( (This)->lpVtbl -> Present1(This,SyncInterval,PresentFlags,pPresentParameters) ) - -#define IDXGISwapChain3_IsTemporaryMonoSupported(This) \ - ( (This)->lpVtbl -> IsTemporaryMonoSupported(This) ) - -#define IDXGISwapChain3_GetRestrictToOutput(This,ppRestrictToOutput) \ - ( (This)->lpVtbl -> GetRestrictToOutput(This,ppRestrictToOutput) ) - -#define IDXGISwapChain3_SetBackgroundColor(This,pColor) \ - ( (This)->lpVtbl -> SetBackgroundColor(This,pColor) ) - -#define IDXGISwapChain3_GetBackgroundColor(This,pColor) \ - ( (This)->lpVtbl -> GetBackgroundColor(This,pColor) ) - -#define IDXGISwapChain3_SetRotation(This,Rotation) \ - ( (This)->lpVtbl -> SetRotation(This,Rotation) ) - -#define IDXGISwapChain3_GetRotation(This,pRotation) \ - ( (This)->lpVtbl -> GetRotation(This,pRotation) ) - - -#define IDXGISwapChain3_SetSourceSize(This,Width,Height) \ - ( (This)->lpVtbl -> SetSourceSize(This,Width,Height) ) - -#define IDXGISwapChain3_GetSourceSize(This,pWidth,pHeight) \ - ( (This)->lpVtbl -> GetSourceSize(This,pWidth,pHeight) ) - -#define IDXGISwapChain3_SetMaximumFrameLatency(This,MaxLatency) \ - ( (This)->lpVtbl -> SetMaximumFrameLatency(This,MaxLatency) ) - -#define IDXGISwapChain3_GetMaximumFrameLatency(This,pMaxLatency) \ - ( (This)->lpVtbl -> GetMaximumFrameLatency(This,pMaxLatency) ) - -#define IDXGISwapChain3_GetFrameLatencyWaitableObject(This) \ - ( (This)->lpVtbl -> GetFrameLatencyWaitableObject(This) ) - -#define IDXGISwapChain3_SetMatrixTransform(This,pMatrix) \ - ( (This)->lpVtbl -> SetMatrixTransform(This,pMatrix) ) - -#define IDXGISwapChain3_GetMatrixTransform(This,pMatrix) \ - ( (This)->lpVtbl -> GetMatrixTransform(This,pMatrix) ) - - -#define IDXGISwapChain3_GetCurrentBackBufferIndex(This) \ - ( (This)->lpVtbl -> GetCurrentBackBufferIndex(This) ) - -#define IDXGISwapChain3_CheckColorSpaceSupport(This,ColorSpace,pColorSpaceSupport) \ - ( (This)->lpVtbl -> CheckColorSpaceSupport(This,ColorSpace,pColorSpaceSupport) ) - -#define IDXGISwapChain3_SetColorSpace1(This,ColorSpace) \ - ( (This)->lpVtbl -> SetColorSpace1(This,ColorSpace) ) - -#define IDXGISwapChain3_ResizeBuffers1(This,BufferCount,Width,Height,Format,SwapChainFlags,pCreationNodeMask,ppPresentQueue) \ - ( (This)->lpVtbl -> ResizeBuffers1(This,BufferCount,Width,Height,Format,SwapChainFlags,pCreationNodeMask,ppPresentQueue) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGISwapChain3_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxgi1_4_0000_0001 */ -/* [local] */ - -typedef -enum DXGI_OVERLAY_COLOR_SPACE_SUPPORT_FLAG - { - DXGI_OVERLAY_COLOR_SPACE_SUPPORT_FLAG_PRESENT = 0x1 - } DXGI_OVERLAY_COLOR_SPACE_SUPPORT_FLAG; - - - -extern RPC_IF_HANDLE __MIDL_itf_dxgi1_4_0000_0001_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxgi1_4_0000_0001_v0_0_s_ifspec; - -#ifndef __IDXGIOutput4_INTERFACE_DEFINED__ -#define __IDXGIOutput4_INTERFACE_DEFINED__ - -/* interface IDXGIOutput4 */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGIOutput4; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("dc7dca35-2196-414d-9F53-617884032a60") - IDXGIOutput4 : public IDXGIOutput3 - { - public: - virtual HRESULT STDMETHODCALLTYPE CheckOverlayColorSpaceSupport( - /* [annotation][in] */ - _In_ DXGI_FORMAT Format, - /* [annotation][in] */ - _In_ DXGI_COLOR_SPACE_TYPE ColorSpace, - /* [annotation][in] */ - _In_ IUnknown *pConcernedDevice, - /* [annotation][out] */ - _Out_ UINT *pFlags) = 0; - - }; - - -#else /* C style interface */ - - typedef struct IDXGIOutput4Vtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGIOutput4 * This, - /* [in] */ REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGIOutput4 * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGIOutput4 * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGIOutput4 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [in] */ UINT DataSize, - /* [annotation][in] */ - _In_reads_bytes_(DataSize) const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGIOutput4 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][in] */ - _In_opt_ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGIOutput4 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][out][in] */ - _Inout_ UINT *pDataSize, - /* [annotation][out] */ - _Out_writes_bytes_(*pDataSize) void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGIOutput4 * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *GetDesc )( - IDXGIOutput4 * This, - /* [annotation][out] */ - _Out_ DXGI_OUTPUT_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *GetDisplayModeList )( - IDXGIOutput4 * This, - /* [in] */ DXGI_FORMAT EnumFormat, - /* [in] */ UINT Flags, - /* [annotation][out][in] */ - _Inout_ UINT *pNumModes, - /* [annotation][out] */ - _Out_writes_to_opt_(*pNumModes,*pNumModes) DXGI_MODE_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *FindClosestMatchingMode )( - IDXGIOutput4 * This, - /* [annotation][in] */ - _In_ const DXGI_MODE_DESC *pModeToMatch, - /* [annotation][out] */ - _Out_ DXGI_MODE_DESC *pClosestMatch, - /* [annotation][in] */ - _In_opt_ IUnknown *pConcernedDevice); - - HRESULT ( STDMETHODCALLTYPE *WaitForVBlank )( - IDXGIOutput4 * This); - - HRESULT ( STDMETHODCALLTYPE *TakeOwnership )( - IDXGIOutput4 * This, - /* [annotation][in] */ - _In_ IUnknown *pDevice, - BOOL Exclusive); - - void ( STDMETHODCALLTYPE *ReleaseOwnership )( - IDXGIOutput4 * This); - - HRESULT ( STDMETHODCALLTYPE *GetGammaControlCapabilities )( - IDXGIOutput4 * This, - /* [annotation][out] */ - _Out_ DXGI_GAMMA_CONTROL_CAPABILITIES *pGammaCaps); - - HRESULT ( STDMETHODCALLTYPE *SetGammaControl )( - IDXGIOutput4 * This, - /* [annotation][in] */ - _In_ const DXGI_GAMMA_CONTROL *pArray); - - HRESULT ( STDMETHODCALLTYPE *GetGammaControl )( - IDXGIOutput4 * This, - /* [annotation][out] */ - _Out_ DXGI_GAMMA_CONTROL *pArray); - - HRESULT ( STDMETHODCALLTYPE *SetDisplaySurface )( - IDXGIOutput4 * This, - /* [annotation][in] */ - _In_ IDXGISurface *pScanoutSurface); - - HRESULT ( STDMETHODCALLTYPE *GetDisplaySurfaceData )( - IDXGIOutput4 * This, - /* [annotation][in] */ - _In_ IDXGISurface *pDestination); - - HRESULT ( STDMETHODCALLTYPE *GetFrameStatistics )( - IDXGIOutput4 * This, - /* [annotation][out] */ - _Out_ DXGI_FRAME_STATISTICS *pStats); - - HRESULT ( STDMETHODCALLTYPE *GetDisplayModeList1 )( - IDXGIOutput4 * This, - /* [in] */ DXGI_FORMAT EnumFormat, - /* [in] */ UINT Flags, - /* [annotation][out][in] */ - _Inout_ UINT *pNumModes, - /* [annotation][out] */ - _Out_writes_to_opt_(*pNumModes,*pNumModes) DXGI_MODE_DESC1 *pDesc); - - HRESULT ( STDMETHODCALLTYPE *FindClosestMatchingMode1 )( - IDXGIOutput4 * This, - /* [annotation][in] */ - _In_ const DXGI_MODE_DESC1 *pModeToMatch, - /* [annotation][out] */ - _Out_ DXGI_MODE_DESC1 *pClosestMatch, - /* [annotation][in] */ - _In_opt_ IUnknown *pConcernedDevice); - - HRESULT ( STDMETHODCALLTYPE *GetDisplaySurfaceData1 )( - IDXGIOutput4 * This, - /* [annotation][in] */ - _In_ IDXGIResource *pDestination); - - HRESULT ( STDMETHODCALLTYPE *DuplicateOutput )( - IDXGIOutput4 * This, - /* [annotation][in] */ - _In_ IUnknown *pDevice, - /* [annotation][out] */ - _COM_Outptr_ IDXGIOutputDuplication **ppOutputDuplication); - - BOOL ( STDMETHODCALLTYPE *SupportsOverlays )( - IDXGIOutput4 * This); - - HRESULT ( STDMETHODCALLTYPE *CheckOverlaySupport )( - IDXGIOutput4 * This, - /* [annotation][in] */ - _In_ DXGI_FORMAT EnumFormat, - /* [annotation][out] */ - _In_ IUnknown *pConcernedDevice, - /* [annotation][out] */ - _Out_ UINT *pFlags); - - HRESULT ( STDMETHODCALLTYPE *CheckOverlayColorSpaceSupport )( - IDXGIOutput4 * This, - /* [annotation][in] */ - _In_ DXGI_FORMAT Format, - /* [annotation][in] */ - _In_ DXGI_COLOR_SPACE_TYPE ColorSpace, - /* [annotation][in] */ - _In_ IUnknown *pConcernedDevice, - /* [annotation][out] */ - _Out_ UINT *pFlags); - - END_INTERFACE - } IDXGIOutput4Vtbl; - - interface IDXGIOutput4 - { - CONST_VTBL struct IDXGIOutput4Vtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGIOutput4_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGIOutput4_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGIOutput4_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGIOutput4_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGIOutput4_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGIOutput4_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGIOutput4_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGIOutput4_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#define IDXGIOutput4_GetDisplayModeList(This,EnumFormat,Flags,pNumModes,pDesc) \ - ( (This)->lpVtbl -> GetDisplayModeList(This,EnumFormat,Flags,pNumModes,pDesc) ) - -#define IDXGIOutput4_FindClosestMatchingMode(This,pModeToMatch,pClosestMatch,pConcernedDevice) \ - ( (This)->lpVtbl -> FindClosestMatchingMode(This,pModeToMatch,pClosestMatch,pConcernedDevice) ) - -#define IDXGIOutput4_WaitForVBlank(This) \ - ( (This)->lpVtbl -> WaitForVBlank(This) ) - -#define IDXGIOutput4_TakeOwnership(This,pDevice,Exclusive) \ - ( (This)->lpVtbl -> TakeOwnership(This,pDevice,Exclusive) ) - -#define IDXGIOutput4_ReleaseOwnership(This) \ - ( (This)->lpVtbl -> ReleaseOwnership(This) ) - -#define IDXGIOutput4_GetGammaControlCapabilities(This,pGammaCaps) \ - ( (This)->lpVtbl -> GetGammaControlCapabilities(This,pGammaCaps) ) - -#define IDXGIOutput4_SetGammaControl(This,pArray) \ - ( (This)->lpVtbl -> SetGammaControl(This,pArray) ) - -#define IDXGIOutput4_GetGammaControl(This,pArray) \ - ( (This)->lpVtbl -> GetGammaControl(This,pArray) ) - -#define IDXGIOutput4_SetDisplaySurface(This,pScanoutSurface) \ - ( (This)->lpVtbl -> SetDisplaySurface(This,pScanoutSurface) ) - -#define IDXGIOutput4_GetDisplaySurfaceData(This,pDestination) \ - ( (This)->lpVtbl -> GetDisplaySurfaceData(This,pDestination) ) - -#define IDXGIOutput4_GetFrameStatistics(This,pStats) \ - ( (This)->lpVtbl -> GetFrameStatistics(This,pStats) ) - - -#define IDXGIOutput4_GetDisplayModeList1(This,EnumFormat,Flags,pNumModes,pDesc) \ - ( (This)->lpVtbl -> GetDisplayModeList1(This,EnumFormat,Flags,pNumModes,pDesc) ) - -#define IDXGIOutput4_FindClosestMatchingMode1(This,pModeToMatch,pClosestMatch,pConcernedDevice) \ - ( (This)->lpVtbl -> FindClosestMatchingMode1(This,pModeToMatch,pClosestMatch,pConcernedDevice) ) - -#define IDXGIOutput4_GetDisplaySurfaceData1(This,pDestination) \ - ( (This)->lpVtbl -> GetDisplaySurfaceData1(This,pDestination) ) - -#define IDXGIOutput4_DuplicateOutput(This,pDevice,ppOutputDuplication) \ - ( (This)->lpVtbl -> DuplicateOutput(This,pDevice,ppOutputDuplication) ) - - -#define IDXGIOutput4_SupportsOverlays(This) \ - ( (This)->lpVtbl -> SupportsOverlays(This) ) - - -#define IDXGIOutput4_CheckOverlaySupport(This,EnumFormat,pConcernedDevice,pFlags) \ - ( (This)->lpVtbl -> CheckOverlaySupport(This,EnumFormat,pConcernedDevice,pFlags) ) - - -#define IDXGIOutput4_CheckOverlayColorSpaceSupport(This,Format,ColorSpace,pConcernedDevice,pFlags) \ - ( (This)->lpVtbl -> CheckOverlayColorSpaceSupport(This,Format,ColorSpace,pConcernedDevice,pFlags) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGIOutput4_INTERFACE_DEFINED__ */ - - -#ifndef __IDXGIFactory4_INTERFACE_DEFINED__ -#define __IDXGIFactory4_INTERFACE_DEFINED__ - -/* interface IDXGIFactory4 */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGIFactory4; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("1bc6ea02-ef36-464f-bf0c-21ca39e5168a") - IDXGIFactory4 : public IDXGIFactory3 - { - public: - virtual HRESULT STDMETHODCALLTYPE EnumAdapterByLuid( - /* [annotation] */ - _In_ LUID AdapterLuid, - /* [annotation] */ - _In_ REFIID riid, - /* [annotation] */ - _COM_Outptr_ void **ppvAdapter) = 0; - - virtual HRESULT STDMETHODCALLTYPE EnumWarpAdapter( - /* [annotation] */ - _In_ REFIID riid, - /* [annotation] */ - _COM_Outptr_ void **ppvAdapter) = 0; - - }; - - -#else /* C style interface */ - - typedef struct IDXGIFactory4Vtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGIFactory4 * This, - /* [in] */ REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGIFactory4 * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGIFactory4 * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGIFactory4 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [in] */ UINT DataSize, - /* [annotation][in] */ - _In_reads_bytes_(DataSize) const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGIFactory4 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][in] */ - _In_opt_ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGIFactory4 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][out][in] */ - _Inout_ UINT *pDataSize, - /* [annotation][out] */ - _Out_writes_bytes_(*pDataSize) void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGIFactory4 * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *EnumAdapters )( - IDXGIFactory4 * This, - /* [in] */ UINT Adapter, - /* [annotation][out] */ - _COM_Outptr_ IDXGIAdapter **ppAdapter); - - HRESULT ( STDMETHODCALLTYPE *MakeWindowAssociation )( - IDXGIFactory4 * This, - HWND WindowHandle, - UINT Flags); - - HRESULT ( STDMETHODCALLTYPE *GetWindowAssociation )( - IDXGIFactory4 * This, - /* [annotation][out] */ - _Out_ HWND *pWindowHandle); - - HRESULT ( STDMETHODCALLTYPE *CreateSwapChain )( - IDXGIFactory4 * This, - /* [annotation][in] */ - _In_ IUnknown *pDevice, - /* [annotation][in] */ - _In_ DXGI_SWAP_CHAIN_DESC *pDesc, - /* [annotation][out] */ - _COM_Outptr_ IDXGISwapChain **ppSwapChain); - - HRESULT ( STDMETHODCALLTYPE *CreateSoftwareAdapter )( - IDXGIFactory4 * This, - /* [in] */ HMODULE Module, - /* [annotation][out] */ - _COM_Outptr_ IDXGIAdapter **ppAdapter); - - HRESULT ( STDMETHODCALLTYPE *EnumAdapters1 )( - IDXGIFactory4 * This, - /* [in] */ UINT Adapter, - /* [annotation][out] */ - _COM_Outptr_ IDXGIAdapter1 **ppAdapter); - - BOOL ( STDMETHODCALLTYPE *IsCurrent )( - IDXGIFactory4 * This); - - BOOL ( STDMETHODCALLTYPE *IsWindowedStereoEnabled )( - IDXGIFactory4 * This); - - HRESULT ( STDMETHODCALLTYPE *CreateSwapChainForHwnd )( - IDXGIFactory4 * This, - /* [annotation][in] */ - _In_ IUnknown *pDevice, - /* [annotation][in] */ - _In_ HWND hWnd, - /* [annotation][in] */ - _In_ const DXGI_SWAP_CHAIN_DESC1 *pDesc, - /* [annotation][in] */ - _In_opt_ const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *pFullscreenDesc, - /* [annotation][in] */ - _In_opt_ IDXGIOutput *pRestrictToOutput, - /* [annotation][out] */ - _COM_Outptr_ IDXGISwapChain1 **ppSwapChain); - - HRESULT ( STDMETHODCALLTYPE *CreateSwapChainForCoreWindow )( - IDXGIFactory4 * This, - /* [annotation][in] */ - _In_ IUnknown *pDevice, - /* [annotation][in] */ - _In_ IUnknown *pWindow, - /* [annotation][in] */ - _In_ const DXGI_SWAP_CHAIN_DESC1 *pDesc, - /* [annotation][in] */ - _In_opt_ IDXGIOutput *pRestrictToOutput, - /* [annotation][out] */ - _COM_Outptr_ IDXGISwapChain1 **ppSwapChain); - - HRESULT ( STDMETHODCALLTYPE *GetSharedResourceAdapterLuid )( - IDXGIFactory4 * This, - /* [annotation] */ - _In_ HANDLE hResource, - /* [annotation] */ - _Out_ LUID *pLuid); - - HRESULT ( STDMETHODCALLTYPE *RegisterStereoStatusWindow )( - IDXGIFactory4 * This, - /* [annotation][in] */ - _In_ HWND WindowHandle, - /* [annotation][in] */ - _In_ UINT wMsg, - /* [annotation][out] */ - _Out_ DWORD *pdwCookie); - - HRESULT ( STDMETHODCALLTYPE *RegisterStereoStatusEvent )( - IDXGIFactory4 * This, - /* [annotation][in] */ - _In_ HANDLE hEvent, - /* [annotation][out] */ - _Out_ DWORD *pdwCookie); - - void ( STDMETHODCALLTYPE *UnregisterStereoStatus )( - IDXGIFactory4 * This, - /* [annotation][in] */ - _In_ DWORD dwCookie); - - HRESULT ( STDMETHODCALLTYPE *RegisterOcclusionStatusWindow )( - IDXGIFactory4 * This, - /* [annotation][in] */ - _In_ HWND WindowHandle, - /* [annotation][in] */ - _In_ UINT wMsg, - /* [annotation][out] */ - _Out_ DWORD *pdwCookie); - - HRESULT ( STDMETHODCALLTYPE *RegisterOcclusionStatusEvent )( - IDXGIFactory4 * This, - /* [annotation][in] */ - _In_ HANDLE hEvent, - /* [annotation][out] */ - _Out_ DWORD *pdwCookie); - - void ( STDMETHODCALLTYPE *UnregisterOcclusionStatus )( - IDXGIFactory4 * This, - /* [annotation][in] */ - _In_ DWORD dwCookie); - - HRESULT ( STDMETHODCALLTYPE *CreateSwapChainForComposition )( - IDXGIFactory4 * This, - /* [annotation][in] */ - _In_ IUnknown *pDevice, - /* [annotation][in] */ - _In_ const DXGI_SWAP_CHAIN_DESC1 *pDesc, - /* [annotation][in] */ - _In_opt_ IDXGIOutput *pRestrictToOutput, - /* [annotation][out] */ - _COM_Outptr_ IDXGISwapChain1 **ppSwapChain); - - UINT ( STDMETHODCALLTYPE *GetCreationFlags )( - IDXGIFactory4 * This); - - HRESULT ( STDMETHODCALLTYPE *EnumAdapterByLuid )( - IDXGIFactory4 * This, - /* [annotation] */ - _In_ LUID AdapterLuid, - /* [annotation] */ - _In_ REFIID riid, - /* [annotation] */ - _COM_Outptr_ void **ppvAdapter); - - HRESULT ( STDMETHODCALLTYPE *EnumWarpAdapter )( - IDXGIFactory4 * This, - /* [annotation] */ - _In_ REFIID riid, - /* [annotation] */ - _COM_Outptr_ void **ppvAdapter); - - END_INTERFACE - } IDXGIFactory4Vtbl; - - interface IDXGIFactory4 - { - CONST_VTBL struct IDXGIFactory4Vtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGIFactory4_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGIFactory4_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGIFactory4_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGIFactory4_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGIFactory4_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGIFactory4_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGIFactory4_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGIFactory4_EnumAdapters(This,Adapter,ppAdapter) \ - ( (This)->lpVtbl -> EnumAdapters(This,Adapter,ppAdapter) ) - -#define IDXGIFactory4_MakeWindowAssociation(This,WindowHandle,Flags) \ - ( (This)->lpVtbl -> MakeWindowAssociation(This,WindowHandle,Flags) ) - -#define IDXGIFactory4_GetWindowAssociation(This,pWindowHandle) \ - ( (This)->lpVtbl -> GetWindowAssociation(This,pWindowHandle) ) - -#define IDXGIFactory4_CreateSwapChain(This,pDevice,pDesc,ppSwapChain) \ - ( (This)->lpVtbl -> CreateSwapChain(This,pDevice,pDesc,ppSwapChain) ) - -#define IDXGIFactory4_CreateSoftwareAdapter(This,Module,ppAdapter) \ - ( (This)->lpVtbl -> CreateSoftwareAdapter(This,Module,ppAdapter) ) - - -#define IDXGIFactory4_EnumAdapters1(This,Adapter,ppAdapter) \ - ( (This)->lpVtbl -> EnumAdapters1(This,Adapter,ppAdapter) ) - -#define IDXGIFactory4_IsCurrent(This) \ - ( (This)->lpVtbl -> IsCurrent(This) ) - - -#define IDXGIFactory4_IsWindowedStereoEnabled(This) \ - ( (This)->lpVtbl -> IsWindowedStereoEnabled(This) ) - -#define IDXGIFactory4_CreateSwapChainForHwnd(This,pDevice,hWnd,pDesc,pFullscreenDesc,pRestrictToOutput,ppSwapChain) \ - ( (This)->lpVtbl -> CreateSwapChainForHwnd(This,pDevice,hWnd,pDesc,pFullscreenDesc,pRestrictToOutput,ppSwapChain) ) - -#define IDXGIFactory4_CreateSwapChainForCoreWindow(This,pDevice,pWindow,pDesc,pRestrictToOutput,ppSwapChain) \ - ( (This)->lpVtbl -> CreateSwapChainForCoreWindow(This,pDevice,pWindow,pDesc,pRestrictToOutput,ppSwapChain) ) - -#define IDXGIFactory4_GetSharedResourceAdapterLuid(This,hResource,pLuid) \ - ( (This)->lpVtbl -> GetSharedResourceAdapterLuid(This,hResource,pLuid) ) - -#define IDXGIFactory4_RegisterStereoStatusWindow(This,WindowHandle,wMsg,pdwCookie) \ - ( (This)->lpVtbl -> RegisterStereoStatusWindow(This,WindowHandle,wMsg,pdwCookie) ) - -#define IDXGIFactory4_RegisterStereoStatusEvent(This,hEvent,pdwCookie) \ - ( (This)->lpVtbl -> RegisterStereoStatusEvent(This,hEvent,pdwCookie) ) - -#define IDXGIFactory4_UnregisterStereoStatus(This,dwCookie) \ - ( (This)->lpVtbl -> UnregisterStereoStatus(This,dwCookie) ) - -#define IDXGIFactory4_RegisterOcclusionStatusWindow(This,WindowHandle,wMsg,pdwCookie) \ - ( (This)->lpVtbl -> RegisterOcclusionStatusWindow(This,WindowHandle,wMsg,pdwCookie) ) - -#define IDXGIFactory4_RegisterOcclusionStatusEvent(This,hEvent,pdwCookie) \ - ( (This)->lpVtbl -> RegisterOcclusionStatusEvent(This,hEvent,pdwCookie) ) - -#define IDXGIFactory4_UnregisterOcclusionStatus(This,dwCookie) \ - ( (This)->lpVtbl -> UnregisterOcclusionStatus(This,dwCookie) ) - -#define IDXGIFactory4_CreateSwapChainForComposition(This,pDevice,pDesc,pRestrictToOutput,ppSwapChain) \ - ( (This)->lpVtbl -> CreateSwapChainForComposition(This,pDevice,pDesc,pRestrictToOutput,ppSwapChain) ) - - -#define IDXGIFactory4_GetCreationFlags(This) \ - ( (This)->lpVtbl -> GetCreationFlags(This) ) - - -#define IDXGIFactory4_EnumAdapterByLuid(This,AdapterLuid,riid,ppvAdapter) \ - ( (This)->lpVtbl -> EnumAdapterByLuid(This,AdapterLuid,riid,ppvAdapter) ) - -#define IDXGIFactory4_EnumWarpAdapter(This,riid,ppvAdapter) \ - ( (This)->lpVtbl -> EnumWarpAdapter(This,riid,ppvAdapter) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGIFactory4_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxgi1_4_0000_0003 */ -/* [local] */ - -typedef -enum DXGI_MEMORY_SEGMENT_GROUP - { - DXGI_MEMORY_SEGMENT_GROUP_LOCAL = 0, - DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL = 1 - } DXGI_MEMORY_SEGMENT_GROUP; - -typedef struct DXGI_QUERY_VIDEO_MEMORY_INFO - { - UINT64 Budget; - UINT64 CurrentUsage; - UINT64 AvailableForReservation; - UINT64 CurrentReservation; - } DXGI_QUERY_VIDEO_MEMORY_INFO; - - - -extern RPC_IF_HANDLE __MIDL_itf_dxgi1_4_0000_0003_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxgi1_4_0000_0003_v0_0_s_ifspec; - -#ifndef __IDXGIAdapter3_INTERFACE_DEFINED__ -#define __IDXGIAdapter3_INTERFACE_DEFINED__ - -/* interface IDXGIAdapter3 */ -/* [unique][local][uuid][object] */ - - -EXTERN_C const IID IID_IDXGIAdapter3; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("645967A4-1392-4310-A798-8053CE3E93FD") - IDXGIAdapter3 : public IDXGIAdapter2 - { - public: - virtual HRESULT STDMETHODCALLTYPE RegisterHardwareContentProtectionTeardownStatusEvent( - /* [annotation][in] */ - _In_ HANDLE hEvent, - /* [annotation][out] */ - _Out_ DWORD *pdwCookie) = 0; - - virtual void STDMETHODCALLTYPE UnregisterHardwareContentProtectionTeardownStatus( - /* [annotation][in] */ - _In_ DWORD dwCookie) = 0; - - virtual HRESULT STDMETHODCALLTYPE QueryVideoMemoryInfo( - /* [annotation][in] */ - _In_ UINT NodeIndex, - /* [annotation][in] */ - _In_ DXGI_MEMORY_SEGMENT_GROUP MemorySegmentGroup, - /* [annotation][out] */ - _Out_ DXGI_QUERY_VIDEO_MEMORY_INFO *pVideoMemoryInfo) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetVideoMemoryReservation( - /* [annotation][in] */ - _In_ UINT NodeIndex, - /* [annotation][in] */ - _In_ DXGI_MEMORY_SEGMENT_GROUP MemorySegmentGroup, - /* [annotation][in] */ - _In_ UINT64 Reservation) = 0; - - virtual HRESULT STDMETHODCALLTYPE RegisterVideoMemoryBudgetChangeNotificationEvent( - /* [annotation][in] */ - _In_ HANDLE hEvent, - /* [annotation][out] */ - _Out_ DWORD *pdwCookie) = 0; - - virtual void STDMETHODCALLTYPE UnregisterVideoMemoryBudgetChangeNotification( - /* [annotation][in] */ - _In_ DWORD dwCookie) = 0; - - }; - - -#else /* C style interface */ - - typedef struct IDXGIAdapter3Vtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDXGIAdapter3 * This, - /* [in] */ REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDXGIAdapter3 * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDXGIAdapter3 * This); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( - IDXGIAdapter3 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [in] */ UINT DataSize, - /* [annotation][in] */ - _In_reads_bytes_(DataSize) const void *pData); - - HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( - IDXGIAdapter3 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][in] */ - _In_opt_ const IUnknown *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( - IDXGIAdapter3 * This, - /* [annotation][in] */ - _In_ REFGUID Name, - /* [annotation][out][in] */ - _Inout_ UINT *pDataSize, - /* [annotation][out] */ - _Out_writes_bytes_(*pDataSize) void *pData); - - HRESULT ( STDMETHODCALLTYPE *GetParent )( - IDXGIAdapter3 * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void **ppParent); - - HRESULT ( STDMETHODCALLTYPE *EnumOutputs )( - IDXGIAdapter3 * This, - /* [in] */ UINT Output, - /* [annotation][out][in] */ - _COM_Outptr_ IDXGIOutput **ppOutput); - - HRESULT ( STDMETHODCALLTYPE *GetDesc )( - IDXGIAdapter3 * This, - /* [annotation][out] */ - _Out_ DXGI_ADAPTER_DESC *pDesc); - - HRESULT ( STDMETHODCALLTYPE *CheckInterfaceSupport )( - IDXGIAdapter3 * This, - /* [annotation][in] */ - _In_ REFGUID InterfaceName, - /* [annotation][out] */ - _Out_ LARGE_INTEGER *pUMDVersion); - - HRESULT ( STDMETHODCALLTYPE *GetDesc1 )( - IDXGIAdapter3 * This, - /* [annotation][out] */ - _Out_ DXGI_ADAPTER_DESC1 *pDesc); - - HRESULT ( STDMETHODCALLTYPE *GetDesc2 )( - IDXGIAdapter3 * This, - /* [annotation][out] */ - _Out_ DXGI_ADAPTER_DESC2 *pDesc); - - HRESULT ( STDMETHODCALLTYPE *RegisterHardwareContentProtectionTeardownStatusEvent )( - IDXGIAdapter3 * This, - /* [annotation][in] */ - _In_ HANDLE hEvent, - /* [annotation][out] */ - _Out_ DWORD *pdwCookie); - - void ( STDMETHODCALLTYPE *UnregisterHardwareContentProtectionTeardownStatus )( - IDXGIAdapter3 * This, - /* [annotation][in] */ - _In_ DWORD dwCookie); - - HRESULT ( STDMETHODCALLTYPE *QueryVideoMemoryInfo )( - IDXGIAdapter3 * This, - /* [annotation][in] */ - _In_ UINT NodeIndex, - /* [annotation][in] */ - _In_ DXGI_MEMORY_SEGMENT_GROUP MemorySegmentGroup, - /* [annotation][out] */ - _Out_ DXGI_QUERY_VIDEO_MEMORY_INFO *pVideoMemoryInfo); - - HRESULT ( STDMETHODCALLTYPE *SetVideoMemoryReservation )( - IDXGIAdapter3 * This, - /* [annotation][in] */ - _In_ UINT NodeIndex, - /* [annotation][in] */ - _In_ DXGI_MEMORY_SEGMENT_GROUP MemorySegmentGroup, - /* [annotation][in] */ - _In_ UINT64 Reservation); - - HRESULT ( STDMETHODCALLTYPE *RegisterVideoMemoryBudgetChangeNotificationEvent )( - IDXGIAdapter3 * This, - /* [annotation][in] */ - _In_ HANDLE hEvent, - /* [annotation][out] */ - _Out_ DWORD *pdwCookie); - - void ( STDMETHODCALLTYPE *UnregisterVideoMemoryBudgetChangeNotification )( - IDXGIAdapter3 * This, - /* [annotation][in] */ - _In_ DWORD dwCookie); - - END_INTERFACE - } IDXGIAdapter3Vtbl; - - interface IDXGIAdapter3 - { - CONST_VTBL struct IDXGIAdapter3Vtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDXGIAdapter3_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IDXGIAdapter3_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IDXGIAdapter3_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IDXGIAdapter3_SetPrivateData(This,Name,DataSize,pData) \ - ( (This)->lpVtbl -> SetPrivateData(This,Name,DataSize,pData) ) - -#define IDXGIAdapter3_SetPrivateDataInterface(This,Name,pUnknown) \ - ( (This)->lpVtbl -> SetPrivateDataInterface(This,Name,pUnknown) ) - -#define IDXGIAdapter3_GetPrivateData(This,Name,pDataSize,pData) \ - ( (This)->lpVtbl -> GetPrivateData(This,Name,pDataSize,pData) ) - -#define IDXGIAdapter3_GetParent(This,riid,ppParent) \ - ( (This)->lpVtbl -> GetParent(This,riid,ppParent) ) - - -#define IDXGIAdapter3_EnumOutputs(This,Output,ppOutput) \ - ( (This)->lpVtbl -> EnumOutputs(This,Output,ppOutput) ) - -#define IDXGIAdapter3_GetDesc(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc(This,pDesc) ) - -#define IDXGIAdapter3_CheckInterfaceSupport(This,InterfaceName,pUMDVersion) \ - ( (This)->lpVtbl -> CheckInterfaceSupport(This,InterfaceName,pUMDVersion) ) - - -#define IDXGIAdapter3_GetDesc1(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc1(This,pDesc) ) - - -#define IDXGIAdapter3_GetDesc2(This,pDesc) \ - ( (This)->lpVtbl -> GetDesc2(This,pDesc) ) - - -#define IDXGIAdapter3_RegisterHardwareContentProtectionTeardownStatusEvent(This,hEvent,pdwCookie) \ - ( (This)->lpVtbl -> RegisterHardwareContentProtectionTeardownStatusEvent(This,hEvent,pdwCookie) ) - -#define IDXGIAdapter3_UnregisterHardwareContentProtectionTeardownStatus(This,dwCookie) \ - ( (This)->lpVtbl -> UnregisterHardwareContentProtectionTeardownStatus(This,dwCookie) ) - -#define IDXGIAdapter3_QueryVideoMemoryInfo(This,NodeIndex,MemorySegmentGroup,pVideoMemoryInfo) \ - ( (This)->lpVtbl -> QueryVideoMemoryInfo(This,NodeIndex,MemorySegmentGroup,pVideoMemoryInfo) ) - -#define IDXGIAdapter3_SetVideoMemoryReservation(This,NodeIndex,MemorySegmentGroup,Reservation) \ - ( (This)->lpVtbl -> SetVideoMemoryReservation(This,NodeIndex,MemorySegmentGroup,Reservation) ) - -#define IDXGIAdapter3_RegisterVideoMemoryBudgetChangeNotificationEvent(This,hEvent,pdwCookie) \ - ( (This)->lpVtbl -> RegisterVideoMemoryBudgetChangeNotificationEvent(This,hEvent,pdwCookie) ) - -#define IDXGIAdapter3_UnregisterVideoMemoryBudgetChangeNotification(This,dwCookie) \ - ( (This)->lpVtbl -> UnregisterVideoMemoryBudgetChangeNotification(This,dwCookie) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IDXGIAdapter3_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_dxgi1_4_0000_0004 */ -/* [local] */ - -#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_GAMES) */ -#pragma endregion -DEFINE_GUID(IID_IDXGISwapChain3,0x94d99bdb,0xf1f8,0x4ab0,0xb2,0x36,0x7d,0xa0,0x17,0x0e,0xda,0xb1); -DEFINE_GUID(IID_IDXGIOutput4,0xdc7dca35,0x2196,0x414d,0x9F,0x53,0x61,0x78,0x84,0x03,0x2a,0x60); -DEFINE_GUID(IID_IDXGIFactory4,0x1bc6ea02,0xef36,0x464f,0xbf,0x0c,0x21,0xca,0x39,0xe5,0x16,0x8a); -DEFINE_GUID(IID_IDXGIAdapter3,0x645967A4,0x1392,0x4310,0xA7,0x98,0x80,0x53,0xCE,0x3E,0x93,0xFD); - - -extern RPC_IF_HANDLE __MIDL_itf_dxgi1_4_0000_0004_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_dxgi1_4_0000_0004_v0_0_s_ifspec; - -/* Additional Prototypes for ALL interfaces */ - -/* end of Additional Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/pc/gfx/gfx_cc.c b/src/pc/gfx/gfx_cc.c new file mode 100644 index 00000000..d43f54bc --- /dev/null +++ b/src/pc/gfx/gfx_cc.c @@ -0,0 +1,41 @@ +#include "gfx_cc.h" + +void gfx_cc_get_features(uint32_t shader_id, struct CCFeatures *cc_features) { + for (int i = 0; i < 4; i++) { + cc_features->c[0][i] = (shader_id >> (i * 3)) & 7; + cc_features->c[1][i] = (shader_id >> (12 + i * 3)) & 7; + } + + cc_features->opt_alpha = (shader_id & SHADER_OPT_ALPHA) != 0; + cc_features->opt_fog = (shader_id & SHADER_OPT_FOG) != 0; + cc_features->opt_texture_edge = (shader_id & SHADER_OPT_TEXTURE_EDGE) != 0; + cc_features->opt_noise = (shader_id & SHADER_OPT_NOISE) != 0; + + cc_features->used_textures[0] = false; + cc_features->used_textures[1] = false; + cc_features->num_inputs = 0; + + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 4; j++) { + if (cc_features->c[i][j] >= SHADER_INPUT_1 && cc_features->c[i][j] <= SHADER_INPUT_4) { + if (cc_features->c[i][j] > cc_features->num_inputs) { + cc_features->num_inputs = cc_features->c[i][j]; + } + } + if (cc_features->c[i][j] == SHADER_TEXEL0 || cc_features->c[i][j] == SHADER_TEXEL0A) { + cc_features->used_textures[0] = true; + } + if (cc_features->c[i][j] == SHADER_TEXEL1) { + cc_features->used_textures[1] = true; + } + } + } + + cc_features->do_single[0] = cc_features->c[0][2] == 0; + cc_features->do_single[1] = cc_features->c[1][2] == 0; + cc_features->do_multiply[0] = cc_features->c[0][1] == 0 && cc_features->c[0][3] == 0; + cc_features->do_multiply[1] = cc_features->c[1][1] == 0 && cc_features->c[1][3] == 0; + cc_features->do_mix[0] = cc_features->c[0][1] == cc_features->c[0][3]; + cc_features->do_mix[1] = cc_features->c[1][1] == cc_features->c[1][3]; + cc_features->color_alpha_same = (shader_id & 0xfff) == ((shader_id >> 12) & 0xfff); +} diff --git a/src/pc/gfx/gfx_cc.h b/src/pc/gfx/gfx_cc.h index 3342dca3..2840b83e 100644 --- a/src/pc/gfx/gfx_cc.h +++ b/src/pc/gfx/gfx_cc.h @@ -1,3 +1,9 @@ +#ifndef GFX_CC_H +#define GFX_CC_H + +#include +#include + enum { CC_0, CC_TEXEL0, @@ -24,3 +30,29 @@ enum { #define SHADER_OPT_FOG (1 << 25) #define SHADER_OPT_TEXTURE_EDGE (1 << 26) #define SHADER_OPT_NOISE (1 << 27) + +struct CCFeatures { + uint8_t c[2][4]; + bool opt_alpha; + bool opt_fog; + bool opt_texture_edge; + bool opt_noise; + bool used_textures[2]; + int num_inputs; + bool do_single[2]; + bool do_multiply[2]; + bool do_mix[2]; + bool color_alpha_same; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +void gfx_cc_get_features(uint32_t shader_id, struct CCFeatures *cc_features); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/pc/gfx/gfx_direct3d11.cpp b/src/pc/gfx/gfx_direct3d11.cpp index 0d0428bd..d27524b7 100644 --- a/src/pc/gfx/gfx_direct3d11.cpp +++ b/src/pc/gfx/gfx_direct3d11.cpp @@ -1,7 +1,5 @@ #ifdef RAPI_D3D11 -#if defined(_WIN32) || defined(_WIN64) - #include #include #include @@ -14,15 +12,8 @@ #include #include -extern "C" { -#include "../cliopts.h" -#include "../configfile.h" -#include "../platform.h" -#include "../pc_main.h" -} - #ifndef _LANGUAGE_C -# define _LANGUAGE_C +#define _LANGUAGE_C #endif #include @@ -31,15 +22,18 @@ extern "C" { #include "gfx_rendering_api.h" #include "gfx_direct3d_common.h" +#define DECLARE_GFX_DXGI_FUNCTIONS +#include "gfx_dxgi.h" + #include "gfx_screen_config.h" -#define WINCLASS_NAME L"SUPERMARIO64" -#define WINDOW_CLIENT_MIN_WIDTH 320 -#define WINDOW_CLIENT_MIN_HEIGHT 240 +#define THREE_POINT_FILTERING 0 #define DEBUG_D3D 0 using namespace Microsoft::WRL; // For ComPtr +namespace { + struct PerFrameCB { uint32_t noise_frame; float noise_scale_x; @@ -64,7 +58,7 @@ struct TextureData { bool linear_filtering; }; -struct ShaderProgram { +struct ShaderProgramD3D11 { ComPtr vertex_shader; ComPtr pixel_shader; ComPtr input_layout; @@ -77,10 +71,17 @@ struct ShaderProgram { }; static struct { + HMODULE d3d11_module; + PFN_D3D11_CREATE_DEVICE D3D11CreateDevice; + + HMODULE d3dcompiler_module; + pD3DCompile D3DCompile; + + D3D_FEATURE_LEVEL feature_level; + ComPtr device; + ComPtr swap_chain; ComPtr context; - ComPtr swap_chain; // For Windows versions older than 8.1 - ComPtr swap_chain2; // For Windows version 8.1 or newer ComPtr backbuffer_view; ComPtr depth_stencil_view; ComPtr rasterizer_state; @@ -93,14 +94,12 @@ static struct { ComPtr debug; #endif - HANDLE frame_latency_waitable_object; - DXGI_SAMPLE_DESC sample_description; PerFrameCB per_frame_cb_data; PerDrawCB per_draw_cb_data; - struct ShaderProgram shader_program_pool[64]; + struct ShaderProgramD3D11 shader_program_pool[64]; uint8_t shader_program_pool_size; std::vector textures; @@ -109,7 +108,7 @@ static struct { // Current state - struct ShaderProgram *shader_program; + struct ShaderProgramD3D11 *shader_program; uint32_t current_width, current_height; @@ -119,7 +118,7 @@ static struct { // Previous states (to prevent setting states needlessly) - struct ShaderProgram *last_shader_program = nullptr; + struct ShaderProgramD3D11 *last_shader_program = nullptr; uint32_t last_vertex_buffer_stride = 0; ComPtr last_blend_state = nullptr; ComPtr last_resource_views[2] = { nullptr, nullptr }; @@ -128,120 +127,50 @@ static struct { int8_t last_depth_mask = -1; int8_t last_zmode_decal = -1; D3D_PRIMITIVE_TOPOLOGY last_primitive_topology = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED; - - // Game loop callback - - void (*run_one_game_iter)(void); - bool (*on_key_down)(int scancode); - bool (*on_key_up)(int scancode); - void (*on_all_keys_up)(void); } d3d; -static HWND h_wnd; -static bool lower_latency; static LARGE_INTEGER last_time, accumulated_time, frequency; -static uint8_t sync_interval; -static RECT last_window_rect; -static bool is_full_screen, last_maximized_state; -static void toggle_borderless_window_full_screen(void) { - if (is_full_screen) { - // set this right away so the fucking wndproc doesn't bother with anything stupid - is_full_screen = false; +static void create_render_target_views(bool is_resize) { + DXGI_SWAP_CHAIN_DESC1 desc1; - RECT r = last_window_rect; + if (is_resize) { + // Release previous stuff (if any) - // Set in window mode with the last saved position and size - SetWindowLongPtr(h_wnd, GWL_STYLE, WS_VISIBLE | WS_OVERLAPPEDWINDOW); + d3d.backbuffer_view.Reset(); + d3d.depth_stencil_view.Reset(); - if (last_maximized_state) { - SetWindowPos(h_wnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE); - ShowWindow(h_wnd, SW_MAXIMIZE); - } else { - SetWindowPos(h_wnd, NULL, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_FRAMECHANGED); - ShowWindow(h_wnd, SW_RESTORE); - } - } else { - // set this right away so the fucking wndproc doesn't bother with anything stupid - is_full_screen = true; + // Resize swap chain buffers - // Save if window is maximized or not - WINDOWPLACEMENT window_placement; - window_placement.length = sizeof(WINDOWPLACEMENT); - GetWindowPlacement(h_wnd, &window_placement); - last_maximized_state = window_placement.showCmd == SW_SHOWMAXIMIZED; - - // Save window position and size if the window is not maximized - GetWindowRect(h_wnd, &last_window_rect); - configWindow.x = last_window_rect.left; - configWindow.y = last_window_rect.top; - configWindow.w = last_window_rect.right - last_window_rect.left; - configWindow.h = last_window_rect.bottom - last_window_rect.top; - - // Get in which monitor the window is - HMONITOR h_monitor = MonitorFromWindow(h_wnd, MONITOR_DEFAULTTONEAREST); - - // Get info from that monitor - MONITORINFOEX monitor_info; - monitor_info.cbSize = sizeof(MONITORINFOEX); - GetMonitorInfo(h_monitor, &monitor_info); - RECT r = monitor_info.rcMonitor; - - // Set borderless full screen to that monitor - SetWindowLongPtr(h_wnd, GWL_STYLE, WS_VISIBLE | WS_POPUP); - SetWindowPos(h_wnd, HWND_TOP, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_FRAMECHANGED); - } -} - -static void create_render_target_views(uint32_t width, uint32_t height) { - if (width == 0 || height == 0) { - return; - } - if (d3d.current_width == width && d3d.current_height == height) { - return; + ThrowIfFailed(d3d.swap_chain->GetDesc1(&desc1)); + ThrowIfFailed(d3d.swap_chain->ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN, desc1.Flags), + gfx_dxgi_get_h_wnd(), "Failed to resize IDXGISwapChain buffers."); } - // Release previous stuff (if any) + // Get new size - d3d.backbuffer_view.Reset(); - d3d.depth_stencil_view.Reset(); - - // Resize swap chain - - if (lower_latency) { - UINT swap_chain_flags = DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT; - ThrowIfFailed(d3d.swap_chain2->ResizeBuffers(0, width, height, DXGI_FORMAT_UNKNOWN, swap_chain_flags), - h_wnd, "Failed to resize IDXGISwapChain2 buffers."); - } else { - UINT swap_chain_flags = 0; - ThrowIfFailed(d3d.swap_chain->ResizeBuffers(0, width, height, DXGI_FORMAT_UNKNOWN, swap_chain_flags), - h_wnd, "Failed to resize IDXGISwapChain buffers."); - } + ThrowIfFailed(d3d.swap_chain->GetDesc1(&desc1)); // Create back buffer ComPtr backbuffer_texture; - if (lower_latency) { - ThrowIfFailed(d3d.swap_chain2->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID *) backbuffer_texture.GetAddressOf()), - h_wnd, "Failed to get backbuffer from IDXGISwapChain2."); - } else { - ThrowIfFailed(d3d.swap_chain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID *) backbuffer_texture.GetAddressOf()), - h_wnd, "Failed to get backbuffer from IDXGISwapChain."); - } + ThrowIfFailed(d3d.swap_chain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID *) backbuffer_texture.GetAddressOf()), + gfx_dxgi_get_h_wnd(), "Failed to get backbuffer from IDXGISwapChain."); - ThrowIfFailed(d3d.device->CreateRenderTargetView(backbuffer_texture.Get(), NULL, d3d.backbuffer_view.GetAddressOf()), - h_wnd, "Failed to create render target view."); + ThrowIfFailed(d3d.device->CreateRenderTargetView(backbuffer_texture.Get(), nullptr, d3d.backbuffer_view.GetAddressOf()), + gfx_dxgi_get_h_wnd(), "Failed to create render target view."); // Create depth buffer D3D11_TEXTURE2D_DESC depth_stencil_texture_desc; ZeroMemory(&depth_stencil_texture_desc, sizeof(D3D11_TEXTURE2D_DESC)); - depth_stencil_texture_desc.Width = width; - depth_stencil_texture_desc.Height = height; + depth_stencil_texture_desc.Width = desc1.Width; + depth_stencil_texture_desc.Height = desc1.Height; depth_stencil_texture_desc.MipLevels = 1; depth_stencil_texture_desc.ArraySize = 1; - depth_stencil_texture_desc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; + depth_stencil_texture_desc.Format = d3d.feature_level >= D3D_FEATURE_LEVEL_10_0 ? + DXGI_FORMAT_D32_FLOAT : DXGI_FORMAT_D24_UNORM_S8_UINT; depth_stencil_texture_desc.SampleDesc = d3d.sample_description; depth_stencil_texture_desc.Usage = D3D11_USAGE_DEFAULT; depth_stencil_texture_desc.BindFlags = D3D11_BIND_DEPTH_STENCIL; @@ -249,227 +178,69 @@ static void create_render_target_views(uint32_t width, uint32_t height) { depth_stencil_texture_desc.MiscFlags = 0; ComPtr depth_stencil_texture; - ThrowIfFailed(d3d.device->CreateTexture2D(&depth_stencil_texture_desc, NULL, depth_stencil_texture.GetAddressOf())); - ThrowIfFailed(d3d.device->CreateDepthStencilView(depth_stencil_texture.Get(), NULL, d3d.depth_stencil_view.GetAddressOf())); + ThrowIfFailed(d3d.device->CreateTexture2D(&depth_stencil_texture_desc, nullptr, depth_stencil_texture.GetAddressOf())); + ThrowIfFailed(d3d.device->CreateDepthStencilView(depth_stencil_texture.Get(), nullptr, d3d.depth_stencil_view.GetAddressOf())); // Save resolution - d3d.current_width = width; - d3d.current_height = height; + d3d.current_width = desc1.Width; + d3d.current_height = desc1.Height; } -static void update_screen_settings(void) { - if (configWindow.fullscreen != is_full_screen) - toggle_borderless_window_full_screen(); - if (!is_full_screen) { - const int screen_width = GetSystemMetrics(SM_CXSCREEN); - const int screen_height = GetSystemMetrics(SM_CYSCREEN); - const int xpos = (configWindow.x == WAPI_WIN_CENTERPOS) ? (screen_width - configWindow.w) * 0.5 : configWindow.x; - const int ypos = (configWindow.y == WAPI_WIN_CENTERPOS) ? (screen_height - configWindow.h) * 0.5 : configWindow.y; - RECT wr = { xpos, ypos, xpos + (int)configWindow.w, ypos + (int)configWindow.h }; - AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); - SetWindowPos(h_wnd, NULL, wr.left, wr.top, wr.right - wr.left, wr.bottom - wr.top, SWP_NOACTIVATE | SWP_NOZORDER); +static void gfx_d3d11_init(void) { + // Load d3d11.dll + d3d.d3d11_module = LoadLibraryW(L"d3d11.dll"); + if (d3d.d3d11_module == nullptr) { + ThrowIfFailed(HRESULT_FROM_WIN32(GetLastError()), gfx_dxgi_get_h_wnd(), "d3d11.dll could not be loaded"); } -} + d3d.D3D11CreateDevice = (PFN_D3D11_CREATE_DEVICE)GetProcAddress(d3d.d3d11_module, "D3D11CreateDevice"); -static void calculate_sync_interval() { - const POINT ptZero = { 0, 0 }; - HMONITOR h_monitor = MonitorFromPoint(ptZero, MONITOR_DEFAULTTOPRIMARY); - - MONITORINFOEX monitor_info; - monitor_info.cbSize = sizeof(MONITORINFOEX); - GetMonitorInfo(h_monitor, &monitor_info); - - DEVMODE dev_mode; - dev_mode.dmSize = sizeof(DEVMODE); - dev_mode.dmDriverExtra = 0; - EnumDisplaySettings(monitor_info.szDevice, ENUM_CURRENT_SETTINGS, &dev_mode); - - if (dev_mode.dmDisplayFrequency >= 29 && dev_mode.dmDisplayFrequency <= 31) { - sync_interval = 1; - } else if (dev_mode.dmDisplayFrequency >= 59 && dev_mode.dmDisplayFrequency <= 61) { - sync_interval = 2; - } else if (dev_mode.dmDisplayFrequency >= 89 && dev_mode.dmDisplayFrequency <= 91) { - sync_interval = 3; - } else if (dev_mode.dmDisplayFrequency >= 119 && dev_mode.dmDisplayFrequency <= 121) { - sync_interval = 4; - } else { - sync_interval = 0; + // Load D3DCompiler_47.dll or D3DCompiler_43.dll + d3d.d3dcompiler_module = LoadLibraryW(L"D3DCompiler_47.dll"); + if (d3d.d3dcompiler_module == nullptr) { + d3d.d3dcompiler_module = LoadLibraryW(L"D3DCompiler_43.dll"); + if (d3d.d3dcompiler_module == nullptr) { + ThrowIfFailed(HRESULT_FROM_WIN32(GetLastError()), gfx_dxgi_get_h_wnd(), "D3DCompiler_47.dll or D3DCompiler_43.dll could not be loaded"); + } } -} - -LRESULT CALLBACK gfx_d3d11_dxgi_wnd_proc(HWND h_wnd, UINT message, WPARAM w_param, LPARAM l_param) { - switch (message) { - case WM_MOVE: - if (!is_full_screen) { - const int x = (short)LOWORD(l_param); - const int y = (short)HIWORD(l_param); - configWindow.x = (x < 0) ? 0 : x; - configWindow.y = (y < 0) ? 0 : y; - } - break; - case WM_SIZE: { - RECT rect; - GetClientRect(h_wnd, &rect); - const int w = rect.right - rect.left; - const int h = rect.bottom - rect.top; - if (!is_full_screen) { - configWindow.w = w; - configWindow.h = h; - } - create_render_target_views(w, h); - break; - } - case WM_EXITSIZEMOVE: { - calculate_sync_interval(); - break; - } - case WM_GETMINMAXINFO: { - RECT wr = { 0, 0, WINDOW_CLIENT_MIN_WIDTH, WINDOW_CLIENT_MIN_HEIGHT }; - AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); - LPMINMAXINFO lpMMI = (LPMINMAXINFO) l_param; - lpMMI->ptMinTrackSize.x = wr.right - wr.left; - lpMMI->ptMinTrackSize.y = wr.bottom - wr.top; - break; - } - case WM_DISPLAYCHANGE: { - calculate_sync_interval(); - break; - } - case WM_DESTROY: { -#if DEBUG_D3D - d3d.debug->ReportLiveDeviceObjects(D3D11_RLDO_DETAIL); -#endif - game_exit(); - break; - } - case WM_ACTIVATEAPP: { - if (d3d.on_all_keys_up != nullptr) { - d3d.on_all_keys_up(); - } - break; - } - case WM_SYSKEYDOWN: { - if ((w_param == VK_RETURN) && ((l_param & 1 << 30) == 0)) { - toggle_borderless_window_full_screen(); - break; - } else { - return DefWindowProcW(h_wnd, message, w_param, l_param); - } - } - case WM_KEYDOWN: { - if (d3d.on_key_down != nullptr) { - d3d.on_key_down((l_param >> 16) & 0x1ff); - } - break; - } - case WM_KEYUP: { - if (d3d.on_key_up != nullptr) { - d3d.on_key_up((l_param >> 16) & 0x1ff); - } - break; - } - default: - break; - } - - // check if we should change size or fullscreen state - - if (configWindow.reset) { - last_maximized_state = false; - configWindow.reset = false; - configWindow.x = WAPI_WIN_CENTERPOS; - configWindow.y = WAPI_WIN_CENTERPOS; - configWindow.w = DESIRED_SCREEN_WIDTH; - configWindow.h = DESIRED_SCREEN_HEIGHT; - configWindow.fullscreen = false; - configWindow.settings_changed = true; - } - - if (configWindow.settings_changed) { - configWindow.settings_changed = false; - update_screen_settings(); - } - - return DefWindowProcW(h_wnd, message, w_param, l_param); -} - -static void gfx_d3d11_dxgi_init(const char *window_title) { - // Prepare window title - - wchar_t w_title[512]; - mbstowcs(w_title, window_title, strlen(window_title) + 1); - - // Create window - - WNDCLASSEXW wcex; - ZeroMemory(&wcex, sizeof(WNDCLASSEX)); - - wcex.cbSize = sizeof(WNDCLASSEX); - wcex.style = CS_HREDRAW | CS_VREDRAW; - wcex.lpfnWndProc = gfx_d3d11_dxgi_wnd_proc; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = nullptr; - wcex.hIcon = nullptr; - wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); - wcex.lpszMenuName = nullptr; - wcex.lpszClassName = WINCLASS_NAME; - wcex.hIconSm = nullptr; - - RegisterClassExW(&wcex); - - RECT wr = { 0, 0, DESIRED_SCREEN_WIDTH, DESIRED_SCREEN_HEIGHT }; - AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); - - h_wnd = CreateWindowW(WINCLASS_NAME, w_title, WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, 0, wr.right - wr.left, wr.bottom - wr.top, nullptr, nullptr, - nullptr, nullptr); - - is_full_screen = false; - - // Center window if the current position in the config is set to auto, otherwise use that position - - int screen_width = GetSystemMetrics(SM_CXSCREEN); - int screen_height = GetSystemMetrics(SM_CYSCREEN); - int xPos = (configWindow.x == WAPI_WIN_CENTERPOS) ? (screen_width - wr.right) * 0.5 : configWindow.x; - int yPos = (configWindow.y == WAPI_WIN_CENTERPOS) ? (screen_height - wr.bottom) * 0.5 : configWindow.y; - SetWindowPos(h_wnd, 0, xPos, yPos, 0, 0, SWP_NOZORDER | SWP_NOSIZE); - - // Check if a lower latency flip model can be used - - lower_latency = IsWindows8Point1OrGreater(); + d3d.D3DCompile = (pD3DCompile)GetProcAddress(d3d.d3dcompiler_module, "D3DCompile"); // Create D3D11 device + gfx_dxgi_create_factory_and_device(DEBUG_D3D, 11, [](IDXGIAdapter1 *adapter, bool test_only) { #if DEBUG_D3D - UINT device_creation_flags = D3D11_CREATE_DEVICE_DEBUG; + UINT device_creation_flags = D3D11_CREATE_DEVICE_DEBUG; #else - UINT device_creation_flags = 0; + UINT device_creation_flags = 0; #endif + D3D_FEATURE_LEVEL FeatureLevels[] = { + D3D_FEATURE_LEVEL_11_0, + D3D_FEATURE_LEVEL_10_1, + D3D_FEATURE_LEVEL_10_0, + D3D_FEATURE_LEVEL_9_3, + D3D_FEATURE_LEVEL_9_2, + D3D_FEATURE_LEVEL_9_1 + }; - D3D_FEATURE_LEVEL FeatureLevels[] = { - D3D_FEATURE_LEVEL_11_0, - D3D_FEATURE_LEVEL_10_1, - D3D_FEATURE_LEVEL_10_0, - D3D_FEATURE_LEVEL_9_3, - D3D_FEATURE_LEVEL_9_2, - D3D_FEATURE_LEVEL_9_1 - }; + HRESULT res = d3d.D3D11CreateDevice( + adapter, + D3D_DRIVER_TYPE_UNKNOWN, // since we use a specific adapter + nullptr, + device_creation_flags, + FeatureLevels, + ARRAYSIZE(FeatureLevels), + D3D11_SDK_VERSION, + test_only ? nullptr : d3d.device.GetAddressOf(), + &d3d.feature_level, + test_only ? nullptr : d3d.context.GetAddressOf()); - ThrowIfFailed(D3D11CreateDevice( - nullptr, - D3D_DRIVER_TYPE_HARDWARE, - nullptr, - device_creation_flags, - FeatureLevels, - ARRAYSIZE(FeatureLevels), - D3D11_SDK_VERSION, - d3d.device.GetAddressOf(), - NULL, - d3d.context.GetAddressOf()), - h_wnd, "Failed to create D3D11 device."); + if (test_only) { + return SUCCEEDED(res); + } else { + ThrowIfFailed(res, gfx_dxgi_get_h_wnd(), "Failed to create D3D11 device."); + return true; + } + }); // Sample description to be used in back buffer and depth buffer @@ -477,116 +248,18 @@ static void gfx_d3d11_dxgi_init(const char *window_title) { d3d.sample_description.Quality = 0; // Create the swap chain - - if (lower_latency) { - - // Create swap chain description - - DXGI_SWAP_CHAIN_DESC1 swap_chain_desc1; - ZeroMemory(&swap_chain_desc1, sizeof(DXGI_SWAP_CHAIN_DESC1)); - - swap_chain_desc1.Width = DESIRED_SCREEN_WIDTH; - swap_chain_desc1.Height = DESIRED_SCREEN_HEIGHT; - swap_chain_desc1.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - swap_chain_desc1.Stereo = FALSE; - swap_chain_desc1.SampleDesc = d3d.sample_description; - swap_chain_desc1.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; - swap_chain_desc1.BufferCount = 2; - swap_chain_desc1.Scaling = DXGI_SCALING_STRETCH; - swap_chain_desc1.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; - swap_chain_desc1.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED; - swap_chain_desc1.Flags = DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT; - - // Create DXGI Factory - - ComPtr dxgi_device2; - ThrowIfFailed(d3d.device.Get()->QueryInterface(__uuidof(IDXGIDevice2), (void **) dxgi_device2.GetAddressOf()), - h_wnd, "Failed to get IDXGIDevice2."); - - ComPtr dxgi_adapter; - ThrowIfFailed(dxgi_device2.Get()->GetAdapter(dxgi_adapter.GetAddressOf()), - h_wnd, "Failed to get IDXGIAdapter."); - - ComPtr dxgi_factory2; - ThrowIfFailed(dxgi_adapter.Get()->GetParent(__uuidof(IDXGIFactory2), (void **) dxgi_factory2.GetAddressOf()), - h_wnd, "Failed to get IDXGIFactory2."); - - // Create Swap Chain - - ComPtr swap_chain1; - ThrowIfFailed(dxgi_factory2.Get()->CreateSwapChainForHwnd(d3d.device.Get(), h_wnd, &swap_chain_desc1, NULL, NULL, swap_chain1.GetAddressOf()), - h_wnd, "Failed to create IDXGISwapChain1."); - - ThrowIfFailed(swap_chain1.As(&d3d.swap_chain2), - h_wnd, "Failed to get IDXGISwapChain2 from IDXGISwapChain1."); - - ThrowIfFailed(d3d.swap_chain2.Get()->SetMaximumFrameLatency(1), - h_wnd, "Failed to Set Maximum Frame Latency to 1."); - - d3d.frame_latency_waitable_object = d3d.swap_chain2.Get()->GetFrameLatencyWaitableObject(); - - // Prevent DXGI from intercepting Alt+Enter - - ThrowIfFailed(dxgi_factory2.Get()->MakeWindowAssociation(h_wnd, DXGI_MWA_NO_WINDOW_CHANGES | DXGI_MWA_NO_ALT_ENTER), - h_wnd, "Failed to call MakeWindowAssociation."); - - } else { - - // Create swap chain description - - DXGI_SWAP_CHAIN_DESC swap_chain_desc; - ZeroMemory(&swap_chain_desc, sizeof(DXGI_SWAP_CHAIN_DESC)); - - swap_chain_desc.BufferDesc.Width = DESIRED_SCREEN_WIDTH; - swap_chain_desc.BufferDesc.Height = DESIRED_SCREEN_HEIGHT; - swap_chain_desc.BufferDesc.RefreshRate.Numerator = 0; - swap_chain_desc.BufferDesc.RefreshRate.Denominator = 1; - swap_chain_desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - swap_chain_desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; - swap_chain_desc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED; - swap_chain_desc.SampleDesc = d3d.sample_description; - swap_chain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; - swap_chain_desc.BufferCount = 1; - swap_chain_desc.OutputWindow = h_wnd; - swap_chain_desc.Windowed = TRUE; - swap_chain_desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; - swap_chain_desc.Flags = 0; - - // Create DXGI Factory - - ComPtr dxgi_device; - ThrowIfFailed(d3d.device.Get()->QueryInterface(__uuidof(IDXGIDevice), (void **) dxgi_device.GetAddressOf()), - h_wnd, "Failed to get IDXGIDevice."); - - ComPtr dxgi_adapter; - ThrowIfFailed(dxgi_device.Get()->GetAdapter(dxgi_adapter.GetAddressOf()), - h_wnd, "Failed to get IDXGIAdapter."); - - ComPtr dxgi_factory; - ThrowIfFailed(dxgi_adapter.Get()->GetParent(__uuidof(IDXGIFactory), (void **) dxgi_factory.GetAddressOf()), - h_wnd, "Failed to get IDXGIFactory."); - - // Create Swap Chain - - ThrowIfFailed(dxgi_factory.Get()->CreateSwapChain(d3d.device.Get(), &swap_chain_desc, d3d.swap_chain.GetAddressOf()), - h_wnd, "Failed to create IDXGISwapChain."); - - // Prevent DXGI from intercepting Alt+Enter - - ThrowIfFailed(dxgi_factory.Get()->MakeWindowAssociation(h_wnd, DXGI_MWA_NO_WINDOW_CHANGES | DXGI_MWA_NO_ALT_ENTER), - h_wnd, "Failed to call MakeWindowAssociation."); - } + d3d.swap_chain = gfx_dxgi_create_swap_chain(d3d.device.Get()); // Create D3D Debug device if in debug mode #if DEBUG_D3D ThrowIfFailed(d3d.device->QueryInterface(__uuidof(ID3D11Debug), (void **) d3d.debug.GetAddressOf()), - h_wnd, "Failed to get ID3D11Debug device."); + gfx_dxgi_get_h_wnd(), "Failed to get ID3D11Debug device."); #endif // Create views - create_render_target_views(DESIRED_SCREEN_WIDTH, DESIRED_SCREEN_HEIGHT); + create_render_target_views(false); // Create main vertex buffer @@ -599,8 +272,8 @@ static void gfx_d3d11_dxgi_init(const char *window_title) { vertex_buffer_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; vertex_buffer_desc.MiscFlags = 0; - ThrowIfFailed(d3d.device->CreateBuffer(&vertex_buffer_desc, NULL, d3d.vertex_buffer.GetAddressOf()), - h_wnd, "Failed to create vertex buffer."); + ThrowIfFailed(d3d.device->CreateBuffer(&vertex_buffer_desc, nullptr, d3d.vertex_buffer.GetAddressOf()), + gfx_dxgi_get_h_wnd(), "Failed to create vertex buffer."); // Create per-frame constant buffer @@ -613,8 +286,8 @@ static void gfx_d3d11_dxgi_init(const char *window_title) { constant_buffer_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; constant_buffer_desc.MiscFlags = 0; - ThrowIfFailed(d3d.device->CreateBuffer(&constant_buffer_desc, NULL, d3d.per_frame_cb.GetAddressOf()), - h_wnd, "Failed to create per-frame constant buffer."); + ThrowIfFailed(d3d.device->CreateBuffer(&constant_buffer_desc, nullptr, d3d.per_frame_cb.GetAddressOf()), + gfx_dxgi_get_h_wnd(), "Failed to create per-frame constant buffer."); d3d.context->PSSetConstantBuffers(0, 1, d3d.per_frame_cb.GetAddressOf()); @@ -626,154 +299,12 @@ static void gfx_d3d11_dxgi_init(const char *window_title) { constant_buffer_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; constant_buffer_desc.MiscFlags = 0; - ThrowIfFailed(d3d.device->CreateBuffer(&constant_buffer_desc, NULL, d3d.per_draw_cb.GetAddressOf()), - h_wnd, "Failed to create per-draw constant buffer."); + ThrowIfFailed(d3d.device->CreateBuffer(&constant_buffer_desc, nullptr, d3d.per_draw_cb.GetAddressOf()), + gfx_dxgi_get_h_wnd(), "Failed to create per-draw constant buffer."); d3d.context->PSSetConstantBuffers(1, 1, d3d.per_draw_cb.GetAddressOf()); - - // Initialize some timer values - - QueryPerformanceFrequency(&frequency); - accumulated_time.QuadPart = 0; - - // Decide vsync interval - - calculate_sync_interval(); - - // Reshape the window according to the config values - - update_screen_settings(); - - if (!is_full_screen) - ShowWindow(h_wnd, SW_SHOW); } -static void gfx_d3d11_dxgi_shutdown(void) { - if (d3d.swap_chain) d3d.swap_chain.Get()->SetFullscreenState(false, nullptr); - if (d3d.swap_chain2) d3d.swap_chain2.Get()->SetFullscreenState(false, nullptr); - - for (unsigned int i = 0; i < sizeof(d3d.shader_program_pool) / sizeof(d3d.shader_program_pool[0]); ++i) { - d3d.shader_program_pool[i].vertex_shader.Reset(); - d3d.shader_program_pool[i].pixel_shader.Reset(); - d3d.shader_program_pool[i].input_layout.Reset(); - d3d.shader_program_pool[i].blend_state.Reset(); - } - - d3d.rasterizer_state.Reset(); - d3d.backbuffer_view.Reset(); - d3d.depth_stencil_view.Reset(); - d3d.depth_stencil_state.Reset(); - d3d.context.Reset(); - d3d.device.Reset(); - d3d.swap_chain.Reset(); - d3d.swap_chain2.Reset(); - - if (h_wnd) { - DestroyWindow(h_wnd); - h_wnd = nullptr; - } -} - -static void gfx_d3d11_dxgi_set_keyboard_callbacks(bool (*on_key_down)(int scancode), bool (*on_key_up)(int scancode), void (*on_all_keys_up)(void)) { - d3d.on_key_down = on_key_down; - d3d.on_key_up = on_key_up; - d3d.on_all_keys_up = on_all_keys_up; -} - -static void gfx_d3d11_dxgi_main_loop(void (*run_one_game_iter)(void)) { - MSG msg = { 0 }; - - bool quit = false; - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - if (msg.message == WM_QUIT) { - quit = true; - } - } - - if (quit) { - return; - } - - if (IsIconic(h_wnd)) { - Sleep(50); - return; - } - - d3d.run_one_game_iter = run_one_game_iter; - - if (sync_interval == 0) { - LARGE_INTEGER current_time; - QueryPerformanceCounter(¤t_time); - - LARGE_INTEGER elapsed_time_microseconds; - elapsed_time_microseconds.QuadPart = current_time.QuadPart - last_time.QuadPart; - elapsed_time_microseconds.QuadPart *= 1000000; - elapsed_time_microseconds.QuadPart /= frequency.QuadPart; - - accumulated_time.QuadPart += elapsed_time_microseconds.QuadPart; - last_time = current_time; - - const uint32_t FRAME_TIME = 1000000 / 30; - - if (accumulated_time.QuadPart >= FRAME_TIME) { - accumulated_time.QuadPart %= FRAME_TIME; - - if (lower_latency) { - WaitForSingleObjectEx(d3d.frame_latency_waitable_object, 1000, true); - } - - if (d3d.run_one_game_iter != nullptr) { - d3d.run_one_game_iter(); - } - - if (lower_latency) { - d3d.swap_chain2->Present(1, 0); - } else { - d3d.swap_chain->Present(1, 0); - } - } else { - Sleep(1); - } - } else { - if (lower_latency) { - WaitForSingleObjectEx(d3d.frame_latency_waitable_object, 1000, true); - } - - if (d3d.run_one_game_iter != nullptr) { - d3d.run_one_game_iter(); - } - - if (lower_latency) { - d3d.swap_chain2->Present(sync_interval, 0); - } else { - d3d.swap_chain->Present(sync_interval, 0); - } - } -} - -static void gfx_d3d11_dxgi_get_dimensions(uint32_t *width, uint32_t *height) { - *width = d3d.current_width; - *height = d3d.current_height; -} - -static void gfx_d3d11_dxgi_handle_events(void) { -} - -static bool gfx_d3d11_dxgi_start_frame(void) { - return true; -} - -static void gfx_d3d11_dxgi_swap_buffers_begin(void) { -} - -static void gfx_d3d11_dxgi_swap_buffers_end(void) { -} - -double gfx_d3d11_dxgi_get_time(void) { - return 0.0; -} static bool gfx_d3d11_z_is_from_0_to_1(void) { return true; @@ -783,182 +314,17 @@ static void gfx_d3d11_unload_shader(struct ShaderProgram *old_prg) { } static void gfx_d3d11_load_shader(struct ShaderProgram *new_prg) { - d3d.shader_program = new_prg; + d3d.shader_program = (struct ShaderProgramD3D11 *)new_prg; } static struct ShaderProgram *gfx_d3d11_create_and_load_new_shader(uint32_t shader_id) { CCFeatures cc_features; - get_cc_features(shader_id, &cc_features); + gfx_cc_get_features(shader_id, &cc_features); char buf[4096]; - size_t len = 0; - size_t num_floats = 4; + size_t len, num_floats; - // Pixel shader input struct - - append_line(buf, &len, "struct PSInput {"); - append_line(buf, &len, " float4 position : SV_POSITION;"); - - if (cc_features.used_textures[0] || cc_features.used_textures[1]) { - append_line(buf, &len, " float2 uv : TEXCOORD;"); - num_floats += 2; - } - - if (cc_features.opt_alpha && cc_features.opt_noise) { - append_line(buf, &len, " float4 screenPos : TEXCOORD1;"); - } - - if (cc_features.opt_fog) { - append_line(buf, &len, " float4 fog : FOG;"); - num_floats += 4; - } - for (uint32_t i = 0; i < cc_features.num_inputs; i++) { - len += sprintf(buf + len, " float%d input%d : INPUT%d;\r\n", cc_features.opt_alpha ? 4 : 3, i + 1, i); - num_floats += cc_features.opt_alpha ? 4 : 3; - } - append_line(buf, &len, "};"); - - // Textures and samplers - - if (cc_features.used_textures[0]) { - append_line(buf, &len, "Texture2D g_texture0 : register(t0);"); - append_line(buf, &len, "SamplerState g_sampler0 : register(s0);"); - } - if (cc_features.used_textures[1]) { - append_line(buf, &len, "Texture2D g_texture1 : register(t1);"); - append_line(buf, &len, "SamplerState g_sampler1 : register(s1);"); - } - - // Constant buffer and random function - - if (cc_features.opt_alpha && cc_features.opt_noise) { - append_line(buf, &len, "cbuffer PerFrameCB : register(b0) {"); - append_line(buf, &len, " uint noise_frame;"); - append_line(buf, &len, " float2 noise_scale;"); - append_line(buf, &len, "}"); - - append_line(buf, &len, "float random(in float3 value) {"); - append_line(buf, &len, " float random = dot(value, float3(12.9898, 78.233, 37.719));"); - append_line(buf, &len, " return frac(sin(random) * 143758.5453);"); - append_line(buf, &len, "}"); - } - - // 3 point texture filtering - // Original author: ArthurCarvalho - // Based on GLSL implementation by twinaphex, mupen64plus-libretro project. - - if (configFiltering == 2) { - if (cc_features.used_textures[0] || cc_features.used_textures[1]) { - append_line(buf, &len, "cbuffer PerDrawCB : register(b1) {"); - append_line(buf, &len, " struct {"); - append_line(buf, &len, " uint width;"); - append_line(buf, &len, " uint height;"); - append_line(buf, &len, " bool linear_filtering;"); - append_line(buf, &len, " } textures[2];"); - append_line(buf, &len, "}"); - append_line(buf, &len, "#define TEX_OFFSET(tex, tSampler, texCoord, off, texSize) tex.Sample(tSampler, texCoord - off / texSize)"); - append_line(buf, &len, "float4 tex2D3PointFilter(in Texture2D tex, in SamplerState tSampler, in float2 texCoord, in float2 texSize) {"); - append_line(buf, &len, " float2 offset = frac(texCoord * texSize - float2(0.5, 0.5));"); - append_line(buf, &len, " offset -= step(1.0, offset.x + offset.y);"); - append_line(buf, &len, " float4 c0 = TEX_OFFSET(tex, tSampler, texCoord, offset, texSize);"); - append_line(buf, &len, " float4 c1 = TEX_OFFSET(tex, tSampler, texCoord, float2(offset.x - sign(offset.x), offset.y), texSize);"); - append_line(buf, &len, " float4 c2 = TEX_OFFSET(tex, tSampler, texCoord, float2(offset.x, offset.y - sign(offset.y)), texSize);"); - append_line(buf, &len, " return c0 + abs(offset.x)*(c1-c0) + abs(offset.y)*(c2-c0);"); - append_line(buf, &len, "}"); - } - } - - // Vertex shader - - append_str(buf, &len, "PSInput VSMain(float4 position : POSITION"); - if (cc_features.used_textures[0] || cc_features.used_textures[1]) { - append_str(buf, &len, ", float2 uv : TEXCOORD"); - } - if (cc_features.opt_fog) { - append_str(buf, &len, ", float4 fog : FOG"); - } - for (uint32_t i = 0; i < cc_features.num_inputs; i++) { - len += sprintf(buf + len, ", float%d input%d : INPUT%d", cc_features.opt_alpha ? 4 : 3, i + 1, i); - } - append_line(buf, &len, ") {"); - append_line(buf, &len, " PSInput result;"); - append_line(buf, &len, " result.position = position;"); - if (cc_features.opt_alpha && cc_features.opt_noise) { - append_line(buf, &len, " result.screenPos = position;"); - } - if (cc_features.used_textures[0] || cc_features.used_textures[1]) { - append_line(buf, &len, " result.uv = uv;"); - } - if (cc_features.opt_fog) { - append_line(buf, &len, " result.fog = fog;"); - } - for (uint32_t i = 0; i < cc_features.num_inputs; i++) { - len += sprintf(buf + len, " result.input%d = input%d;\r\n", i + 1, i + 1); - } - append_line(buf, &len, " return result;"); - append_line(buf, &len, "}"); - - // Pixel shader - - append_line(buf, &len, "float4 PSMain(PSInput input) : SV_TARGET {"); - if (cc_features.used_textures[0]) { - if (configFiltering == 2) { - append_line(buf, &len, " float4 texVal0;"); - append_line(buf, &len, " if (textures[0].linear_filtering)"); - append_line(buf, &len, " texVal0 = tex2D3PointFilter(g_texture0, g_sampler0, input.uv, float2(textures[0].width, textures[0].height));"); - append_line(buf, &len, " else"); - append_line(buf, &len, " texVal0 = g_texture0.Sample(g_sampler0, input.uv);"); - } else { - append_line(buf, &len, " float4 texVal0 = g_texture0.Sample(g_sampler0, input.uv);"); - } - } - if (cc_features.used_textures[1]) { - if (configFiltering == 2) { - append_line(buf, &len, " float4 texVal1;"); - append_line(buf, &len, " if (textures[1].linear_filtering)"); - append_line(buf, &len, " texVal1 = tex2D3PointFilter(g_texture1, g_sampler1, input.uv, float2(textures[1].width, textures[1].height));"); - append_line(buf, &len, " else"); - append_line(buf, &len, " texVal1 = g_texture1.Sample(g_sampler1, input.uv);"); - } else { - append_line(buf, &len, " float4 texVal1 = g_texture1.Sample(g_sampler1, input.uv);"); - } - } - - append_str(buf, &len, cc_features.opt_alpha ? " float4 texel = " : " float3 texel = "); - if (!cc_features.color_alpha_same && cc_features.opt_alpha) { - append_str(buf, &len, "float4("); - append_formula(buf, &len, cc_features.c, cc_features.do_single[0], cc_features.do_multiply[0], cc_features.do_mix[0], false, false, true); - append_str(buf, &len, ", "); - append_formula(buf, &len, cc_features.c, cc_features.do_single[1], cc_features.do_multiply[1], cc_features.do_mix[1], true, true, true); - append_str(buf, &len, ")"); - } else { - append_formula(buf, &len, cc_features.c, cc_features.do_single[0], cc_features.do_multiply[0], cc_features.do_mix[0], cc_features.opt_alpha, false, cc_features.opt_alpha); - } - append_line(buf, &len, ";"); - - if (cc_features.opt_texture_edge && cc_features.opt_alpha) { - append_line(buf, &len, " if (texel.a > 0.3) texel.a = 1.0; else discard;"); - } - // TODO discard if alpha is 0? - if (cc_features.opt_fog) { - if (cc_features.opt_alpha) { - append_line(buf, &len, " texel = float4(lerp(texel.rgb, input.fog.rgb, input.fog.a), texel.a);"); - } else { - append_line(buf, &len, " texel = lerp(texel, input.fog.rgb, input.fog.a);"); - } - } - - if (cc_features.opt_alpha && cc_features.opt_noise) { - append_line(buf, &len, " float2 coords = (input.screenPos.xy / input.screenPos.w) * noise_scale;"); - append_line(buf, &len, " texel.a *= round(random(float3(floor(coords), noise_frame)));"); - } - - if (cc_features.opt_alpha) { - append_line(buf, &len, " return texel;"); - } else { - append_line(buf, &len, " return float4(texel, 1.0);"); - } - append_line(buf, &len, "}"); + gfx_direct3d_common_build_shader(buf, len, num_floats, cc_features, false, THREE_POINT_FILTERING); ComPtr vs, ps; ComPtr error_blob; @@ -969,20 +335,24 @@ static struct ShaderProgram *gfx_d3d11_create_and_load_new_shader(uint32_t shade UINT compile_flags = D3DCOMPILE_OPTIMIZATION_LEVEL2; #endif - HRESULT hr = D3DCompile(buf, len, nullptr, nullptr, nullptr, "VSMain", "vs_4_0_level_9_1", compile_flags, 0, vs.GetAddressOf(), error_blob.GetAddressOf()); + HRESULT hr = d3d.D3DCompile(buf, len, nullptr, nullptr, nullptr, "VSMain", "vs_4_0_level_9_1", compile_flags, 0, vs.GetAddressOf(), error_blob.GetAddressOf()); - if (FAILED(hr)) - sys_fatal("%s", (char *) error_blob->GetBufferPointer()); + if (FAILED(hr)) { + MessageBox(gfx_dxgi_get_h_wnd(), (char *) error_blob->GetBufferPointer(), "Error", MB_OK | MB_ICONERROR); + throw hr; + } - hr = D3DCompile(buf, len, nullptr, nullptr, nullptr, "PSMain", "ps_4_0_level_9_1", compile_flags, 0, ps.GetAddressOf(), error_blob.GetAddressOf()); + hr = d3d.D3DCompile(buf, len, nullptr, nullptr, nullptr, "PSMain", "ps_4_0_level_9_1", compile_flags, 0, ps.GetAddressOf(), error_blob.GetAddressOf()); - if (FAILED(hr)) - sys_fatal("%s", (char *) error_blob->GetBufferPointer()); + if (FAILED(hr)) { + MessageBox(gfx_dxgi_get_h_wnd(), (char *) error_blob->GetBufferPointer(), "Error", MB_OK | MB_ICONERROR); + throw hr; + } - struct ShaderProgram *prg = &d3d.shader_program_pool[d3d.shader_program_pool_size++]; + struct ShaderProgramD3D11 *prg = &d3d.shader_program_pool[d3d.shader_program_pool_size++]; - ThrowIfFailed(d3d.device->CreateVertexShader(vs->GetBufferPointer(), vs->GetBufferSize(), NULL, prg->vertex_shader.GetAddressOf())); - ThrowIfFailed(d3d.device->CreatePixelShader(ps->GetBufferPointer(), ps->GetBufferSize(), NULL, prg->pixel_shader.GetAddressOf())); + ThrowIfFailed(d3d.device->CreateVertexShader(vs->GetBufferPointer(), vs->GetBufferSize(), nullptr, prg->vertex_shader.GetAddressOf())); + ThrowIfFailed(d3d.device->CreatePixelShader(ps->GetBufferPointer(), ps->GetBufferSize(), nullptr, prg->pixel_shader.GetAddressOf())); // Input Layout @@ -1031,22 +401,24 @@ static struct ShaderProgram *gfx_d3d11_create_and_load_new_shader(uint32_t shade prg->used_textures[0] = cc_features.used_textures[0]; prg->used_textures[1] = cc_features.used_textures[1]; - return d3d.shader_program = prg; + return (struct ShaderProgram *)(d3d.shader_program = prg); } static struct ShaderProgram *gfx_d3d11_lookup_shader(uint32_t shader_id) { for (size_t i = 0; i < d3d.shader_program_pool_size; i++) { if (d3d.shader_program_pool[i].shader_id == shader_id) { - return &d3d.shader_program_pool[i]; + return (struct ShaderProgram *)&d3d.shader_program_pool[i]; } } - return NULL; + return nullptr; } static void gfx_d3d11_shader_get_info(struct ShaderProgram *prg, uint8_t *num_inputs, bool used_textures[2]) { - *num_inputs = prg->num_inputs; - used_textures[0] = prg->used_textures[0]; - used_textures[1] = prg->used_textures[1]; + struct ShaderProgramD3D11 *p = (struct ShaderProgramD3D11 *)prg; + + *num_inputs = p->num_inputs; + used_textures[0] = p->used_textures[0]; + used_textures[1] = p->used_textures[1]; } static uint32_t gfx_d3d11_new_texture(void) { @@ -1066,7 +438,7 @@ static D3D11_TEXTURE_ADDRESS_MODE gfx_cm_to_d3d11(uint32_t val) { return (val & G_TX_MIRROR) ? D3D11_TEXTURE_ADDRESS_MIRROR : D3D11_TEXTURE_ADDRESS_WRAP; } -static void gfx_d3d11_upload_texture(uint8_t *rgba32_buf, int width, int height) { +static void gfx_d3d11_upload_texture(const uint8_t *rgba32_buf, int width, int height) { // Create texture D3D11_TEXTURE2D_DESC texture_desc; @@ -1106,6 +478,11 @@ static void gfx_d3d11_upload_texture(uint8_t *rgba32_buf, int width, int height) texture_data->width = width; texture_data->height = height; + if (texture_data->resource_view.Get() != nullptr) { + // Free the previous texture in this slot + texture_data->resource_view.Reset(); + } + ThrowIfFailed(d3d.device->CreateShaderResourceView(texture.Get(), &resource_view_desc, texture_data->resource_view.GetAddressOf())); } @@ -1113,11 +490,11 @@ static void gfx_d3d11_set_sampler_parameters(int tile, bool linear_filter, uint3 D3D11_SAMPLER_DESC sampler_desc; ZeroMemory(&sampler_desc, sizeof(D3D11_SAMPLER_DESC)); - if (configFiltering == 2) - sampler_desc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; - else - sampler_desc.Filter = linear_filter ? D3D11_FILTER_MIN_MAG_MIP_LINEAR : D3D11_FILTER_MIN_MAG_MIP_POINT; - +#if THREE_POINT_FILTERING + sampler_desc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; +#else + sampler_desc.Filter = linear_filter ? D3D11_FILTER_MIN_MAG_MIP_LINEAR : D3D11_FILTER_MIN_MAG_MIP_POINT; +#endif sampler_desc.AddressU = gfx_cm_to_d3d11(cms); sampler_desc.AddressV = gfx_cm_to_d3d11(cmt); sampler_desc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP; @@ -1224,12 +601,12 @@ static void gfx_d3d11_draw_triangles(float buf_vbo[], size_t buf_vbo_len, size_t d3d.last_resource_views[i] = d3d.textures[d3d.current_texture_ids[i]].resource_view.Get(); d3d.context->PSSetShaderResources(i, 1, d3d.textures[d3d.current_texture_ids[i]].resource_view.GetAddressOf()); - if (configFiltering == 2) { - d3d.per_draw_cb_data.textures[i].width = d3d.textures[d3d.current_texture_ids[i]].width; - d3d.per_draw_cb_data.textures[i].height = d3d.textures[d3d.current_texture_ids[i]].height; - d3d.per_draw_cb_data.textures[i].linear_filtering = d3d.textures[d3d.current_texture_ids[i]].linear_filtering; - textures_changed = true; - } +#if THREE_POINT_FILTERING + d3d.per_draw_cb_data.textures[i].width = d3d.textures[d3d.current_texture_ids[i]].width; + d3d.per_draw_cb_data.textures[i].height = d3d.textures[d3d.current_texture_ids[i]].height; + d3d.per_draw_cb_data.textures[i].linear_filtering = d3d.textures[d3d.current_texture_ids[i]].linear_filtering; + textures_changed = true; +#endif if (d3d.last_sampler_states[i].Get() != d3d.textures[d3d.current_texture_ids[i]].sampler_state.Get()) { d3d.last_sampler_states[i] = d3d.textures[d3d.current_texture_ids[i]].sampler_state.Get(); @@ -1285,9 +662,9 @@ static void gfx_d3d11_draw_triangles(float buf_vbo[], size_t buf_vbo_len, size_t d3d.context->Draw(buf_vbo_num_tris * 3, 0); } -static void gfx_d3d11_init(void) { } - -static void gfx_d3d11_shutdown(void) { } +static void gfx_d3d11_on_resize(void) { + create_render_target_views(true); +} static void gfx_d3d11_start_frame(void) { // Set render targets @@ -1318,7 +695,15 @@ static void gfx_d3d11_start_frame(void) { d3d.context->Unmap(d3d.per_frame_cb.Get(), 0); } -struct GfxRenderingAPI gfx_d3d11_api = { +static void gfx_d3d11_end_frame(void) { +} + +static void gfx_d3d11_finish_render(void) { +} + +} // namespace + +struct GfxRenderingAPI gfx_direct3d11_api = { gfx_d3d11_z_is_from_0_to_1, gfx_d3d11_unload_shader, gfx_d3d11_load_shader, @@ -1337,27 +722,10 @@ struct GfxRenderingAPI gfx_d3d11_api = { gfx_d3d11_set_use_alpha, gfx_d3d11_draw_triangles, gfx_d3d11_init, + gfx_d3d11_on_resize, gfx_d3d11_start_frame, - gfx_d3d11_shutdown, + gfx_d3d11_end_frame, + gfx_d3d11_finish_render }; -struct GfxWindowManagerAPI gfx_dxgi = { - gfx_d3d11_dxgi_init, - gfx_d3d11_dxgi_set_keyboard_callbacks, - gfx_d3d11_dxgi_main_loop, - gfx_d3d11_dxgi_get_dimensions, - gfx_d3d11_dxgi_handle_events, - gfx_d3d11_dxgi_start_frame, - gfx_d3d11_dxgi_swap_buffers_begin, - gfx_d3d11_dxgi_swap_buffers_end, - gfx_d3d11_dxgi_get_time, - gfx_d3d11_dxgi_shutdown, -}; - -#else - -#error "D3D11 is only supported on Windows" - -#endif // _WIN32 - -#endif // RAPI_D3D11 +#endif diff --git a/src/pc/gfx/gfx_direct3d11.h b/src/pc/gfx/gfx_direct3d11.h index 60b122b3..5d795602 100644 --- a/src/pc/gfx/gfx_direct3d11.h +++ b/src/pc/gfx/gfx_direct3d11.h @@ -1,10 +1,12 @@ +#ifdef RAPI_D3D11 + #ifndef GFX_DIRECT3D11_H #define GFX_DIRECT3D11_H -#include "gfx_window_manager_api.h" #include "gfx_rendering_api.h" -extern struct GfxWindowManagerAPI gfx_dxgi; -extern struct GfxRenderingAPI gfx_d3d11_api; +extern struct GfxRenderingAPI gfx_direct3d11_api; + +#endif #endif diff --git a/src/pc/gfx/gfx_direct3d12.cpp b/src/pc/gfx/gfx_direct3d12.cpp index 3fe9aed1..2a31043b 100644 --- a/src/pc/gfx/gfx_direct3d12.cpp +++ b/src/pc/gfx/gfx_direct3d12.cpp @@ -1,7 +1,6 @@ #ifdef RAPI_D3D12 -#if defined(_WIN32) || defined(_WIN64) - +#include #include #include #include @@ -13,21 +12,16 @@ #include #include -// These are needed when compiling with MinGW -#include -#include +// This is needed when compiling with MinGW, used in d3d12.h #define __in_ecount_opt(size) -#define __in -#define __out -#define __REQUIRED_RPCNDR_H_VERSION__ 475 -#include -#include #include #include -#include +#include "dxsdk/d3d12.h" #include +#include "gfx_direct3d12_guids.h" + #include "dxsdk/d3dx12.h" #ifndef _LANGUAGE_C @@ -35,12 +29,8 @@ #endif #include -extern "C" { -#include "../cliopts.h" -#include "../configfile.h" -#include "../platform.h" -#include "../pc_main.h" -} +#define DECLARE_GFX_DXGI_FUNCTIONS +#include "gfx_dxgi.h" #include "gfx_cc.h" #include "gfx_window_manager_api.h" @@ -49,21 +39,13 @@ extern "C" { #include "gfx_screen_config.h" -#define WINCLASS_NAME L"SUPERMARIO64" -#define GFX_API_NAME "Direct3D 12" #define DEBUG_D3D 0 -#ifdef VERSION_EU -#define FRAME_INTERVAL_US_NUMERATOR 40000 -#define FRAME_INTERVAL_US_DENOMINATOR 1 -#else -#define FRAME_INTERVAL_US_NUMERATOR 100000 -#define FRAME_INTERVAL_US_DENOMINATOR 3 -#endif - using namespace Microsoft::WRL; // For ComPtr -struct ShaderProgram { +namespace { + +struct ShaderProgramD3D12 { uint32_t shader_id; uint8_t num_inputs; bool used_textures[2]; @@ -106,13 +88,26 @@ struct TextureData { int sampler_parameters; }; +struct NoiseCB { + uint32_t noise_frame; + float noise_scale_x; + float noise_scale_y; + uint32_t padding; +}; + static struct { - struct ShaderProgram shader_program_pool[64]; + HMODULE d3d12_module; + PFN_D3D12_CREATE_DEVICE D3D12CreateDevice; + PFN_D3D12_GET_DEBUG_INTERFACE D3D12GetDebugInterface; + + HMODULE d3dcompiler_module; + pD3DCompile D3DCompile; + + struct ShaderProgramD3D12 shader_program_pool[64]; uint8_t shader_program_pool_size; uint32_t current_width, current_height; - ComPtr factory; ComPtr device; ComPtr command_queue; ComPtr copy_command_queue; @@ -146,17 +141,13 @@ static struct { int frame_index; ComPtr fence; HANDLE fence_event; - HANDLE waitable_object; - uint64_t qpc_init, qpc_freq; - uint64_t frame_timestamp; // in units of 1/FRAME_INTERVAL_US_DENOMINATOR microseconds - std::map frame_stats; - std::set> pending_frame_stats; - bool dropped_frame; - bool sync_interval_means_frames_to_wait; - UINT length_in_vsync_frames; uint64_t frame_counter; + ComPtr noise_cb; + void *mapped_noise_cb_address; + struct NoiseCB noise_cb_data; + ComPtr vertex_buffer; void *mapped_vbuf_address; int vbuf_pos; @@ -169,25 +160,20 @@ static struct { // Current state: ID3D12PipelineState *pipeline_state; - struct ShaderProgram *shader_program; + struct ShaderProgramD3D12 *shader_program; bool depth_test; bool depth_mask; bool zmode_decal; CD3DX12_VIEWPORT viewport; CD3DX12_RECT scissor; - - void (*run_one_game_iter)(void); - bool (*on_key_down)(int scancode); - bool (*on_key_up)(int scancode); - void (*on_all_keys_up)(void); } d3d; static int texture_uploads = 0; static int max_texture_uploads; static D3D12_CPU_DESCRIPTOR_HANDLE get_cpu_descriptor_handle(ComPtr& heap) { -#if __MINGW32__ +#ifdef __MINGW32__ // We would like to do this: // D3D12_CPU_DESCRIPTOR_HANDLE handle = heap->GetCPUDescriptorHandleForHeapStart(); // but MinGW64 doesn't follow the calling conventions of VC++ for some reason. @@ -232,19 +218,19 @@ static D3D12_RESOURCE_ALLOCATION_INFO get_resource_allocation_info(const D3D12_R #endif } -static bool gfx_d3d12_z_is_from_0_to_1(void) { +static bool gfx_direct3d12_z_is_from_0_to_1(void) { return true; } -static void gfx_d3d12_unload_shader(struct ShaderProgram *old_prg) { +static void gfx_direct3d12_unload_shader(struct ShaderProgram *old_prg) { } -static void gfx_d3d12_load_shader(struct ShaderProgram *new_prg) { - d3d.shader_program = new_prg; +static void gfx_direct3d12_load_shader(struct ShaderProgram *new_prg) { + d3d.shader_program = (struct ShaderProgramD3D12 *)new_prg; d3d.must_reload_pipeline = true; } -static struct ShaderProgram *gfx_d3d12_create_and_load_new_shader(uint32_t shader_id) { +static struct ShaderProgram *gfx_direct3d12_create_and_load_new_shader(uint32_t shader_id) { /*static FILE *fp; if (!fp) { fp = fopen("shaders.txt", "w"); @@ -252,124 +238,22 @@ static struct ShaderProgram *gfx_d3d12_create_and_load_new_shader(uint32_t shade fprintf(fp, "0x%08x\n", shader_id); fflush(fp);*/ - struct ShaderProgram *prg = &d3d.shader_program_pool[d3d.shader_program_pool_size++]; + struct ShaderProgramD3D12 *prg = &d3d.shader_program_pool[d3d.shader_program_pool_size++]; CCFeatures cc_features; - get_cc_features(shader_id, &cc_features); + gfx_cc_get_features(shader_id, &cc_features); char buf[2048]; - size_t len = 0; - size_t num_floats = 4; + size_t len, num_floats; - append_str(buf, &len, "#define RS \"RootFlags(ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | DENY_VERTEX_SHADER_ROOT_ACCESS)"); - if (cc_features.used_textures[0]) { - append_str(buf, &len, ",DescriptorTable(SRV(t0), visibility = SHADER_VISIBILITY_PIXEL)"); - append_str(buf, &len, ",DescriptorTable(Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL)"); - } - if (cc_features.used_textures[1]) { - append_str(buf, &len, ",DescriptorTable(SRV(t1), visibility = SHADER_VISIBILITY_PIXEL)"); - append_str(buf, &len, ",DescriptorTable(Sampler(s1), visibility = SHADER_VISIBILITY_PIXEL)"); - } - append_line(buf, &len, "\""); - - append_line(buf, &len, "struct PSInput {"); - append_line(buf, &len, "float4 position : SV_POSITION;"); - if (cc_features.used_textures[0] || cc_features.used_textures[1]) { - append_line(buf, &len, "float2 uv : TEXCOORD;"); - num_floats += 2; - } - if (cc_features.opt_fog) { - append_line(buf, &len, "float4 fog : FOG;"); - num_floats += 4; - } - for (int i = 0; i < cc_features.num_inputs; i++) { - len += sprintf(buf + len, "float%d input%d : INPUT%d;\r\n", cc_features.opt_alpha ? 4 : 3, i + 1, i); - num_floats += cc_features.opt_alpha ? 4 : 3; - } - append_line(buf, &len, "};"); - - if (cc_features.used_textures[0]) { - append_line(buf, &len, "Texture2D g_texture0 : register(t0);"); - append_line(buf, &len, "SamplerState g_sampler0 : register(s0);"); - } - if (cc_features.used_textures[1]) { - append_line(buf, &len, "Texture2D g_texture1 : register(t1);"); - append_line(buf, &len, "SamplerState g_sampler1 : register(s1);"); - } - - // Vertex shader - append_str(buf, &len, "PSInput VSMain(float4 position : POSITION"); - if (cc_features.used_textures[0] || cc_features.used_textures[1]) { - append_str(buf, &len, ", float2 uv : TEXCOORD"); - } - if (cc_features.opt_fog) { - append_str(buf, &len, ", float4 fog : FOG"); - } - for (int i = 0; i < cc_features.num_inputs; i++) { - len += sprintf(buf + len, ", float%d input%d : INPUT%d", cc_features.opt_alpha ? 4 : 3, i + 1, i); - } - append_line(buf, &len, ") {"); - append_line(buf, &len, "PSInput result;"); - append_line(buf, &len, "result.position = position;"); - if (cc_features.used_textures[0] || cc_features.used_textures[1]) { - append_line(buf, &len, "result.uv = uv;"); - } - if (cc_features.opt_fog) { - append_line(buf, &len, "result.fog = fog;"); - } - for (int i = 0; i < cc_features.num_inputs; i++) { - len += sprintf(buf + len, "result.input%d = input%d;\r\n", i + 1, i + 1); - } - append_line(buf, &len, "return result;"); - append_line(buf, &len, "}"); - - // Pixel shader - append_line(buf, &len, "[RootSignature(RS)]"); - append_line(buf, &len, "float4 PSMain(PSInput input) : SV_TARGET {"); - if (cc_features.used_textures[0]) { - append_line(buf, &len, "float4 texVal0 = g_texture0.Sample(g_sampler0, input.uv);"); - } - if (cc_features.used_textures[1]) { - append_line(buf, &len, "float4 texVal1 = g_texture1.Sample(g_sampler1, input.uv);"); - } - - append_str(buf, &len, cc_features.opt_alpha ? "float4 texel = " : "float3 texel = "); - if (!cc_features.color_alpha_same && cc_features.opt_alpha) { - append_str(buf, &len, "float4("); - append_formula(buf, &len, cc_features.c, cc_features.do_single[0], cc_features.do_multiply[0], cc_features.do_mix[0], false, false, true); - append_str(buf, &len, ", "); - append_formula(buf, &len, cc_features.c, cc_features.do_single[1], cc_features.do_multiply[1], cc_features.do_mix[1], true, true, true); - append_str(buf, &len, ")"); - } else { - append_formula(buf, &len, cc_features.c, cc_features.do_single[0], cc_features.do_multiply[0], cc_features.do_mix[0], cc_features.opt_alpha, false, cc_features.opt_alpha); - } - append_line(buf, &len, ";"); - - if (cc_features.opt_texture_edge && cc_features.opt_alpha) { - append_line(buf, &len, "if (texel.a > 0.3) texel.a = 1.0; else discard;"); - } - // TODO discard if alpha is 0? - if (cc_features.opt_fog) { - if (cc_features.opt_alpha) { - append_line(buf, &len, "texel = float4(lerp(texel.rgb, input.fog.rgb, input.fog.a), texel.a);"); - } else { - append_line(buf, &len, "texel = lerp(texel, input.fog.rgb, input.fog.a);"); - } - } - - if (cc_features.opt_alpha) { - append_line(buf, &len, "return texel;"); - } else { - append_line(buf, &len, "return float4(texel, 1.0);"); - } - append_line(buf, &len, "}"); + gfx_direct3d_common_build_shader(buf, len, num_floats, cc_features, true, false); //fwrite(buf, 1, len, stdout); - ThrowIfFailed(D3DCompile(buf, len, nullptr, nullptr, nullptr, "VSMain", "vs_5_1", /*D3DCOMPILE_OPTIMIZATION_LEVEL3*/0, 0, &prg->vertex_shader, nullptr)); - ThrowIfFailed(D3DCompile(buf, len, nullptr, nullptr, nullptr, "PSMain", "ps_5_1", /*D3DCOMPILE_OPTIMIZATION_LEVEL3*/0, 0, &prg->pixel_shader, nullptr)); + ThrowIfFailed(d3d.D3DCompile(buf, len, nullptr, nullptr, nullptr, "VSMain", "vs_5_1", D3DCOMPILE_OPTIMIZATION_LEVEL3, 0, &prg->vertex_shader, nullptr)); + ThrowIfFailed(d3d.D3DCompile(buf, len, nullptr, nullptr, nullptr, "PSMain", "ps_5_1", D3DCOMPILE_OPTIMIZATION_LEVEL3, 0, &prg->pixel_shader, nullptr)); - ThrowIfFailed(d3d.device->CreateRootSignature(0, prg->pixel_shader->GetBufferPointer(), prg->pixel_shader->GetBufferSize(), IID_ID3D12RootSignature, IID_PPV_ARGS_Helper(&prg->root_signature))); + ThrowIfFailed(d3d.device->CreateRootSignature(0, prg->pixel_shader->GetBufferPointer(), prg->pixel_shader->GetBufferSize(), IID_PPV_ARGS(&prg->root_signature))); prg->shader_id = shader_id; prg->num_inputs = cc_features.num_inputs; @@ -379,35 +263,37 @@ static struct ShaderProgram *gfx_d3d12_create_and_load_new_shader(uint32_t shade //prg->num_attribs = cnt; d3d.must_reload_pipeline = true; - return d3d.shader_program = prg; + return (struct ShaderProgram *)(d3d.shader_program = prg); } -static struct ShaderProgram *gfx_d3d12_lookup_shader(uint32_t shader_id) { +static struct ShaderProgram *gfx_direct3d12_lookup_shader(uint32_t shader_id) { for (size_t i = 0; i < d3d.shader_program_pool_size; i++) { if (d3d.shader_program_pool[i].shader_id == shader_id) { - return &d3d.shader_program_pool[i]; + return (struct ShaderProgram *)&d3d.shader_program_pool[i]; } } return nullptr; } -static void gfx_d3d12_shader_get_info(struct ShaderProgram *prg, uint8_t *num_inputs, bool used_textures[2]) { - *num_inputs = prg->num_inputs; - used_textures[0] = prg->used_textures[0]; - used_textures[1] = prg->used_textures[1]; +static void gfx_direct3d12_shader_get_info(struct ShaderProgram *prg, uint8_t *num_inputs, bool used_textures[2]) { + struct ShaderProgramD3D12 *p = (struct ShaderProgramD3D12 *)prg; + + *num_inputs = p->num_inputs; + used_textures[0] = p->used_textures[0]; + used_textures[1] = p->used_textures[1]; } -static uint32_t gfx_d3d12_new_texture(void) { +static uint32_t gfx_direct3d12_new_texture(void) { d3d.textures.resize(d3d.textures.size() + 1); return (uint32_t)(d3d.textures.size() - 1); } -static void gfx_d3d12_select_texture(int tile, uint32_t texture_id) { +static void gfx_direct3d12_select_texture(int tile, uint32_t texture_id) { d3d.current_tile = tile; d3d.current_texture_ids[tile] = texture_id; } -static void gfx_d3d12_upload_texture(uint8_t *rgba32_buf, int width, int height) { +static void gfx_direct3d12_upload_texture(const uint8_t *rgba32_buf, int width, int height) { texture_uploads++; ComPtr texture_resource; @@ -423,8 +309,7 @@ static void gfx_d3d12_upload_texture(uint8_t *rgba32_buf, int width, int height) texture_desc.SampleDesc.Count = 1; texture_desc.SampleDesc.Quality = 0; texture_desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; - texture_desc.Alignment = ((width + 31) / 32) * ((height + 31) / 32) > 16 ? - 0 : D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT; + texture_desc.Alignment = ((width + 31) / 32) * ((height + 31) / 32) > 16 ? 0 : D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT; D3D12_RESOURCE_ALLOCATION_INFO alloc_info = get_resource_allocation_info(&texture_desc); @@ -440,7 +325,13 @@ static void gfx_d3d12_upload_texture(uint8_t *rgba32_buf, int width, int height) heaps.resize(heaps.size() + 1); found_heap = &heaps.back(); - const int textures_per_heap = 64; + // In case of HD textures, make sure too much memory isn't wasted + int textures_per_heap = 524288 / alloc_info.SizeInBytes; + if (textures_per_heap < 1) { + textures_per_heap = 1; + } else if (textures_per_heap > 64) { + textures_per_heap = 64; + } D3D12_HEAP_DESC heap_desc = {}; heap_desc.SizeInBytes = alloc_info.SizeInBytes * textures_per_heap; @@ -453,7 +344,7 @@ static void gfx_d3d12_upload_texture(uint8_t *rgba32_buf, int width, int height) heap_desc.Properties.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; heap_desc.Properties.Type = D3D12_HEAP_TYPE_DEFAULT; heap_desc.Flags = D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES; - ThrowIfFailed(d3d.device->CreateHeap(&heap_desc, IID_ID3D12Heap, IID_PPV_ARGS_Helper(&found_heap->heap))); + ThrowIfFailed(d3d.device->CreateHeap(&heap_desc, IID_PPV_ARGS(&found_heap->heap))); for (int i = 0; i < textures_per_heap; i++) { found_heap->free_list.push_back(i); } @@ -461,7 +352,7 @@ static void gfx_d3d12_upload_texture(uint8_t *rgba32_buf, int width, int height) uint8_t heap_offset = found_heap->free_list.back(); found_heap->free_list.pop_back(); - ThrowIfFailed(d3d.device->CreatePlacedResource(found_heap->heap.Get(), heap_offset * alloc_info.SizeInBytes, &texture_desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_ID3D12Resource, IID_PPV_ARGS_Helper(&texture_resource))); + ThrowIfFailed(d3d.device->CreatePlacedResource(found_heap->heap.Get(), heap_offset * alloc_info.SizeInBytes, &texture_desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_PPV_ARGS(&texture_resource))); D3D12_PLACED_SUBRESOURCE_FOOTPRINT layout; UINT num_rows; @@ -480,7 +371,7 @@ static void gfx_d3d12_upload_texture(uint8_t *rgba32_buf, int width, int height) &rdb, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, - IID_ID3D12Resource, IID_PPV_ARGS_Helper(&upload_heap))); + IID_PPV_ARGS(&upload_heap))); } else { upload_heap = upload_heaps.back(); upload_heaps.pop_back(); @@ -526,39 +417,39 @@ static int gfx_cm_to_index(uint32_t val) { return (val & G_TX_MIRROR) ? 1 : 0; } -static void gfx_d3d12_set_sampler_parameters(int tile, bool linear_filter, uint32_t cms, uint32_t cmt) { +static void gfx_direct3d12_set_sampler_parameters(int tile, bool linear_filter, uint32_t cms, uint32_t cmt) { d3d.textures[d3d.current_texture_ids[tile]].sampler_parameters = linear_filter * 9 + gfx_cm_to_index(cms) * 3 + gfx_cm_to_index(cmt); } -static void gfx_d3d12_set_depth_test(bool depth_test) { +static void gfx_direct3d12_set_depth_test(bool depth_test) { d3d.depth_test = depth_test; d3d.must_reload_pipeline = true; } -static void gfx_d3d12_set_depth_mask(bool z_upd) { +static void gfx_direct3d12_set_depth_mask(bool z_upd) { d3d.depth_mask = z_upd; d3d.must_reload_pipeline = true; } -static void gfx_d3d12_set_zmode_decal(bool zmode_decal) { +static void gfx_direct3d12_set_zmode_decal(bool zmode_decal) { d3d.zmode_decal = zmode_decal; d3d.must_reload_pipeline = true; } -static void gfx_d3d12_set_viewport(int x, int y, int width, int height) { +static void gfx_direct3d12_set_viewport(int x, int y, int width, int height) { d3d.viewport = CD3DX12_VIEWPORT(x, d3d.current_height - y - height, width, height); } -static void gfx_d3d12_set_scissor(int x, int y, int width, int height) { +static void gfx_direct3d12_set_scissor(int x, int y, int width, int height) { d3d.scissor = CD3DX12_RECT(x, d3d.current_height - y - height, x + width, d3d.current_height - y); } -static void gfx_d3d12_set_use_alpha(bool use_alpha) { +static void gfx_direct3d12_set_use_alpha(bool use_alpha) { // Already part of the pipeline state from shader info } -static void gfx_d3d12_draw_triangles(float buf_vbo[], size_t buf_vbo_len, size_t buf_vbo_num_tris) { - struct ShaderProgram *prg = d3d.shader_program; +static void gfx_direct3d12_draw_triangles(float buf_vbo[], size_t buf_vbo_len, size_t buf_vbo_num_tris) { + struct ShaderProgramD3D12 *prg = d3d.shader_program; if (d3d.must_reload_pipeline) { ComPtr& pipeline_state = d3d.pipeline_states[PipelineDesc{ @@ -621,7 +512,7 @@ static void gfx_d3d12_draw_triangles(float buf_vbo[], size_t buf_vbo_len, size_t desc.NumRenderTargets = 1; desc.RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM; desc.SampleDesc.Count = 1; - ThrowIfFailed(d3d.device->CreateGraphicsPipelineState(&desc, IID_ID3D12PipelineState, IID_PPV_ARGS_Helper(&pipeline_state))); + ThrowIfFailed(d3d.device->CreateGraphicsPipelineState(&desc, IID_PPV_ARGS(&pipeline_state))); } d3d.pipeline_state = pipeline_state.Get(); d3d.must_reload_pipeline = false; @@ -633,7 +524,12 @@ static void gfx_d3d12_draw_triangles(float buf_vbo[], size_t buf_vbo_len, size_t ID3D12DescriptorHeap *heaps[] = { d3d.srv_heap.Get(), d3d.sampler_heap.Get() }; d3d.command_list->SetDescriptorHeaps(2, heaps); - int texture_pos = 0; + int root_param_index = 0; + + if ((prg->shader_id & (SHADER_OPT_ALPHA | SHADER_OPT_NOISE)) == (SHADER_OPT_ALPHA | SHADER_OPT_NOISE)) { + d3d.command_list->SetGraphicsRootConstantBufferView(root_param_index++, d3d.noise_cb->GetGPUVirtualAddress()); + } + for (int i = 0; i < 2; i++) { if (prg->used_textures[i]) { struct TextureData& td = d3d.textures[d3d.current_texture_ids[i]]; @@ -652,12 +548,10 @@ static void gfx_d3d12_draw_triangles(float buf_vbo[], size_t buf_vbo_len, size_t } CD3DX12_GPU_DESCRIPTOR_HANDLE srv_gpu_handle(get_gpu_descriptor_handle(d3d.srv_heap), td.descriptor_index, d3d.srv_descriptor_size); - d3d.command_list->SetGraphicsRootDescriptorTable(2 * texture_pos, srv_gpu_handle); + d3d.command_list->SetGraphicsRootDescriptorTable(root_param_index++, srv_gpu_handle); CD3DX12_GPU_DESCRIPTOR_HANDLE sampler_gpu_handle(get_gpu_descriptor_handle(d3d.sampler_heap), td.sampler_parameters, d3d.sampler_descriptor_size); - d3d.command_list->SetGraphicsRootDescriptorTable(2 * texture_pos + 1, sampler_gpu_handle); - - ++texture_pos; + d3d.command_list->SetGraphicsRootDescriptorTable(root_param_index++, sampler_gpu_handle); } } @@ -687,11 +581,7 @@ static void gfx_d3d12_draw_triangles(float buf_vbo[], size_t buf_vbo_len, size_t d3d.command_list->DrawInstanced(3 * buf_vbo_num_tris, 1, 0, 0); } -static void gfx_d3d12_init(void) { } - -static void gfx_d3d12_shutdown(void) { } - -static void gfx_d3d12_start_frame(void) { +static void gfx_direct3d12_start_frame(void) { ++d3d.frame_counter; d3d.srv_pos = 0; texture_uploads = 0; @@ -713,6 +603,16 @@ static void gfx_d3d12_start_frame(void) { d3d.command_list->ClearRenderTargetView(rtv_handle, clear_color, 0, nullptr); d3d.command_list->ClearDepthStencilView(dsv_handle, D3D12_CLEAR_FLAG_DEPTH, 1.0f, 0, 0, nullptr); + d3d.noise_cb_data.noise_frame++; + if (d3d.noise_cb_data.noise_frame > 150) { + // No high values, as noise starts to look ugly + d3d.noise_cb_data.noise_frame = 0; + } + float aspect_ratio = (float) d3d.current_width / (float) d3d.current_height; + d3d.noise_cb_data.noise_scale_x = 120 * aspect_ratio; // 120 = N64 height resolution (240) / 2 + d3d.noise_cb_data.noise_scale_y = 120; + memcpy(d3d.mapped_noise_cb_address, &d3d.noise_cb_data, sizeof(struct NoiseCB)); + d3d.vbuf_pos = 0; } @@ -762,12 +662,12 @@ static void create_depth_buffer(void) { rd.SampleDesc.Quality = 0; rd.Flags = D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL; rd.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; - ThrowIfFailed(d3d.device->CreateCommittedResource(&hp, D3D12_HEAP_FLAG_NONE, &rd, D3D12_RESOURCE_STATE_DEPTH_WRITE, &depth_optimized_cv, IID_ID3D12Resource, IID_PPV_ARGS_Helper(&d3d.depth_stencil_buffer))); + ThrowIfFailed(d3d.device->CreateCommittedResource(&hp, D3D12_HEAP_FLAG_NONE, &rd, D3D12_RESOURCE_STATE_DEPTH_WRITE, &depth_optimized_cv, IID_PPV_ARGS(&d3d.depth_stencil_buffer))); d3d.device->CreateDepthStencilView(d3d.depth_stencil_buffer.Get(), &dsv_desc, get_cpu_descriptor_handle(d3d.dsv_heap)); } -static void gfx_d3d12_dxgi_on_resize(void) { +static void gfx_direct3d12_on_resize(void) { if (d3d.render_targets[0].Get() != nullptr) { d3d.render_targets[0].Reset(); d3d.render_targets[1].Reset(); @@ -778,115 +678,49 @@ static void gfx_d3d12_dxgi_on_resize(void) { } } -static void onkeydown(WPARAM w_param, LPARAM l_param) { - int key = ((l_param >> 16) & 0x1ff); - if (d3d.on_key_down != nullptr) { - d3d.on_key_down(key); +static void gfx_direct3d12_init(void ) { + // Load d3d12.dll + d3d.d3d12_module = LoadLibraryW(L"d3d12.dll"); + if (d3d.d3d12_module == nullptr) { + ThrowIfFailed(HRESULT_FROM_WIN32(GetLastError()), gfx_dxgi_get_h_wnd(), "d3d12.dll could not be loaded"); } -} -static void onkeyup(WPARAM w_param, LPARAM l_param) { - int key = ((l_param >> 16) & 0x1ff); - if (d3d.on_key_up != nullptr) { - d3d.on_key_up(key); + d3d.D3D12CreateDevice = (PFN_D3D12_CREATE_DEVICE)GetProcAddress(d3d.d3d12_module, "D3D12CreateDevice"); +#if DEBUG_D3D + d3d.D3D12GetDebugInterface = (PFN_D3D12_GET_DEBUG_INTERFACE)GetProcAddress(d3d.d3d12_module, "D3D12GetDebugInterface"); +#endif + + // Load D3DCompiler_47.dll + d3d.d3dcompiler_module = LoadLibraryW(L"D3DCompiler_47.dll"); + if (d3d.d3dcompiler_module == nullptr) { + ThrowIfFailed(HRESULT_FROM_WIN32(GetLastError()), gfx_dxgi_get_h_wnd(), "D3DCompiler_47.dll could not be loaded"); } -} - -LRESULT CALLBACK gfx_d3d12_dxgi_wnd_proc(HWND h_wnd, UINT message, WPARAM w_param, LPARAM l_param) { - switch (message) { - case WM_MOVE: { - const int x = (short)LOWORD(l_param); - const int y = (short)HIWORD(l_param); - configWindow.x = (x < 0) ? 0 : x; - configWindow.y = (y < 0) ? 0 : y; - break; - } - case WM_SIZE: - gfx_d3d12_dxgi_on_resize(); - break; - case WM_DESTROY: - game_exit(); - break; - case WM_PAINT: - if (d3d.run_one_game_iter != nullptr) - d3d.run_one_game_iter(); - break; - case WM_ACTIVATEAPP: - if (d3d.on_all_keys_up != nullptr) - d3d.on_all_keys_up(); - break; - case WM_KEYDOWN: - onkeydown(w_param, l_param); - break; - case WM_KEYUP: - onkeyup(w_param, l_param); - break; - default: - return DefWindowProcW(h_wnd, message, w_param, l_param); - } - return 0; -} - -static void gfx_d3d12_dxgi_init(const char *window_title) { - LARGE_INTEGER qpc_init, qpc_freq; - QueryPerformanceCounter(&qpc_init); - QueryPerformanceFrequency(&qpc_freq); - d3d.qpc_init = qpc_init.QuadPart; - d3d.qpc_freq = qpc_freq.QuadPart; - - // Prepare window title - - wchar_t w_title[512]; - mbstowcs(w_title, window_title, strlen(window_title) + 1); - - // Create window - WNDCLASSEXW wcex; - - wcex.cbSize = sizeof(WNDCLASSEX); - - wcex.style = CS_HREDRAW | CS_VREDRAW; - wcex.lpfnWndProc = gfx_d3d12_dxgi_wnd_proc; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = nullptr; - wcex.hIcon = nullptr; - wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); - wcex.lpszMenuName = nullptr; - wcex.lpszClassName = WINCLASS_NAME; - wcex.hIconSm = nullptr; - - ATOM winclass = RegisterClassExW(&wcex); - - RECT wr = {0, 0, DESIRED_SCREEN_WIDTH, DESIRED_SCREEN_HEIGHT}; - AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); - - HWND h_wnd = CreateWindowW(WINCLASS_NAME, w_title, WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, 0, wr.right - wr.left, wr.bottom - wr.top, nullptr, nullptr, nullptr, nullptr); - + d3d.D3DCompile = (pD3DCompile)GetProcAddress(d3d.d3dcompiler_module, "D3DCompile"); + // Create device { UINT debug_flags = 0; #if DEBUG_D3D ComPtr debug_controller; - if (SUCCEEDED(D3D12GetDebugInterface(IID_ID3D12Debug, IID_PPV_ARGS_Helper(&debug_controller)))) { + if (SUCCEEDED(d3d.D3D12GetDebugInterface(IID_PPV_ARGS(&debug_controller)))) { debug_controller->EnableDebugLayer(); debug_flags |= DXGI_CREATE_FACTORY_DEBUG; } #endif - ThrowIfFailed(CreateDXGIFactory2(debug_flags, IID_IDXGIFactory4, &d3d.factory)); - ComPtr hw_adapter; - for (UINT i = 0; d3d.factory->EnumAdapters1(i, &hw_adapter) != DXGI_ERROR_NOT_FOUND; i++) { - DXGI_ADAPTER_DESC1 desc; - hw_adapter->GetDesc1(&desc); - if (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) { - continue; + gfx_dxgi_create_factory_and_device(DEBUG_D3D, 12, [](IDXGIAdapter1 *adapter, bool test_only) { + HRESULT res = d3d.D3D12CreateDevice( + adapter, + D3D_FEATURE_LEVEL_11_0, + IID_ID3D12Device, + test_only ? nullptr : IID_PPV_ARGS_Helper(&d3d.device)); + + if (test_only) { + return SUCCEEDED(res); + } else { + ThrowIfFailed(res, gfx_dxgi_get_h_wnd(), "Failed to create D3D12 device."); + return true; } - if (SUCCEEDED(D3D12CreateDevice(hw_adapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_ID3D12Device, nullptr))) { - break; - } - } - ThrowIfFailed(D3D12CreateDevice(hw_adapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_ID3D12Device, IID_PPV_ARGS_Helper(&d3d.device))); + }); } // Create command queues @@ -894,36 +728,20 @@ static void gfx_d3d12_dxgi_init(const char *window_title) { D3D12_COMMAND_QUEUE_DESC queue_desc = {}; queue_desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; queue_desc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; - ThrowIfFailed(d3d.device->CreateCommandQueue(&queue_desc, IID_ID3D12CommandQueue, IID_PPV_ARGS_Helper(&d3d.command_queue))); + ThrowIfFailed(d3d.device->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&d3d.command_queue))); } { D3D12_COMMAND_QUEUE_DESC queue_desc = {}; queue_desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; queue_desc.Type = D3D12_COMMAND_LIST_TYPE_COPY; - ThrowIfFailed(d3d.device->CreateCommandQueue(&queue_desc, IID_ID3D12CommandQueue, IID_PPV_ARGS_Helper(&d3d.copy_command_queue))); + ThrowIfFailed(d3d.device->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&d3d.copy_command_queue))); } // Create swap chain { - DXGI_SWAP_CHAIN_DESC1 swap_chain_desc = {}; - swap_chain_desc.BufferCount = 2; - swap_chain_desc.Width = DESIRED_SCREEN_WIDTH; - swap_chain_desc.Height = DESIRED_SCREEN_HEIGHT; - swap_chain_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - swap_chain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; - swap_chain_desc.Scaling = DXGI_SCALING_NONE; - swap_chain_desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; - swap_chain_desc.Flags = DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT; - swap_chain_desc.SampleDesc.Count = 1; - - ComPtr swap_chain1; - ThrowIfFailed(d3d.factory->CreateSwapChainForHwnd(d3d.command_queue.Get(), h_wnd, &swap_chain_desc, nullptr, nullptr, &swap_chain1)); - //ThrowIfFailed(factory->MakeWindowAssociation(h_wnd, DXGI_MWA_NO_ALT_ENTER)); - ThrowIfFailed(swap_chain1->QueryInterface(IID_IDXGISwapChain3, &d3d.swap_chain)); + ComPtr swap_chain1 = gfx_dxgi_create_swap_chain(d3d.command_queue.Get()); + ThrowIfFailed(swap_chain1->QueryInterface(__uuidof(IDXGISwapChain3), &d3d.swap_chain)); d3d.frame_index = d3d.swap_chain->GetCurrentBackBufferIndex(); - ThrowIfFailed(d3d.swap_chain->SetMaximumFrameLatency(1)); - d3d.waitable_object = d3d.swap_chain->GetFrameLatencyWaitableObject(); - WaitForSingleObject(d3d.waitable_object, INFINITE); } // Create render target views @@ -932,7 +750,7 @@ static void gfx_d3d12_dxgi_init(const char *window_title) { rtv_heap_desc.NumDescriptors = 2; rtv_heap_desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV; rtv_heap_desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; - ThrowIfFailed(d3d.device->CreateDescriptorHeap(&rtv_heap_desc, IID_ID3D12DescriptorHeap, IID_PPV_ARGS_Helper(&d3d.rtv_heap))); + ThrowIfFailed(d3d.device->CreateDescriptorHeap(&rtv_heap_desc, IID_PPV_ARGS(&d3d.rtv_heap))); d3d.rtv_descriptor_size = d3d.device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV); create_render_target_views(); @@ -944,7 +762,7 @@ static void gfx_d3d12_dxgi_init(const char *window_title) { dsv_heap_desc.NumDescriptors = 1; dsv_heap_desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV; dsv_heap_desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; - ThrowIfFailed(d3d.device->CreateDescriptorHeap(&dsv_heap_desc, IID_ID3D12DescriptorHeap, IID_PPV_ARGS_Helper(&d3d.dsv_heap))); + ThrowIfFailed(d3d.device->CreateDescriptorHeap(&dsv_heap_desc, IID_PPV_ARGS(&d3d.dsv_heap))); create_depth_buffer(); } @@ -955,7 +773,7 @@ static void gfx_d3d12_dxgi_init(const char *window_title) { srv_heap_desc.NumDescriptors = 1024; // Max unique textures per frame srv_heap_desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; srv_heap_desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; - ThrowIfFailed(d3d.device->CreateDescriptorHeap(&srv_heap_desc, IID_ID3D12DescriptorHeap, IID_PPV_ARGS_Helper(&d3d.srv_heap))); + ThrowIfFailed(d3d.device->CreateDescriptorHeap(&srv_heap_desc, IID_PPV_ARGS(&d3d.srv_heap))); d3d.srv_descriptor_size = d3d.device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); } @@ -965,7 +783,7 @@ static void gfx_d3d12_dxgi_init(const char *window_title) { sampler_heap_desc.NumDescriptors = 18; sampler_heap_desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER; sampler_heap_desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; - ThrowIfFailed(d3d.device->CreateDescriptorHeap(&sampler_heap_desc, IID_ID3D12DescriptorHeap, IID_PPV_ARGS_Helper(&d3d.sampler_heap))); + ThrowIfFailed(d3d.device->CreateDescriptorHeap(&sampler_heap_desc, IID_PPV_ARGS(&d3d.sampler_heap))); d3d.sampler_descriptor_size = d3d.device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER); static const D3D12_TEXTURE_ADDRESS_MODE address_modes[] = { @@ -995,21 +813,43 @@ static void gfx_d3d12_dxgi_init(const char *window_title) { } } - ThrowIfFailed(d3d.device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_ID3D12CommandAllocator, IID_PPV_ARGS_Helper(&d3d.command_allocator))); - ThrowIfFailed(d3d.device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_COPY, IID_ID3D12CommandAllocator, IID_PPV_ARGS_Helper(&d3d.copy_command_allocator))); + // Create constant buffer view for noise + { + /*D3D12_DESCRIPTOR_HEAP_DESC cbv_heap_desc = {}; + cbv_heap_desc.NumDescriptors = 1; + cbv_heap_desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; + srv_heap_desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; + ThrowIfFailed(d3d.device->CreateDescriptorHeap*/ + + CD3DX12_HEAP_PROPERTIES hp(D3D12_HEAP_TYPE_UPLOAD); + CD3DX12_RESOURCE_DESC rdb = CD3DX12_RESOURCE_DESC::Buffer(256); + ThrowIfFailed(d3d.device->CreateCommittedResource( + &hp, + D3D12_HEAP_FLAG_NONE, + &rdb, + D3D12_RESOURCE_STATE_GENERIC_READ, + nullptr, + IID_PPV_ARGS(&d3d.noise_cb))); + + CD3DX12_RANGE read_range(0, 0); // Read not possible from CPU + ThrowIfFailed(d3d.noise_cb->Map(0, &read_range, &d3d.mapped_noise_cb_address)); + } - ThrowIfFailed(d3d.device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, d3d.command_allocator.Get(), nullptr, IID_ID3D12GraphicsCommandList, IID_PPV_ARGS_Helper(&d3d.command_list))); - ThrowIfFailed(d3d.device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_COPY, d3d.copy_command_allocator.Get(), nullptr, IID_ID3D12GraphicsCommandList, IID_PPV_ARGS_Helper(&d3d.copy_command_list))); + ThrowIfFailed(d3d.device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&d3d.command_allocator))); + ThrowIfFailed(d3d.device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_COPY, IID_PPV_ARGS(&d3d.copy_command_allocator))); + + ThrowIfFailed(d3d.device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, d3d.command_allocator.Get(), nullptr, IID_PPV_ARGS(&d3d.command_list))); + ThrowIfFailed(d3d.device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_COPY, d3d.copy_command_allocator.Get(), nullptr, IID_PPV_ARGS(&d3d.copy_command_list))); ThrowIfFailed(d3d.command_list->Close()); - ThrowIfFailed(d3d.device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_ID3D12Fence, IID_PPV_ARGS_Helper(&d3d.fence))); + ThrowIfFailed(d3d.device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&d3d.fence))); d3d.fence_event = CreateEvent(nullptr, FALSE, FALSE, nullptr); if (d3d.fence_event == nullptr) { ThrowIfFailed(HRESULT_FROM_WIN32(GetLastError())); } - ThrowIfFailed(d3d.device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_ID3D12Fence, IID_PPV_ARGS_Helper(&d3d.copy_fence))); + ThrowIfFailed(d3d.device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&d3d.copy_fence))); { // Create a buffer of 1 MB in size. With a 120 star speed run 192 kB seems to be max usage. @@ -1021,178 +861,14 @@ static void gfx_d3d12_dxgi_init(const char *window_title) { &rdb, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, - IID_ID3D12Resource, - IID_PPV_ARGS_Helper(&d3d.vertex_buffer))); + IID_PPV_ARGS(&d3d.vertex_buffer))); CD3DX12_RANGE read_range(0, 0); // Read not possible from CPU ThrowIfFailed(d3d.vertex_buffer->Map(0, &read_range, &d3d.mapped_vbuf_address)); } - - ShowWindow(h_wnd, SW_SHOW); - UpdateWindow(h_wnd); } -static void gfx_d3d12_dxgi_shutdown(void) { - if (d3d.render_targets[0].Get() != nullptr) { - d3d.render_targets[0].Reset(); - d3d.render_targets[1].Reset(); - } - - // uhh -} - -static void gfx_d3d12_dxgi_set_keyboard_callbacks(bool (*on_key_down)(int scancode), bool (*on_key_up)(int scancode), void (*on_all_keys_up)(void)) { - d3d.on_key_down = on_key_down; - d3d.on_key_up = on_key_up; - d3d.on_all_keys_up = on_all_keys_up; -} - -static void gfx_d3d12_dxgi_main_loop(void (*run_one_game_iter)(void)) { - d3d.run_one_game_iter = run_one_game_iter; - - MSG msg; - while (GetMessage(&msg, nullptr, 0, 0)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } -} - -static void gfx_d3d12_dxgi_get_dimensions(uint32_t *width, uint32_t *height) { - *width = d3d.current_width; - *height = d3d.current_height; -} - -static void gfx_d3d12_dxgi_handle_events(void) { - /*MSG msg; - while (PeekMessageW(&msg, nullptr, 0, 0, PM_REMOVE)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - }*/ -} - -static uint64_t qpc_to_us(uint64_t qpc) { - return qpc / d3d.qpc_freq * 1000000 + qpc % d3d.qpc_freq * 1000000 / d3d.qpc_freq; -} - -static bool gfx_d3d12_dxgi_start_frame(void) { - DXGI_FRAME_STATISTICS stats; - if (d3d.swap_chain->GetFrameStatistics(&stats) == S_OK && (stats.SyncRefreshCount != 0 || stats.SyncQPCTime.QuadPart != 0ULL)) { - { - LARGE_INTEGER t0; - QueryPerformanceCounter(&t0); - //printf("Get frame stats: %llu\n", (unsigned long long)(t0.QuadPart - d3d.qpc_init)); - } - //printf("stats: %u %u %u %u %u %.6f\n", d3d.pending_frame_stats.rbegin()->first, d3d.pending_frame_stats.rbegin()->second, stats.PresentCount, stats.PresentRefreshCount, stats.SyncRefreshCount, (double)(stats.SyncQPCTime.QuadPart - d3d.qpc_init) / d3d.qpc_freq); - if (d3d.frame_stats.empty() || d3d.frame_stats.rbegin()->second.PresentCount != stats.PresentCount) { - d3d.frame_stats.insert(std::make_pair(stats.PresentCount, stats)); - } - if (d3d.frame_stats.size() > 3) { - d3d.frame_stats.erase(d3d.frame_stats.begin()); - } - } - if (!d3d.frame_stats.empty()) { - while (!d3d.pending_frame_stats.empty() && d3d.pending_frame_stats.begin()->first < d3d.frame_stats.rbegin()->first) { - d3d.pending_frame_stats.erase(d3d.pending_frame_stats.begin()); - } - } - while (d3d.pending_frame_stats.size() > 15) { - // Just make sure the list doesn't grow too large if GetFrameStatistics fails. - d3d.pending_frame_stats.erase(d3d.pending_frame_stats.begin()); - } - - d3d.frame_timestamp += FRAME_INTERVAL_US_NUMERATOR; - - if (d3d.frame_stats.size() >= 2) { - DXGI_FRAME_STATISTICS *first = &d3d.frame_stats.begin()->second; - DXGI_FRAME_STATISTICS *last = &d3d.frame_stats.rbegin()->second; - uint64_t sync_qpc_diff = last->SyncQPCTime.QuadPart - first->SyncQPCTime.QuadPart; - UINT sync_vsync_diff = last->SyncRefreshCount - first->SyncRefreshCount; - UINT present_vsync_diff = last->PresentRefreshCount - first->PresentRefreshCount; - UINT present_diff = last->PresentCount - first->PresentCount; - - if (sync_vsync_diff == 0) { - sync_vsync_diff = 1; - } - - double estimated_vsync_interval = (double)sync_qpc_diff / (double)sync_vsync_diff; - //printf("Estimated vsync_interval: %f\n", estimated_vsync_interval); - uint64_t estimated_vsync_interval_us = qpc_to_us(estimated_vsync_interval); - if (estimated_vsync_interval_us < 2 || estimated_vsync_interval_us > 1000000) { - // Unreasonable, maybe a monitor change - estimated_vsync_interval_us = 16666; - estimated_vsync_interval = estimated_vsync_interval_us * d3d.qpc_freq / 1000000; - } - - UINT queued_vsyncs = 0; - bool is_first = true; - for (const std::pair& p : d3d.pending_frame_stats) { - if (is_first && d3d.sync_interval_means_frames_to_wait) { - is_first = false; - continue; - } - queued_vsyncs += p.second; - } - - uint64_t last_frame_present_end_qpc = (last->SyncQPCTime.QuadPart - d3d.qpc_init) + estimated_vsync_interval * queued_vsyncs; - uint64_t last_end_us = qpc_to_us(last_frame_present_end_qpc); - - double vsyncs_to_wait = (double)(int64_t)(d3d.frame_timestamp / FRAME_INTERVAL_US_DENOMINATOR - last_end_us) / estimated_vsync_interval_us; - //printf("ts: %llu, last_end_us: %llu, Init v: %f\n", d3d.frame_timestamp / 3, last_end_us, vsyncs_to_wait); - - if (vsyncs_to_wait <= 0) { - // Too late - - if ((int64_t)(d3d.frame_timestamp / FRAME_INTERVAL_US_DENOMINATOR - last_end_us) < -66666) { - // The application must have been paused or similar - vsyncs_to_wait = round(((double)FRAME_INTERVAL_US_NUMERATOR / FRAME_INTERVAL_US_DENOMINATOR) / estimated_vsync_interval_us); - if (vsyncs_to_wait < 1) { - vsyncs_to_wait = 1; - } - d3d.frame_timestamp = FRAME_INTERVAL_US_DENOMINATOR * (last_end_us + vsyncs_to_wait * estimated_vsync_interval_us); - } else { - // Drop frame - //printf("Dropping frame\n"); - d3d.dropped_frame = true; - return false; - } - } - if (floor(vsyncs_to_wait) != vsyncs_to_wait) { - uint64_t left = last_end_us + floor(vsyncs_to_wait) * estimated_vsync_interval_us; - uint64_t right = last_end_us + ceil(vsyncs_to_wait) * estimated_vsync_interval_us; - uint64_t adjusted_desired_time = d3d.frame_timestamp / FRAME_INTERVAL_US_DENOMINATOR + (last_end_us + (FRAME_INTERVAL_US_NUMERATOR / FRAME_INTERVAL_US_DENOMINATOR) > d3d.frame_timestamp / FRAME_INTERVAL_US_DENOMINATOR ? 2000 : -2000); - int64_t diff_left = adjusted_desired_time - left; - int64_t diff_right = right - adjusted_desired_time; - if (diff_left < 0) { - diff_left = -diff_left; - } - if (diff_right < 0) { - diff_right = -diff_right; - } - if (diff_left < diff_right) { - vsyncs_to_wait = floor(vsyncs_to_wait); - } else { - vsyncs_to_wait = ceil(vsyncs_to_wait); - } - if (vsyncs_to_wait == 0) { - //printf("vsyncs_to_wait became 0 so dropping frame\n"); - d3d.dropped_frame = true; - return false; - } - } - //printf("v: %d\n", (int)vsyncs_to_wait); - if (vsyncs_to_wait > 4) { - // Invalid, so change to 4 - vsyncs_to_wait = 4; - } - d3d.length_in_vsync_frames = vsyncs_to_wait; - } else { - d3d.length_in_vsync_frames = 2; - } - - return true; -} - -static void gfx_d3d12_dxgi_swap_buffers_begin(void) { +static void gfx_direct3d12_end_frame(void) { if (max_texture_uploads < texture_uploads && texture_uploads != 38 && texture_uploads != 34 && texture_uploads != 29) { max_texture_uploads = texture_uploads; } @@ -1226,17 +902,9 @@ static void gfx_d3d12_dxgi_swap_buffers_begin(void) { QueryPerformanceCounter(&t0); //printf("Present: %llu %u\n", (unsigned long long)(t0.QuadPart - d3d.qpc_init), d3d.length_in_vsync_frames); } - - //d3d.length_in_vsync_frames = 1; - ThrowIfFailed(d3d.swap_chain->Present(d3d.length_in_vsync_frames, 0)); - UINT this_present_id; - if (d3d.swap_chain->GetLastPresentCount(&this_present_id) == S_OK) { - d3d.pending_frame_stats.insert(std::make_pair(this_present_id, d3d.length_in_vsync_frames)); - } - d3d.dropped_frame = false; } -static void gfx_d3d12_dxgi_swap_buffers_end(void) { +static void gfx_direct3d12_finish_render(void) { LARGE_INTEGER t0, t1, t2; QueryPerformanceCounter(&t0); @@ -1258,13 +926,6 @@ static void gfx_d3d12_dxgi_swap_buffers_end(void) { } d3d.texture_heap_allocations_to_reclaim_at_end_of_frame.clear(); - if (!d3d.dropped_frame) { - WaitForSingleObject(d3d.waitable_object, INFINITE); - } - - DXGI_FRAME_STATISTICS stats; - d3d.swap_chain->GetFrameStatistics(&stats); - QueryPerformanceCounter(&t2); d3d.frame_index = d3d.swap_chain->GetCurrentBackBufferIndex(); @@ -1272,57 +933,34 @@ static void gfx_d3d12_dxgi_swap_buffers_end(void) { ThrowIfFailed(d3d.copy_command_allocator->Reset()); ThrowIfFailed(d3d.copy_command_list->Reset(d3d.copy_command_allocator.Get(), nullptr)); - d3d.sync_interval_means_frames_to_wait = d3d.pending_frame_stats.rbegin()->first == stats.PresentCount; - //printf("done %llu gpu:%d wait:%d freed:%llu frame:%u %u monitor:%u t:%llu\n", (unsigned long long)(t0.QuadPart - d3d.qpc_init), (int)(t1.QuadPart - t0.QuadPart), (int)(t2.QuadPart - t0.QuadPart), (unsigned long long)(t2.QuadPart - d3d.qpc_init), d3d.pending_frame_stats.rbegin()->first, stats.PresentCount, stats.SyncRefreshCount, (unsigned long long)(stats.SyncQPCTime.QuadPart - d3d.qpc_init)); } -double gfx_d3d12_dxgi_get_time(void) { - LARGE_INTEGER t; - QueryPerformanceCounter(&t); - return (double)(t.QuadPart - d3d.qpc_init) / d3d.qpc_freq; -} +} // namespace -struct GfxRenderingAPI gfx_d3d12_api = { - gfx_d3d12_z_is_from_0_to_1, - gfx_d3d12_unload_shader, - gfx_d3d12_load_shader, - gfx_d3d12_create_and_load_new_shader, - gfx_d3d12_lookup_shader, - gfx_d3d12_shader_get_info, - gfx_d3d12_new_texture, - gfx_d3d12_select_texture, - gfx_d3d12_upload_texture, - gfx_d3d12_set_sampler_parameters, - gfx_d3d12_set_depth_test, - gfx_d3d12_set_depth_mask, - gfx_d3d12_set_zmode_decal, - gfx_d3d12_set_viewport, - gfx_d3d12_set_scissor, - gfx_d3d12_set_use_alpha, - gfx_d3d12_draw_triangles, - gfx_d3d12_init, - gfx_d3d12_start_frame, - gfx_d3d12_shutdown, +struct GfxRenderingAPI gfx_direct3d12_api = { + gfx_direct3d12_z_is_from_0_to_1, + gfx_direct3d12_unload_shader, + gfx_direct3d12_load_shader, + gfx_direct3d12_create_and_load_new_shader, + gfx_direct3d12_lookup_shader, + gfx_direct3d12_shader_get_info, + gfx_direct3d12_new_texture, + gfx_direct3d12_select_texture, + gfx_direct3d12_upload_texture, + gfx_direct3d12_set_sampler_parameters, + gfx_direct3d12_set_depth_test, + gfx_direct3d12_set_depth_mask, + gfx_direct3d12_set_zmode_decal, + gfx_direct3d12_set_viewport, + gfx_direct3d12_set_scissor, + gfx_direct3d12_set_use_alpha, + gfx_direct3d12_draw_triangles, + gfx_direct3d12_init, + gfx_direct3d12_on_resize, + gfx_direct3d12_start_frame, + gfx_direct3d12_end_frame, + gfx_direct3d12_finish_render }; -struct GfxWindowManagerAPI gfx_dxgi = { - gfx_d3d12_dxgi_init, - gfx_d3d12_dxgi_set_keyboard_callbacks, - gfx_d3d12_dxgi_main_loop, - gfx_d3d12_dxgi_get_dimensions, - gfx_d3d12_dxgi_handle_events, - gfx_d3d12_dxgi_start_frame, - gfx_d3d12_dxgi_swap_buffers_begin, - gfx_d3d12_dxgi_swap_buffers_end, - gfx_d3d12_dxgi_get_time, - gfx_d3d12_dxgi_shutdown, -}; - -#else - -#error "D3D12 is only supported on Windows" - -#endif // _WIN32 - -#endif // RAPI_D3D12 +#endif diff --git a/src/pc/gfx/gfx_direct3d12.h b/src/pc/gfx/gfx_direct3d12.h index 7b8f5a66..559566ff 100644 --- a/src/pc/gfx/gfx_direct3d12.h +++ b/src/pc/gfx/gfx_direct3d12.h @@ -1,10 +1,12 @@ +#ifdef RAPI_D3D12 + #ifndef GFX_DIRECT3D12_H #define GFX_DIRECT3D12_H -#include "gfx_window_manager_api.h" #include "gfx_rendering_api.h" -extern struct GfxWindowManagerAPI gfx_dxgi; -extern struct GfxRenderingAPI gfx_d3d12_api; +extern struct GfxRenderingAPI gfx_direct3d12_api; + +#endif #endif diff --git a/src/pc/gfx/gfx_direct3d12_guids.h b/src/pc/gfx/gfx_direct3d12_guids.h new file mode 100644 index 00000000..e18a0181 --- /dev/null +++ b/src/pc/gfx/gfx_direct3d12_guids.h @@ -0,0 +1,62 @@ +#ifndef GFX_DIRECT3D12_GUIDS_H +#define GFX_DIRECT3D12_GUIDS_H + +#ifdef __MINGW32__ + +// This file is only needed due to missing MinGW-specific headers for d3d12.h. +// It will define IID_* symbols having the "selectany" attribute (assuming +// d3d12.h was earlier included), as well as make __uuidof(...) work. + +#define DEF_GUID(type,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \ + __CRT_UUID_DECL(type,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \ + const GUID IID_##type = __uuidof(type) + +DEF_GUID(ID3D12Object,0xc4fec28f,0x7966,0x4e95,0x9f,0x94,0xf4,0x31,0xcb,0x56,0xc3,0xb8); +DEF_GUID(ID3D12DeviceChild,0x905db94b,0xa00c,0x4140,0x9d,0xf5,0x2b,0x64,0xca,0x9e,0xa3,0x57); +DEF_GUID(ID3D12RootSignature,0xc54a6b66,0x72df,0x4ee8,0x8b,0xe5,0xa9,0x46,0xa1,0x42,0x92,0x14); +DEF_GUID(ID3D12RootSignatureDeserializer,0x34AB647B,0x3CC8,0x46AC,0x84,0x1B,0xC0,0x96,0x56,0x45,0xC0,0x46); +DEF_GUID(ID3D12VersionedRootSignatureDeserializer,0x7F91CE67,0x090C,0x4BB7,0xB7,0x8E,0xED,0x8F,0xF2,0xE3,0x1D,0xA0); +DEF_GUID(ID3D12Pageable,0x63ee58fb,0x1268,0x4835,0x86,0xda,0xf0,0x08,0xce,0x62,0xf0,0xd6); +DEF_GUID(ID3D12Heap,0x6b3b2502,0x6e51,0x45b3,0x90,0xee,0x98,0x84,0x26,0x5e,0x8d,0xf3); +DEF_GUID(ID3D12Resource,0x696442be,0xa72e,0x4059,0xbc,0x79,0x5b,0x5c,0x98,0x04,0x0f,0xad); +DEF_GUID(ID3D12CommandAllocator,0x6102dee4,0xaf59,0x4b09,0xb9,0x99,0xb4,0x4d,0x73,0xf0,0x9b,0x24); +DEF_GUID(ID3D12Fence,0x0a753dcf,0xc4d8,0x4b91,0xad,0xf6,0xbe,0x5a,0x60,0xd9,0x5a,0x76); +DEF_GUID(ID3D12Fence1,0x433685fe,0xe22b,0x4ca0,0xa8,0xdb,0xb5,0xb4,0xf4,0xdd,0x0e,0x4a); +DEF_GUID(ID3D12PipelineState,0x765a30f3,0xf624,0x4c6f,0xa8,0x28,0xac,0xe9,0x48,0x62,0x24,0x45); +DEF_GUID(ID3D12DescriptorHeap,0x8efb471d,0x616c,0x4f49,0x90,0xf7,0x12,0x7b,0xb7,0x63,0xfa,0x51); +DEF_GUID(ID3D12QueryHeap,0x0d9658ae,0xed45,0x469e,0xa6,0x1d,0x97,0x0e,0xc5,0x83,0xca,0xb4); +DEF_GUID(ID3D12CommandSignature,0xc36a797c,0xec80,0x4f0a,0x89,0x85,0xa7,0xb2,0x47,0x50,0x82,0xd1); +DEF_GUID(ID3D12CommandList,0x7116d91c,0xe7e4,0x47ce,0xb8,0xc6,0xec,0x81,0x68,0xf4,0x37,0xe5); +DEF_GUID(ID3D12GraphicsCommandList,0x5b160d0f,0xac1b,0x4185,0x8b,0xa8,0xb3,0xae,0x42,0xa5,0xa4,0x55); +DEF_GUID(ID3D12GraphicsCommandList1,0x553103fb,0x1fe7,0x4557,0xbb,0x38,0x94,0x6d,0x7d,0x0e,0x7c,0xa7); +DEF_GUID(ID3D12GraphicsCommandList2,0x38C3E585,0xFF17,0x412C,0x91,0x50,0x4F,0xC6,0xF9,0xD7,0x2A,0x28); +DEF_GUID(ID3D12CommandQueue,0x0ec870a6,0x5d7e,0x4c22,0x8c,0xfc,0x5b,0xaa,0xe0,0x76,0x16,0xed); +DEF_GUID(ID3D12Device,0x189819f1,0x1db6,0x4b57,0xbe,0x54,0x18,0x21,0x33,0x9b,0x85,0xf7); +DEF_GUID(ID3D12PipelineLibrary,0xc64226a8,0x9201,0x46af,0xb4,0xcc,0x53,0xfb,0x9f,0xf7,0x41,0x4f); +DEF_GUID(ID3D12PipelineLibrary1,0x80eabf42,0x2568,0x4e5e,0xbd,0x82,0xc3,0x7f,0x86,0x96,0x1d,0xc3); +DEF_GUID(ID3D12Device1,0x77acce80,0x638e,0x4e65,0x88,0x95,0xc1,0xf2,0x33,0x86,0x86,0x3e); +DEF_GUID(ID3D12Device2,0x30baa41e,0xb15b,0x475c,0xa0,0xbb,0x1a,0xf5,0xc5,0xb6,0x43,0x28); +DEF_GUID(ID3D12Device3,0x81dadc15,0x2bad,0x4392,0x93,0xc5,0x10,0x13,0x45,0xc4,0xaa,0x98); +DEF_GUID(ID3D12ProtectedSession,0xA1533D18,0x0AC1,0x4084,0x85,0xB9,0x89,0xA9,0x61,0x16,0x80,0x6B); +DEF_GUID(ID3D12ProtectedResourceSession,0x6CD696F4,0xF289,0x40CC,0x80,0x91,0x5A,0x6C,0x0A,0x09,0x9C,0x3D); +DEF_GUID(ID3D12Device4,0xe865df17,0xa9ee,0x46f9,0xa4,0x63,0x30,0x98,0x31,0x5a,0xa2,0xe5); +DEF_GUID(ID3D12LifetimeOwner,0xe667af9f,0xcd56,0x4f46,0x83,0xce,0x03,0x2e,0x59,0x5d,0x70,0xa8); +DEF_GUID(ID3D12SwapChainAssistant,0xf1df64b6,0x57fd,0x49cd,0x88,0x07,0xc0,0xeb,0x88,0xb4,0x5c,0x8f); +DEF_GUID(ID3D12LifetimeTracker,0x3fd03d36,0x4eb1,0x424a,0xa5,0x82,0x49,0x4e,0xcb,0x8b,0xa8,0x13); +DEF_GUID(ID3D12StateObject,0x47016943,0xfca8,0x4594,0x93,0xea,0xaf,0x25,0x8b,0x55,0x34,0x6d); +DEF_GUID(ID3D12StateObjectProperties,0xde5fa827,0x9bf9,0x4f26,0x89,0xff,0xd7,0xf5,0x6f,0xde,0x38,0x60); +DEF_GUID(ID3D12Device5,0x8b4f173b,0x2fea,0x4b80,0x8f,0x58,0x43,0x07,0x19,0x1a,0xb9,0x5d); +DEF_GUID(ID3D12DeviceRemovedExtendedDataSettings,0x82BC481C,0x6B9B,0x4030,0xAE,0xDB,0x7E,0xE3,0xD1,0xDF,0x1E,0x63); +DEF_GUID(ID3D12DeviceRemovedExtendedData,0x98931D33,0x5AE8,0x4791,0xAA,0x3C,0x1A,0x73,0xA2,0x93,0x4E,0x71); +DEF_GUID(ID3D12Device6,0xc70b221b,0x40e4,0x4a17,0x89,0xaf,0x02,0x5a,0x07,0x27,0xa6,0xdc); +DEF_GUID(ID3D12Resource1,0x9D5E227A,0x4430,0x4161,0x88,0xB3,0x3E,0xCA,0x6B,0xB1,0x6E,0x19); +DEF_GUID(ID3D12Heap1,0x572F7389,0x2168,0x49E3,0x96,0x93,0xD6,0xDF,0x58,0x71,0xBF,0x6D); +DEF_GUID(ID3D12GraphicsCommandList3,0x6FDA83A7,0xB84C,0x4E38,0x9A,0xC8,0xC7,0xBD,0x22,0x01,0x6B,0x3D); +DEF_GUID(ID3D12MetaCommand,0xDBB84C27,0x36CE,0x4FC9,0xB8,0x01,0xF0,0x48,0xC4,0x6A,0xC5,0x70); +DEF_GUID(ID3D12GraphicsCommandList4,0x8754318e,0xd3a9,0x4541,0x98,0xcf,0x64,0x5b,0x50,0xdc,0x48,0x74); +DEF_GUID(ID3D12Tools,0x7071e1f0,0xe84b,0x4b33,0x97,0x4f,0x12,0xfa,0x49,0xde,0x65,0xc5); +DEF_GUID(ID3D12GraphicsCommandList5,0x55050859,0x4024,0x474c,0x87,0xf5,0x64,0x72,0xea,0xee,0x44,0xea); + +#endif + +#endif diff --git a/src/pc/gfx/gfx_direct3d_common.cpp b/src/pc/gfx/gfx_direct3d_common.cpp index 334814bd..c4d6014e 100644 --- a/src/pc/gfx/gfx_direct3d_common.cpp +++ b/src/pc/gfx/gfx_direct3d_common.cpp @@ -1,24 +1,10 @@ -#if (defined(RAPI_D3D11) || defined(RAPI_D3D12)) && (defined(_WIN32) || defined(_WIN64)) +#if defined(RAPI_D3D11) || defined(RAPI_D3D12) #include -extern "C" { -#include "../platform.h" -} - #include "gfx_direct3d_common.h" #include "gfx_cc.h" -void ThrowIfFailed(HRESULT res) { - if (FAILED(res)) - sys_fatal("error while initializing D3D:\nerror code 0x%08X", res); -} - -void ThrowIfFailed(HRESULT res, HWND h_wnd, const char *message) { - if (FAILED(res)) - sys_fatal("%s\nerror code 0x%08X", message, res); -} - void get_cc_features(uint32_t shader_id, CCFeatures *cc_features) { for (int i = 0; i < 4; i++) { cc_features->c[0][i] = (shader_id >> (i * 3)) & 7; @@ -59,17 +45,17 @@ void get_cc_features(uint32_t shader_id, CCFeatures *cc_features) { cc_features->color_alpha_same = (shader_id & 0xfff) == ((shader_id >> 12) & 0xfff); } -void append_str(char *buf, size_t *len, const char *str) { +static void append_str(char *buf, size_t *len, const char *str) { while (*str != '\0') buf[(*len)++] = *str++; } -void append_line(char *buf, size_t *len, const char *str) { +static void append_line(char *buf, size_t *len, const char *str) { while (*str != '\0') buf[(*len)++] = *str++; buf[(*len)++] = '\r'; buf[(*len)++] = '\n'; } -const char *shader_item_to_str(uint32_t item, bool with_alpha, bool only_alpha, bool inputs_have_alpha, bool hint_single_element) { +static const char *shader_item_to_str(uint32_t item, bool with_alpha, bool only_alpha, bool inputs_have_alpha, bool hint_single_element) { if (!only_alpha) { switch (item) { default: @@ -113,7 +99,7 @@ const char *shader_item_to_str(uint32_t item, bool with_alpha, bool only_alpha, } } -void append_formula(char *buf, size_t *len, uint8_t c[2][4], bool do_single, bool do_multiply, bool do_mix, bool with_alpha, bool only_alpha, bool opt_alpha) { +static void append_formula(char *buf, size_t *len, const uint8_t c[2][4], bool do_single, bool do_multiply, bool do_mix, bool with_alpha, bool only_alpha, bool opt_alpha) { if (do_single) { append_str(buf, len, shader_item_to_str(c[only_alpha][3], with_alpha, only_alpha, opt_alpha, false)); } else if (do_multiply) { @@ -140,4 +126,188 @@ void append_formula(char *buf, size_t *len, uint8_t c[2][4], bool do_single, boo } } +void gfx_direct3d_common_build_shader(char buf[4096], size_t& len, size_t& num_floats, const CCFeatures& cc_features, bool include_root_signature, bool three_point_filtering) { + len = 0; + num_floats = 4; + + // Pixel shader input struct + + if (include_root_signature) { + append_str(buf, &len, "#define RS \"RootFlags(ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | DENY_VERTEX_SHADER_ROOT_ACCESS)"); + if (cc_features.opt_alpha && cc_features.opt_noise) { + append_str(buf, &len, ",CBV(b0, visibility = SHADER_VISIBILITY_PIXEL)"); + } + if (cc_features.used_textures[0]) { + append_str(buf, &len, ",DescriptorTable(SRV(t0), visibility = SHADER_VISIBILITY_PIXEL)"); + append_str(buf, &len, ",DescriptorTable(Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL)"); + } + if (cc_features.used_textures[1]) { + append_str(buf, &len, ",DescriptorTable(SRV(t1), visibility = SHADER_VISIBILITY_PIXEL)"); + append_str(buf, &len, ",DescriptorTable(Sampler(s1), visibility = SHADER_VISIBILITY_PIXEL)"); + } + append_line(buf, &len, "\""); + } + + append_line(buf, &len, "struct PSInput {"); + append_line(buf, &len, " float4 position : SV_POSITION;"); + if (cc_features.used_textures[0] || cc_features.used_textures[1]) { + append_line(buf, &len, " float2 uv : TEXCOORD;"); + num_floats += 2; + } + if (cc_features.opt_alpha && cc_features.opt_noise) { + append_line(buf, &len, " float4 screenPos : TEXCOORD1;"); + } + if (cc_features.opt_fog) { + append_line(buf, &len, " float4 fog : FOG;"); + num_floats += 4; + } + for (int i = 0; i < cc_features.num_inputs; i++) { + len += sprintf(buf + len, " float%d input%d : INPUT%d;\r\n", cc_features.opt_alpha ? 4 : 3, i + 1, i); + num_floats += cc_features.opt_alpha ? 4 : 3; + } + append_line(buf, &len, "};"); + + // Textures and samplers + + if (cc_features.used_textures[0]) { + append_line(buf, &len, "Texture2D g_texture0 : register(t0);"); + append_line(buf, &len, "SamplerState g_sampler0 : register(s0);"); + } + if (cc_features.used_textures[1]) { + append_line(buf, &len, "Texture2D g_texture1 : register(t1);"); + append_line(buf, &len, "SamplerState g_sampler1 : register(s1);"); + } + + // Constant buffer and random function + + if (cc_features.opt_alpha && cc_features.opt_noise) { + append_line(buf, &len, "cbuffer PerFrameCB : register(b0) {"); + append_line(buf, &len, " uint noise_frame;"); + append_line(buf, &len, " float2 noise_scale;"); + append_line(buf, &len, "}"); + + append_line(buf, &len, "float random(in float3 value) {"); + append_line(buf, &len, " float random = dot(value, float3(12.9898, 78.233, 37.719));"); + append_line(buf, &len, " return frac(sin(random) * 143758.5453);"); + append_line(buf, &len, "}"); + } + + // 3 point texture filtering + // Original author: ArthurCarvalho + // Based on GLSL implementation by twinaphex, mupen64plus-libretro project. + + if (three_point_filtering && (cc_features.used_textures[0] || cc_features.used_textures[1])) { + append_line(buf, &len, "cbuffer PerDrawCB : register(b1) {"); + append_line(buf, &len, " struct {"); + append_line(buf, &len, " uint width;"); + append_line(buf, &len, " uint height;"); + append_line(buf, &len, " bool linear_filtering;"); + append_line(buf, &len, " } textures[2];"); + append_line(buf, &len, "}"); + append_line(buf, &len, "#define TEX_OFFSET(tex, tSampler, texCoord, off, texSize) tex.Sample(tSampler, texCoord - off / texSize)"); + append_line(buf, &len, "float4 tex2D3PointFilter(in Texture2D tex, in SamplerState tSampler, in float2 texCoord, in float2 texSize) {"); + append_line(buf, &len, " float2 offset = frac(texCoord * texSize - float2(0.5, 0.5));"); + append_line(buf, &len, " offset -= step(1.0, offset.x + offset.y);"); + append_line(buf, &len, " float4 c0 = TEX_OFFSET(tex, tSampler, texCoord, offset, texSize);"); + append_line(buf, &len, " float4 c1 = TEX_OFFSET(tex, tSampler, texCoord, float2(offset.x - sign(offset.x), offset.y), texSize);"); + append_line(buf, &len, " float4 c2 = TEX_OFFSET(tex, tSampler, texCoord, float2(offset.x, offset.y - sign(offset.y)), texSize);"); + append_line(buf, &len, " return c0 + abs(offset.x)*(c1-c0) + abs(offset.y)*(c2-c0);"); + append_line(buf, &len, "}"); + } + + // Vertex shader + + append_str(buf, &len, "PSInput VSMain(float4 position : POSITION"); + if (cc_features.used_textures[0] || cc_features.used_textures[1]) { + append_str(buf, &len, ", float2 uv : TEXCOORD"); + } + if (cc_features.opt_fog) { + append_str(buf, &len, ", float4 fog : FOG"); + } + for (int i = 0; i < cc_features.num_inputs; i++) { + len += sprintf(buf + len, ", float%d input%d : INPUT%d", cc_features.opt_alpha ? 4 : 3, i + 1, i); + } + append_line(buf, &len, ") {"); + append_line(buf, &len, " PSInput result;"); + append_line(buf, &len, " result.position = position;"); + if (cc_features.opt_alpha && cc_features.opt_noise) { + append_line(buf, &len, " result.screenPos = position;"); + } + if (cc_features.used_textures[0] || cc_features.used_textures[1]) { + append_line(buf, &len, " result.uv = uv;"); + } + if (cc_features.opt_fog) { + append_line(buf, &len, " result.fog = fog;"); + } + for (int i = 0; i < cc_features.num_inputs; i++) { + len += sprintf(buf + len, " result.input%d = input%d;\r\n", i + 1, i + 1); + } + append_line(buf, &len, " return result;"); + append_line(buf, &len, "}"); + + // Pixel shader + if (include_root_signature) { + append_line(buf, &len, "[RootSignature(RS)]"); + } + append_line(buf, &len, "float4 PSMain(PSInput input) : SV_TARGET {"); + if (cc_features.used_textures[0]) { + if (three_point_filtering) { + append_line(buf, &len, " float4 texVal0;"); + append_line(buf, &len, " if (textures[0].linear_filtering)"); + append_line(buf, &len, " texVal0 = tex2D3PointFilter(g_texture0, g_sampler0, input.uv, float2(textures[0].width, textures[0].height));"); + append_line(buf, &len, " else"); + append_line(buf, &len, " texVal0 = g_texture0.Sample(g_sampler0, input.uv);"); + } else { + append_line(buf, &len, " float4 texVal0 = g_texture0.Sample(g_sampler0, input.uv);"); + } + } + if (cc_features.used_textures[1]) { + if (three_point_filtering) { + append_line(buf, &len, " float4 texVal1;"); + append_line(buf, &len, " if (textures[1].linear_filtering)"); + append_line(buf, &len, " texVal1 = tex2D3PointFilter(g_texture1, g_sampler1, input.uv, float2(textures[1].width, textures[1].height));"); + append_line(buf, &len, " else"); + append_line(buf, &len, " texVal1 = g_texture1.Sample(g_sampler1, input.uv);"); + } else { + append_line(buf, &len, " float4 texVal1 = g_texture1.Sample(g_sampler1, input.uv);"); + } + } + + append_str(buf, &len, cc_features.opt_alpha ? " float4 texel = " : " float3 texel = "); + if (!cc_features.color_alpha_same && cc_features.opt_alpha) { + append_str(buf, &len, "float4("); + append_formula(buf, &len, cc_features.c, cc_features.do_single[0], cc_features.do_multiply[0], cc_features.do_mix[0], false, false, true); + append_str(buf, &len, ", "); + append_formula(buf, &len, cc_features.c, cc_features.do_single[1], cc_features.do_multiply[1], cc_features.do_mix[1], true, true, true); + append_str(buf, &len, ")"); + } else { + append_formula(buf, &len, cc_features.c, cc_features.do_single[0], cc_features.do_multiply[0], cc_features.do_mix[0], cc_features.opt_alpha, false, cc_features.opt_alpha); + } + append_line(buf, &len, ";"); + + if (cc_features.opt_texture_edge && cc_features.opt_alpha) { + append_line(buf, &len, " if (texel.a > 0.3) texel.a = 1.0; else discard;"); + } + // TODO discard if alpha is 0? + if (cc_features.opt_fog) { + if (cc_features.opt_alpha) { + append_line(buf, &len, " texel = float4(lerp(texel.rgb, input.fog.rgb, input.fog.a), texel.a);"); + } else { + append_line(buf, &len, " texel = lerp(texel, input.fog.rgb, input.fog.a);"); + } + } + + if (cc_features.opt_alpha && cc_features.opt_noise) { + append_line(buf, &len, " float2 coords = (input.screenPos.xy / input.screenPos.w) * noise_scale;"); + append_line(buf, &len, " texel.a *= round(random(float3(floor(coords), noise_frame)));"); + } + + if (cc_features.opt_alpha) { + append_line(buf, &len, " return texel;"); + } else { + append_line(buf, &len, " return float4(texel, 1.0);"); + } + append_line(buf, &len, "}"); +} + #endif diff --git a/src/pc/gfx/gfx_direct3d_common.h b/src/pc/gfx/gfx_direct3d_common.h index 09769a7c..1eb316d7 100644 --- a/src/pc/gfx/gfx_direct3d_common.h +++ b/src/pc/gfx/gfx_direct3d_common.h @@ -4,29 +4,10 @@ #define GFX_DIRECT3D_COMMON_H #include -#include -struct CCFeatures { - uint8_t c[2][4]; - bool opt_alpha; - bool opt_fog; - bool opt_texture_edge; - bool opt_noise; - bool used_textures[2]; - uint32_t num_inputs; - bool do_single[2]; - bool do_multiply[2]; - bool do_mix[2]; - bool color_alpha_same; -}; +#include "gfx_cc.h" -void ThrowIfFailed(HRESULT res); -void ThrowIfFailed(HRESULT res, HWND h_wnd, const char *message); -void get_cc_features(uint32_t shader_id, CCFeatures *shader_features); -void append_str(char *buf, size_t *len, const char *str); -void append_line(char *buf, size_t *len, const char *str); -const char *shader_item_to_str(uint32_t item, bool with_alpha, bool only_alpha, bool inputs_have_alpha, bool hint_single_element); -void append_formula(char *buf, size_t *len, uint8_t c[2][4], bool do_single, bool do_multiply, bool do_mix, bool with_alpha, bool only_alpha, bool opt_alpha); +void gfx_direct3d_common_build_shader(char buf[4096], size_t& len, size_t& num_floats, const CCFeatures& cc_features, bool include_root_signature, bool three_point_filtering); #endif diff --git a/src/pc/gfx/gfx_dxgi.cpp b/src/pc/gfx/gfx_dxgi.cpp new file mode 100644 index 00000000..04674952 --- /dev/null +++ b/src/pc/gfx/gfx_dxgi.cpp @@ -0,0 +1,641 @@ +#ifdef WAPI_DXGI + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include + + +#ifndef _LANGUAGE_C +#define _LANGUAGE_C +#endif +#include + +#include "../configfile.h" +#include "../pc_main.h" + +#include "gfx_window_manager_api.h" +#include "gfx_rendering_api.h" +#include "gfx_direct3d_common.h" +#include "gfx_screen_config.h" +#include "gfx_pc.h" + +#define WINCLASS_NAME L"N64GAME" + +#define DECLARE_GFX_DXGI_FUNCTIONS +#include "gfx_dxgi.h" + +#ifdef VERSION_EU +#define FRAME_INTERVAL_US_NUMERATOR 40000 +#define FRAME_INTERVAL_US_DENOMINATOR 1 +#else +#define FRAME_INTERVAL_US_NUMERATOR 100000 +#define FRAME_INTERVAL_US_DENOMINATOR 3 +#endif + +using namespace Microsoft::WRL; // For ComPtr + +static struct { + HWND h_wnd; + bool showing_error; + uint32_t current_width, current_height; + std::string window_title; + + HMODULE dxgi_module; + HRESULT (__stdcall *CreateDXGIFactory1)(REFIID riid, void **factory); + HRESULT (__stdcall *CreateDXGIFactory2)(UINT flags, REFIID iid, void **factory); + + bool process_dpi_awareness_done; + + RECT last_window_rect; + bool is_full_screen, last_maximized_state; + + ComPtr factory; + ComPtr swap_chain; + HANDLE waitable_object; + uint64_t qpc_init, qpc_freq; + uint64_t frame_timestamp; // in units of 1/FRAME_INTERVAL_US_DENOMINATOR microseconds + std::map frame_stats; + std::set> pending_frame_stats; + bool dropped_frame; + bool sync_interval_means_frames_to_wait; + UINT length_in_vsync_frames; + + void (*run_one_game_iter)(void); + bool (*on_key_down)(int scancode); + bool (*on_key_up)(int scancode); + void (*on_all_keys_up)(void); +} dxgi; + +static void load_dxgi_library(void) { + dxgi.dxgi_module = LoadLibraryW(L"dxgi.dll"); + *(FARPROC *)&dxgi.CreateDXGIFactory1 = GetProcAddress(dxgi.dxgi_module, "CreateDXGIFactory1"); + *(FARPROC *)&dxgi.CreateDXGIFactory2 = GetProcAddress(dxgi.dxgi_module, "CreateDXGIFactory2"); +} + +template +static void run_as_dpi_aware(Fun f) { + // Make sure Windows 8.1 or newer doesn't upscale/downscale the rendered images. + // This is an issue on Windows 8.1 and newer where moving around the window + // between different monitors having different scaling settings will + // by default result in the DirectX image will also be scaled accordingly. + // The resulting scale factor is the curent monitor's scale factor divided by + // the initial monitor's scale factor. Setting per-monitor aware disables scaling. + + // On Windows 10 1607 and later, that is solved by setting the awarenenss per window, + // which is done by using SetThreadDpiAwarenessContext before and after creating + // any window. When the message handler runs, the corresponding context also applies. + + // From windef.h, missing in MinGW. + DECLARE_HANDLE(DPI_AWARENESS_CONTEXT); + #define DPI_AWARENESS_CONTEXT_UNAWARE ((DPI_AWARENESS_CONTEXT)-1) + #define DPI_AWARENESS_CONTEXT_SYSTEM_AWARE ((DPI_AWARENESS_CONTEXT)-2) + #define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE ((DPI_AWARENESS_CONTEXT)-3) + #define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((DPI_AWARENESS_CONTEXT)-4) + #define DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED ((DPI_AWARENESS_CONTEXT)-5) + + DPI_AWARENESS_CONTEXT (WINAPI *SetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT dpiContext); + *(FARPROC *)&SetThreadDpiAwarenessContext = GetProcAddress(GetModuleHandleW(L"user32.dll"), "SetThreadDpiAwarenessContext"); + DPI_AWARENESS_CONTEXT old_awareness_context; + if (SetThreadDpiAwarenessContext != nullptr) { + old_awareness_context = SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); + } else { + // Solution for Windows 8.1 and newer, but before Windows 10 1607. + // SetProcessDpiAwareness must be called before any drawing related API is called. + if (!dxgi.process_dpi_awareness_done) { + HMODULE shcore_module = LoadLibraryW(L"SHCore.dll"); + if (shcore_module != nullptr) { + HRESULT (WINAPI *SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS value); + *(FARPROC *)&SetProcessDpiAwareness = GetProcAddress(shcore_module, "SetProcessDpiAwareness"); + if (SetProcessDpiAwareness != nullptr) { + SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE); + // Ignore result, will fail if already called or manifest already specifies dpi awareness. + } + FreeLibrary(shcore_module); + } + dxgi.process_dpi_awareness_done = true; + } + } + + f(); + + // Restore the old context + if (SetThreadDpiAwarenessContext != nullptr && old_awareness_context != nullptr) { + SetThreadDpiAwarenessContext(old_awareness_context); + } +} + +static void toggle_borderless_window_full_screen(bool enable) { + // Windows 7 + flip mode + waitable object can't go to exclusive fullscreen, + // so do borderless instead. If DWM is enabled, this means we get one monitor + // sync interval of latency extra. On Win 10 however (maybe Win 8 too), due to + // "fullscreen optimizations" the latency is eliminated. + + if (enable == dxgi.is_full_screen) { + return; + } + + if (!enable) { + RECT r = dxgi.last_window_rect; + + // Set in window mode with the last saved position and size + SetWindowLongPtr(dxgi.h_wnd, GWL_STYLE, WS_VISIBLE | WS_OVERLAPPEDWINDOW); + + if (dxgi.last_maximized_state) { + SetWindowPos(dxgi.h_wnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE); + ShowWindow(dxgi.h_wnd, SW_MAXIMIZE); + } else { + SetWindowPos(dxgi.h_wnd, NULL, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_FRAMECHANGED); + ShowWindow(dxgi.h_wnd, SW_RESTORE); + } + + ShowCursor(TRUE); + + dxgi.is_full_screen = false; + } else { + // Save if window is maximized or not + WINDOWPLACEMENT window_placement; + window_placement.length = sizeof(WINDOWPLACEMENT); + GetWindowPlacement(dxgi.h_wnd, &window_placement); + dxgi.last_maximized_state = window_placement.showCmd == SW_SHOWMAXIMIZED; + + // Save window position and size if the window is not maximized + GetWindowRect(dxgi.h_wnd, &dxgi.last_window_rect); + configWindow.x = dxgi.last_window_rect.left; + configWindow.y = dxgi.last_window_rect.top; + configWindow.w = dxgi.last_window_rect.right - dxgi.last_window_rect.left; + configWindow.h = dxgi.last_window_rect.bottom - dxgi.last_window_rect.top; + + // Get in which monitor the window is + HMONITOR h_monitor = MonitorFromWindow(dxgi.h_wnd, MONITOR_DEFAULTTONEAREST); + + // Get info from that monitor + MONITORINFOEX monitor_info; + monitor_info.cbSize = sizeof(MONITORINFOEX); + GetMonitorInfo(h_monitor, &monitor_info); + RECT r = monitor_info.rcMonitor; + + // Set borderless full screen to that monitor + SetWindowLongPtr(dxgi.h_wnd, GWL_STYLE, WS_VISIBLE | WS_POPUP); + SetWindowPos(dxgi.h_wnd, HWND_TOP, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_FRAMECHANGED); + + ShowCursor(FALSE); + + dxgi.is_full_screen = true; + } +} + +static void update_screen_settings(void) { + if (configWindow.fullscreen != dxgi.is_full_screen) + toggle_borderless_window_full_screen(configWindow.fullscreen); + if (!dxgi.is_full_screen) { + const int screen_width = GetSystemMetrics(SM_CXSCREEN); + const int screen_height = GetSystemMetrics(SM_CYSCREEN); + const int xpos = (configWindow.x == WAPI_WIN_CENTERPOS) ? (screen_width - configWindow.w) * 0.5 : configWindow.x; + const int ypos = (configWindow.y == WAPI_WIN_CENTERPOS) ? (screen_height - configWindow.h) * 0.5 : configWindow.y; + RECT wr = { xpos, ypos, xpos + (int)configWindow.w, ypos + (int)configWindow.h }; + AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); + SetWindowPos(dxgi.h_wnd, NULL, wr.left, wr.top, wr.right - wr.left, wr.bottom - wr.top, SWP_NOACTIVATE | SWP_NOZORDER); + } +} + +static void gfx_dxgi_on_resize(void) { + if (dxgi.swap_chain.Get() != nullptr) { + gfx_get_current_rendering_api()->on_resize(); + + DXGI_SWAP_CHAIN_DESC1 desc1; + ThrowIfFailed(dxgi.swap_chain->GetDesc1(&desc1)); + dxgi.current_width = desc1.Width; + dxgi.current_height = desc1.Height; + if (!dxgi.is_full_screen) { + configWindow.w = dxgi.current_width; + configWindow.h = dxgi.current_height; + } + } +} + +static void onkeydown(WPARAM w_param, LPARAM l_param) { + int key = ((l_param >> 16) & 0x1ff); + if (dxgi.on_key_down != nullptr) { + dxgi.on_key_down(key); + } +} +static void onkeyup(WPARAM w_param, LPARAM l_param) { + int key = ((l_param >> 16) & 0x1ff); + if (dxgi.on_key_up != nullptr) { + dxgi.on_key_up(key); + } +} + +static LRESULT CALLBACK gfx_dxgi_wnd_proc(HWND h_wnd, UINT message, WPARAM w_param, LPARAM l_param) { + switch (message) { + case WM_SIZE: + gfx_dxgi_on_resize(); + break; + case WM_DESTROY: + game_exit(); + break; + case WM_PAINT: + if (dxgi.showing_error) { + return DefWindowProcW(h_wnd, message, w_param, l_param); + } else { + if (dxgi.run_one_game_iter != nullptr) { + dxgi.run_one_game_iter(); + } + } + break; + case WM_ACTIVATEAPP: + if (dxgi.on_all_keys_up != nullptr) { + dxgi.on_all_keys_up(); + } + break; + case WM_KEYDOWN: + onkeydown(w_param, l_param); + break; + case WM_KEYUP: + onkeyup(w_param, l_param); + break; + case WM_SYSKEYDOWN: + if ((w_param == VK_RETURN) && ((l_param & 1 << 30) == 0)) { + toggle_borderless_window_full_screen(!dxgi.is_full_screen); + break; + } else { + return DefWindowProcW(h_wnd, message, w_param, l_param); + } + default: + return DefWindowProcW(h_wnd, message, w_param, l_param); + } + + if (configWindow.reset) { + dxgi.last_maximized_state = false; + configWindow.reset = false; + configWindow.x = WAPI_WIN_CENTERPOS; + configWindow.y = WAPI_WIN_CENTERPOS; + configWindow.w = DESIRED_SCREEN_WIDTH; + configWindow.h = DESIRED_SCREEN_HEIGHT; + configWindow.fullscreen = false; + configWindow.settings_changed = true; + } + + if (configWindow.settings_changed) { + configWindow.settings_changed = false; + update_screen_settings(); + } + + return 0; +} + +static void gfx_dxgi_init(const char *window_title) { + LARGE_INTEGER qpc_init, qpc_freq; + QueryPerformanceCounter(&qpc_init); + QueryPerformanceFrequency(&qpc_freq); + dxgi.qpc_init = qpc_init.QuadPart; + dxgi.qpc_freq = qpc_freq.QuadPart; + + // Prepare window title + + wchar_t w_title[512]; + int len = strlen(window_title); + mbstowcs(w_title, window_title, len + 1); + dxgi.window_title = window_title; + + // Create window + WNDCLASSEXW wcex; + + wcex.cbSize = sizeof(WNDCLASSEX); + + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = gfx_dxgi_wnd_proc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = nullptr; + wcex.hIcon = nullptr; + wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); + wcex.lpszMenuName = nullptr; + wcex.lpszClassName = WINCLASS_NAME; + wcex.hIconSm = nullptr; + + ATOM winclass = RegisterClassExW(&wcex); + + + run_as_dpi_aware([&] () { + // We need to be dpi aware when calculating the size + RECT wr = {0, 0, DESIRED_SCREEN_WIDTH, DESIRED_SCREEN_HEIGHT}; + AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); + + dxgi.h_wnd = CreateWindowW(WINCLASS_NAME, w_title, WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, 0, wr.right - wr.left, wr.bottom - wr.top, nullptr, nullptr, nullptr, nullptr); + }); + + load_dxgi_library(); + + ShowWindow(dxgi.h_wnd, SW_SHOW); + UpdateWindow(dxgi.h_wnd); + + update_screen_settings(); +} + +static void gfx_dxgi_set_keyboard_callbacks(bool (*on_key_down)(int scancode), bool (*on_key_up)(int scancode), void (*on_all_keys_up)(void)) { + dxgi.on_key_down = on_key_down; + dxgi.on_key_up = on_key_up; + dxgi.on_all_keys_up = on_all_keys_up; +} + +static void gfx_dxgi_main_loop(void (*run_one_game_iter)(void)) { + dxgi.run_one_game_iter = run_one_game_iter; + + MSG msg; + while (GetMessage(&msg, nullptr, 0, 0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } +} + +static void gfx_dxgi_get_dimensions(uint32_t *width, uint32_t *height) { + *width = dxgi.current_width; + *height = dxgi.current_height; +} + +static void gfx_dxgi_handle_events(void) { + /*MSG msg; + while (PeekMessageW(&msg, nullptr, 0, 0, PM_REMOVE)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + }*/ +} + +static uint64_t qpc_to_us(uint64_t qpc) { + return qpc / dxgi.qpc_freq * 1000000 + qpc % dxgi.qpc_freq * 1000000 / dxgi.qpc_freq; +} + +static bool gfx_dxgi_start_frame(void) { + DXGI_FRAME_STATISTICS stats; + if (dxgi.swap_chain->GetFrameStatistics(&stats) == S_OK && (stats.SyncRefreshCount != 0 || stats.SyncQPCTime.QuadPart != 0ULL)) { + { + LARGE_INTEGER t0; + QueryPerformanceCounter(&t0); + //printf("Get frame stats: %llu\n", (unsigned long long)(t0.QuadPart - dxgi.qpc_init)); + } + //printf("stats: %u %u %u %u %u %.6f\n", dxgi.pending_frame_stats.rbegin()->first, dxgi.pending_frame_stats.rbegin()->second, stats.PresentCount, stats.PresentRefreshCount, stats.SyncRefreshCount, (double)(stats.SyncQPCTime.QuadPart - dxgi.qpc_init) / dxgi.qpc_freq); + if (dxgi.frame_stats.empty() || dxgi.frame_stats.rbegin()->second.PresentCount != stats.PresentCount) { + dxgi.frame_stats.insert(std::make_pair(stats.PresentCount, stats)); + } + if (dxgi.frame_stats.size() > 3) { + dxgi.frame_stats.erase(dxgi.frame_stats.begin()); + } + } + if (!dxgi.frame_stats.empty()) { + while (!dxgi.pending_frame_stats.empty() && dxgi.pending_frame_stats.begin()->first < dxgi.frame_stats.rbegin()->first) { + dxgi.pending_frame_stats.erase(dxgi.pending_frame_stats.begin()); + } + } + while (dxgi.pending_frame_stats.size() > 15) { + // Just make sure the list doesn't grow too large if GetFrameStatistics fails. + dxgi.pending_frame_stats.erase(dxgi.pending_frame_stats.begin()); + } + + dxgi.frame_timestamp += FRAME_INTERVAL_US_NUMERATOR; + + if (dxgi.frame_stats.size() >= 2) { + DXGI_FRAME_STATISTICS *first = &dxgi.frame_stats.begin()->second; + DXGI_FRAME_STATISTICS *last = &dxgi.frame_stats.rbegin()->second; + uint64_t sync_qpc_diff = last->SyncQPCTime.QuadPart - first->SyncQPCTime.QuadPart; + UINT sync_vsync_diff = last->SyncRefreshCount - first->SyncRefreshCount; + UINT present_vsync_diff = last->PresentRefreshCount - first->PresentRefreshCount; + UINT present_diff = last->PresentCount - first->PresentCount; + + if (sync_vsync_diff == 0) { + sync_vsync_diff = 1; + } + + double estimated_vsync_interval = (double)sync_qpc_diff / (double)sync_vsync_diff; + uint64_t estimated_vsync_interval_us = qpc_to_us(estimated_vsync_interval); + //printf("Estimated vsync_interval: %d\n", (int)estimated_vsync_interval_us); + if (estimated_vsync_interval_us < 2 || estimated_vsync_interval_us > 1000000) { + // Unreasonable, maybe a monitor change + estimated_vsync_interval_us = 16666; + estimated_vsync_interval = estimated_vsync_interval_us * dxgi.qpc_freq / 1000000; + } + + UINT queued_vsyncs = 0; + bool is_first = true; + for (const std::pair& p : dxgi.pending_frame_stats) { + if (is_first && dxgi.sync_interval_means_frames_to_wait) { + is_first = false; + continue; + } + queued_vsyncs += p.second; + } + + uint64_t last_frame_present_end_qpc = (last->SyncQPCTime.QuadPart - dxgi.qpc_init) + estimated_vsync_interval * queued_vsyncs; + uint64_t last_end_us = qpc_to_us(last_frame_present_end_qpc); + + double vsyncs_to_wait = (double)(int64_t)(dxgi.frame_timestamp / FRAME_INTERVAL_US_DENOMINATOR - last_end_us) / estimated_vsync_interval_us; + //printf("ts: %llu, last_end_us: %llu, Init v: %f\n", dxgi.frame_timestamp / 3, last_end_us, vsyncs_to_wait); + + if (vsyncs_to_wait <= 0) { + // Too late + + if ((int64_t)(dxgi.frame_timestamp / FRAME_INTERVAL_US_DENOMINATOR - last_end_us) < -66666) { + // The application must have been paused or similar + vsyncs_to_wait = round(((double)FRAME_INTERVAL_US_NUMERATOR / FRAME_INTERVAL_US_DENOMINATOR) / estimated_vsync_interval_us); + if (vsyncs_to_wait < 1) { + vsyncs_to_wait = 1; + } + dxgi.frame_timestamp = FRAME_INTERVAL_US_DENOMINATOR * (last_end_us + vsyncs_to_wait * estimated_vsync_interval_us); + } else { + // Drop frame + //printf("Dropping frame\n"); + dxgi.dropped_frame = true; + return false; + } + } + if (floor(vsyncs_to_wait) != vsyncs_to_wait) { + uint64_t left = last_end_us + floor(vsyncs_to_wait) * estimated_vsync_interval_us; + uint64_t right = last_end_us + ceil(vsyncs_to_wait) * estimated_vsync_interval_us; + uint64_t adjusted_desired_time = dxgi.frame_timestamp / FRAME_INTERVAL_US_DENOMINATOR + (last_end_us + (FRAME_INTERVAL_US_NUMERATOR / FRAME_INTERVAL_US_DENOMINATOR) > dxgi.frame_timestamp / FRAME_INTERVAL_US_DENOMINATOR ? 2000 : -2000); + int64_t diff_left = adjusted_desired_time - left; + int64_t diff_right = right - adjusted_desired_time; + if (diff_left < 0) { + diff_left = -diff_left; + } + if (diff_right < 0) { + diff_right = -diff_right; + } + if (diff_left < diff_right) { + vsyncs_to_wait = floor(vsyncs_to_wait); + } else { + vsyncs_to_wait = ceil(vsyncs_to_wait); + } + if (vsyncs_to_wait == 0) { + //printf("vsyncs_to_wait became 0 so dropping frame\n"); + dxgi.dropped_frame = true; + return false; + } + } + //printf("v: %d\n", (int)vsyncs_to_wait); + if (vsyncs_to_wait > 4) { + // Invalid, so change to 4 + vsyncs_to_wait = 4; + } + dxgi.length_in_vsync_frames = vsyncs_to_wait; + } else { + dxgi.length_in_vsync_frames = 2; + } + + return true; +} + +static void gfx_dxgi_swap_buffers_begin(void) { + //dxgi.length_in_vsync_frames = 1; + ThrowIfFailed(dxgi.swap_chain->Present(dxgi.length_in_vsync_frames, 0)); + UINT this_present_id; + if (dxgi.swap_chain->GetLastPresentCount(&this_present_id) == S_OK) { + dxgi.pending_frame_stats.insert(std::make_pair(this_present_id, dxgi.length_in_vsync_frames)); + } + dxgi.dropped_frame = false; +} + +static void gfx_dxgi_swap_buffers_end(void) { + LARGE_INTEGER t0, t1, t2; + QueryPerformanceCounter(&t0); + QueryPerformanceCounter(&t1); + + if (!dxgi.dropped_frame) { + if (dxgi.waitable_object != nullptr) { + WaitForSingleObject(dxgi.waitable_object, INFINITE); + } + // else TODO: maybe sleep until some estimated time the frame will be shown to reduce lag + } + + DXGI_FRAME_STATISTICS stats; + dxgi.swap_chain->GetFrameStatistics(&stats); + + QueryPerformanceCounter(&t2); + + dxgi.sync_interval_means_frames_to_wait = dxgi.pending_frame_stats.rbegin()->first == stats.PresentCount; + + //printf("done %llu gpu:%d wait:%d freed:%llu frame:%u %u monitor:%u t:%llu\n", (unsigned long long)(t0.QuadPart - dxgi.qpc_init), (int)(t1.QuadPart - t0.QuadPart), (int)(t2.QuadPart - t0.QuadPart), (unsigned long long)(t2.QuadPart - dxgi.qpc_init), dxgi.pending_frame_stats.rbegin()->first, stats.PresentCount, stats.SyncRefreshCount, (unsigned long long)(stats.SyncQPCTime.QuadPart - dxgi.qpc_init)); +} + +static double gfx_dxgi_get_time(void) { + LARGE_INTEGER t; + QueryPerformanceCounter(&t); + return (double)(t.QuadPart - dxgi.qpc_init) / dxgi.qpc_freq; +} + +void gfx_dxgi_create_factory_and_device(bool debug, int d3d_version, bool (*create_device_fn)(IDXGIAdapter1 *adapter, bool test_only)) { + if (dxgi.CreateDXGIFactory2 != nullptr) { + ThrowIfFailed(dxgi.CreateDXGIFactory2(debug ? DXGI_CREATE_FACTORY_DEBUG : 0, __uuidof(IDXGIFactory2), &dxgi.factory)); + } else { + ThrowIfFailed(dxgi.CreateDXGIFactory1(__uuidof(IDXGIFactory2), &dxgi.factory)); + } + + ComPtr adapter; + for (UINT i = 0; dxgi.factory->EnumAdapters1(i, &adapter) != DXGI_ERROR_NOT_FOUND; i++) { + DXGI_ADAPTER_DESC1 desc; + adapter->GetDesc1(&desc); + if (desc.Flags & 2/*DXGI_ADAPTER_FLAG_SOFTWARE*/) { // declaration missing in mingw headers + continue; + } + if (create_device_fn(adapter.Get(), true)) { + break; + } + } + create_device_fn(adapter.Get(), false); + + wchar_t w_title[512]; + int len = dxgi.window_title.length(); + mbstowcs(w_title, dxgi.window_title.c_str(), len + 1); + SetWindowTextW(dxgi.h_wnd, w_title); +} + +ComPtr gfx_dxgi_create_swap_chain(IUnknown *device) { + bool win8 = IsWindows8OrGreater(); // DXGI_SCALING_NONE is only supported on Win8 and beyond + bool dxgi_13 = dxgi.CreateDXGIFactory2 != nullptr; // DXGI 1.3 introduced waitable object + + DXGI_SWAP_CHAIN_DESC1 swap_chain_desc = {}; + swap_chain_desc.BufferCount = 2; + swap_chain_desc.Width = 0; + swap_chain_desc.Height = 0; + swap_chain_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + swap_chain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + swap_chain_desc.Scaling = win8 ? DXGI_SCALING_NONE : DXGI_SCALING_STRETCH; + swap_chain_desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // Apparently this was backported to Win 7 Platform Update + swap_chain_desc.Flags = dxgi_13 ? DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT : 0; + swap_chain_desc.SampleDesc.Count = 1; + + run_as_dpi_aware([&] () { + // When setting size for the buffers, the values that DXGI puts into the desc (that can later be retrieved by GetDesc1) + // have been divided by the current scaling factor. By making this call dpi aware, no division will be performed. + // The same goes for IDXGISwapChain::ResizeBuffers(), however that function is currently only called from the message handler. + ThrowIfFailed(dxgi.factory->CreateSwapChainForHwnd(device, dxgi.h_wnd, &swap_chain_desc, nullptr, nullptr, &dxgi.swap_chain)); + }); + ThrowIfFailed(dxgi.factory->MakeWindowAssociation(dxgi.h_wnd, DXGI_MWA_NO_ALT_ENTER)); + + ComPtr swap_chain2; + if (dxgi.swap_chain->QueryInterface(__uuidof(IDXGISwapChain2), &swap_chain2) == S_OK) { + ThrowIfFailed(swap_chain2->SetMaximumFrameLatency(1)); + dxgi.waitable_object = swap_chain2->GetFrameLatencyWaitableObject(); + WaitForSingleObject(dxgi.waitable_object, INFINITE); + } else { + ComPtr device1; + ThrowIfFailed(device->QueryInterface(IID_PPV_ARGS(&device1))); + ThrowIfFailed(device1->SetMaximumFrameLatency(1)); + } + + ThrowIfFailed(dxgi.swap_chain->GetDesc1(&swap_chain_desc)); + dxgi.current_width = swap_chain_desc.Width; + dxgi.current_height = swap_chain_desc.Height; + + return dxgi.swap_chain; +} + +HWND gfx_dxgi_get_h_wnd(void) { + return dxgi.h_wnd; +} + +void gfx_dxgi_shutdown(void) { +} + +void ThrowIfFailed(HRESULT res) { + if (FAILED(res)) { + fprintf(stderr, "Error: 0x%08X\n", res); + throw res; + } +} + +void ThrowIfFailed(HRESULT res, HWND h_wnd, const char *message) { + if (FAILED(res)) { + char full_message[256]; + sprintf(full_message, "%s\n\nHRESULT: 0x%08X", message, res); + dxgi.showing_error = true; + MessageBox(h_wnd, full_message, "Error", MB_OK | MB_ICONERROR); + throw res; + } +} + +struct GfxWindowManagerAPI gfx_dxgi = { + gfx_dxgi_init, + gfx_dxgi_set_keyboard_callbacks, + gfx_dxgi_main_loop, + gfx_dxgi_get_dimensions, + gfx_dxgi_handle_events, + gfx_dxgi_start_frame, + gfx_dxgi_swap_buffers_begin, + gfx_dxgi_swap_buffers_end, + gfx_dxgi_get_time, + gfx_dxgi_shutdown, +}; + +#endif diff --git a/src/pc/gfx/gfx_dxgi.h b/src/pc/gfx/gfx_dxgi.h new file mode 100644 index 00000000..6f42474c --- /dev/null +++ b/src/pc/gfx/gfx_dxgi.h @@ -0,0 +1,16 @@ +#ifndef GFX_DXGI_H +#define GFX_DXGI_H + +#include "gfx_rendering_api.h" + +#ifdef DECLARE_GFX_DXGI_FUNCTIONS +void gfx_dxgi_create_factory_and_device(bool debug, int d3d_version, bool (*create_device_fn)(IDXGIAdapter1 *adapter, bool test_only)); +Microsoft::WRL::ComPtr gfx_dxgi_create_swap_chain(IUnknown *device); +HWND gfx_dxgi_get_h_wnd(void); +void ThrowIfFailed(HRESULT res); +void ThrowIfFailed(HRESULT res, HWND h_wnd, const char *message); +#endif + +extern struct GfxWindowManagerAPI gfx_dxgi; + +#endif diff --git a/src/pc/gfx/gfx_opengl.c b/src/pc/gfx/gfx_opengl.c index b3476cef..b3d090b0 100644 --- a/src/pc/gfx/gfx_opengl.c +++ b/src/pc/gfx/gfx_opengl.c @@ -634,6 +634,9 @@ static void gfx_opengl_init(void) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } +static void gfx_opengl_on_resize(void) { +} + static void gfx_opengl_start_frame(void) { frame_count++; @@ -644,6 +647,12 @@ static void gfx_opengl_start_frame(void) { glEnable(GL_SCISSOR_TEST); } +static void gfx_opengl_end_frame(void) { +} + +static void gfx_opengl_finish_render(void) { +} + static void gfx_opengl_shutdown(void) { } @@ -666,7 +675,10 @@ struct GfxRenderingAPI gfx_opengl_api = { gfx_opengl_set_use_alpha, gfx_opengl_draw_triangles, gfx_opengl_init, + gfx_opengl_on_resize, gfx_opengl_start_frame, + gfx_opengl_end_frame, + gfx_opengl_finish_render, gfx_opengl_shutdown }; diff --git a/src/pc/gfx/gfx_opengl_legacy.c b/src/pc/gfx/gfx_opengl_legacy.c index 4ab19c87..ebee0d17 100644 --- a/src/pc/gfx/gfx_opengl_legacy.c +++ b/src/pc/gfx/gfx_opengl_legacy.c @@ -569,6 +569,9 @@ static void gfx_opengl_init(void) { TEXENV_COMBINE_OP(1, GL_SRC_COLOR, GL_SRC_ALPHA); } +static void gfx_opengl_on_resize(void) { +} + static void gfx_opengl_start_frame(void) { glDisable(GL_SCISSOR_TEST); glDepthMask(GL_TRUE); // Must be set to clear Z-buffer @@ -577,6 +580,15 @@ static void gfx_opengl_start_frame(void) { glEnable(GL_SCISSOR_TEST); } +static void gfx_opengl_end_frame(void) { +} + +static void gfx_opengl_finish_render(void) { +} + +static void gfx_opengl_shutdown(void) { +} + static void gfx_opengl_shutdown(void) { } @@ -599,7 +611,10 @@ struct GfxRenderingAPI gfx_opengl_api = { gfx_opengl_set_use_alpha, gfx_opengl_draw_triangles, gfx_opengl_init, + gfx_opengl_on_resize, gfx_opengl_start_frame, + gfx_opengl_end_frame, + gfx_opengl_finish_render, gfx_opengl_shutdown }; diff --git a/src/pc/gfx/gfx_pc.c b/src/pc/gfx/gfx_pc.c index 24cbb91c..a78f2ffd 100644 --- a/src/pc/gfx/gfx_pc.c +++ b/src/pc/gfx/gfx_pc.c @@ -778,16 +778,10 @@ static void gfx_sp_vertex(size_t n_vertices, size_t dest_index, const Vtx *verti calculate_normal_dir(&lookat_y, rsp.current_lookat_coeffs[1]); rsp.lights_changed = false; } - - // Inspired by: - // https://github.com/gonetz/GLideN64/commit/c8cbafff71a81bee5112aaafe6e21d6648ff8125#diff-69d8715ec7f9fd627ec4f5516edd003dL484 - const bool useFirstColor = (dest_index & 1) == 0; - const unsigned char* col = useFirstColor - ? rsp.current_lights[rsp.current_num_lights - 1].col - : rsp.current_lights[rsp.current_num_lights - 1].colc; - int r = col[0]; - int g = col[1]; - int b = col[2]; + + int r = rsp.current_lights[rsp.current_num_lights - 1].col[0]; + int g = rsp.current_lights[rsp.current_num_lights - 1].col[1]; + int b = rsp.current_lights[rsp.current_num_lights - 1].col[2]; for (int i = 0; i < rsp.current_num_lights - 1; i++) { float intensity = 0; @@ -796,14 +790,9 @@ static void gfx_sp_vertex(size_t n_vertices, size_t dest_index, const Vtx *verti intensity += vn->n[2] * rsp.current_lights_coeffs[i][2]; intensity /= 127.0f; if (intensity > 0.0f) { - // Inspired by: - // https://github.com/gonetz/GLideN64/commit/c8cbafff71a81bee5112aaafe6e21d6648ff8125#diff-69d8715ec7f9fd627ec4f5516edd003dL492 - col = useFirstColor - ? rsp.current_lights[i].col - : rsp.current_lights[i].colc; - r += intensity * col[0]; - g += intensity * col[1]; - b += intensity * col[2]; + r += intensity * rsp.current_lights[i].col[0]; + g += intensity * rsp.current_lights[i].col[1]; + b += intensity * rsp.current_lights[i].col[2]; } } @@ -1777,6 +1766,10 @@ void gfx_precache_textures(void) { } #endif +struct GfxRenderingAPI *gfx_get_current_rendering_api(void) { + return gfx_rapi; +} + void gfx_start_frame(void) { gfx_wapi->handle_events(); gfx_wapi->get_dimensions(&gfx_current_dimensions.width, &gfx_current_dimensions.height); @@ -1804,11 +1797,13 @@ void gfx_run(Gfx *commands) { gfx_flush(); double t1 = gfx_wapi->get_time(); //printf("Process %f %f\n", t1, t1 - t0); + gfx_rapi->end_frame(); gfx_wapi->swap_buffers_begin(); } void gfx_end_frame(void) { if (!dropped_frame) { + gfx_rapi->finish_render(); gfx_wapi->swap_buffers_end(); } } diff --git a/src/pc/gfx/gfx_pc.h b/src/pc/gfx/gfx_pc.h index 0d1780b3..716221a4 100644 --- a/src/pc/gfx/gfx_pc.h +++ b/src/pc/gfx/gfx_pc.h @@ -11,11 +11,20 @@ struct GfxDimensions { extern struct GfxDimensions gfx_current_dimensions; +#ifdef __cplusplus +extern "C" { +#endif + void gfx_init(struct GfxWindowManagerAPI *wapi, struct GfxRenderingAPI *rapi, const char *window_title); +struct GfxRenderingAPI *gfx_get_current_rendering_api(void); void gfx_start_frame(void); void gfx_run(Gfx *commands); void gfx_end_frame(void); void gfx_precache_textures(void); void gfx_shutdown(void); +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/pc/gfx/gfx_rendering_api.h b/src/pc/gfx/gfx_rendering_api.h index 75aedef9..e76efe74 100644 --- a/src/pc/gfx/gfx_rendering_api.h +++ b/src/pc/gfx/gfx_rendering_api.h @@ -16,7 +16,7 @@ struct GfxRenderingAPI { void (*shader_get_info)(struct ShaderProgram *prg, uint8_t *num_inputs, bool used_textures[2]); uint32_t (*new_texture)(void); void (*select_texture)(int tile, uint32_t texture_id); - void (*upload_texture)(uint8_t *rgba32_buf, int width, int height); + void (*upload_texture)(const uint8_t *rgba32_buf, int width, int height); void (*set_sampler_parameters)(int sampler, bool linear_filter, uint32_t cms, uint32_t cmt); void (*set_depth_test)(bool depth_test); void (*set_depth_mask)(bool z_upd); @@ -26,7 +26,10 @@ struct GfxRenderingAPI { void (*set_use_alpha)(bool use_alpha); void (*draw_triangles)(float buf_vbo[], size_t buf_vbo_len, size_t buf_vbo_num_tris); void (*init)(void); + void (*on_resize)(void); void (*start_frame)(void); + void (*end_frame)(void); + void (*finish_render)(void); void (*shutdown)(void); }; diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c index 2284f47f..ed6ee746 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -12,9 +12,12 @@ #include "audio/external.h" #include "gfx/gfx_pc.h" + #include "gfx/gfx_opengl.h" #include "gfx/gfx_direct3d11.h" #include "gfx/gfx_direct3d12.h" + +#include "gfx/gfx_dxgi.h" #include "gfx/gfx_sdl.h" #include "audio/audio_api.h" @@ -193,10 +196,10 @@ void main_func(void) { #endif #if defined(RAPI_D3D11) - rendering_api = &gfx_d3d11_api; + rendering_api = &gfx_direct3d11_api; # define RAPI_NAME "DirectX 11" #elif defined(RAPI_D3D12) - rendering_api = &gfx_d3d12_api; + rendering_api = &gfx_direct3d12_api; # define RAPI_NAME "DirectX 12" #elif defined(RAPI_GL) || defined(RAPI_GL_LEGACY) rendering_api = &gfx_opengl_api; diff --git a/src/pc/pc_main.h b/src/pc/pc_main.h index 00ab34be..79bff549 100644 --- a/src/pc/pc_main.h +++ b/src/pc/pc_main.h @@ -1,7 +1,15 @@ #ifndef _PC_MAIN_H #define _PC_MAIN_H +#ifdef __cplusplus +extern "C" { +#endif + void game_deinit(void); void game_exit(void); +#ifdef __cplusplus +} +#endif + #endif // _PC_MAIN_H