diff --git a/dlls/AcpHal/AcpHal.cpp b/dlls/AcpHal/AcpHal.cpp index 35c9501..3f471bb 100644 --- a/dlls/AcpHal/AcpHal.cpp +++ b/dlls/AcpHal/AcpHal.cpp @@ -16,8 +16,19 @@ HRESULT AcpHalReleaseShapeContexts_X() { return 0; } -HRESULT ApuAlloc_X(void* ptr, void* a2, size_t size, UINT32 alignment) { - ptr = malloc(size); +HRESULT ApuAlloc_X( + void** virtualAddress, + UINT32* physicalAddress, + UINT32 sizeInBytes, + UINT32 alignmentInBytes, + UINT32 flags +) +{ + *virtualAddress = malloc(sizeInBytes); + + if (physicalAddress != nullptr) + *physicalAddress = 0; + return 0; } diff --git a/dlls/AcpHal/AcpHal.h b/dlls/AcpHal/AcpHal.h index 10ade2f..32c5b8a 100644 --- a/dlls/AcpHal/AcpHal.h +++ b/dlls/AcpHal/AcpHal.h @@ -1,10 +1,62 @@ #pragma once #include -struct ApuHeapState { -/* 0x0000 */ public: uint32_t bytesFree; -/* 0x0004 */ public: uint32_t bytesAllocated; -/* 0x0008 */ public: uint32_t bytesLost; -/* 0x000c */ public: uint32_t maximumBlockSizeAvailable; -/* 0x0010 */ public: uint32_t allocationCount; +#include "messages.h" + +struct ApuHeapState +{ + UINT32 bytesFree; // Size of all unallocated regions + UINT32 bytesAllocated; // Size of all allocated regions as visible to the title + UINT32 bytesLost; // Size of all memory lost to alignment requests and fragmented blocks too small to allocate + UINT32 maximumBlockSizeAvailable; // Largest block available (actual space available can be less due to alignment requirements) + UINT32 allocationCount; // Count all allocated blocks +}; + +enum ACP_COMMAND_TYPE +{ + ACP_COMMAND_TYPE_LOAD_SHAPE_FLOWGRAPH = 1, // Load a new flow graph and process it (data: ACP_COMMAND_LOAD_SHAPE_FLOWGRAPH) + ACP_COMMAND_TYPE_REGISTER_MESSAGE, // Registers for one or more messages (data: ACP_COMMAND_MESSAGE) + ACP_COMMAND_TYPE_UNREGISTER_MESSAGE, // Unregisters one or more messages (data: ACP_COMMAND_MESSAGE) + ACP_COMMAND_TYPE_START_FLOWGRAPH, // Start processing the flowgraph (data: none) + ACP_COMMAND_TYPE_ENABLE_XMA_CONTEXT, // Enables an XMA context (data: ACP_COMMAND_ENABLE_OR_DISABLE_XMA_CONTEXT) + ACP_COMMAND_TYPE_ENABLE_XMA_CONTEXTS, // Enables a block XMA of contexts (data: ACP_COMMAND_ENABLE_OR_DISABLE_XMA_CONTEXTS) + ACP_COMMAND_TYPE_DISABLE_XMA_CONTEXT, // Disables an XMA context (data: ACP_COMMAND_ENABLE_OR_DISABLE_XMA_CONTEXT) + ACP_COMMAND_TYPE_DISABLE_XMA_CONTEXTS, // Disables a block of XMA contexts (data: ACP_COMMAND_ENABLE_OR_DISABLE_XMA_CONTEXTS) + ACP_COMMAND_TYPE_UPDATE_SRC_CONTEXT, // Updates a SRC context (data: ACP_COMMAND_UPDATE_XMA_CONTEXT) + ACP_COMMAND_TYPE_UPDATE_EQCOMP_CONTEXT, // Updates an EQ/Comp context (data: ACP_COMMAND_UPDATE_EQCOMP_CONTEXT) + ACP_COMMAND_TYPE_UPDATE_FILTVOL_CONTEXT, // Updates a Filt/Vol context (data: ACP_COMMAND_UPDATE_FILTVOL_CONTEXT) + ACP_COMMAND_TYPE_UPDATE_DMA_CONTEXT, // Updates a DMA context (data: ACP_COMMAND_UPDATE_DMA_CONTEXT) + ACP_COMMAND_TYPE_UPDATE_PCM_CONTEXT, // Updates a PCM context (data: ACP_COMMAND_UPDATE_PCM_CONTEXT) + ACP_COMMAND_TYPE_UPDATE_XMA_CONTEXT, // Updates a XMA context (data: ACP_COMMAND_UPDATE_XMA_CONTEXT) + ACP_COMMAND_TYPE_INCREMENT_DMA_WRITE_POINTER, // Update a DMA write pointer (data: ACP_COMMAND_INCREMENT_DMA_POINTER) + ACP_COMMAND_TYPE_INCREMENT_DMA_READ_POINTER, // Updates a DMA read pointer (data: ACP_COMMAND_INCREMENT_PCM_WRITE_POINTER) + ACP_COMMAND_TYPE_INCREMENT_PCM_WRITE_POINTER, // Updates a PCM context write pointer (data: ACP_COMMAND_INCREMENT_XMA_WRITE_BUFFER_OFFSET_READ) + ACP_COMMAND_TYPE_INCREMENT_XMA_WRITE_BUFFER_OFFSET_READ, // Updates the read offset in an XMA context write buffer (data: ACP_COMMAND_INCREMENT_XMA_WRITE_BUFFER_OFFSET_READ) + ACP_COMMAND_TYPE_UPDATE_XMA_READ_BUFFER, // Updates a PCM context write pointer (data: ACP_COMMAND_UPDATE_XMA_READ_BUFFER) + ACP_COMMAND_TYPE_UPDATE_ALL_CONTEXTS, // Updates blocks of contexts (data: ACP_COMMAND_UPDATE_ALL_CONTEXTS) + ACP_COMMAND_TYPE_UPDATE_SRC_CONTEXTS, // Updates a block of SRC contexts (data: ACP_COMMAND_UPDATE_CONTEXTS) + ACP_COMMAND_TYPE_UPDATE_EQCOMP_CONTEXTS, // Updates a block of EQ/Comp contexts (data: ACP_COMMAND_UPDATE_CONTEXTS) + ACP_COMMAND_TYPE_UPDATE_FILTVOL_CONTEXTS, // Updates a block of Filt/Vol contexts (data: ACP_COMMAND_UPDATE_CONTEXTS) + ACP_COMMAND_TYPE_UPDATE_DMA_READ_CONTEXTS, // Updates a block of DMA read contexts (data: ACP_COMMAND_UPDATE_CONTEXTS) + ACP_COMMAND_TYPE_UPDATE_DMA_WRITE_CONTEXTS, // Updates a block of DMA write contexts (data: ACP_COMMAND_UPDATE_CONTEXTS) + ACP_COMMAND_TYPE_UPDATE_PCM_CONTEXTS, // Updates a block of PCM contexts (data: ACP_COMMAND_UPDATE_CONTEXTS) + ACP_COMMAND_TYPE_UPDATE_XMA_CONTEXTS, // Updates a block of XMA contexts (data: ACP_COMMAND_UPDATE_CONTEXTS) + + ACP_COMMAND_TYPE_COUNT = ACP_COMMAND_TYPE_UPDATE_XMA_CONTEXTS // Count of command types (not an actual command) +}; + +struct ACP_MESSAGE +{ + UINT32 type; // Message type + UINT32 droppedMessageCount; // Count of dropped messages prior to this message + UINT32 usec; // time when this message is constructed + union // Message data + { + ACP_MESSAGE_AUDIO_FRAME_START audioFrameStart; + ACP_MESSAGE_FLOWGRAPH_COMPLETED flowgraphCompleted; + ACP_MESSAGE_SHAPE_COMMAND_BLOCKED shapeCommandBlocked; + ACP_MESSAGE_COMMAND_COMPLETED commandCompleted; + ACP_MESSAGE_FLOWGRAPH_TERMINATED flowgraphTerminated; + ACP_MESSAGE_ERROR error; + }; }; \ No newline at end of file diff --git a/dlls/AcpHal/AcpHal.vcxproj b/dlls/AcpHal/AcpHal.vcxproj index b8592b3..505ced0 100644 --- a/dlls/AcpHal/AcpHal.vcxproj +++ b/dlls/AcpHal/AcpHal.vcxproj @@ -116,6 +116,7 @@ Use pch.h stdcpp17 + true Windows @@ -134,6 +135,7 @@ true Use pch.h + true Windows @@ -146,7 +148,9 @@ + + diff --git a/dlls/AcpHal/AcpHal.vcxproj.filters b/dlls/AcpHal/AcpHal.vcxproj.filters index 618a4c3..07c7d73 100644 --- a/dlls/AcpHal/AcpHal.vcxproj.filters +++ b/dlls/AcpHal/AcpHal.vcxproj.filters @@ -24,6 +24,12 @@ Source Files + + Header Files + + + Header Files + diff --git a/dlls/AcpHal/contexts.h b/dlls/AcpHal/contexts.h new file mode 100644 index 0000000..7981948 --- /dev/null +++ b/dlls/AcpHal/contexts.h @@ -0,0 +1,209 @@ +#pragma once + +struct SHAPE_EQCOMP_CONTEXT { + UINT32 timestamp : 21; + UINT32 reserved0 : 2; + UINT32 internalSaturate : 1; + UINT32 mixBufPeakMag : 4; + UINT32 peakMag : 4; + UINT32 eqAB0 : 24; + UINT32 eqAB1_L : 8; + UINT32 eqAB1_H : 16; + UINT32 eqAB2_L : 16; + UINT32 eqAB2_H : 8; + UINT32 eqAA1 : 24; + UINT32 eqAA2 : 24; + UINT32 eqBB0_L : 8; + UINT32 eqBB0_H : 16; + UINT32 eqBB1_L : 16; + UINT32 eqBB1_H : 8; + UINT32 eqBB2 : 24; + UINT32 eqBA1 : 24; + UINT32 eqBA2_L : 8; + UINT32 eqBA2_H : 16; + UINT32 eqCB0_L : 16; + UINT32 eqCB0_H : 8; + UINT32 eqCB1 : 24; + UINT32 eqCB2 : 24; + UINT32 eqCA1_L : 8; + UINT32 eqCA1_H : 16; + UINT32 eqCA2_L : 16; + UINT32 eqCA2_H : 8; + UINT32 reserved1 : 24; + UINT32 eqAInputDelay0 : 24; + UINT32 reserved2 : 8; + UINT32 eqAInputDelay1 : 24; + UINT32 reserved3 : 8; + UINT32 eqDelayElements2 : 32; + UINT32 eqDelayElements3 : 32; + UINT32 eqDelayElements4 : 32; + UINT32 eqDelayElements5 : 32; + UINT32 eqDelayElements6 : 32; + UINT32 eqDelayElements7 : 32; + UINT32 compInputLevel : 32; + UINT32 compGainReduction : 24; + UINT32 reserved4 : 8; + UINT32 compGain : 16; + UINT32 reserved5 : 16; + UINT32 eqAB0Target : 24; + UINT32 eqAB1Target_L : 8; + UINT32 eqAB1Target_H : 16; + UINT32 eqAB2Target_L : 16; + UINT32 eqAB2Target_H : 8; + UINT32 eqAA1Target : 24; + UINT32 eqAA2Target : 24; + UINT32 eqBB0Target_L : 8; + UINT32 eqBB0Target_H : 16; + UINT32 eqBB1Target_L : 16; + UINT32 eqBB1Target_H : 8; + UINT32 eqBB2Target : 24; + UINT32 eqBA1Target : 24; + UINT32 eqBA2Target_L : 8; + UINT32 eqBA2Target_H : 16; + UINT32 eqCB0Target_L : 16; + UINT32 eqCB0Target_H : 8; + UINT32 eqCB1Target : 24; + UINT32 eqCB2Target : 24; + UINT32 eqCA1Target_L : 8; + UINT32 eqCA1Target_H : 16; + UINT32 eqCA2Target_L : 16; + UINT32 eqCA2Target_H : 8; + UINT32 reserved6 : 24; + UINT32 compRelease : 24; + UINT32 reserved7 : 2; + UINT32 compExpand : 1; + UINT32 compLogGain : 1; + UINT32 compSidechainMode : 2; + UINT32 compMode : 1; + UINT32 compEnable : 1; + UINT32 compThreshold : 24; + UINT32 reserved8 : 8; + UINT32 compAttack : 24; + UINT32 reserved9 : 8; + UINT32 compOneOverRatio : 16; + UINT32 compGainTarget : 16; +}; + +struct SHAPE_SRC_CONTEXT { + UINT32 timestamp : 21; + UINT32 blocksToSkip : 2; + UINT32 internalSaturate : 1; + UINT32 mixBufPeakMag : 4; + UINT32 peakMag : 4; + UINT32 samplingIncrement : 21; + UINT32 reserved0 : 1; + UINT32 cmd : 2; + UINT32 mixBufPeakMag2 : 4; + UINT32 peakMag2 : 4; + UINT32 sampleCount : 32; + UINT32 samplePointer : 25; + UINT32 reserved1 : 7; + UINT32 samplingIncrementTarget : 21; + UINT32 reserved2 : 11; + UINT32 reserved3[ 3 ]; +}; + +struct SHAPE_FILTVOL_CONTEXT { + UINT32 timestamp : 21; + UINT32 reserved0 : 2; + UINT32 internalSaturate : 1; + UINT32 mixBufPeakMag : 4; + UINT32 peakMag : 4; + UINT32 delay1 : 30; + UINT32 headroom : 2; + UINT32 delay2 : 30; + UINT32 svfMode : 2; + UINT32 gainTarget : 16; + UINT32 gain : 16; + UINT32 qRecip : 24; + UINT32 reserved1 : 8; + UINT32 qRecipTarget : 24; + UINT32 reserved2 : 8; + UINT32 fc : 24; + UINT32 reserved3 : 8; + UINT32 fcTarget : 24; + UINT32 reserved4 : 8; +}; + +struct SHAPE_DMA_CONTEXT { + UINT32 timestamp : 21; + UINT32 reserved0 : 3; + UINT32 mixBufPeakMag : 4; + UINT32 peakMag : 4; + UINT32 readPointer : 5; + UINT32 reserved1 : 3; + UINT32 writePointer : 5; + UINT32 reserved2 : 3; + UINT32 full : 1; + UINT32 reserved3 : 15; + UINT32 reserved4 : 9; + UINT32 address : 23; + UINT32 numFrames : 5; + UINT32 reserved5 : 3; + UINT32 floatConvert : 1; + UINT32 reserved6 : 7; + UINT32 numChannels : 3; + UINT32 reserved7 : 5; + UINT32 channel : 3; + UINT32 reserved8 : 5; +}; + +struct SHAPE_XMA_CONTEXT { + UINT32 sizeRead0 : 12; + UINT32 numLoops : 8; + UINT32 validBuffer : 2; + UINT32 sizeWrite : 5; + UINT32 offsetWrite : 5; + UINT32 sizeRead1 : 12; + UINT32 loopSubframeEnd : 2; + UINT32 reserved1 : 3; + UINT32 loopSubframeSkip : 3; + UINT32 numSubframeToDecode : 4; + UINT32 numSubframesToSkip : 3; + UINT32 sampleRate : 2; + UINT32 numChannels : 1; + UINT32 reserved2 : 1; + UINT32 validWrite : 1; + UINT32 offsetRead : 26; + UINT32 errorStatus : 5; + UINT32 errorSet : 1; + UINT32 loopStartOffset : 26; + UINT32 parserErrorStatus : 5; + UINT32 parserErrorSet : 1; + UINT32 loopEndOffset : 26; + UINT32 packetMetaData : 5; + UINT32 currentBuffer : 1; + UINT32 ptrRead0; + UINT32 ptrRead1; + UINT32 ptrWrite; + UINT32 ptrOverlapAdd; + UINT32 writeBufferOffsetRead : 5; + UINT32 reserved3 : 25; + UINT32 stopWhenDone : 1; + UINT32 interruptWhenDone : 1; + UINT32 reserved4[ 2 ]; + UINT32 reserved5[ 1 ]; +}; + +struct SHAPE_PCM_CONTEXT { + UINT32 bufferStart : 32; + UINT32 bufferLength : 21; + UINT32 reserved0 : 11; + UINT32 loopCount : 8; + UINT32 reserved1 : 8; + UINT32 full : 1; + UINT32 reserved2 : 15; + UINT32 readPointer : 21; + UINT32 reserved3 : 11; + UINT32 loopStartWritePointer : 21; + UINT32 reserved4 : 11; + UINT32 loopEnd : 21; + UINT32 reserved5 : 11; + UINT32 mode : 1; + UINT32 reserved6 : 15; + UINT32 format : 2; + UINT32 reserved7 : 14; + UINT32 reserved8; +}; + + diff --git a/dlls/AcpHal/messages.h b/dlls/AcpHal/messages.h new file mode 100644 index 0000000..1d1e002 --- /dev/null +++ b/dlls/AcpHal/messages.h @@ -0,0 +1,82 @@ +#pragma once +typedef UINT32 APU_ADDRESS; + +struct ACP_MESSAGE_AUDIO_FRAME_START +{ + UINT32 audioFrame; // Audio frame index +}; + +// Flowgraph completed message +// Used by the following messages: +// ACP_MESSAGE_TYPE_FLOWGRAPH_COMPLETED +struct ACP_MESSAGE_FLOWGRAPH_COMPLETED +{ + APU_ADDRESS flowgraph; // Flowgraph that completed +}; + +// SHAPE command is blocked +// Used by the following messages: +// ACP_MESSAGE_TYPE_SRC_BLOCKED +// ACP_MESSAGE_TYPE_DMA_BLOCKED +struct ACP_MESSAGE_SHAPE_COMMAND_BLOCKED +{ + UINT32 contextIndex; // Index of context that was blocked + APU_ADDRESS flowgraph; // Flowgraph with blocked context +}; + +// An ACP command has completed +// +// Command completed messages will only be sent for commands submitted with a non-zero commandId. +// (see IAcpHal::SubmitCommand) +// Used by the following messages: +// ACP_MESSAGE_TYPE_COMMAND_COMPLETED +struct ACP_MESSAGE_COMMAND_COMPLETED +{ + UINT32 commandType; // Command type that completed + UINT64 commandId; // Command ID of completed command + UINT32 audioFrame; // Audio frame when command completed +}; + +// Flowgraph was terminated +// Used by the following messages: +// ACP_MESSAGE_TYPE_FLOWGRAPH_TERMINATED +struct ACP_MESSAGE_FLOWGRAPH_TERMINATED +{ + APU_ADDRESS flowgraph; // Flowgraph + UINT32 numCommandsCompleted; // Number of flowgraph commands completed or queued before time ran out + UINT32 reason; // Reason the flowgraph was terminated +}; + +// Error message +// Used by the following messages: +// ACP_MESSAGE_TYPE_ERROR +// +// errorCode additionalData +// ----------------------------------- ------------------------------------------ +// ACP_E_INVALID_FLOWGRAPH Flowgraph APU_ADDRESS +// The specified flowgraph is invalid. Examine the flowgraph entry headers. +// Invalid entries will have the error bit set. +// +// ACP_E_INVALID_COMMAND 'commandId' from IAcpHal::SubmitCommand() +// The command submitted is invalid. +// +// ACP_E_MESSAGE_ALREADY_REGISTERED ACP_MESSAGE_TYPE_* +// An attempt was made to register for a message type that has already been registered. +// +// ACP_E_MESSAGE_NOT_REGISTERED ACP_MESSAGE_TYPE_* +// An attempt was made to unregister a message type that has not been registered. +// +// ACP_E_INVALID_COMMAND_TYPE ACP_COMMAND_TYPE_* +// A submitted command is not of a valid type. +// +// ACP_E_NOT_ALLOCATED 'commandId' from IAcpHal::SubmitCommand() +// A request was made to update a SHAPE flowgraph context that has not been allocated. +// +// ACP_E_XMA_PARSER_ERROR XMA context index +// The specified XMA context generated a parser error. +// +struct ACP_MESSAGE_ERROR +{ + HRESULT errorCode; // Error code + UINT32 additionalData; // Additional data relevant to the error +}; \ No newline at end of file diff --git a/dlls/MMDevAPI/Exports.def b/dlls/MMDevAPI/Exports.def index aee671e..6513d47 100644 --- a/dlls/MMDevAPI/Exports.def +++ b/dlls/MMDevAPI/Exports.def @@ -1,7 +1,7 @@ LIBRARY MMDevAPI EXPORTS - ActivateAudioInterfaceAsync = ActivateAudioInterfaceAsync_X - DllCanUnloadNow = DllCanUnloadNow_X - DllGetClassObject = DllGetClassObject_X - RefreshWasapiDeviceList = RefreshWasapiDeviceList_X - SetWasapiThreadAffinityMask = SetWasapiThreadAffinityMask_X + RestoreBitstreamOut = RestoreBitstreamOut_X + DisableBitstreamOut = DisableBitstreamOut_X + EnableSpatialAudio = EnableSpatialAudio_X + SetWasapiThreadAffinityMask = SetWasapiThreadAffinityMask_X + RefreshWasapiDeviceList = RefreshWasapiDeviceList_X diff --git a/dlls/MMDevAPI/MMDevAPI.cpp b/dlls/MMDevAPI/MMDevAPI.cpp index 05834f9..df85a88 100644 --- a/dlls/MMDevAPI/MMDevAPI.cpp +++ b/dlls/MMDevAPI/MMDevAPI.cpp @@ -1,42 +1,52 @@ #include "pch.h" #include "framework.h" -void ActivateAudioInterfaceAsync_X() -{ +#define MMDEVAPI_EXPORT(Name) __pragma(comment(linker, "/export:" #Name "=C:\\WINDOWS\\System32\\MMDevAPI." #Name)) +#define MMDEVAPI_EXPORT_ORDINAL(Name, Ordinal) __pragma(comment(linker, "/export:" #Name "=C:\\WINDOWS\\System32\\MMDevAPI." #Name ",@" #Ordinal)) +#define MMDEVAPI_EXPORT_ORDINAL_PRIVATE(Name, Ordinal) __pragma(comment(linker, "/export:" #Name "=C:\\WINDOWS\\System32\\MMDevAPI.#" #Ordinal ",@" #Ordinal ",NONAME")) -} +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(CleanupDeviceAPI, 2) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(InitializeDeviceAPI, 3) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(MMDeviceCreateRegistryPropertyStore, 4) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(MMDeviceGetDeviceEnumerator, 5) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(MMDeviceGetEndpointManager, 6) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(GetClassFromEndpointId, 7) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(GetEndpointGuidFromEndpointId, 8) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(GetSessionIdFromEndpointId, 9) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(RegisterForMediaCallback, 10) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(UnregisterMediaCallback, 11) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(GenerateMediaEvent, 12) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(AETraceOutputDebugString, 13) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(MMDeviceGetPolicyConfig, 14) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(FlushDeviceTopologyCache, 15) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(GetNeverSetAsDefaultProperty, 16) +MMDEVAPI_EXPORT_ORDINAL(ActivateAudioInterfaceAsync, 17) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(GetEndpointIdFromDeviceInterfaceId, 18) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(mmdDevFindMmDevProperty, 19) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(mmdDevGetInterfacePropertyStore, 20) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(mmdDevGetInterfaceIdFromMMDevice, 21) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(mmdDevGetInterfaceDataFlow, 22) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(mmdDevGetMMDeviceFromInterfaceId, 23) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(mmdDevGetInterfaceClassGuid, 24) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(mmdDevGetMMDeviceIdFromInterfaceId, 25) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(mmdDevGetInstanceIdFromInterfaceId, 26) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(mmdDevGetRelatedInterfaceId, 27) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(mmdDevGetInterfaceIdFromMMDeviceId, 28) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(mmdDevGetInstanceIdFromMMDeviceId, 29) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(mmdDevGetEndpointFormFactorFromMMDeviceId, 30) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(mmdDevGetDeviceIdFromPnpInterface, 31) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(GetCategoryPath, 32) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(MMDeviceCreateRegistryPropertyStore2, 33) +MMDEVAPI_EXPORT_ORDINAL_PRIVATE(MMDeviceCreateAudioSystemEffectsPropertyStore, 34) +MMDEVAPI_EXPORT_ORDINAL(DllCanUnloadNow, 35) +MMDEVAPI_EXPORT_ORDINAL(DllGetClassObject, 36) +MMDEVAPI_EXPORT_ORDINAL(DllRegisterServer, 37) +MMDEVAPI_EXPORT_ORDINAL(DllUnregisterServer, 38) -void DisableBitstreamOut_X() -{ -} +void DisableBitstreamOut_X( ) {} +HRESULT EnableSpatialAudio_X( ) { return S_OK; } +void RestoreBitstreamOut_X( ) {} +DWORD_PTR SetWasapiThreadAffinityMask_X(DWORD_PTR dwThreadAffinityMask) { return 0; } +void RefreshWasapiDeviceList_X() {} -void DllCanUnloadNow_X() -{ - -} - -void DllGetClassObject_X() -{ - -} - -void EnableSpatialAudio_X() -{ - -} - -void RefreshWasapiDeviceList_X() -{ - -} - -void RestoreBitstreamOut_X() -{ - -} - -void SetWasapiThreadAffinityMask_X() -{ - -} \ No newline at end of file diff --git a/dlls/MMDevAPI/MMDevAPI.vcxproj b/dlls/MMDevAPI/MMDevAPI.vcxproj index 04b1b9d..a7c5718 100644 --- a/dlls/MMDevAPI/MMDevAPI.vcxproj +++ b/dlls/MMDevAPI/MMDevAPI.vcxproj @@ -115,6 +115,7 @@ Use pch.h stdcpp17 + true Windows @@ -134,6 +135,7 @@ true Use pch.h + true Windows diff --git a/dlls/XAudio2_9/XAudio2_9.vcxproj b/dlls/XAudio2_9/XAudio2_9.vcxproj index f5b2979..8aa3594 100644 --- a/dlls/XAudio2_9/XAudio2_9.vcxproj +++ b/dlls/XAudio2_9/XAudio2_9.vcxproj @@ -116,6 +116,7 @@ Use pch.h stdcpp17 + true Windows @@ -135,6 +136,7 @@ true Use pch.h + true Windows diff --git a/dlls/XFrontPanelDisplay/XFrontPanelDisplay.vcxproj b/dlls/XFrontPanelDisplay/XFrontPanelDisplay.vcxproj index 1453fd1..85f20b1 100644 --- a/dlls/XFrontPanelDisplay/XFrontPanelDisplay.vcxproj +++ b/dlls/XFrontPanelDisplay/XFrontPanelDisplay.vcxproj @@ -115,6 +115,7 @@ Use pch.h stdcpp17 + true Windows @@ -133,6 +134,7 @@ true Use pch.h + true Windows diff --git a/dlls/XboxIntegratedMultiplayer/XboxIntegratedMultiplayer.vcxproj b/dlls/XboxIntegratedMultiplayer/XboxIntegratedMultiplayer.vcxproj index 301b88d..724e4a8 100644 --- a/dlls/XboxIntegratedMultiplayer/XboxIntegratedMultiplayer.vcxproj +++ b/dlls/XboxIntegratedMultiplayer/XboxIntegratedMultiplayer.vcxproj @@ -115,6 +115,7 @@ Use pch.h stdcpp17 + true Windows @@ -133,6 +134,7 @@ true Use pch.h + true Windows diff --git a/dlls/appmodel/appmodel.vcxproj b/dlls/appmodel/appmodel.vcxproj index 611bcfa..643fe05 100644 --- a/dlls/appmodel/appmodel.vcxproj +++ b/dlls/appmodel/appmodel.vcxproj @@ -58,6 +58,7 @@ Use pch.h stdcpp17 + true Windows @@ -75,6 +76,7 @@ true Use pch.h + true Windows diff --git a/dlls/common/common.vcxproj b/dlls/common/common.vcxproj index 46b5d8c..f9ee8ef 100644 --- a/dlls/common/common.vcxproj +++ b/dlls/common/common.vcxproj @@ -118,6 +118,7 @@ stdcpp20 + true Windows @@ -137,6 +138,7 @@ stdcpp20 + true Windows diff --git a/dlls/d3d11_x/ID3D11BufferWrapper.cpp b/dlls/d3d11_x/ID3D11BufferWrapper.cpp deleted file mode 100644 index dcb425e..0000000 --- a/dlls/d3d11_x/ID3D11BufferWrapper.cpp +++ /dev/null @@ -1,99 +0,0 @@ -#include "pch.h" -#include "ID3DWrappers.h" - -HRESULT d3d11x::ID3D11BufferWrapper::QueryInterface(REFIID riid, void** ppvObject) -{ - // DEBUG - char iidstr[ sizeof("{AAAAAAAA-BBBB-CCCC-DDEE-FFGGHHIIJJKK}") ]; - OLECHAR iidwstr[ sizeof(iidstr) ]; - StringFromGUID2(riid, iidwstr, ARRAYSIZE(iidwstr)); - WideCharToMultiByte(CP_UTF8, 0, iidwstr, -1, iidstr, sizeof(iidstr), nullptr, nullptr); - printf("[ID3D11BufferWrapper] QueryInterface: %s\n", iidstr); - - if (riid == __uuidof(::ID3D11Buffer)) - { - *ppvObject = this; - AddRef( ); - return S_OK; - } - - *ppvObject = nullptr; - return E_NOINTERFACE; -} - -ULONG d3d11x::ID3D11BufferWrapper::AddRef( ) -{ - printf("[ID3D11BufferWrapper] --> AddRef\n"); - return InterlockedIncrement(&m_RefCount); -} - -ULONG d3d11x::ID3D11BufferWrapper::Release( ) -{ - //printf("[ID3D11BufferWrapper] --> Release\n"); - ULONG refCount = InterlockedDecrement(&m_RefCount); - - if (refCount == 0) - { - //printf("[ID3D11BufferWrapper] releasing real buffer at 0x%llX\n", m_realBuffer); - m_realBuffer->Release( ); - delete this; - } - - return refCount; -} - - -void __stdcall d3d11x::ID3D11BufferWrapper::GetDevice(ID3D11Device** ppDevice) -{ - // Probably not necessary but just to be sure -AleBlbl - ::ID3D11Device** device = nullptr; - this->m_realBuffer->GetDevice(device); - ppDevice = reinterpret_cast(ppDevice); -} - -HRESULT __stdcall d3d11x::ID3D11BufferWrapper::GetPrivateData(REFGUID guid, UINT* pDataSize, void* pData) -{ - return m_realBuffer->GetPrivateData(guid, pDataSize, pData); -} - -HRESULT __stdcall d3d11x::ID3D11BufferWrapper::SetPrivateData(REFGUID guid, UINT DataSize, const void* pData) -{ - return m_realBuffer->SetPrivateData(guid, DataSize, pData); -} - -HRESULT __stdcall d3d11x::ID3D11BufferWrapper::SetPrivateDataInterface(REFGUID guid, const IUnknown* pData) -{ - return m_realBuffer->SetPrivateDataInterface(guid, pData); -} - -HRESULT __stdcall d3d11x::ID3D11BufferWrapper::SetName(const wchar_t* name) -{ - printf("[ID3D11RenderTargetViewWrapper]: SetName STUB\n"); - return S_OK; -} - -void __stdcall d3d11x::ID3D11BufferWrapper::GetType(D3D11_RESOURCE_DIMENSION* pResourceDimension) -{ - return m_realBuffer->GetType(pResourceDimension); -} - -void __stdcall d3d11x::ID3D11BufferWrapper::SetEvictionPriority(UINT EvictionPriority) -{ - return m_realBuffer->SetEvictionPriority(EvictionPriority); -} - -UINT __stdcall d3d11x::ID3D11BufferWrapper::GetEvictionPriority(void) -{ - return m_realBuffer->GetEvictionPriority( ); -} - -void __stdcall d3d11x::ID3D11BufferWrapper::GetDescriptor(D3D11X_DESCRIPTOR_RESOURCE* descriptor) -{ - printf("[ID3D11Texture2DWrapper]: GetDescriptor STUB\n"); -} - -void __stdcall d3d11x::ID3D11BufferWrapper::GetDesc(D3D11_BUFFER_DESC* pDesc) -{ - return m_realBuffer->GetDesc(pDesc); -} - diff --git a/dlls/d3d11_x/ID3D11TextureWrapper.cpp b/dlls/d3d11_x/ID3D11TextureWrapper.cpp deleted file mode 100644 index a7b9b48..0000000 --- a/dlls/d3d11_x/ID3D11TextureWrapper.cpp +++ /dev/null @@ -1,277 +0,0 @@ -#include "pch.h" -#include "ID3DWrappers.h" - -namespace d3d11x -{ - - HRESULT ID3D11Texture1DWrapper::QueryInterface(REFIID riid, void** ppvObject) - { - // DEBUG - char iidstr[ sizeof("{AAAAAAAA-BBBB-CCCC-DDEE-FFGGHHIIJJKK}") ]; - OLECHAR iidwstr[ sizeof(iidstr) ]; - StringFromGUID2(riid, iidwstr, ARRAYSIZE(iidwstr)); - WideCharToMultiByte(CP_UTF8, 0, iidwstr, -1, iidstr, sizeof(iidstr), nullptr, nullptr); - printf("[ID3D11Texture1DWrapper] QueryInterface: %s\n", iidstr); - - if (riid == __uuidof(::ID3D11Texture1D)) - { - *ppvObject = this; - AddRef( ); - return S_OK; - } - - *ppvObject = nullptr; - return E_NOINTERFACE; - } - - ULONG ID3D11Texture1DWrapper::AddRef( ) - { - printf("[ID3D11Texture1DWrapper] --> AddRef\n"); - return InterlockedIncrement(&m_RefCount); - } - - ULONG ID3D11Texture1DWrapper::Release( ) - { - printf("[ID3D11Texture1DWrapper] --> Release\n"); - ULONG refCount = InterlockedDecrement(&m_RefCount); - if (refCount == 0) - delete this; - return refCount; - } - - // @Patoke todo: unwrap? - void __stdcall ID3D11Texture1DWrapper::GetDevice(ID3D11Device** ppDevice) - { - // Probably not necessary but just to be sure -AleBlbl - ::ID3D11Device** device = nullptr; - this->m_realTexture->GetDevice(device); - ppDevice = reinterpret_cast(ppDevice); - } - - HRESULT __stdcall ID3D11Texture1DWrapper::GetPrivateData(REFGUID guid, UINT* pDataSize, void* pData) - { - return m_realTexture->GetPrivateData(guid, pDataSize, pData); - } - - HRESULT __stdcall ID3D11Texture1DWrapper::SetPrivateData(REFGUID guid, UINT DataSize, const void* pData) - { - return m_realTexture->SetPrivateData(guid, DataSize, pData); - } - - HRESULT __stdcall ID3D11Texture1DWrapper::SetPrivateDataInterface(REFGUID guid, const IUnknown* pData) - { - return m_realTexture->SetPrivateDataInterface(guid, pData); - } - - HRESULT __stdcall ID3D11Texture1DWrapper::SetName(const wchar_t* name) - { - printf("[ID3D11Texture1DWrapper]: SetName STUB\n"); - return S_OK; - } - - void __stdcall ID3D11Texture1DWrapper::GetType(D3D11_RESOURCE_DIMENSION* pResourceDimension) - { - return m_realTexture->GetType(pResourceDimension); - } - - void __stdcall ID3D11Texture1DWrapper::SetEvictionPriority(UINT EvictionPriority) - { - return m_realTexture->SetEvictionPriority(EvictionPriority); - } - - UINT __stdcall ID3D11Texture1DWrapper::GetEvictionPriority(void) - { - return m_realTexture->GetEvictionPriority( ); - } - - void __stdcall ID3D11Texture1DWrapper::GetDescriptor(D3D11X_DESCRIPTOR_RESOURCE* descriptor) - { - printf("[ID3D11Texture1DWrapper]: GetDescriptor STUB\n"); - } - - void __stdcall ID3D11Texture1DWrapper::GetDesc(D3D11_TEXTURE1D_DESC* pDesc) - { - return m_realTexture->GetDesc(pDesc); - } - - HRESULT ID3D11Texture2DWrapper::QueryInterface(REFIID riid, void** ppvObject) - { - // DEBUG - char iidstr[ sizeof("{AAAAAAAA-BBBB-CCCC-DDEE-FFGGHHIIJJKK}") ]; - OLECHAR iidwstr[ sizeof(iidstr) ]; - StringFromGUID2(riid, iidwstr, ARRAYSIZE(iidwstr)); - WideCharToMultiByte(CP_UTF8, 0, iidwstr, -1, iidstr, sizeof(iidstr), nullptr, nullptr); - printf("[ID3D11Texture2DWrapper] QueryInterface: %s\n", iidstr); - - if (riid == __uuidof(::ID3D11Texture2D)) - { - *ppvObject = this; - AddRef( ); - return S_OK; - } - - *ppvObject = nullptr; - return E_NOINTERFACE; - } - - ULONG ID3D11Texture2DWrapper::AddRef( ) - { - printf("[ID3D11Texture2DWrapper] --> AddRef\n"); - return InterlockedIncrement(&m_RefCount); - } - - ULONG ID3D11Texture2DWrapper::Release( ) - { - printf("[ID3D11Texture2DWrapper] --> Release\n"); - ULONG refCount = InterlockedDecrement(&m_RefCount); - if (refCount == 0) - delete this; - return refCount; - } - - // @Patoke todo: unwrap? - void __stdcall ID3D11Texture2DWrapper::GetDevice(ID3D11Device** ppDevice) - { - // Probably not necessary but just to be sure -AleBlbl - ::ID3D11Device** device = nullptr; - this->m_realTexture->GetDevice(device); - ppDevice = reinterpret_cast(ppDevice); - } - - HRESULT __stdcall ID3D11Texture2DWrapper::GetPrivateData(REFGUID guid, UINT* pDataSize, void* pData) - { - return m_realTexture->GetPrivateData(guid, pDataSize, pData); - } - - HRESULT __stdcall ID3D11Texture2DWrapper::SetPrivateData(REFGUID guid, UINT DataSize, const void* pData) - { - return m_realTexture->SetPrivateData(guid, DataSize, pData); - } - - HRESULT __stdcall ID3D11Texture2DWrapper::SetPrivateDataInterface(REFGUID guid, const IUnknown* pData) - { - return m_realTexture->SetPrivateDataInterface(guid, pData); - } - - HRESULT __stdcall ID3D11Texture2DWrapper::SetName(const wchar_t* name) - { - printf("[ID3D11Texture2DWrapper]: SetName STUB\n"); - return S_OK; - } - - void __stdcall ID3D11Texture2DWrapper::GetType(D3D11_RESOURCE_DIMENSION* pResourceDimension) - { - return m_realTexture->GetType(pResourceDimension); - } - - void __stdcall ID3D11Texture2DWrapper::SetEvictionPriority(UINT EvictionPriority) - { - return m_realTexture->SetEvictionPriority(EvictionPriority); - } - - UINT __stdcall ID3D11Texture2DWrapper::GetEvictionPriority(void) - { - return m_realTexture->GetEvictionPriority(); - } - - void __stdcall ID3D11Texture2DWrapper::GetDescriptor(D3D11X_DESCRIPTOR_RESOURCE* descriptor) - { - printf("[ID3D11Texture2DWrapper]: GetDescriptor STUB\n"); - } - - void __stdcall ID3D11Texture2DWrapper::GetDesc(D3D11_TEXTURE2D_DESC* pDesc) - { - return m_realTexture->GetDesc(pDesc); - } - - HRESULT ID3D11Texture3DWrapper::QueryInterface(REFIID riid, void** ppvObject) - { - // DEBUG - char iidstr[ sizeof("{AAAAAAAA-BBBB-CCCC-DDEE-FFGGHHIIJJKK}") ]; - OLECHAR iidwstr[ sizeof(iidstr) ]; - StringFromGUID2(riid, iidwstr, ARRAYSIZE(iidwstr)); - WideCharToMultiByte(CP_UTF8, 0, iidwstr, -1, iidstr, sizeof(iidstr), nullptr, nullptr); - printf("[ID3D11Texture3DWrapper] QueryInterface: %s\n", iidstr); - - if (riid == __uuidof(::ID3D11Texture3D)) - { - *ppvObject = this; - AddRef( ); - return S_OK; - } - - *ppvObject = nullptr; - return E_NOINTERFACE; - } - - ULONG ID3D11Texture3DWrapper::AddRef( ) - { - printf("[ID3D11Texture3DWrapper] --> AddRef\n"); - return InterlockedIncrement(&m_RefCount); - } - - ULONG ID3D11Texture3DWrapper::Release( ) - { - printf("[ID3D11Texture3DWrapper] --> Release\n"); - ULONG refCount = InterlockedDecrement(&m_RefCount); - if (refCount == 0) - delete this; - return refCount; - } - - // @Patoke todo: unwrap? - void __stdcall ID3D11Texture3DWrapper::GetDevice(ID3D11Device** ppDevice) - { - // Probably not necessary but just to be sure -AleBlbl - ::ID3D11Device** device = nullptr; - this->m_realTexture->GetDevice(device); - ppDevice = reinterpret_cast(ppDevice); - } - - HRESULT __stdcall ID3D11Texture3DWrapper::GetPrivateData(REFGUID guid, UINT* pDataSize, void* pData) - { - return m_realTexture->GetPrivateData(guid, pDataSize, pData); - } - - HRESULT __stdcall ID3D11Texture3DWrapper::SetPrivateData(REFGUID guid, UINT DataSize, const void* pData) - { - return m_realTexture->SetPrivateData(guid, DataSize, pData); - } - - HRESULT __stdcall ID3D11Texture3DWrapper::SetPrivateDataInterface(REFGUID guid, const IUnknown* pData) - { - return m_realTexture->SetPrivateDataInterface(guid, pData); - } - - HRESULT __stdcall ID3D11Texture3DWrapper::SetName(const wchar_t* name) - { - printf("[ID3D11Texture3DWrapper]: SetName STUB\n"); - return S_OK; - } - - void __stdcall ID3D11Texture3DWrapper::GetType(D3D11_RESOURCE_DIMENSION* pResourceDimension) - { - return m_realTexture->GetType(pResourceDimension); - } - - void __stdcall ID3D11Texture3DWrapper::SetEvictionPriority(UINT EvictionPriority) - { - return m_realTexture->SetEvictionPriority(EvictionPriority); - } - - UINT __stdcall ID3D11Texture3DWrapper::GetEvictionPriority(void) - { - return m_realTexture->GetEvictionPriority( ); - } - - void __stdcall ID3D11Texture3DWrapper::GetDescriptor(D3D11X_DESCRIPTOR_RESOURCE* descriptor) - { - printf("[ID3D11Texture3DWrapper]: GetDescriptor STUB\n"); - } - - void __stdcall ID3D11Texture3DWrapper::GetDesc(D3D11_TEXTURE3D_DESC* pDesc) - { - return m_realTexture->GetDesc(pDesc); - } - -} \ No newline at end of file diff --git a/dlls/d3d11_x/ID3D11ViewWrapper.cpp b/dlls/d3d11_x/ID3D11ViewWrapper.cpp deleted file mode 100644 index 8fe00ac..0000000 --- a/dlls/d3d11_x/ID3D11ViewWrapper.cpp +++ /dev/null @@ -1,333 +0,0 @@ -#include "pch.h" -#include "ID3DWrappers.h" - - -namespace d3d11x -{ - HRESULT ID3D11RenderTargetViewWrapper::QueryInterface(REFIID riid, void** ppvObject) - { - if (riid == __uuidof(::ID3D11RenderTargetView)) - { - *ppvObject = this; - AddRef( ); - return S_OK; - } - - // DEBUG - char iidstr[ sizeof("{AAAAAAAA-BBBB-CCCC-DDEE-FFGGHHIIJJKK}") ]; - OLECHAR iidwstr[ sizeof(iidstr) ]; - StringFromGUID2(riid, iidwstr, ARRAYSIZE(iidwstr)); - WideCharToMultiByte(CP_UTF8, 0, iidwstr, -1, iidstr, sizeof(iidstr), nullptr, nullptr); - printf("[IDXGIDeviceWrapper] QueryInterface: %s\n", iidstr); - - - *ppvObject = nullptr; - return E_NOINTERFACE; - } - - ULONG ID3D11RenderTargetViewWrapper::AddRef( ) - { - printf("[ID3D11RenderTargetViewWrapper] --> AddRef\n"); - return InterlockedIncrement(&m_RefCount); - } - - ULONG ID3D11RenderTargetViewWrapper::Release( ) - { - printf("[ID3D11RenderTargetViewWrapper] --> Release\n"); - ULONG refCount = InterlockedDecrement(&m_RefCount); - if (refCount == 0) - delete this; - return refCount; - } - - void __stdcall ID3D11RenderTargetViewWrapper::GetDevice(ID3D11Device** ppDevice) - { - // Probably not necessary but just to be sure -AleBlbl - ::ID3D11Device** device = nullptr; - this->m_realTarget->GetDevice(device); - ppDevice = reinterpret_cast(ppDevice); - } - - HRESULT __stdcall ID3D11RenderTargetViewWrapper::GetPrivateData(REFGUID guid, UINT* pDataSize, void* pData) - { - return m_realTarget->GetPrivateData(guid, pDataSize, pData); - } - - HRESULT __stdcall ID3D11RenderTargetViewWrapper::SetPrivateData(REFGUID guid, UINT DataSize, const void* pData) - { - return m_realTarget->SetPrivateData(guid, DataSize, pData); - } - - HRESULT __stdcall ID3D11RenderTargetViewWrapper::SetPrivateDataInterface(REFGUID guid, const IUnknown* pData) - { - return m_realTarget->SetPrivateDataInterface(guid, pData); - } - - HRESULT __stdcall ID3D11RenderTargetViewWrapper::SetName(const wchar_t* name) - { - printf("[ID3D11RenderTargetViewWrapper]: SetName STUB\n"); - return S_OK; - } - - void __stdcall ID3D11RenderTargetViewWrapper::GetResource(ID3D11Resource** ppResource) - { - D3D11_RENDER_TARGET_VIEW_DESC desc; - m_realTarget->GetDesc(&desc); - - printf("RenderTargetView GetResource Dimension: %i\n", desc.ViewDimension); - - ::ID3D11Texture2D* texture2d = nullptr; - m_realTarget->GetResource(reinterpret_cast<::ID3D11Resource**>(&texture2d)); - *reinterpret_cast(ppResource) = new ID3D11Texture2DWrapper(texture2d); - } - - void __stdcall ID3D11RenderTargetViewWrapper::GetDesc(D3D11_RENDER_TARGET_VIEW_DESC* pDesc) - { - m_realTarget->GetDesc(pDesc); - } - - HRESULT ID3D11DepthStencilViewWrapper::QueryInterface(REFIID riid, void** ppvObject) - { - if (riid == __uuidof(::ID3D11DepthStencilView)) - { - *ppvObject = this; - AddRef( ); - return S_OK; - } - - // DEBUG - char iidstr[ sizeof("{AAAAAAAA-BBBB-CCCC-DDEE-FFGGHHIIJJKK}") ]; - OLECHAR iidwstr[ sizeof(iidstr) ]; - StringFromGUID2(riid, iidwstr, ARRAYSIZE(iidwstr)); - WideCharToMultiByte(CP_UTF8, 0, iidwstr, -1, iidstr, sizeof(iidstr), nullptr, nullptr); - printf("[IDXGIDeviceWrapper] QueryInterface: %s\n", iidstr); - - *ppvObject = nullptr; - return E_NOINTERFACE; - } - - ULONG ID3D11DepthStencilViewWrapper::AddRef( ) - { - printf("[ID3D11DepthStencilViewWrapper] --> AddRef\n"); - return InterlockedIncrement(&m_RefCount); - } - - ULONG ID3D11DepthStencilViewWrapper::Release( ) - { - printf("[ID3D11DepthStencilViewWrapper] --> Release\n"); - ULONG refCount = InterlockedDecrement(&m_RefCount); - if (refCount == 0) - delete this; - return refCount; - } - - void __stdcall ID3D11DepthStencilViewWrapper::GetDevice(ID3D11Device** ppDevice) - { - // Probably not necessary but just to be sure -AleBlbl - ::ID3D11Device** device = nullptr; - this->m_realTarget->GetDevice(device); - ppDevice = reinterpret_cast(ppDevice); - } - - HRESULT __stdcall ID3D11DepthStencilViewWrapper::GetPrivateData(REFGUID guid, UINT* pDataSize, void* pData) - { - return m_realTarget->GetPrivateData(guid, pDataSize, pData); - } - - HRESULT __stdcall ID3D11DepthStencilViewWrapper::SetPrivateData(REFGUID guid, UINT DataSize, const void* pData) - { - return m_realTarget->SetPrivateData(guid, DataSize, pData); - } - - HRESULT __stdcall ID3D11DepthStencilViewWrapper::SetPrivateDataInterface(REFGUID guid, const IUnknown* pData) - { - return m_realTarget->SetPrivateDataInterface(guid, pData); - } - - HRESULT __stdcall ID3D11DepthStencilViewWrapper::SetName(const wchar_t* name) - { - printf("[ID3D11DepthStencilViewWrapper]: SetName STUB\n"); - return S_OK; - } - - void __stdcall ID3D11DepthStencilViewWrapper::GetResource(ID3D11Resource** ppResource) - { - D3D11_DEPTH_STENCIL_VIEW_DESC desc; - m_realTarget->GetDesc(&desc); - printf("DepthStencilView GetResource Dimension: %i\n", desc.ViewDimension); - - ::ID3D11Texture2D* texture2d = nullptr; - m_realTarget->GetResource(reinterpret_cast<::ID3D11Resource**>(&texture2d)); - *reinterpret_cast(ppResource) = new ID3D11Texture2DWrapper(texture2d); - } - - void __stdcall ID3D11DepthStencilViewWrapper::GetDesc(D3D11_DEPTH_STENCIL_VIEW_DESC* pDesc) - { - m_realTarget->GetDesc(pDesc); - } - - HRESULT ID3D11ShaderResourceViewWrapper::QueryInterface(REFIID riid, void** ppvObject) - { - if (riid == __uuidof(::ID3D11ShaderResourceView)) - { - *ppvObject = this; - AddRef( ); - return S_OK; - } - - // DEBUG - char iidstr[ sizeof("{AAAAAAAA-BBBB-CCCC-DDEE-FFGGHHIIJJKK}") ]; - OLECHAR iidwstr[ sizeof(iidstr) ]; - StringFromGUID2(riid, iidwstr, ARRAYSIZE(iidwstr)); - WideCharToMultiByte(CP_UTF8, 0, iidwstr, -1, iidstr, sizeof(iidstr), nullptr, nullptr); - printf("[IDXGIDeviceWrapper] QueryInterface: %s\n", iidstr); - - *ppvObject = nullptr; - return E_NOINTERFACE; - } - - ULONG ID3D11ShaderResourceViewWrapper::AddRef( ) - { - printf("[ID3D11ShaderResourceViewWrapper] --> AddRef\n"); - return InterlockedIncrement(&m_RefCount); - } - - ULONG ID3D11ShaderResourceViewWrapper::Release( ) - { - printf("[ID3D11ShaderResourceViewWrapper] --> Release\n"); - ULONG refCount = InterlockedDecrement(&m_RefCount); - if (refCount == 0) - { - m_realTarget->Release( ); - delete this; - } - - return refCount; - } - - void __stdcall ID3D11ShaderResourceViewWrapper::GetDevice(ID3D11Device** ppDevice) - { - // Probably not necessary but just to be sure -AleBlbl - ::ID3D11Device** device = nullptr; - this->m_realTarget->GetDevice(device); - ppDevice = reinterpret_cast(ppDevice); - } - - HRESULT __stdcall ID3D11ShaderResourceViewWrapper::GetPrivateData(REFGUID guid, UINT* pDataSize, void* pData) - { - return m_realTarget->GetPrivateData(guid, pDataSize, pData); - } - - HRESULT __stdcall ID3D11ShaderResourceViewWrapper::SetPrivateData(REFGUID guid, UINT DataSize, const void* pData) - { - return m_realTarget->SetPrivateData(guid, DataSize, pData); - } - - HRESULT __stdcall ID3D11ShaderResourceViewWrapper::SetPrivateDataInterface(REFGUID guid, const IUnknown* pData) - { - return m_realTarget->SetPrivateDataInterface(guid, pData); - } - - HRESULT __stdcall ID3D11ShaderResourceViewWrapper::SetName(const wchar_t* name) - { - printf("[ID3D11ShaderResourceViewWrapper]: SetName STUB\n"); - return S_OK; - } - - void __stdcall ID3D11ShaderResourceViewWrapper::GetResource(ID3D11Resource** ppResource) - { - D3D11_SHADER_RESOURCE_VIEW_DESC desc; - m_realTarget->GetDesc(&desc); - printf("ShaderResourceView GetResource Dimension: %i\n", desc.ViewDimension); - - ::ID3D11Texture2D* texture2d = nullptr; - m_realTarget->GetResource(reinterpret_cast<::ID3D11Resource**>(&texture2d)); - *reinterpret_cast(ppResource) = new ID3D11Texture2DWrapper(texture2d); - } - - void __stdcall ID3D11ShaderResourceViewWrapper::GetDesc(D3D11_SHADER_RESOURCE_VIEW_DESC* pDesc) - { - m_realTarget->GetDesc(pDesc); - } - - HRESULT ID3D11UnorderedAccessViewWrapper::QueryInterface(REFIID riid, void** ppvObject) - { - if (riid == __uuidof(::ID3D11UnorderedAccessView)) - { - *ppvObject = this; - AddRef( ); - return S_OK; - } - - // DEBUG - char iidstr[ sizeof("{AAAAAAAA-BBBB-CCCC-DDEE-FFGGHHIIJJKK}") ]; - OLECHAR iidwstr[ sizeof(iidstr) ]; - StringFromGUID2(riid, iidwstr, ARRAYSIZE(iidwstr)); - WideCharToMultiByte(CP_UTF8, 0, iidwstr, -1, iidstr, sizeof(iidstr), nullptr, nullptr); - printf("[IDXGIDeviceWrapper] QueryInterface: %s\n", iidstr); - - *ppvObject = nullptr; - return E_NOINTERFACE; - } - - ULONG ID3D11UnorderedAccessViewWrapper::AddRef( ) - { - printf("[ID3D11UnorderedAccessViewWrapper] --> AddRef\n"); - return InterlockedIncrement(&m_RefCount); - } - - ULONG ID3D11UnorderedAccessViewWrapper::Release( ) - { - printf("[ID3D11UnorderedAccessViewWrapper] --> Release\n"); - ULONG refCount = InterlockedDecrement(&m_RefCount); - if (refCount == 0) - delete this; - return refCount; - } - - void __stdcall ID3D11UnorderedAccessViewWrapper::GetDevice(ID3D11Device** ppDevice) - { - // Probably not necessary but just to be sure -AleBlbl - ::ID3D11Device** device = nullptr; - this->m_realTarget->GetDevice(device); - ppDevice = reinterpret_cast(ppDevice); - } - - HRESULT __stdcall ID3D11UnorderedAccessViewWrapper::GetPrivateData(REFGUID guid, UINT* pDataSize, void* pData) - { - return m_realTarget->GetPrivateData(guid, pDataSize, pData); - } - - HRESULT __stdcall ID3D11UnorderedAccessViewWrapper::SetPrivateData(REFGUID guid, UINT DataSize, const void* pData) - { - return m_realTarget->SetPrivateData(guid, DataSize, pData); - } - - HRESULT __stdcall ID3D11UnorderedAccessViewWrapper::SetPrivateDataInterface(REFGUID guid, const IUnknown* pData) - { - return m_realTarget->SetPrivateDataInterface(guid, pData); - } - - HRESULT __stdcall ID3D11UnorderedAccessViewWrapper::SetName(const wchar_t* name) - { - printf("[ID3D11UnorderedAccessViewWrapper]: SetName STUB\n"); - return S_OK; - } - - void __stdcall ID3D11UnorderedAccessViewWrapper::GetResource(ID3D11Resource** ppResource) - { - D3D11_UNORDERED_ACCESS_VIEW_DESC desc; - m_realTarget->GetDesc(&desc); - printf("UnorderedAccessView GetResource Dimension: %i\n", desc.ViewDimension); - - ::ID3D11Texture2D* texture2d = nullptr; - m_realTarget->GetResource(reinterpret_cast<::ID3D11Resource**>(&texture2d)); - *reinterpret_cast(ppResource) = new ID3D11Texture2DWrapper(texture2d); - } - - void __stdcall ID3D11UnorderedAccessViewWrapper::GetDesc(D3D11_UNORDERED_ACCESS_VIEW_DESC* pDesc) - { - m_realTarget->GetDesc(pDesc); - } - -} \ No newline at end of file diff --git a/dlls/d3d11_x/ID3DDeviceContext.h b/dlls/d3d11_x/ID3DDeviceContext.h deleted file mode 100644 index 2575b0b..0000000 --- a/dlls/d3d11_x/ID3DDeviceContext.h +++ /dev/null @@ -1,837 +0,0 @@ -#pragma once -#include "ID3DX.h" -#include -#include - -namespace d3d11x -{ - struct D3D11XTinyDevice - { - unsigned int m_Reserved1[ 8 ]; - unsigned int* m_pBatchCurrent; - unsigned int* m_pBatchLimit; - unsigned int* m_pCeCurrent; - unsigned int* m_pCeBiasedLimit; - unsigned int* m_pCeLimit; - unsigned int m_Reserved2[ 64 ]; - }; - - struct D3D11XShaderUserDataManagerDraw - { - unsigned int m_DirtyFlags; - unsigned int m_Reserved1; - unsigned __int64 m_Topology; - ID3D11InputLayout* m_pInputLayout; - ID3D11VertexShader* m_pVs; - ID3D11PixelShader* m_pPs; - unsigned int m_Reserved2[ 128 ]; - }; - - struct D3D11X_COUNTER_DATA - { - unsigned int Size; - unsigned int Version; - unsigned __int64 GRBM[ 2 ][ 1 ]; - unsigned __int64 SRBM[ 2 ][ 1 ]; - unsigned __int64 CPF[ 2 ][ 1 ]; - unsigned __int64 CPG[ 2 ][ 1 ]; - unsigned __int64 CPC[ 2 ][ 1 ]; - unsigned __int64 CB[ 4 ][ 8 ]; - unsigned __int64 DB[ 4 ][ 8 ]; - unsigned __int64 SU[ 4 ][ 4 ]; - unsigned __int64 SC[ 8 ][ 4 ]; - unsigned __int64 SX[ 8 ][ 4 ]; - unsigned __int64 SPI[ 4 ][ 4 ]; - unsigned __int64 SQ[ 16 ][ 4 ]; - unsigned __int64 TA[ 5 ][ 40 ]; - unsigned __int64 TD[ 2 ][ 40 ]; - unsigned __int64 TCP[ 8 ][ 40 ]; - unsigned __int64 TCC[ 4 ][ 8 ]; - unsigned __int64 TCA[ 4 ][ 2 ]; - unsigned __int64 GDS[ 4 ][ 1 ]; - unsigned __int64 VGT[ 4 ][ 4 ]; - unsigned __int64 IA[ 4 ][ 2 ]; - unsigned __int64 WD[ 4 ][ 1 ]; - unsigned __int64 MC_MCB_L1TLB[ 4 ][ 1 ]; - unsigned __int64 MC_HV_MCB_L1TLB[ 4 ][ 1 ]; - unsigned __int64 MC_MCD_L1TLB[ 4 ][ 2 ]; - unsigned __int64 MC_HV_MCD_L1TLB[ 4 ][ 2 ]; - unsigned __int64 MC_L2TLB[ 2 ][ 1 ]; - unsigned __int64 MC_HV_L2TLB[ 2 ][ 1 ]; - unsigned __int64 MC_ARB[ 4 ][ 6 ]; - unsigned __int64 MC_CITF[ 4 ][ 4 ]; - unsigned __int64 MC_HUB[ 4 ][ 1 ]; - unsigned __int64 GRN[ 4 ][ 1 ]; - unsigned __int64 GRN1[ 4 ][ 1 ]; - unsigned __int64 GRN2[ 4 ][ 1 ]; - }; - - enum D3D11_STAGE : __int32 - { - D3D11_STAGE_VS = 0x0, - D3D11_STAGE_HS = 0x1, - D3D11_STAGE_DS = 0x2, - D3D11_STAGE_GS = 0x3, - D3D11_STAGE_PS = 0x4, - D3D11_STAGE_CS = 0x5, - }; - - enum D3D11X_GPU_PIPELINED_EVENT : __int32 - { - D3D11X_GPU_PIPELINED_EVENT_STREAMOUT_FLUSH = 0x1F, - D3D11X_GPU_PIPELINED_EVENT_FLUSH_AND_INV_CB_PIXEL_DATA = 0x31, - D3D11X_GPU_PIPELINED_EVENT_DB_CACHE_FLUSH_AND_INV = 0x2A, - D3D11X_GPU_PIPELINED_EVENT_FLUSH_AND_INV_CB_META = 0x2E, - D3D11X_GPU_PIPELINED_EVENT_FLUSH_AND_INV_DB_META = 0x2C, - D3D11X_GPU_PIPELINED_EVENT_CS_PARTIAL_FLUSH = 0x407, - D3D11X_GPU_PIPELINED_EVENT_VS_PARTIAL_FLUSH = 0x40F, - D3D11X_GPU_PIPELINED_EVENT_PS_PARTIAL_FLUSH = 0x410, - D3D11X_GPU_PIPELINED_EVENT_PFP_SYNC_ME = 0x80000001, - D3D11X_GPU_PIPELINED_EVENT_INDEX_MASK = 0xF00, - D3D11X_GPU_PIPELINED_EVENT_INDEX_SHIFT = 0x8, - D3D11X_GPU_PIPELINED_EVENT_TYPE_MASK = 0x3F, - D3D11X_GPU_PIPELINED_EVENT_TYPE_SHIFT = 0x0, - D3D11X_GPU_PIPELINED_EVENT_SPECIAL_MASK = 0x80000000, - }; - - enum _D3D11X_GDS_REGION_TYPE : __int32 - { - D3D11X_GDS_REGION_PS = 0x0, - D3D11X_GDS_REGION_CS = 0x1, - D3D11X_GDS_REGION_ALL_MEMORY = 0x2, - }; - - struct D3D11X_FORMAT - { - // @Patoke todo: implement - unsigned __int64 pad; - }; - - enum D3D11X_HW_STAGE : __int32 - { - D3D11X_HW_STAGE_PS = 0x0, - D3D11X_HW_STAGE_VS = 0x1, - D3D11X_HW_STAGE_GS = 0x2, - D3D11X_HW_STAGE_ES = 0x3, - D3D11X_HW_STAGE_HS = 0x4, - D3D11X_HW_STAGE_LS = 0x5, - D3D11X_HW_STAGE_CS = 0x6, - }; - - MIDL_INTERFACE("c0bfa96c-e089-44fb-8eaf-26f8796190da") - ID3D11DeviceContext : public ID3D11DeviceChild_X - { - public: - virtual void STDMETHODCALLTYPE VSSetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers) = 0; - - - - virtual void STDMETHODCALLTYPE PSSetShaderResources( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews, - _In_reads_opt_(NumViews) ID3D11ShaderResourceView* const* ppShaderResourceViews) = 0; - - virtual void STDMETHODCALLTYPE PSSetShader( - _In_opt_ ID3D11PixelShader* pPixelShader, - _In_reads_opt_(NumClassInstances) ID3D11ClassInstance* const* ppClassInstances, - UINT NumClassInstances) = 0; - - virtual void STDMETHODCALLTYPE PSSetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _In_reads_opt_(NumSamplers) ID3D11SamplerState* const* ppSamplers) = 0; - - virtual void STDMETHODCALLTYPE VSSetShader( - _In_opt_ ID3D11VertexShader* pVertexShader, - _In_reads_opt_(NumClassInstances) ID3D11ClassInstance* const* ppClassInstances, - UINT NumClassInstances) = 0; - - virtual void STDMETHODCALLTYPE DrawIndexed( - _In_ UINT IndexCount, - _In_ UINT StartIndexLocation, - _In_ INT BaseVertexLocation) = 0; - - virtual void STDMETHODCALLTYPE Draw( - _In_ UINT VertexCount, - _In_ UINT StartVertexLocation) = 0; - - virtual HRESULT STDMETHODCALLTYPE Map( - _In_ ID3D11Resource* pResource, - _In_ UINT Subresource, - _In_ D3D11_MAP MapType, - _In_ UINT MapFlags, - _Out_opt_ D3D11_MAPPED_SUBRESOURCE* pMappedResource) = 0; - - virtual void STDMETHODCALLTYPE Unmap( - _In_ ID3D11Resource* pResource, - _In_ UINT Subresource) = 0; - - virtual void STDMETHODCALLTYPE PSSetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers) = 0; - - virtual void STDMETHODCALLTYPE IASetInputLayout( - _In_opt_ ID3D11InputLayout* pInputLayout) = 0; - - virtual void STDMETHODCALLTYPE IASetVertexBuffers( - _In_range_(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppVertexBuffers, - _In_reads_opt_(NumBuffers) const UINT* pStrides, - _In_reads_opt_(NumBuffers) const UINT* pOffsets) = 0; - - virtual void STDMETHODCALLTYPE IASetIndexBuffer( - _In_opt_ ID3D11Buffer* pIndexBuffer, - _In_ DXGI_FORMAT Format, - _In_ UINT Offset) = 0; - - virtual void STDMETHODCALLTYPE DrawIndexedInstanced( - _In_ UINT IndexCountPerInstance, - _In_ UINT InstanceCount, - _In_ UINT StartIndexLocation, - _In_ INT BaseVertexLocation, - _In_ UINT StartInstanceLocation) = 0; - - virtual void STDMETHODCALLTYPE DrawInstanced( - _In_ UINT VertexCountPerInstance, - _In_ UINT InstanceCount, - _In_ UINT StartVertexLocation, - _In_ UINT StartInstanceLocation) = 0; - - virtual void STDMETHODCALLTYPE GSSetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers) = 0; - - virtual void STDMETHODCALLTYPE GSSetShader( - _In_opt_ ID3D11GeometryShader* pShader, - _In_reads_opt_(NumClassInstances) ID3D11ClassInstance* const* ppClassInstances, - UINT NumClassInstances) = 0; - - virtual void STDMETHODCALLTYPE VSSetShaderResources( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews, - _In_reads_opt_(NumViews) ID3D11ShaderResourceView* const* ppShaderResourceViews) = 0; - - virtual void STDMETHODCALLTYPE VSSetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _In_reads_opt_(NumSamplers) ID3D11SamplerState* const* ppSamplers) = 0; - - virtual void STDMETHODCALLTYPE Begin( - _In_ ID3D11Asynchronous* pAsync) = 0; - - virtual void STDMETHODCALLTYPE End( - _In_ ID3D11Asynchronous* pAsync) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetData( - _In_ ID3D11Asynchronous* pAsync, - _Out_writes_bytes_opt_(DataSize) void* pData, - _In_ UINT DataSize, - _In_ UINT GetDataFlags) = 0; - - virtual void STDMETHODCALLTYPE SetPredication( - _In_opt_ ID3D11Predicate* pPredicate, - _In_ BOOL PredicateValue) = 0; - - virtual void STDMETHODCALLTYPE GSSetShaderResources( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews, - _In_reads_opt_(NumViews) ID3D11ShaderResourceView* const* ppShaderResourceViews) = 0; - - virtual void STDMETHODCALLTYPE GSSetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _In_reads_opt_(NumSamplers) ID3D11SamplerState* const* ppSamplers) = 0; - - virtual void STDMETHODCALLTYPE OMSetRenderTargets( - _In_range_(0, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT) UINT NumViews, - _In_reads_opt_(NumViews) ID3D11RenderTargetView* const* ppRenderTargetViews, - _In_opt_ ID3D11DepthStencilView* pDepthStencilView) = 0; - - virtual void STDMETHODCALLTYPE OMSetRenderTargetsAndUnorderedAccessViews( - _In_ UINT NumRTVs, - _In_reads_opt_(NumRTVs) ID3D11RenderTargetView* const* ppRenderTargetViews, - _In_opt_ ID3D11DepthStencilView* pDepthStencilView, - _In_range_(0, D3D11_1_UAV_SLOT_COUNT - 1) UINT UAVStartSlot, - _In_ UINT NumUAVs, - _In_reads_opt_(NumUAVs) ID3D11UnorderedAccessView* const* ppUnorderedAccessViews, - _In_reads_opt_(NumUAVs) const UINT* pUAVInitialCounts) = 0; - - virtual void STDMETHODCALLTYPE OMSetBlendState( - _In_opt_ ID3D11BlendState* pBlendState, - _In_opt_ const FLOAT BlendFactor[ 4 ], - _In_ UINT SampleMask) = 0; - - virtual void STDMETHODCALLTYPE OMSetDepthStencilState( - _In_opt_ ID3D11DepthStencilState* pDepthStencilState, - _In_ UINT StencilRef) = 0; - - virtual void STDMETHODCALLTYPE SOSetTargets( - _In_range_(0, D3D11_SO_BUFFER_SLOT_COUNT) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppSOTargets, - _In_reads_opt_(NumBuffers) const UINT* pOffsets) = 0; - - virtual void STDMETHODCALLTYPE DrawAuto(void) = 0; - - virtual void STDMETHODCALLTYPE DrawIndexedInstancedIndirect( - _In_ ID3D11Buffer* pBufferForArgs, - _In_ UINT AlignedByteOffsetForArgs) = 0; - - virtual void STDMETHODCALLTYPE DrawInstancedIndirect( - _In_ ID3D11Buffer* pBufferForArgs, - _In_ UINT AlignedByteOffsetForArgs) = 0; - - virtual void STDMETHODCALLTYPE Dispatch( - _In_ UINT ThreadGroupCountX, - _In_ UINT ThreadGroupCountY, - _In_ UINT ThreadGroupCountZ) = 0; - - virtual void STDMETHODCALLTYPE DispatchIndirect( - _In_ ID3D11Buffer* pBufferForArgs, - _In_ UINT AlignedByteOffsetForArgs) = 0; - - virtual void STDMETHODCALLTYPE RSSetState( - _In_opt_ ID3D11RasterizerState* pRasterizerState) = 0; - - virtual void STDMETHODCALLTYPE RSSetViewports( - _In_range_(0, D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumViewports, - _In_reads_opt_(NumViewports) const D3D11_VIEWPORT* pViewports) = 0; - - virtual void STDMETHODCALLTYPE RSSetScissorRects( - _In_range_(0, D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumRects, - _In_reads_opt_(NumRects) const D3D11_RECT* pRects) = 0; - - virtual void STDMETHODCALLTYPE CopySubresourceRegion( - _In_ ID3D11Resource* pDstResource, - _In_ UINT DstSubresource, - _In_ UINT DstX, - _In_ UINT DstY, - _In_ UINT DstZ, - _In_ ID3D11Resource* pSrcResource, - _In_ UINT SrcSubresource, - _In_opt_ const D3D11_BOX* pSrcBox) = 0; - - virtual void STDMETHODCALLTYPE CopyResource( - _In_ ID3D11Resource* pDstResource, - _In_ ID3D11Resource* pSrcResource) = 0; - - virtual void STDMETHODCALLTYPE UpdateSubresource( - _In_ ID3D11Resource* pDstResource, - _In_ UINT DstSubresource, - _In_opt_ const D3D11_BOX* pDstBox, - _In_ const void* pSrcData, - _In_ UINT SrcRowPitch, - _In_ UINT SrcDepthPitch) = 0; - - virtual void STDMETHODCALLTYPE CopyStructureCount( - _In_ ID3D11Buffer* pDstBuffer, - _In_ UINT DstAlignedByteOffset, - _In_ ID3D11UnorderedAccessView* pSrcView) = 0; - - virtual void STDMETHODCALLTYPE ClearRenderTargetView( - _In_ ID3D11RenderTargetView* pRenderTargetView, - _In_ const FLOAT ColorRGBA[ 4 ]) = 0; - - virtual void STDMETHODCALLTYPE ClearUnorderedAccessViewUint( - _In_ ID3D11UnorderedAccessView* pUnorderedAccessView, - _In_ const UINT Values[ 4 ]) = 0; - - virtual void STDMETHODCALLTYPE ClearUnorderedAccessViewFloat( - _In_ ID3D11UnorderedAccessView* pUnorderedAccessView, - _In_ const FLOAT Values[ 4 ]) = 0; - - virtual void STDMETHODCALLTYPE ClearDepthStencilView( - _In_ ID3D11DepthStencilView* pDepthStencilView, - _In_ UINT ClearFlags, - _In_ FLOAT Depth, - _In_ UINT8 Stencil) = 0; - - virtual void STDMETHODCALLTYPE GenerateMips( - _In_ ID3D11ShaderResourceView* pShaderResourceView) = 0; - - virtual void STDMETHODCALLTYPE SetResourceMinLOD( - _In_ ID3D11Resource* pResource, - FLOAT MinLOD) = 0; - - virtual FLOAT STDMETHODCALLTYPE GetResourceMinLOD( - _In_ ID3D11Resource* pResource) = 0; - - virtual void STDMETHODCALLTYPE ResolveSubresource( - _In_ ID3D11Resource* pDstResource, - _In_ UINT DstSubresource, - _In_ ID3D11Resource* pSrcResource, - _In_ UINT SrcSubresource, - _In_ DXGI_FORMAT Format) = 0; - - virtual void STDMETHODCALLTYPE ExecuteCommandList( - _In_ ID3D11CommandList* pCommandList, - BOOL RestoreContextState) = 0; - - virtual void STDMETHODCALLTYPE HSSetShaderResources( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews, - _In_reads_opt_(NumViews) ID3D11ShaderResourceView* const* ppShaderResourceViews) = 0; - - virtual void STDMETHODCALLTYPE HSSetShader( - _In_opt_ ID3D11HullShader* pHullShader, - _In_reads_opt_(NumClassInstances) ID3D11ClassInstance* const* ppClassInstances, - UINT NumClassInstances) = 0; - - virtual void STDMETHODCALLTYPE HSSetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _In_reads_opt_(NumSamplers) ID3D11SamplerState* const* ppSamplers) = 0; - - virtual void STDMETHODCALLTYPE HSSetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers) = 0; - - virtual void STDMETHODCALLTYPE DSSetShaderResources( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews, - _In_reads_opt_(NumViews) ID3D11ShaderResourceView* const* ppShaderResourceViews) = 0; - - virtual void STDMETHODCALLTYPE DSSetShader( - _In_opt_ ID3D11DomainShader* pDomainShader, - _In_reads_opt_(NumClassInstances) ID3D11ClassInstance* const* ppClassInstances, - UINT NumClassInstances) = 0; - - virtual void STDMETHODCALLTYPE DSSetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _In_reads_opt_(NumSamplers) ID3D11SamplerState* const* ppSamplers) = 0; - - virtual void STDMETHODCALLTYPE DSSetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers) = 0; - - virtual void STDMETHODCALLTYPE CSSetShaderResources( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews, - _In_reads_opt_(NumViews) ID3D11ShaderResourceView* const* ppShaderResourceViews) = 0; - - virtual void STDMETHODCALLTYPE CSSetUnorderedAccessViews( - _In_range_(0, D3D11_1_UAV_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_1_UAV_SLOT_COUNT - StartSlot) UINT NumUAVs, - _In_reads_opt_(NumUAVs) ID3D11UnorderedAccessView* const* ppUnorderedAccessViews, - _In_reads_opt_(NumUAVs) const UINT* pUAVInitialCounts) = 0; - - virtual void STDMETHODCALLTYPE CSSetShader( - _In_opt_ ID3D11ComputeShader* pComputeShader, - _In_reads_opt_(NumClassInstances) ID3D11ClassInstance* const* ppClassInstances, - UINT NumClassInstances) = 0; - - virtual void STDMETHODCALLTYPE CSSetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _In_reads_opt_(NumSamplers) ID3D11SamplerState* const* ppSamplers) = 0; - - virtual void STDMETHODCALLTYPE CSSetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers) = 0; - - virtual void STDMETHODCALLTYPE VSGetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers) = 0; - - virtual void STDMETHODCALLTYPE PSGetShaderResources( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews, - _Out_writes_opt_(NumViews) ID3D11ShaderResourceView** ppShaderResourceViews) = 0; - - virtual void STDMETHODCALLTYPE PSGetShader( - _Outptr_result_maybenull_ ID3D11PixelShader** ppPixelShader, - _Out_writes_opt_(*pNumClassInstances) ID3D11ClassInstance** ppClassInstances, - _Inout_opt_ UINT* pNumClassInstances) = 0; - - virtual void STDMETHODCALLTYPE PSGetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _Out_writes_opt_(NumSamplers) ID3D11SamplerState** ppSamplers) = 0; - - virtual void STDMETHODCALLTYPE VSGetShader( - _Outptr_result_maybenull_ ID3D11VertexShader** ppVertexShader, - _Out_writes_opt_(*pNumClassInstances) ID3D11ClassInstance** ppClassInstances, - _Inout_opt_ UINT* pNumClassInstances) = 0; - - virtual void STDMETHODCALLTYPE PSGetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers) = 0; - - virtual void STDMETHODCALLTYPE IAGetInputLayout( - _Outptr_result_maybenull_ ID3D11InputLayout** ppInputLayout) = 0; - - virtual void STDMETHODCALLTYPE IAGetVertexBuffers( - _In_range_(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppVertexBuffers, - _Out_writes_opt_(NumBuffers) UINT* pStrides, - _Out_writes_opt_(NumBuffers) UINT* pOffsets) = 0; - - virtual void STDMETHODCALLTYPE IAGetIndexBuffer( - _Outptr_opt_result_maybenull_ ID3D11Buffer** pIndexBuffer, - _Out_opt_ DXGI_FORMAT* Format, - _Out_opt_ UINT* Offset) = 0; - - virtual void STDMETHODCALLTYPE GSGetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers) = 0; - - virtual void STDMETHODCALLTYPE GSGetShader( - _Outptr_result_maybenull_ ID3D11GeometryShader** ppGeometryShader, - _Out_writes_opt_(*pNumClassInstances) ID3D11ClassInstance** ppClassInstances, - _Inout_opt_ UINT* pNumClassInstances) = 0; - - virtual void STDMETHODCALLTYPE IAGetPrimitiveTopology( - _Out_ D3D11_PRIMITIVE_TOPOLOGY* pTopology) = 0; - - virtual void STDMETHODCALLTYPE VSGetShaderResources( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews, - _Out_writes_opt_(NumViews) ID3D11ShaderResourceView** ppShaderResourceViews) = 0; - - virtual void STDMETHODCALLTYPE VSGetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _Out_writes_opt_(NumSamplers) ID3D11SamplerState** ppSamplers) = 0; - - virtual void STDMETHODCALLTYPE GetPredication( - _Outptr_opt_result_maybenull_ ID3D11Predicate** ppPredicate, - _Out_opt_ BOOL* pPredicateValue) = 0; - - virtual void STDMETHODCALLTYPE GSGetShaderResources( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews, - _Out_writes_opt_(NumViews) ID3D11ShaderResourceView** ppShaderResourceViews) = 0; - - virtual void STDMETHODCALLTYPE GSGetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _Out_writes_opt_(NumSamplers) ID3D11SamplerState** ppSamplers) = 0; - - virtual void STDMETHODCALLTYPE OMGetRenderTargets( - _In_range_(0, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT) UINT NumViews, - _Out_writes_opt_(NumViews) ID3D11RenderTargetView** ppRenderTargetViews, - _Outptr_opt_result_maybenull_ ID3D11DepthStencilView** ppDepthStencilView) = 0; - - virtual void STDMETHODCALLTYPE OMGetRenderTargetsAndUnorderedAccessViews( - _In_range_(0, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT) UINT NumRTVs, - _Out_writes_opt_(NumRTVs) ID3D11RenderTargetView** ppRenderTargetViews, - _Outptr_opt_result_maybenull_ ID3D11DepthStencilView** ppDepthStencilView, - _In_range_(0, D3D11_PS_CS_UAV_REGISTER_COUNT - 1) UINT UAVStartSlot, - _In_range_(0, D3D11_PS_CS_UAV_REGISTER_COUNT - UAVStartSlot) UINT NumUAVs, - _Out_writes_opt_(NumUAVs) ID3D11UnorderedAccessView** ppUnorderedAccessViews) = 0; - - virtual void STDMETHODCALLTYPE OMGetBlendState( - _Outptr_opt_result_maybenull_ ID3D11BlendState** ppBlendState, - _Out_opt_ FLOAT BlendFactor[ 4 ], - _Out_opt_ UINT* pSampleMask) = 0; - - virtual void STDMETHODCALLTYPE OMGetDepthStencilState( - _Outptr_opt_result_maybenull_ ID3D11DepthStencilState** ppDepthStencilState, - _Out_opt_ UINT* pStencilRef) = 0; - - virtual void STDMETHODCALLTYPE SOGetTargets( - _In_range_(0, D3D11_SO_BUFFER_SLOT_COUNT) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppSOTargets) = 0; - - virtual void STDMETHODCALLTYPE RSGetState( - _Outptr_result_maybenull_ ID3D11RasterizerState** ppRasterizerState) = 0; - - virtual void STDMETHODCALLTYPE RSGetViewports( - _Inout_ /*_range(0, D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE )*/ UINT* pNumViewports, - _Out_writes_opt_(*pNumViewports) D3D11_VIEWPORT* pViewports) = 0; - - virtual void STDMETHODCALLTYPE RSGetScissorRects( - _Inout_ /*_range(0, D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE )*/ UINT* pNumRects, - _Out_writes_opt_(*pNumRects) D3D11_RECT* pRects) = 0; - - virtual void STDMETHODCALLTYPE HSGetShaderResources( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews, - _Out_writes_opt_(NumViews) ID3D11ShaderResourceView** ppShaderResourceViews) = 0; - - virtual void STDMETHODCALLTYPE HSGetShader( - _Outptr_result_maybenull_ ID3D11HullShader** ppHullShader, - _Out_writes_opt_(*pNumClassInstances) ID3D11ClassInstance** ppClassInstances, - _Inout_opt_ UINT* pNumClassInstances) = 0; - - virtual void STDMETHODCALLTYPE HSGetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _Out_writes_opt_(NumSamplers) ID3D11SamplerState** ppSamplers) = 0; - - virtual void STDMETHODCALLTYPE HSGetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers) = 0; - - virtual void STDMETHODCALLTYPE DSGetShaderResources( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews, - _Out_writes_opt_(NumViews) ID3D11ShaderResourceView** ppShaderResourceViews) = 0; - - virtual void STDMETHODCALLTYPE DSGetShader( - _Outptr_result_maybenull_ ID3D11DomainShader** ppDomainShader, - _Out_writes_opt_(*pNumClassInstances) ID3D11ClassInstance** ppClassInstances, - _Inout_opt_ UINT* pNumClassInstances) = 0; - - virtual void STDMETHODCALLTYPE DSGetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _Out_writes_opt_(NumSamplers) ID3D11SamplerState** ppSamplers) = 0; - - virtual void STDMETHODCALLTYPE DSGetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers) = 0; - - virtual void STDMETHODCALLTYPE CSGetShaderResources( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews, - _Out_writes_opt_(NumViews) ID3D11ShaderResourceView** ppShaderResourceViews) = 0; - - virtual void STDMETHODCALLTYPE CSGetUnorderedAccessViews( - _In_range_(0, D3D11_1_UAV_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_1_UAV_SLOT_COUNT - StartSlot) UINT NumUAVs, - _Out_writes_opt_(NumUAVs) ID3D11UnorderedAccessView** ppUnorderedAccessViews) = 0; - - virtual void STDMETHODCALLTYPE CSGetShader( - _Outptr_result_maybenull_ ID3D11ComputeShader** ppComputeShader, - _Out_writes_opt_(*pNumClassInstances) ID3D11ClassInstance** ppClassInstances, - _Inout_opt_ UINT* pNumClassInstances) = 0; - - virtual void STDMETHODCALLTYPE CSGetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _Out_writes_opt_(NumSamplers) ID3D11SamplerState** ppSamplers) = 0; - - virtual void STDMETHODCALLTYPE CSGetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers) = 0; - - virtual void STDMETHODCALLTYPE ClearState(void) = 0; - - virtual void STDMETHODCALLTYPE Flush(void) = 0; - - virtual D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE GetType(void) = 0; - - virtual UINT STDMETHODCALLTYPE GetContextFlags(void) = 0; - - virtual HRESULT STDMETHODCALLTYPE FinishCommandList( - BOOL RestoreDeferredContextState, - _COM_Outptr_opt_ ID3D11CommandList** ppCommandList) = 0; - - }; - - MIDL_INTERFACE("bb2c6faa-b5fb-4082-8e6b-388b8cfa90e1") - ID3D11DeviceContext1 : public ID3D11DeviceContext - { - public: - virtual void STDMETHODCALLTYPE CopySubresourceRegion1( - _In_ ID3D11Resource * pDstResource, - _In_ UINT DstSubresource, - _In_ UINT DstX, - _In_ UINT DstY, - _In_ UINT DstZ, - _In_ ID3D11Resource * pSrcResource, - _In_ UINT SrcSubresource, - _In_opt_ const D3D11_BOX * pSrcBox, - _In_ UINT CopyFlags) = 0; - - virtual void STDMETHODCALLTYPE UpdateSubresource1( - _In_ ID3D11Resource* pDstResource, - _In_ UINT DstSubresource, - _In_opt_ const D3D11_BOX* pDstBox, - _In_ const void* pSrcData, - _In_ UINT SrcRowPitch, - _In_ UINT SrcDepthPitch, - _In_ UINT CopyFlags) = 0; - - virtual void STDMETHODCALLTYPE DiscardResource( - _In_ ID3D11Resource* pResource) = 0; - - virtual void STDMETHODCALLTYPE DiscardView( - _In_ ID3D11View* pResourceView) = 0; - - virtual void STDMETHODCALLTYPE VSSetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers, - _In_reads_opt_(NumBuffers) const UINT* pFirstConstant, - _In_reads_opt_(NumBuffers) const UINT* pNumConstants) = 0; - - virtual void STDMETHODCALLTYPE HSSetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers, - _In_reads_opt_(NumBuffers) const UINT* pFirstConstant, - _In_reads_opt_(NumBuffers) const UINT* pNumConstants) = 0; - - virtual void STDMETHODCALLTYPE DSSetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers, - _In_reads_opt_(NumBuffers) const UINT* pFirstConstant, - _In_reads_opt_(NumBuffers) const UINT* pNumConstants) = 0; - - virtual void STDMETHODCALLTYPE GSSetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers, - _In_reads_opt_(NumBuffers) const UINT* pFirstConstant, - _In_reads_opt_(NumBuffers) const UINT* pNumConstants) = 0; - - virtual void STDMETHODCALLTYPE PSSetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers, - _In_reads_opt_(NumBuffers) const UINT* pFirstConstant, - _In_reads_opt_(NumBuffers) const UINT* pNumConstants) = 0; - - virtual void STDMETHODCALLTYPE CSSetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers, - _In_reads_opt_(NumBuffers) const UINT* pFirstConstant, - _In_reads_opt_(NumBuffers) const UINT* pNumConstants) = 0; - - virtual void STDMETHODCALLTYPE VSGetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers, - _Out_writes_opt_(NumBuffers) UINT* pFirstConstant, - _Out_writes_opt_(NumBuffers) UINT* pNumConstants) = 0; - - virtual void STDMETHODCALLTYPE HSGetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers, - _Out_writes_opt_(NumBuffers) UINT* pFirstConstant, - _Out_writes_opt_(NumBuffers) UINT* pNumConstants) = 0; - - virtual void STDMETHODCALLTYPE DSGetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers, - _Out_writes_opt_(NumBuffers) UINT* pFirstConstant, - _Out_writes_opt_(NumBuffers) UINT* pNumConstants) = 0; - - virtual void STDMETHODCALLTYPE GSGetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers, - _Out_writes_opt_(NumBuffers) UINT* pFirstConstant, - _Out_writes_opt_(NumBuffers) UINT* pNumConstants) = 0; - - virtual void STDMETHODCALLTYPE PSGetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers, - _Out_writes_opt_(NumBuffers) UINT* pFirstConstant, - _Out_writes_opt_(NumBuffers) UINT* pNumConstants) = 0; - - virtual void STDMETHODCALLTYPE CSGetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers, - _Out_writes_opt_(NumBuffers) UINT* pFirstConstant, - _Out_writes_opt_(NumBuffers) UINT* pNumConstants) = 0; - - virtual void STDMETHODCALLTYPE SwapDeviceContextState( - _In_ ID3DDeviceContextState* pState, - _Outptr_opt_ ID3DDeviceContextState** ppPreviousState) = 0; - - virtual void STDMETHODCALLTYPE ClearView( - _In_ ID3D11View* pView, - _In_ const FLOAT Color[ 4 ], - _In_reads_opt_(NumRects) const D3D11_RECT* pRect, - UINT NumRects) = 0; - - virtual void STDMETHODCALLTYPE DiscardView1( - _In_ ID3D11View* pResourceView, - _In_reads_opt_(NumRects) const D3D11_RECT* pRects, - UINT NumRects) = 0; - - }; - - MIDL_INTERFACE("420d5b32-b90c-4da4-bef0-359f6a24a83a") - ID3D11DeviceContext2 : public ID3D11DeviceContext1 - { - public: - virtual HRESULT STDMETHODCALLTYPE UpdateTileMappings( - _In_ ID3D11Resource * pTiledResource, - _In_ UINT NumTiledResourceRegions, - _In_reads_opt_(NumTiledResourceRegions) const D3D11_TILED_RESOURCE_COORDINATE * pTiledResourceRegionStartCoordinates, - _In_reads_opt_(NumTiledResourceRegions) const D3D11_TILE_REGION_SIZE * pTiledResourceRegionSizes, - _In_opt_ ID3D11Buffer * pTilePool, - _In_ UINT NumRanges, - _In_reads_opt_(NumRanges) const UINT * pRangeFlags, - _In_reads_opt_(NumRanges) const UINT * pTilePoolStartOffsets, - _In_reads_opt_(NumRanges) const UINT * pRangeTileCounts, - _In_ UINT Flags) = 0; - - virtual HRESULT STDMETHODCALLTYPE CopyTileMappings( - _In_ ID3D11Resource* pDestTiledResource, - _In_ const D3D11_TILED_RESOURCE_COORDINATE* pDestRegionStartCoordinate, - _In_ ID3D11Resource* pSourceTiledResource, - _In_ const D3D11_TILED_RESOURCE_COORDINATE* pSourceRegionStartCoordinate, - _In_ const D3D11_TILE_REGION_SIZE* pTileRegionSize, - _In_ UINT Flags) = 0; - - virtual void STDMETHODCALLTYPE CopyTiles( - _In_ ID3D11Resource* pTiledResource, - _In_ const D3D11_TILED_RESOURCE_COORDINATE* pTileRegionStartCoordinate, - _In_ const D3D11_TILE_REGION_SIZE* pTileRegionSize, - _In_ ID3D11Buffer* pBuffer, - _In_ UINT64 BufferStartOffsetInBytes, - _In_ UINT Flags) = 0; - - virtual void STDMETHODCALLTYPE UpdateTiles( - _In_ ID3D11Resource* pDestTiledResource, - _In_ const D3D11_TILED_RESOURCE_COORDINATE* pDestTileRegionStartCoordinate, - _In_ const D3D11_TILE_REGION_SIZE* pDestTileRegionSize, - _In_ const void* pSourceTileData, - _In_ UINT Flags) = 0; - - virtual HRESULT STDMETHODCALLTYPE ResizeTilePool( - _In_ ID3D11Buffer* pTilePool, - _In_ UINT64 NewSizeInBytes) = 0; - - virtual void STDMETHODCALLTYPE TiledResourceBarrier( - _In_opt_ ID3D11DeviceChild* pTiledResourceOrViewAccessBeforeBarrier, - _In_opt_ ID3D11DeviceChild* pTiledResourceOrViewAccessAfterBarrier) = 0; - - virtual BOOL STDMETHODCALLTYPE IsAnnotationEnabled(void) = 0; - - virtual void STDMETHODCALLTYPE SetMarkerInt( - _In_ LPCWSTR pLabel, - INT Data) = 0; - - virtual void STDMETHODCALLTYPE BeginEventInt( - _In_ LPCWSTR pLabel, - INT Data) = 0; - - virtual void STDMETHODCALLTYPE EndEvent(void) = 0; - - }; - - // just for the guid :3 - D3DINTERFACE(ID3D11DeviceContextX, 48800095, 7134, 4be7, 91, 86, b8, 6b, ec, b2, 64, 77) { - public: - - }; - -} \ No newline at end of file diff --git a/dlls/d3d11_x/ID3DWrappers.cpp b/dlls/d3d11_x/ID3DWrappers.cpp deleted file mode 100644 index 5200ac5..0000000 --- a/dlls/d3d11_x/ID3DWrappers.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "pch.h" -#include "ID3DWrappers.h" - -namespace d3d11x { - HRESULT ID3D11ResourceWrapperX::QueryInterface(REFIID riid, void** ppvObject) - { - // DEBUG - char iidstr[ sizeof("{AAAAAAAA-BBBB-CCCC-DDEE-FFGGHHIIJJKK}") ]; - OLECHAR iidwstr[ sizeof(iidstr) ]; - StringFromGUID2(riid, iidwstr, ARRAYSIZE(iidwstr)); - WideCharToMultiByte(CP_UTF8, 0, iidwstr, -1, iidstr, sizeof(iidstr), nullptr, nullptr); - printf("[ID3D11ResourceWrapperX] QueryInterface: %s\n", iidstr); - - *ppvObject = nullptr; - return E_NOINTERFACE; - } - - ULONG ID3D11ResourceWrapperX::AddRef( ) - { - printf("[ID3D11ResourceWrapperX] --> AddRef\n"); - return InterlockedIncrement(&m_RefCount); - } - - ULONG ID3D11ResourceWrapperX::Release( ) - { - printf("[ID3D11ResourceWrapperX] --> Release\n"); - ULONG refCount = InterlockedDecrement(&m_RefCount); - if (refCount == 0) - delete this; - return refCount; - } - - // @Patoke todo: unwrap? - void __stdcall ID3D11ResourceWrapperX::GetDevice(ID3D11Device** ppDevice) - { - // Probably not necessary but just to be sure -AleBlbl - ::ID3D11Device** device = nullptr; - this->m_realResource->GetDevice(device); - ppDevice = reinterpret_cast(ppDevice); - } - - HRESULT __stdcall ID3D11ResourceWrapperX::GetPrivateData(REFGUID guid, UINT* pDataSize, void* pData) - { - return m_realResource->GetPrivateData(guid, pDataSize, pData); - } - - HRESULT __stdcall ID3D11ResourceWrapperX::SetPrivateData(REFGUID guid, UINT DataSize, const void* pData) - { - return m_realResource->SetPrivateData(guid, DataSize, pData); - } - - HRESULT __stdcall ID3D11ResourceWrapperX::SetPrivateDataInterface(REFGUID guid, const IUnknown* pData) - { - return m_realResource->SetPrivateDataInterface(guid, pData); - } - - HRESULT __stdcall ID3D11ResourceWrapperX::SetName(const wchar_t* name) - { - printf("[ID3D11ResourceWrapperX]: SetName STUB\n"); - return S_OK; - } - - void __stdcall ID3D11ResourceWrapperX::GetType(D3D11_RESOURCE_DIMENSION* pResourceDimension) - { - return m_realResource->GetType(pResourceDimension); - } - - void __stdcall ID3D11ResourceWrapperX::SetEvictionPriority(UINT EvictionPriority) - { - return m_realResource->SetEvictionPriority(EvictionPriority); - } - - UINT __stdcall ID3D11ResourceWrapperX::GetEvictionPriority(void) - { - return m_realResource->GetEvictionPriority( ); - } - - void __stdcall ID3D11ResourceWrapperX::GetDescriptor(D3D11X_DESCRIPTOR_RESOURCE* descriptor) - { - printf("[ID3D11ResourceWrapperX]: GetDescriptor STUB\n"); - } -} \ No newline at end of file diff --git a/dlls/d3d11_x/ID3DWrappers.h b/dlls/d3d11_x/ID3DWrappers.h deleted file mode 100644 index ea0f902..0000000 --- a/dlls/d3d11_x/ID3DWrappers.h +++ /dev/null @@ -1,3103 +0,0 @@ -#pragma once -#include "ID3DX.h" -#include "ID3DDeviceContext.h" -#include -#include -#include -#include - -static std::map D3D11X_HARDWARE_TO_TOPOLOGY_MAP = { - {0x000001ffc0009e00, 0}, {0x000003ffc0009e00, 1}, {0x000005ffc0009e00, 2}, {0x000007ffc0009e00, 3}, - {0x000009ffc0009e00, 4}, {0x00000dffc0009e00, 5}, {0x00000bffc0009e00, 6}, {0x000001ffc0009e00, 7}, - {0x000001ffc0009e00, 8}, {0x000001ffc0009e00, 9}, {0x0000157fc0009e00, 10}, {0x0000177fc0009e00, 11}, - {0x0000197fc0009e00, 12}, {0x00001b7fc0009e00, 13}, {0x00001dffc0009e00, 14}, {0x00001fffc0009e00, 15}, - {0x000021ffc0009e00, 16}, {0x000023ffc0009e00, 17}, {0x000025ffc0009e00, 18}, {0x000027ffc0009e00, 19}, - {0x000029ffc0009e00, 20}, {0x00002bffc0009e00, 21}, {0x00002dffc0009e00, 22}, {0x00002fffc0009e00, 23}, - {0x000031ffc0009e00, 24}, {0x000033ffc0009e00, 25}, {0x000035ffc0009e00, 26}, {0x000037ffc0009e00, 27}, - {0x000039ffc0009e00, 28}, {0x000001ffc0009e00, 29}, {0x000001ffc0009e00, 30}, {0x000001ffc0009e00, 31}, - {0x000001ffc0009e00, 32}, {0x001013ffc0009e00, 33}, {0x0020137fc0009e00, 34}, {0x00301354c0009e00, 35}, - {0x0040133fc0009e00, 36}, {0x00501332c0009e00, 37}, {0x00601329c0009e00, 38}, {0x00701323c0009e00, 39}, - {0x0080131fc0009e00, 40}, {0x0090131bc0009e00, 41}, {0x00a01318c0009e00, 42}, {0x00b01316c0009e00, 43}, - {0x00c01314c0009e00, 44}, {0x00d01312c0009e00, 45}, {0x00e01311c0009e00, 46}, {0x00f01310c0009e00, 47}, - {0x0100130fc0009e00, 48}, {0x0110130ec0009e00, 49}, {0x0120130dc0009e00, 50}, {0x0130130cc0009e00, 51}, - {0x0140130bc0009e00, 52}, {0x0150130bc0009e00, 53}, {0x0160130ac0009e00, 54}, {0x0170130ac0009e00, 55}, - {0x01801309c0009e00, 56}, {0x01901309c0009e00, 57}, {0x01a01308c0009e00, 58}, {0x01b01308c0009e00, 59}, - {0x01c01308c0009e00, 60}, {0x01d01307c0009e00, 61}, {0x01e01307c0009e00, 62}, {0x01f01307c0009e00, 63}, - {0x02001307c0009e00, 64} -}; - -namespace d3d11x -{ - struct D3D11X_TESSELLATION_PARAMETERS; - struct D3D11X_THREAD_TRACE_DESC; - struct D3D11X_GRAPHICS_SHADER_LIMITS; - struct D3D11X_COMPUTE_SHADER_LIMITS; - struct D3D11X_GS_PARAMETERS; - struct _D3D11X_MSAA_SCAN_CONVERTER_SETTINGS; - struct _D3D11X_MSAA_EQAA_SETTINGS; - struct _D3D11X_MSAA_SAMPLE_PRIORITIES; - struct _D3D11X_MSAA_SAMPLE_POSITIONS; - - typedef POINT D3D11X_POINT; - typedef D3D11_RECT D3D11X_RECT; - - typedef struct _D3D11X_MSAA_SCAN_CONVERTER_SETTINGS - { - UINT NumSamplesMsaaLog2 : 3; - UINT MaxSampleDistanceInSubpixels : 4; - UINT NumSamplesMsaaExposedToPSLog2 : 3; - UINT DetailToExposedMode : 2; - UINT ApplyMaskAfterCentroid : 1; - } D3D11X_MSAA_SCAN_CONVERTER_SETTINGS; - - typedef struct _D3D11X_MSAA_EQAA_SETTINGS - { - UINT MaxAnchorSamplesLog2 : 3; - UINT NumSamplesForPSIterationLog2 : 3; - UINT NumSamplesForMaskExportLog2 : 3; - UINT NumSamplesForAlphaToMaskLog2 : 3; - UINT HightQualityIntersections : 1; - UINT InterpolateCompZ : 1; - UINT InterpolateSrcZ : 1; - UINT StaticAnchorAssociations : 1; - UINT OverrasterizationAmount : 3; - UINT EnablePostZOverrasterization : 1; - } D3D11X_MSAA_EQAA_SETTINGS; - - typedef struct _D3D11X_MSAA_SAMPLE_PRIORITIES - { - BYTE CentroidPriorities[ 16 ]; - } D3D11X_MSAA_SAMPLE_PRIORITIES; - - typedef struct _D3D11X_MSAA_SAMPLE_POSITIONS - { - INT8 SampleLocs00[ 16 ][ 2 ]; // Sample positions stored as one byte per component, X then Y - INT8 SampleLocs10[ 16 ][ 2 ]; // There are up to 16 possible sample positions per pixel - INT8 SampleLocs01[ 16 ][ 2 ]; // They can be set differently for each pixel in a 2x2 quad - INT8 SampleLocs11[ 16 ][ 2 ]; - } D3D11X_MSAA_SAMPLE_POSITIONS; - - class ID3D11BufferWrapper : public ID3D11Buffer_X - { - public: - ID3D11Buffer* m_realBuffer; - - ID3D11BufferWrapper(::ID3D11Buffer* buf) : m_realBuffer(buf) - { - m_RefCount = 1; - } - - - // IGraphicsUnknown - HRESULT QueryInterface(REFIID riid, void** ppvObject) override; - ULONG AddRef() override; - ULONG Release() override; - - // ID3D11DeviceChild - void STDMETHODCALLTYPE GetDevice(_Outptr_ ID3D11Device** ppDevice) override; - HRESULT STDMETHODCALLTYPE GetPrivateData(_In_ REFGUID guid, _Inout_ UINT* pDataSize, - _Out_writes_bytes_opt_(*pDataSize) void* pData) override; - HRESULT STDMETHODCALLTYPE SetPrivateData(_In_ REFGUID guid, _In_ UINT DataSize, - _In_reads_bytes_opt_(DataSize) const void* pData) override; - HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(_In_ REFGUID guid, _In_opt_ const IUnknown* pData) override; - HRESULT STDMETHODCALLTYPE SetName(const wchar_t* name) override; - - // ID3D11Resource - void STDMETHODCALLTYPE GetType(_Out_ D3D11_RESOURCE_DIMENSION* pResourceDimension) override; - void STDMETHODCALLTYPE SetEvictionPriority(_In_ UINT EvictionPriority) override; - UINT STDMETHODCALLTYPE GetEvictionPriority(void) override; - void STDMETHODCALLTYPE GetDescriptor(D3D11X_DESCRIPTOR_RESOURCE* descriptor) override; - - // ID3D11Buffer - void STDMETHODCALLTYPE GetDesc(_Out_ D3D11_BUFFER_DESC* pDesc) override; - }; - - class ID3D11ResourceWrapperX : public ID3D11DeviceChild_X - { - public: - ID3D11Resource* m_realResource; - - ID3D11ResourceWrapperX(::ID3D11Resource* resource) : m_realResource(resource) - { - m_RefCount = 1; - } - - // IGraphicsUnknown - HRESULT QueryInterface(REFIID riid, void** ppvObject) override; - ULONG AddRef() override; - ULONG Release() override; - - // ID3D11DeviceChild - void STDMETHODCALLTYPE GetDevice(_Outptr_ ID3D11Device** ppDevice) override; - HRESULT STDMETHODCALLTYPE GetPrivateData(_In_ REFGUID guid, _Inout_ UINT* pDataSize, - _Out_writes_bytes_opt_(*pDataSize) void* pData) override; - HRESULT STDMETHODCALLTYPE SetPrivateData(_In_ REFGUID guid, _In_ UINT DataSize, - _In_reads_bytes_opt_(DataSize) const void* pData) override; - HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(_In_ REFGUID guid, _In_opt_ const IUnknown* pData) override; - HRESULT STDMETHODCALLTYPE SetName(const wchar_t* name) override; - - virtual void STDMETHODCALLTYPE GetType( - /* [annotation] */ - _Out_ D3D11_RESOURCE_DIMENSION* pResourceDimension); - - virtual void STDMETHODCALLTYPE SetEvictionPriority( - /* [annotation] */ - _In_ UINT EvictionPriority); - - virtual UINT STDMETHODCALLTYPE GetEvictionPriority(void); - - // xbox extra function - virtual void STDMETHODCALLTYPE GetDescriptor(D3D11X_DESCRIPTOR_RESOURCE* descriptor); - }; - - class ID3D11Texture1DWrapper : public ID3D11Texture1D_X - { - public: - ID3D11Texture1D* m_realTexture; - - ID3D11Texture1DWrapper(::ID3D11Texture1D* tex) : m_realTexture(tex) - { - m_RefCount = 1; - } - - - // IGraphicsUnknown - HRESULT QueryInterface(REFIID riid, void** ppvObject) override; - ULONG AddRef() override; - ULONG Release() override; - - // ID3D11DeviceChild - void STDMETHODCALLTYPE GetDevice(_Outptr_ ID3D11Device** ppDevice) override; - HRESULT STDMETHODCALLTYPE GetPrivateData(_In_ REFGUID guid, _Inout_ UINT* pDataSize, - _Out_writes_bytes_opt_(*pDataSize) void* pData) override; - HRESULT STDMETHODCALLTYPE SetPrivateData(_In_ REFGUID guid, _In_ UINT DataSize, - _In_reads_bytes_opt_(DataSize) const void* pData) override; - HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(_In_ REFGUID guid, _In_opt_ const IUnknown* pData) override; - HRESULT STDMETHODCALLTYPE SetName(const wchar_t* name) override; - - // ID3D11Resource - void STDMETHODCALLTYPE GetType(_Out_ D3D11_RESOURCE_DIMENSION* pResourceDimension) override; - void STDMETHODCALLTYPE SetEvictionPriority(_In_ UINT EvictionPriority) override; - UINT STDMETHODCALLTYPE GetEvictionPriority(void) override; - void STDMETHODCALLTYPE GetDescriptor(D3D11X_DESCRIPTOR_RESOURCE* descriptor) override; - - // ID3D11Texture1D - void STDMETHODCALLTYPE GetDesc(_Out_ D3D11_TEXTURE1D_DESC* pDesc) override; - }; - - class ID3D11Texture2DWrapper : public ID3D11Texture2D_X - { - public: - ID3D11Texture2D* m_realTexture; - - ID3D11Texture2DWrapper(::ID3D11Texture2D* tex) : m_realTexture(tex) - { - m_RefCount = 1; - } - - - // IGraphicsUnknown - HRESULT QueryInterface(REFIID riid, void** ppvObject) override; - ULONG AddRef() override; - ULONG Release() override; - - // ID3D11DeviceChild - void STDMETHODCALLTYPE GetDevice(_Outptr_ ID3D11Device** ppDevice) override; - HRESULT STDMETHODCALLTYPE GetPrivateData(_In_ REFGUID guid, _Inout_ UINT* pDataSize, - _Out_writes_bytes_opt_(*pDataSize) void* pData) override; - HRESULT STDMETHODCALLTYPE SetPrivateData(_In_ REFGUID guid,_In_ UINT DataSize, - _In_reads_bytes_opt_(DataSize) const void* pData) override; - HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(_In_ REFGUID guid,_In_opt_ const IUnknown* pData) override; - HRESULT STDMETHODCALLTYPE SetName(const wchar_t* name) override; - - // ID3D11Resource - void STDMETHODCALLTYPE GetType(_Out_ D3D11_RESOURCE_DIMENSION* pResourceDimension) override; - void STDMETHODCALLTYPE SetEvictionPriority(_In_ UINT EvictionPriority) override; - UINT STDMETHODCALLTYPE GetEvictionPriority(void) override; - void STDMETHODCALLTYPE GetDescriptor(D3D11X_DESCRIPTOR_RESOURCE* descriptor) override; - - // ID3D11Texture2D - void STDMETHODCALLTYPE GetDesc(_Out_ D3D11_TEXTURE2D_DESC* pDesc) override; - }; - - class ID3D11Texture3DWrapper : public ID3D11Texture3D_X - { - public: - ID3D11Texture3D* m_realTexture; - - ID3D11Texture3DWrapper(::ID3D11Texture3D* tex) : m_realTexture(tex) - { - m_RefCount = 1; - } - - - // IGraphicsUnknown - HRESULT QueryInterface(REFIID riid, void** ppvObject) override; - ULONG AddRef() override; - ULONG Release() override; - - // ID3D11DeviceChild - void STDMETHODCALLTYPE GetDevice(_Outptr_ ID3D11Device** ppDevice) override; - HRESULT STDMETHODCALLTYPE GetPrivateData(_In_ REFGUID guid, _Inout_ UINT* pDataSize, - _Out_writes_bytes_opt_(*pDataSize) void* pData) override; - HRESULT STDMETHODCALLTYPE SetPrivateData(_In_ REFGUID guid, _In_ UINT DataSize, - _In_reads_bytes_opt_(DataSize) const void* pData) override; - HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(_In_ REFGUID guid, _In_opt_ const IUnknown* pData) override; - HRESULT STDMETHODCALLTYPE SetName(const wchar_t* name) override; - - // ID3D11Resource - void STDMETHODCALLTYPE GetType(_Out_ D3D11_RESOURCE_DIMENSION* pResourceDimension) override; - void STDMETHODCALLTYPE SetEvictionPriority(_In_ UINT EvictionPriority) override; - UINT STDMETHODCALLTYPE GetEvictionPriority(void) override; - void STDMETHODCALLTYPE GetDescriptor(D3D11X_DESCRIPTOR_RESOURCE* descriptor) override; - - // ID3D11Texture3D - void STDMETHODCALLTYPE GetDesc(_Out_ D3D11_TEXTURE3D_DESC* pDesc) override; - }; - - class ID3D11RenderTargetViewWrapper : ID3D11RenderTargetView_X - { - public: - ID3D11RenderTargetView* m_realTarget; - - ID3D11RenderTargetViewWrapper(::ID3D11RenderTargetView* tex) : m_realTarget(tex) - { - this->m_pResource = reinterpret_cast<::ID3D11Resource*>(m_realTarget); - m_RefCount = 1; - } - - - // IGraphicsUnknown - HRESULT QueryInterface(REFIID riid, void** ppvObject) override; - ULONG AddRef() override; - ULONG Release() override; - - // ID3D11DeviceChild - void STDMETHODCALLTYPE GetDevice(_Outptr_ ID3D11Device** ppDevice) override; - HRESULT STDMETHODCALLTYPE GetPrivateData(_In_ REFGUID guid, _Inout_ UINT* pDataSize, - _Out_writes_bytes_opt_(*pDataSize) void* pData) override; - HRESULT STDMETHODCALLTYPE SetPrivateData(_In_ REFGUID guid, _In_ UINT DataSize, - _In_reads_bytes_opt_(DataSize) const void* pData) override; - HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(_In_ REFGUID guid, _In_opt_ const IUnknown* pData) override; - HRESULT STDMETHODCALLTYPE SetName(const wchar_t* name) override; - - // ID3D11View - void STDMETHODCALLTYPE GetResource( - _Outptr_ ID3D11Resource** ppResource) override; - - - // ID3D11RenderTargetView - void STDMETHODCALLTYPE GetDesc( - _Out_ D3D11_RENDER_TARGET_VIEW_DESC* pDesc) override; - }; - - class ID3D11DepthStencilViewWrapper : ID3D11DepthStencilView_X - { - public: - ID3D11DepthStencilView* m_realTarget; - - ID3D11DepthStencilViewWrapper(::ID3D11DepthStencilView* tex) : m_realTarget(tex) - { - this->m_pResource = reinterpret_cast<::ID3D11Resource*>(m_realTarget); - m_RefCount = 1; - } - - - // IGraphicsUnknown - HRESULT QueryInterface(REFIID riid, void** ppvObject) override; - ULONG AddRef() override; - ULONG Release() override; - - // ID3D11DeviceChild - void STDMETHODCALLTYPE GetDevice(_Outptr_ ID3D11Device** ppDevice) override; - HRESULT STDMETHODCALLTYPE GetPrivateData(_In_ REFGUID guid, _Inout_ UINT* pDataSize, - _Out_writes_bytes_opt_(*pDataSize) void* pData) override; - HRESULT STDMETHODCALLTYPE SetPrivateData(_In_ REFGUID guid, _In_ UINT DataSize, - _In_reads_bytes_opt_(DataSize) const void* pData) override; - HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(_In_ REFGUID guid, _In_opt_ const IUnknown* pData) override; - HRESULT STDMETHODCALLTYPE SetName(const wchar_t* name) override; - - // ID3D11View - void STDMETHODCALLTYPE GetResource( - _Outptr_ ID3D11Resource** ppResource) override; - - - // ID3D11DepthStencilView - void STDMETHODCALLTYPE GetDesc( - _Out_ D3D11_DEPTH_STENCIL_VIEW_DESC* pDesc) override; - }; - - class ID3D11ShaderResourceViewWrapper : ID3D11ShaderResourceView_X - { - public: - ID3D11ShaderResourceView* m_realTarget; - - ID3D11ShaderResourceViewWrapper(::ID3D11ShaderResourceView* tex) : m_realTarget(tex) - { - this->m_pResource = reinterpret_cast<::ID3D11Resource*>(m_realTarget); - m_RefCount = 1; - } - - - // IGraphicsUnknown - HRESULT QueryInterface(REFIID riid, void** ppvObject) override; - ULONG AddRef() override; - ULONG Release() override; - - // ID3D11DeviceChild - void STDMETHODCALLTYPE GetDevice(_Outptr_ ID3D11Device** ppDevice) override; - HRESULT STDMETHODCALLTYPE GetPrivateData(_In_ REFGUID guid, _Inout_ UINT* pDataSize, - _Out_writes_bytes_opt_(*pDataSize) void* pData) override; - HRESULT STDMETHODCALLTYPE SetPrivateData(_In_ REFGUID guid, _In_ UINT DataSize, - _In_reads_bytes_opt_(DataSize) const void* pData) override; - HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(_In_ REFGUID guid, _In_opt_ const IUnknown* pData) override; - HRESULT STDMETHODCALLTYPE SetName(const wchar_t* name) override; - - // ID3D11View - void STDMETHODCALLTYPE GetResource( - _Outptr_ ID3D11Resource** ppResource) override; - - - // ID3D11ShaderResourceView - void STDMETHODCALLTYPE GetDesc( - _Out_ D3D11_SHADER_RESOURCE_VIEW_DESC* pDesc) override; - }; - - class ID3D11UnorderedAccessViewWrapper : ID3D11UnorderedAccessView_X - { - public: - ID3D11UnorderedAccessView* m_realTarget; - - ID3D11UnorderedAccessViewWrapper(::ID3D11UnorderedAccessView* tex) : m_realTarget(tex) - { - this->m_pResource = reinterpret_cast<::ID3D11Resource*>(m_realTarget); - m_RefCount = 1; - } - - - // IGraphicsUnknown - HRESULT QueryInterface(REFIID riid, void** ppvObject) override; - ULONG AddRef() override; - ULONG Release() override; - - // ID3D11DeviceChild - void STDMETHODCALLTYPE GetDevice(_Outptr_ ID3D11Device** ppDevice) override; - HRESULT STDMETHODCALLTYPE GetPrivateData(_In_ REFGUID guid, _Inout_ UINT* pDataSize, - _Out_writes_bytes_opt_(*pDataSize) void* pData) override; - HRESULT STDMETHODCALLTYPE SetPrivateData(_In_ REFGUID guid, _In_ UINT DataSize, - _In_reads_bytes_opt_(DataSize) const void* pData) override; - HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(_In_ REFGUID guid, _In_opt_ const IUnknown* pData) override; - HRESULT STDMETHODCALLTYPE SetName(const wchar_t* name) override; - - // ID3D11View - void STDMETHODCALLTYPE GetResource( - _Outptr_ ID3D11Resource** ppResource) override; - - - // ID3D11UnorderedAccessView - void STDMETHODCALLTYPE GetDesc( - _Out_ D3D11_UNORDERED_ACCESS_VIEW_DESC* pDesc) override; - }; - - - //MIDL_INTERFACE("c0bfa96c-e089-44fb-8eaf-26f8796190da") - class ID3D11DeviceContextXWrapper : public ID3D11DeviceChild_X - { - public: - ID3D11DeviceContextXWrapper(::ID3D11DeviceContext2* pDeviceCtx) : m_realDeviceCtx(pDeviceCtx) - { - m_RefCount = 1; - InitFunctionsTables(); - } - - - virtual void STDMETHODCALLTYPE VSSetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers) - { - if (ppConstantBuffers != nullptr && *ppConstantBuffers != nullptr) - { - ID3D11Buffer* modifiedBuffers[ D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT ]; - for (UINT i = 0; i < NumBuffers; ++i) - { - modifiedBuffers[i] = reinterpret_cast(ppConstantBuffers[i])->m_realBuffer; - } - m_realDeviceCtx->VSSetConstantBuffers(StartSlot, NumBuffers, modifiedBuffers); - } - else - { - m_realDeviceCtx->VSSetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); - } - } - - virtual void STDMETHODCALLTYPE PSSetShaderResources( - ID3D11ShaderResourceView* const* ppShaderResourceViews, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_ UINT PacketHeader) - { - UINT NumViews = (PacketHeader >> 19) + 1; - - if (ppShaderResourceViews != NULL) - { - ID3D11ShaderResourceView* modifiedViews[ D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT ]; - - for (UINT i = 0; i < NumViews; i++) - { - if (ppShaderResourceViews[i] == nullptr) - modifiedViews[i] = nullptr; - else - modifiedViews[i] = reinterpret_cast(ppShaderResourceViews[i]) - ->m_realTarget; - } - m_realDeviceCtx->PSSetShaderResources(StartSlot, NumViews, modifiedViews); - } - else - { - m_realDeviceCtx->PSSetShaderResources(StartSlot, NumViews, ppShaderResourceViews); - } - } - - virtual void STDMETHODCALLTYPE PSSetShader( - _In_opt_ ID3D11PixelShader* pPixelShader, - _In_reads_opt_(NumClassInstances) ID3D11ClassInstance* const* ppClassInstances, - UINT NumClassInstances) - { - m_realDeviceCtx->PSSetShader(pPixelShader, nullptr, 0); - } - - virtual void STDMETHODCALLTYPE PSSetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _In_reads_opt_(NumSamplers) ID3D11SamplerState* const* ppSamplers) - { - m_realDeviceCtx->PSSetSamplers(StartSlot, NumSamplers, ppSamplers); - } - - virtual void STDMETHODCALLTYPE VSSetShader( - _In_opt_ ID3D11VertexShader* pVertexShader, - _In_reads_opt_(NumClassInstances) ID3D11ClassInstance* const* ppClassInstances, - UINT NumClassInstances) - { - m_realDeviceCtx->VSSetShader(pVertexShader, nullptr, 0); - } - - virtual void STDMETHODCALLTYPE DrawIndexed( - _In_ UINT64 StartIndexLocationAndIndexCount, - _In_ INT BaseVertexLocation) - { - UINT StartIndexLocation = static_cast(StartIndexLocationAndIndexCount & 0xFFFFFFFF); - UINT IndexCount = static_cast((StartIndexLocationAndIndexCount >> 32) & 0xFFFFFFFF); - - ProcessDirtyFlags(); - m_realDeviceCtx->DrawIndexed(IndexCount, StartIndexLocation, BaseVertexLocation); - } - - void ProcessDirtyFlags() - { - // 0x46 = topology dirty flag - if (m_ShaderUserDataManagerDraw.m_DirtyFlags & 0x46) - { - m_ShaderUserDataManagerDraw.m_DirtyFlags &= ~0x46; - int topology = D3D11X_HARDWARE_TO_TOPOLOGY_MAP.at(m_ShaderUserDataManagerDraw.m_Topology); - // assert for xbox-one specific topology - assert(!(topology == 6 || topology == 17 || topology == 18 || topology == 19 || topology == 20)); - - m_realDeviceCtx->IASetPrimitiveTopology(static_cast(topology)); - } - - // 0x89 = input layout dirty flag - if (m_ShaderUserDataManagerDraw.m_DirtyFlags & 0x89) - { - m_ShaderUserDataManagerDraw.m_DirtyFlags &= ~0x89; - m_realDeviceCtx->IASetInputLayout(m_ShaderUserDataManagerDraw.m_pInputLayout); - } - - // 0x91 = vertex shader dirty flag - if (m_ShaderUserDataManagerDraw.m_DirtyFlags & 0x91) - { - m_ShaderUserDataManagerDraw.m_DirtyFlags &= ~0x91; - m_realDeviceCtx->VSSetShader(m_ShaderUserDataManagerDraw.m_pVs, nullptr, 0); - } - - // 0x121 = pixel shader dirty flag - if (m_ShaderUserDataManagerDraw.m_DirtyFlags & 0x121) - { - m_ShaderUserDataManagerDraw.m_DirtyFlags &= ~0x121; - m_realDeviceCtx->PSSetShader(m_ShaderUserDataManagerDraw.m_pPs, nullptr, 0); - } - } - - virtual void STDMETHODCALLTYPE Draw( - _In_ UINT VertexCount, - _In_ UINT StartVertexLocation) - { - ProcessDirtyFlags(); - m_realDeviceCtx->Draw(VertexCount, StartVertexLocation); - } - - virtual HRESULT STDMETHODCALLTYPE Map( - _In_ ID3D11Resource* pResource, - _In_ UINT Subresource, - _In_ D3D11_MAP MapType, - _In_ UINT MapFlags, - _Out_opt_ D3D11_MAPPED_SUBRESOURCE* pMappedResource) - { - return m_realDeviceCtx->Map(reinterpret_cast(pResource)->m_realResource, - Subresource, MapType, MapFlags, pMappedResource); - } - - virtual void STDMETHODCALLTYPE Unmap( - _In_ ID3D11Resource* pResource, - _In_ UINT Subresource) - { - m_realDeviceCtx->Unmap(reinterpret_cast(pResource)->m_realResource, Subresource); - } - - virtual void STDMETHODCALLTYPE PSSetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers) - { - if (ppConstantBuffers != nullptr && *ppConstantBuffers != nullptr) - { - ID3D11Buffer** modifiedBuffers = new ID3D11Buffer*[NumBuffers]; - for (UINT i = 0; i < NumBuffers; ++i) - { - modifiedBuffers[i] = reinterpret_cast(ppConstantBuffers[i])->m_realBuffer; - } - m_realDeviceCtx->PSSetConstantBuffers(StartSlot, NumBuffers, modifiedBuffers); - } - else - { - m_realDeviceCtx->PSSetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); - } - } - - virtual void STDMETHODCALLTYPE IASetInputLayout( - - _In_opt_ ID3D11InputLayout* pInputLayout) - { - m_realDeviceCtx->IASetInputLayout(pInputLayout); - } - - virtual void STDMETHODCALLTYPE IASetVertexBuffers( - _In_range_(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppVertexBuffers, - _In_reads_opt_(NumBuffers) const UINT* pStrides, - _In_reads_opt_(NumBuffers) const UINT* pOffsets) - { - if (NumBuffers > D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT - StartSlot) - assert("Too many vertex buffers"); - - if (ppVertexBuffers != NULL) - { - ID3D11Buffer* modifiedBuffers[ D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT ]; - for (UINT i = 0; i < NumBuffers; i++) - { - if (ppVertexBuffers[i] == nullptr) - modifiedBuffers[i] = nullptr; - else - modifiedBuffers[i] = reinterpret_cast(ppVertexBuffers[i])->m_realBuffer; - } - - m_realDeviceCtx->IASetVertexBuffers(StartSlot, NumBuffers, modifiedBuffers, pStrides, pOffsets); - } - else - { - m_realDeviceCtx->IASetVertexBuffers(StartSlot, NumBuffers, ppVertexBuffers, pStrides, pOffsets); - } - } - - virtual void STDMETHODCALLTYPE IASetIndexBuffer( - // @Patoke note: this one changes prototype - _In_ UINT HardwareIndexFormat, - _In_opt_ ID3D11Buffer* pIndexBuffer, - _In_ UINT Offset) - { - DXGI_FORMAT Format = HardwareIndexFormat == 1 ? DXGI_FORMAT_R32_UINT : DXGI_FORMAT_R16_UINT; - - if (pIndexBuffer == nullptr) - { - return m_realDeviceCtx->IASetIndexBuffer(pIndexBuffer, Format, Offset); - } - - m_realDeviceCtx->IASetIndexBuffer(reinterpret_cast(pIndexBuffer)->m_realBuffer, - Format, Offset); - } - - virtual void STDMETHODCALLTYPE DrawIndexedInstanced( - _In_ UINT64 StartIndexLocationAndIndexCountPerInstance, - _In_ UINT64 BaseVertexLocationAndStartInstanceLocation, - _In_ UINT InstanceCount) - { - UINT StartIndexLocation = static_cast(StartIndexLocationAndIndexCountPerInstance & 0xFFFFFFFF); - UINT IndexCountPerInstance = static_cast((StartIndexLocationAndIndexCountPerInstance >> 32) & - 0xFFFFFFFF); - - UINT BaseVertexLocation = static_cast(BaseVertexLocationAndStartInstanceLocation & 0xFFFFFFFF); - UINT StartInstanceLocation = static_cast((BaseVertexLocationAndStartInstanceLocation >> 32) & - 0xFFFFFFFF); - - ProcessDirtyFlags(); - m_realDeviceCtx->DrawIndexedInstanced(IndexCountPerInstance, InstanceCount, StartIndexLocation, - BaseVertexLocation, StartInstanceLocation); - } - - virtual void STDMETHODCALLTYPE DrawInstanced( - _In_ UINT VertexCountPerInstance, - _In_ UINT64 StartVertexLocationAndStartInstanceLocation, - _In_ UINT InstanceCount) - { - UINT StartVertexLocation = static_cast(StartVertexLocationAndStartInstanceLocation & 0xFFFFFFFF); - UINT StartInstanceLocation = static_cast((StartVertexLocationAndStartInstanceLocation >> 32) & - 0xFFFFFFFF); - - ProcessDirtyFlags(); - m_realDeviceCtx->DrawInstanced(VertexCountPerInstance, InstanceCount, StartVertexLocation, - StartInstanceLocation); - } - - virtual void STDMETHODCALLTYPE GSSetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers) - { - if (ppConstantBuffers != nullptr && *ppConstantBuffers != nullptr) - { - ID3D11Buffer** modifiedBuffers = new ID3D11Buffer*[NumBuffers]; - for (UINT i = 0; i < NumBuffers; ++i) - { - modifiedBuffers[i] = reinterpret_cast(ppConstantBuffers[i])->m_realBuffer; - } - m_realDeviceCtx->GSSetConstantBuffers(StartSlot, NumBuffers, modifiedBuffers); - } - else - { - m_realDeviceCtx->GSSetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); - } - } - - virtual void STDMETHODCALLTYPE GSSetShader( - _In_opt_ ID3D11GeometryShader* pShader, - _In_reads_opt_(NumClassInstances) ID3D11ClassInstance* const* ppClassInstances, - UINT NumClassInstances) - { - m_realDeviceCtx->GSSetShader(pShader, nullptr, 0); - } - - - virtual void STDMETHODCALLTYPE VSSetShaderResources( - _In_reads_opt_(NumViews) ID3D11ShaderResourceView* const* ppShaderResourceViews, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT PacketHeader) - { - if (PacketHeader < 0) - { - return; - } - - UINT NumViews = (PacketHeader >> 19) + 1; - - if (ppShaderResourceViews != NULL) - { - ID3D11ShaderResourceView** modifiedViews = new ID3D11ShaderResourceView*[NumViews]{0}; - - for (UINT i = 0; i < NumViews; i++) - { - if (ppShaderResourceViews[i] == nullptr) - modifiedViews[i] = nullptr; - else - modifiedViews[i] = reinterpret_cast(ppShaderResourceViews[i]) - ->m_realTarget; - } - m_realDeviceCtx->VSSetShaderResources(StartSlot, NumViews, modifiedViews); - } - else - { - m_realDeviceCtx->VSSetShaderResources(StartSlot, NumViews, ppShaderResourceViews); - } - } - - virtual void STDMETHODCALLTYPE VSSetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _In_reads_opt_(NumSamplers) ID3D11SamplerState* const* ppSamplers) - { - m_realDeviceCtx->VSSetSamplers(StartSlot, NumSamplers, ppSamplers); - } - - virtual void STDMETHODCALLTYPE Begin( - _In_ ID3D11Asynchronous* pAsync) - { - m_realDeviceCtx->Begin(pAsync); - } - - virtual void STDMETHODCALLTYPE End( - _In_ ID3D11Asynchronous* pAsync) - { - m_realDeviceCtx->End(pAsync); - } - - virtual HRESULT STDMETHODCALLTYPE GetData( - _In_ ID3D11Asynchronous* pAsync, - _Out_writes_bytes_opt_(DataSize) void* pData, - _In_ UINT DataSize, - _In_ UINT GetDataFlags) - { - return m_realDeviceCtx->GetData(pAsync, pData, DataSize, GetDataFlags); - } - - virtual void STDMETHODCALLTYPE SetPredication( - _In_opt_ ID3D11Predicate* pPredicate, - _In_ BOOL PredicateValue) - { - m_realDeviceCtx->SetPredication(pPredicate, PredicateValue); - } - - virtual void STDMETHODCALLTYPE GSSetShaderResources( - _In_reads_opt_(NumViews) ID3D11ShaderResourceView* const* ppShaderResourceViews, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT PacketHeader) - { - if (PacketHeader < 0) - { - return; - } - - UINT NumViews = (PacketHeader >> 19) + 1; - - if (ppShaderResourceViews != NULL) - { - ID3D11ShaderResourceView** modifiedViews = new ID3D11ShaderResourceView*[NumViews]{0}; - - for (UINT i = 0; i < NumViews; i++) - { - if (ppShaderResourceViews[i] == nullptr) - modifiedViews[i] = nullptr; - else - modifiedViews[i] = reinterpret_cast(ppShaderResourceViews[i]) - ->m_realTarget; - } - m_realDeviceCtx->GSSetShaderResources(StartSlot, NumViews, modifiedViews); - } - else - { - m_realDeviceCtx->GSSetShaderResources(StartSlot, NumViews, ppShaderResourceViews); - } - } - - virtual void STDMETHODCALLTYPE GSSetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _In_reads_opt_(NumSamplers) ID3D11SamplerState* const* ppSamplers) - { - m_realDeviceCtx->GSSetSamplers(StartSlot, NumSamplers, ppSamplers); - } - - virtual void STDMETHODCALLTYPE OMSetRenderTargets( - _In_range_(0, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT) UINT NumViews, - _In_reads_opt_(NumViews) ID3D11RenderTargetView* const* ppRenderTargetViews, - _In_opt_ ID3D11DepthStencilView_X* pDepthStencilView) - { - auto* depthStencilView = reinterpret_cast(pDepthStencilView); - if (depthStencilView != nullptr) - depthStencilView = reinterpret_cast(pDepthStencilView)->m_realTarget; - - if (ppRenderTargetViews != NULL) - { - ID3D11RenderTargetView** modifiedViews = new ID3D11RenderTargetView*[NumViews]{0}; - for (UINT i = 0; i < NumViews; i++) - { - if (ppRenderTargetViews[i] == nullptr) - modifiedViews[i] = nullptr; - else - modifiedViews[i] = reinterpret_cast(ppRenderTargetViews[i])-> - m_realTarget; - } - m_realDeviceCtx->OMSetRenderTargets(NumViews, modifiedViews, depthStencilView); - } - else - { - m_realDeviceCtx->OMSetRenderTargets(NumViews, ppRenderTargetViews, depthStencilView); - } - } - - virtual void STDMETHODCALLTYPE OMSetRenderTargetsAndUnorderedAccessViews( - _In_ UINT NumRTVs, - _In_reads_opt_(NumRTVs) ID3D11RenderTargetView* const* ppRenderTargetViews, - _In_opt_ ID3D11DepthStencilView* pDepthStencilView, - _In_range_(0, D3D11_1_UAV_SLOT_COUNT - 1) UINT UAVStartSlot, - _In_ UINT NumUAVs, - _In_reads_opt_(NumUAVs) ID3D11UnorderedAccessView* const* ppUnorderedAccessViews, - _In_reads_opt_(NumUAVs) const UINT* pUAVInitialCounts) - { - m_realDeviceCtx->OMSetRenderTargetsAndUnorderedAccessViews(NumRTVs, ppRenderTargetViews, pDepthStencilView, - UAVStartSlot, NumUAVs, ppUnorderedAccessViews, - pUAVInitialCounts); - } - - virtual void STDMETHODCALLTYPE OMSetBlendState( - _In_opt_ ID3D11BlendState* pBlendState, - _In_opt_ const FLOAT BlendFactor[4], - _In_ UINT SampleMask) - { - m_realDeviceCtx->OMSetBlendState(pBlendState, BlendFactor, SampleMask); - } - - virtual void STDMETHODCALLTYPE OMSetDepthStencilState( - _In_opt_ ID3D11DepthStencilState* pDepthStencilState, - _In_ UINT StencilRef) - { - m_realDeviceCtx->OMSetDepthStencilState(pDepthStencilState, StencilRef); - } - - virtual void STDMETHODCALLTYPE SOSetTargets( - _In_range_(0, D3D11_SO_BUFFER_SLOT_COUNT) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppSOTargets, - _In_reads_opt_(NumBuffers) const UINT* pOffsets) - { - m_realDeviceCtx->SOSetTargets(NumBuffers, ppSOTargets, pOffsets); - } - - virtual void STDMETHODCALLTYPE DrawAuto(void) - { - m_realDeviceCtx->DrawAuto(); - } - - virtual void STDMETHODCALLTYPE DrawIndexedInstancedIndirect( - _In_ ID3D11Buffer* pBufferForArgs, - _In_ UINT AlignedByteOffsetForArgs) - { - m_realDeviceCtx->DrawIndexedInstancedIndirect( - reinterpret_cast(pBufferForArgs)->m_realBuffer, AlignedByteOffsetForArgs); - } - - virtual void STDMETHODCALLTYPE DrawInstancedIndirect( - _In_ ID3D11Buffer* pBufferForArgs, - _In_ UINT AlignedByteOffsetForArgs) - { - m_realDeviceCtx->DrawInstancedIndirect(reinterpret_cast(pBufferForArgs)->m_realBuffer, - AlignedByteOffsetForArgs); - } - - virtual void STDMETHODCALLTYPE Dispatch( - _In_ UINT ThreadGroupCountX, - _In_ UINT ThreadGroupCountY, - _In_ UINT ThreadGroupCountZ) - { - m_realDeviceCtx->Dispatch(ThreadGroupCountX, ThreadGroupCountY, ThreadGroupCountZ); - } - - virtual void STDMETHODCALLTYPE DispatchIndirect( - _In_ ID3D11Buffer* pBufferForArgs, - _In_ UINT AlignedByteOffsetForArgs) - { - m_realDeviceCtx->DispatchIndirect(reinterpret_cast(pBufferForArgs)->m_realBuffer, - AlignedByteOffsetForArgs); - } - - virtual void STDMETHODCALLTYPE RSSetState( - _In_opt_ ID3D11RasterizerState* pRasterizerState) - { - m_realDeviceCtx->RSSetState(pRasterizerState); - } - - virtual void STDMETHODCALLTYPE RSSetViewports( - _In_range_(0, D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumViewports, - _In_reads_opt_(NumViewports) const D3D11_VIEWPORT* pViewports) - { - m_realDeviceCtx->RSSetViewports(NumViewports, pViewports); - } - - virtual void STDMETHODCALLTYPE RSSetScissorRects( - _In_range_(0, D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumRects, - _In_reads_opt_(NumRects) const D3D11_RECT* pRects) - { - m_realDeviceCtx->RSSetScissorRects(NumRects, pRects); - } - - virtual void STDMETHODCALLTYPE CopySubresourceRegion( - _In_ ID3D11Resource* pDstResource, - _In_ UINT DstSubresource, - _In_ UINT DstX, - _In_ UINT DstY, - _In_ UINT DstZ, - _In_ ID3D11Resource* pSrcResource, - _In_ UINT SrcSubresource, - _In_opt_ const D3D11_BOX* pSrcBox) - { - m_realDeviceCtx->CopySubresourceRegion( - reinterpret_cast(pDstResource)->m_realResource, DstSubresource, DstX, DstY, - DstZ, reinterpret_cast(pSrcResource)->m_realResource, SrcSubresource, pSrcBox); - } - - virtual void STDMETHODCALLTYPE CopyResource( - _In_ ID3D11Resource* pDstResource, - _In_ ID3D11Resource* pSrcResource) - { - m_realDeviceCtx->CopyResource(reinterpret_cast(pDstResource)->m_realResource, - reinterpret_cast(pSrcResource)->m_realResource); - } - - virtual void STDMETHODCALLTYPE UpdateSubresource( - _In_ ID3D11Resource* pDstResource, - _In_ UINT DstSubresource, - _In_opt_ const D3D11_BOX* pDstBox, - _In_ const void* pSrcData, - _In_ UINT SrcRowPitch, - _In_ UINT SrcDepthPitch) - { - m_realDeviceCtx->UpdateSubresource(reinterpret_cast(pDstResource)->m_realResource, - DstSubresource, pDstBox, pSrcData, SrcRowPitch, SrcDepthPitch); - } - - virtual void STDMETHODCALLTYPE CopyStructureCount( - _In_ ID3D11Buffer* pDstBuffer, - _In_ UINT DstAlignedByteOffset, - _In_ ID3D11UnorderedAccessView* pSrcView) - { - m_realDeviceCtx->CopyStructureCount(reinterpret_cast(pDstBuffer)->m_realBuffer, - DstAlignedByteOffset, - reinterpret_cast(pSrcView)-> - m_realTarget); - } - - virtual void STDMETHODCALLTYPE ClearRenderTargetView( - _In_ ID3D11RenderTargetView* pRenderTargetView, - _In_ const FLOAT ColorRGBA[4]) - { - m_realDeviceCtx->ClearRenderTargetView( - reinterpret_cast(pRenderTargetView)->m_realTarget, ColorRGBA); - } - - virtual void STDMETHODCALLTYPE ClearUnorderedAccessViewUint( - _In_ ID3D11UnorderedAccessView* pUnorderedAccessView, - _In_ const UINT Values[4]) - { - m_realDeviceCtx->ClearUnorderedAccessViewUint( - reinterpret_cast(pUnorderedAccessView)->m_realTarget, Values); - } - - virtual void STDMETHODCALLTYPE ClearUnorderedAccessViewFloat( - _In_ ID3D11UnorderedAccessView* pUnorderedAccessView, - _In_ const FLOAT Values[4]) - { - m_realDeviceCtx->ClearUnorderedAccessViewFloat( - reinterpret_cast(pUnorderedAccessView)->m_realTarget, Values); - } - - virtual void STDMETHODCALLTYPE ClearDepthStencilView( - _In_ ID3D11DepthStencilView* pDepthStencilView, - _In_ UINT ClearFlags, - _In_ FLOAT Depth, - _In_ UINT8 Stencil) - { - m_realDeviceCtx->ClearDepthStencilView( - reinterpret_cast(pDepthStencilView)->m_realTarget, ClearFlags, Depth, - Stencil); - } - - virtual void STDMETHODCALLTYPE GenerateMips( - _In_ ID3D11ShaderResourceView* pShaderResourceView) - { - m_realDeviceCtx->GenerateMips( - reinterpret_cast(pShaderResourceView)->m_realTarget); - } - - virtual void STDMETHODCALLTYPE SetResourceMinLOD( - _In_ ID3D11Resource* pResource, - FLOAT MinLOD) - { - m_realDeviceCtx->SetResourceMinLOD(reinterpret_cast(pResource)->m_realResource, - MinLOD); - } - - virtual FLOAT STDMETHODCALLTYPE GetResourceMinLOD( - _In_ ID3D11Resource* pResource) - { - return m_realDeviceCtx->GetResourceMinLOD( - reinterpret_cast(pResource)->m_realResource); - } - - virtual void STDMETHODCALLTYPE ResolveSubresource( - _In_ ID3D11Resource* pDstResource, - _In_ UINT DstSubresource, - _In_ ID3D11Resource* pSrcResource, - _In_ UINT SrcSubresource, - _In_ DXGI_FORMAT Format) - { - m_realDeviceCtx->ResolveSubresource(reinterpret_cast(pDstResource)->m_realResource, - DstSubresource, - reinterpret_cast(pSrcResource)->m_realResource, - SrcSubresource, Format); - } - - virtual void STDMETHODCALLTYPE ExecuteCommandList( - _In_ ID3D11CommandList* pCommandList, - BOOL RestoreContextState) - { - m_realDeviceCtx->ExecuteCommandList(pCommandList, RestoreContextState); - } - - virtual void STDMETHODCALLTYPE HSSetShaderResources( - _In_reads_opt_(NumViews) ID3D11ShaderResourceView* const* ppShaderResourceViews, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT PacketHeader) - { - if (PacketHeader < 0) - { - return; - } - - UINT NumViews = (PacketHeader >> 19) + 1; - - if (ppShaderResourceViews != NULL) - { - ID3D11ShaderResourceView** modifiedViews = new ID3D11ShaderResourceView*[NumViews]{0}; - - for (UINT i = 0; i < NumViews; i++) - { - if (ppShaderResourceViews[i] == nullptr) - modifiedViews[i] = nullptr; - else - modifiedViews[i] = reinterpret_cast(ppShaderResourceViews[i]) - ->m_realTarget; - } - m_realDeviceCtx->HSSetShaderResources(StartSlot, NumViews, modifiedViews); - } - else - { - m_realDeviceCtx->HSSetShaderResources(StartSlot, NumViews, ppShaderResourceViews); - } - } - - virtual void STDMETHODCALLTYPE HSSetShader( - _In_opt_ ID3D11HullShader* pHullShader, - _In_reads_opt_(NumClassInstances) ID3D11ClassInstance* const* ppClassInstances, - UINT NumClassInstances) - { - m_realDeviceCtx->HSSetShader(pHullShader, nullptr, 0); - } - - virtual void STDMETHODCALLTYPE HSSetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _In_reads_opt_(NumSamplers) ID3D11SamplerState* const* ppSamplers) - { - m_realDeviceCtx->HSSetSamplers(StartSlot, NumSamplers, ppSamplers); - } - - virtual void STDMETHODCALLTYPE HSSetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers) - { - if (ppConstantBuffers != nullptr && *ppConstantBuffers != nullptr) - { - ID3D11Buffer** modifiedBuffers = new ID3D11Buffer*[NumBuffers]; - for (UINT i = 0; i < NumBuffers; ++i) - { - modifiedBuffers[i] = reinterpret_cast(ppConstantBuffers[i])->m_realBuffer; - } - m_realDeviceCtx->HSSetConstantBuffers(StartSlot, NumBuffers, modifiedBuffers); - } - else - { - m_realDeviceCtx->HSSetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); - } - } - - virtual void STDMETHODCALLTYPE DSSetShaderResources( - _In_reads_opt_(NumViews) ID3D11ShaderResourceView* const* ppShaderResourceViews, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT PacketHeader) - { - if (PacketHeader < 0) - { - return; - } - - UINT NumViews = (PacketHeader >> 19) + 1; - - if (ppShaderResourceViews != NULL) - { - ID3D11ShaderResourceView** modifiedViews = new ID3D11ShaderResourceView*[NumViews]{0}; - - for (UINT i = 0; i < NumViews; i++) - { - if (ppShaderResourceViews[i] == nullptr) - modifiedViews[i] = nullptr; - else - modifiedViews[i] = reinterpret_cast(ppShaderResourceViews[i]) - ->m_realTarget; - } - m_realDeviceCtx->HSSetShaderResources(StartSlot, NumViews, modifiedViews); - } - else - { - m_realDeviceCtx->HSSetShaderResources(StartSlot, NumViews, ppShaderResourceViews); - } - } - - virtual void STDMETHODCALLTYPE DSSetShader( - _In_opt_ ID3D11DomainShader* pDomainShader, - _In_reads_opt_(NumClassInstances) ID3D11ClassInstance* const* ppClassInstances, - UINT NumClassInstances) - { - m_realDeviceCtx->DSSetShader(pDomainShader, nullptr, 0); - } - - virtual void STDMETHODCALLTYPE DSSetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _In_reads_opt_(NumSamplers) ID3D11SamplerState* const* ppSamplers) - { - m_realDeviceCtx->DSSetSamplers(StartSlot, NumSamplers, ppSamplers); - } - - virtual void STDMETHODCALLTYPE DSSetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers) - { - if (ppConstantBuffers != nullptr && *ppConstantBuffers != nullptr) - { - ID3D11Buffer** modifiedBuffers = new ID3D11Buffer*[NumBuffers]; - for (UINT i = 0; i < NumBuffers; ++i) - { - modifiedBuffers[i] = reinterpret_cast(ppConstantBuffers[i])->m_realBuffer; - } - m_realDeviceCtx->DSSetConstantBuffers(StartSlot, NumBuffers, modifiedBuffers); - } - else - { - m_realDeviceCtx->DSSetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); - } - } - - virtual void STDMETHODCALLTYPE CSSetShaderResources( - _In_reads_opt_(NumViews) ID3D11ShaderResourceView* const* ppShaderResourceViews, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT PacketHeader) - { - if (PacketHeader < 0) - { - return; - } - - UINT NumViews = (PacketHeader >> 19) + 1; - - if (ppShaderResourceViews != NULL) - { - ID3D11ShaderResourceView** modifiedViews = new ID3D11ShaderResourceView*[NumViews]{0}; - - for (UINT i = 0; i < NumViews; i++) - { - if (ppShaderResourceViews[i] == nullptr) - modifiedViews[i] = nullptr; - else - modifiedViews[i] = reinterpret_cast(ppShaderResourceViews[i]) - ->m_realTarget; - } - m_realDeviceCtx->HSSetShaderResources(StartSlot, NumViews, modifiedViews); - } - else - { - m_realDeviceCtx->HSSetShaderResources(StartSlot, NumViews, ppShaderResourceViews); - } - } - - // @Patoke todo: unwrap - virtual void STDMETHODCALLTYPE CSSetUnorderedAccessViews( - _In_range_(0, D3D11_1_UAV_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_1_UAV_SLOT_COUNT - StartSlot) UINT NumUAVs, - _In_reads_opt_(NumUAVs) ID3D11UnorderedAccessView* const* ppUnorderedAccessViews, - _In_reads_opt_(NumUAVs) const UINT* pUAVInitialCounts) - { - m_realDeviceCtx->CSSetUnorderedAccessViews(StartSlot, NumUAVs, ppUnorderedAccessViews, pUAVInitialCounts); - } - - virtual void STDMETHODCALLTYPE CSSetShader( - _In_opt_ ID3D11ComputeShader* pComputeShader, - _In_reads_opt_(NumClassInstances) ID3D11ClassInstance* const* ppClassInstances, - UINT NumClassInstances) - { - m_realDeviceCtx->CSSetShader(pComputeShader, nullptr, 0); - } - - virtual void STDMETHODCALLTYPE CSSetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _In_reads_opt_(NumSamplers) ID3D11SamplerState* const* ppSamplers) - { - m_realDeviceCtx->CSSetSamplers(StartSlot, NumSamplers, ppSamplers); - } - - virtual void STDMETHODCALLTYPE CSSetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers) - { - if (ppConstantBuffers != nullptr && *ppConstantBuffers != nullptr) - { - ID3D11Buffer** modifiedBuffers = new ID3D11Buffer*[NumBuffers]; - for (UINT i = 0; i < NumBuffers; ++i) - { - modifiedBuffers[i] = reinterpret_cast(ppConstantBuffers[i])->m_realBuffer; - } - m_realDeviceCtx->CSSetConstantBuffers(StartSlot, NumBuffers, modifiedBuffers); - } - else - { - m_realDeviceCtx->CSSetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); - } - } - - virtual void STDMETHODCALLTYPE VSGetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers) - { - if (ppConstantBuffers != NULL) - { - ID3D11Buffer** unwrappedBuffers = new ID3D11Buffer*[NumBuffers]{0}; - - m_realDeviceCtx->VSGetConstantBuffers(StartSlot, NumBuffers, unwrappedBuffers); - - for (UINT i = 0; i < NumBuffers; ++i) - { - ppConstantBuffers[i] = reinterpret_cast(new - ID3D11BufferWrapper(unwrappedBuffers[i])); - } - } - else - { - m_realDeviceCtx->VSGetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); - } - } - - // @Patoke todo: wrap - virtual void STDMETHODCALLTYPE PSGetShaderResources( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews, - _Out_writes_opt_(NumViews) ID3D11ShaderResourceView** ppShaderResourceViews) - { - m_realDeviceCtx->PSGetShaderResources(StartSlot, NumViews, ppShaderResourceViews); - } - - virtual void STDMETHODCALLTYPE PSGetShader( - _Outptr_result_maybenull_ ID3D11PixelShader** ppPixelShader, - _Out_writes_opt_(*pNumClassInstances) ID3D11ClassInstance** ppClassInstances, - _Inout_opt_ UINT* pNumClassInstances) - { - m_realDeviceCtx->PSGetShader(ppPixelShader, ppClassInstances, pNumClassInstances); - } - - virtual void STDMETHODCALLTYPE PSGetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _Out_writes_opt_(NumSamplers) ID3D11SamplerState** ppSamplers) - { - m_realDeviceCtx->PSGetSamplers(StartSlot, NumSamplers, ppSamplers); - } - - virtual void STDMETHODCALLTYPE VSGetShader( - _Outptr_result_maybenull_ ID3D11VertexShader** ppVertexShader, - _Out_writes_opt_(*pNumClassInstances) ID3D11ClassInstance** ppClassInstances, - _Inout_opt_ UINT* pNumClassInstances) - { - m_realDeviceCtx->VSGetShader(ppVertexShader, ppClassInstances, pNumClassInstances); - } - - virtual void STDMETHODCALLTYPE PSGetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers) - { - if (ppConstantBuffers != NULL) - { - ID3D11Buffer** unwrappedBuffers = new ID3D11Buffer*[NumBuffers]{0}; - - m_realDeviceCtx->PSGetConstantBuffers(StartSlot, NumBuffers, unwrappedBuffers); - - for (UINT i = 0; i < NumBuffers; ++i) - { - ppConstantBuffers[i] = reinterpret_cast(new - ID3D11BufferWrapper(unwrappedBuffers[i])); - } - } - else - { - m_realDeviceCtx->PSGetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); - } - } - - virtual void STDMETHODCALLTYPE IAGetInputLayout( - _Outptr_result_maybenull_ ID3D11InputLayout** ppInputLayout) - { - m_realDeviceCtx->IAGetInputLayout(ppInputLayout); - } - - virtual void STDMETHODCALLTYPE IAGetVertexBuffers( - _In_range_(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppVertexBuffers, - _Out_writes_opt_(NumBuffers) UINT* pStrides, - _Out_writes_opt_(NumBuffers) UINT* pOffsets) - { - if (ppVertexBuffers != NULL) - { - ID3D11Buffer** unwrappedBuffers = new ID3D11Buffer*[NumBuffers]{0}; - - m_realDeviceCtx->IAGetVertexBuffers(StartSlot, NumBuffers, unwrappedBuffers, pStrides, pOffsets); - - for (UINT i = 0; i < NumBuffers; ++i) - { - ppVertexBuffers[i] = reinterpret_cast(new ID3D11BufferWrapper(unwrappedBuffers[i])); - } - } - else - { - m_realDeviceCtx->IAGetVertexBuffers(StartSlot, NumBuffers, ppVertexBuffers, pStrides, pOffsets); - } - } - - virtual void STDMETHODCALLTYPE IAGetIndexBuffer( - _Outptr_opt_result_maybenull_ ID3D11Buffer** pIndexBuffer, - _Out_opt_ DXGI_FORMAT* Format, - _Out_opt_ UINT* Offset) - { - m_realDeviceCtx->IAGetIndexBuffer(pIndexBuffer, Format, Offset); - - if (pIndexBuffer != nullptr) - { - *pIndexBuffer = pIndexBuffer - ? reinterpret_cast(new ID3D11BufferWrapper(*pIndexBuffer)) - : nullptr; - } - } - - virtual void STDMETHODCALLTYPE GSGetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers) - { - if (ppConstantBuffers != NULL) - { - ID3D11Buffer** unwrappedBuffers = new ID3D11Buffer*[NumBuffers]{0}; - - m_realDeviceCtx->GSGetConstantBuffers(StartSlot, NumBuffers, unwrappedBuffers); - - for (UINT i = 0; i < NumBuffers; ++i) - { - ppConstantBuffers[i] = reinterpret_cast(new - ID3D11BufferWrapper(unwrappedBuffers[i])); - } - } - else - { - m_realDeviceCtx->GSGetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); - } - } - - virtual void STDMETHODCALLTYPE GSGetShader( - _Outptr_result_maybenull_ ID3D11GeometryShader** ppGeometryShader, - _Out_writes_opt_(*pNumClassInstances) ID3D11ClassInstance** ppClassInstances, - _Inout_opt_ UINT* pNumClassInstances) - { - m_realDeviceCtx->GSGetShader(ppGeometryShader, ppClassInstances, pNumClassInstances); - } - - virtual void STDMETHODCALLTYPE IAGetPrimitiveTopology( - _Out_ D3D11_PRIMITIVE_TOPOLOGY* pTopology) - { - m_realDeviceCtx->IAGetPrimitiveTopology(pTopology); - } - - // @Patoke todo: wrap - virtual void STDMETHODCALLTYPE VSGetShaderResources( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews, - _Out_writes_opt_(NumViews) ID3D11ShaderResourceView** ppShaderResourceViews) - { - m_realDeviceCtx->VSGetShaderResources(StartSlot, NumViews, ppShaderResourceViews); - } - - virtual void STDMETHODCALLTYPE VSGetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _Out_writes_opt_(NumSamplers) ID3D11SamplerState** ppSamplers) - { - m_realDeviceCtx->VSGetSamplers(StartSlot, NumSamplers, ppSamplers); - } - - virtual void STDMETHODCALLTYPE GetPredication( - _Outptr_opt_result_maybenull_ ID3D11Predicate** ppPredicate, - _Out_opt_ BOOL* pPredicateValue) - { - m_realDeviceCtx->GetPredication(ppPredicate, pPredicateValue); - } - - // @Patoke todo: wrap - virtual void STDMETHODCALLTYPE GSGetShaderResources( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews, - _Out_writes_opt_(NumViews) ID3D11ShaderResourceView** ppShaderResourceViews) - { - m_realDeviceCtx->GSGetShaderResources(StartSlot, NumViews, ppShaderResourceViews); - } - - virtual void STDMETHODCALLTYPE GSGetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _Out_writes_opt_(NumSamplers) ID3D11SamplerState** ppSamplers) - { - m_realDeviceCtx->GSGetSamplers(StartSlot, NumSamplers, ppSamplers); - } - - virtual void STDMETHODCALLTYPE OMGetRenderTargets( - _In_range_(0, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT) UINT NumViews, - _Out_writes_opt_(NumViews) ID3D11RenderTargetView_X** ppRenderTargetViews, - _Outptr_opt_result_maybenull_ ID3D11DepthStencilView_X** ppDepthStencilView) - { - ::ID3D11RenderTargetView* target = nullptr; - ::ID3D11DepthStencilView* depth = nullptr; - m_realDeviceCtx->OMGetRenderTargets(NumViews, &target, &depth); - - if (ppRenderTargetViews != nullptr) - { - *ppRenderTargetViews = ppRenderTargetViews - ? reinterpret_cast(new - ID3D11RenderTargetViewWrapper(target)) - : nullptr; - } - - if (ppDepthStencilView != nullptr) - { - *ppDepthStencilView = ppDepthStencilView - ? reinterpret_cast(new - ID3D11DepthStencilViewWrapper(depth)) - : nullptr; - } - } - - // @Patoke todo: wrap - virtual void STDMETHODCALLTYPE OMGetRenderTargetsAndUnorderedAccessViews( - _In_range_(0, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT) UINT NumRTVs, - _Out_writes_opt_(NumRTVs) ID3D11RenderTargetView** ppRenderTargetViews, - _Outptr_opt_result_maybenull_ ID3D11DepthStencilView** ppDepthStencilView, - _In_range_(0, D3D11_PS_CS_UAV_REGISTER_COUNT - 1) UINT UAVStartSlot, - _In_range_(0, D3D11_PS_CS_UAV_REGISTER_COUNT - UAVStartSlot) UINT NumUAVs, - _Out_writes_opt_(NumUAVs) ID3D11UnorderedAccessView** ppUnorderedAccessViews) - { - m_realDeviceCtx->OMGetRenderTargetsAndUnorderedAccessViews(NumRTVs, ppRenderTargetViews, ppDepthStencilView, - UAVStartSlot, NumUAVs, ppUnorderedAccessViews); - } - - virtual void STDMETHODCALLTYPE OMGetBlendState( - _Outptr_opt_result_maybenull_ ID3D11BlendState** ppBlendState, - _Out_opt_ FLOAT BlendFactor[4], - _Out_opt_ UINT* pSampleMask) - { - m_realDeviceCtx->OMGetBlendState(ppBlendState, BlendFactor, pSampleMask); - } - - virtual void STDMETHODCALLTYPE OMGetDepthStencilState( - _Outptr_opt_result_maybenull_ ID3D11DepthStencilState** ppDepthStencilState, - _Out_opt_ UINT* pStencilRef) - { - m_realDeviceCtx->OMGetDepthStencilState(ppDepthStencilState, pStencilRef); - } - - // @Patoke todo: wrap - virtual void STDMETHODCALLTYPE SOGetTargets( - _In_range_(0, D3D11_SO_BUFFER_SLOT_COUNT) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppSOTargets) - { - m_realDeviceCtx->SOGetTargets(NumBuffers, ppSOTargets); - } - - virtual void STDMETHODCALLTYPE RSGetState( - _Outptr_result_maybenull_ ID3D11RasterizerState** ppRasterizerState) - { - m_realDeviceCtx->RSGetState(ppRasterizerState); - } - - virtual void STDMETHODCALLTYPE RSGetViewports( - _Inout_ /*_range(0, D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE )*/ UINT* pNumViewports, - _Out_writes_opt_(*pNumViewports) D3D11_VIEWPORT* pViewports) - { - m_realDeviceCtx->RSGetViewports(pNumViewports, pViewports); - } - - virtual void STDMETHODCALLTYPE RSGetScissorRects( - _Inout_ /*_range(0, D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE )*/ UINT* pNumRects, - _Out_writes_opt_(*pNumRects) D3D11_RECT* pRects) - { - m_realDeviceCtx->RSGetScissorRects(pNumRects, pRects); - } - - // @Patoke todo: wrap - virtual void STDMETHODCALLTYPE HSGetShaderResources( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews, - _Out_writes_opt_(NumViews) ID3D11ShaderResourceView** ppShaderResourceViews) - { - m_realDeviceCtx->HSGetShaderResources(StartSlot, NumViews, ppShaderResourceViews); - } - - virtual void STDMETHODCALLTYPE HSGetShader( - _Outptr_result_maybenull_ ID3D11HullShader** ppHullShader, - _Out_writes_opt_(*pNumClassInstances) ID3D11ClassInstance** ppClassInstances, - _Inout_opt_ UINT* pNumClassInstances) - { - m_realDeviceCtx->HSGetShader(ppHullShader, ppClassInstances, pNumClassInstances); - } - - virtual void STDMETHODCALLTYPE HSGetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _Out_writes_opt_(NumSamplers) ID3D11SamplerState** ppSamplers) - { - m_realDeviceCtx->HSGetSamplers(StartSlot, NumSamplers, ppSamplers); - } - - virtual void STDMETHODCALLTYPE HSGetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers) - { - if (ppConstantBuffers != NULL) - { - ID3D11Buffer** unwrappedBuffers = new ID3D11Buffer*[NumBuffers]{0}; - - m_realDeviceCtx->HSGetConstantBuffers(StartSlot, NumBuffers, unwrappedBuffers); - - for (UINT i = 0; i < NumBuffers; ++i) - { - ppConstantBuffers[i] = reinterpret_cast(new - ID3D11BufferWrapper(unwrappedBuffers[i])); - } - } - else - { - m_realDeviceCtx->HSGetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); - } - } - - // @Patoke todo: wrap - virtual void STDMETHODCALLTYPE DSGetShaderResources( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews, - _Out_writes_opt_(NumViews) ID3D11ShaderResourceView** ppShaderResourceViews) - { - m_realDeviceCtx->DSGetShaderResources(StartSlot, NumViews, ppShaderResourceViews); - } - - virtual void STDMETHODCALLTYPE DSGetShader( - _Outptr_result_maybenull_ ID3D11DomainShader** ppDomainShader, - _Out_writes_opt_(*pNumClassInstances) ID3D11ClassInstance** ppClassInstances, - _Inout_opt_ UINT* pNumClassInstances) - { - m_realDeviceCtx->DSGetShader(ppDomainShader, ppClassInstances, pNumClassInstances); - } - - virtual void STDMETHODCALLTYPE DSGetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _Out_writes_opt_(NumSamplers) ID3D11SamplerState** ppSamplers) - { - m_realDeviceCtx->DSGetSamplers(StartSlot, NumSamplers, ppSamplers); - } - - virtual void STDMETHODCALLTYPE DSGetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers) - { - if (ppConstantBuffers != NULL) - { - ID3D11Buffer** unwrappedBuffers = new ID3D11Buffer*[NumBuffers]{0}; - - m_realDeviceCtx->DSGetConstantBuffers(StartSlot, NumBuffers, unwrappedBuffers); - - for (UINT i = 0; i < NumBuffers; ++i) - { - ppConstantBuffers[i] = reinterpret_cast(new - ID3D11BufferWrapper(unwrappedBuffers[i])); - } - } - else - { - m_realDeviceCtx->DSGetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); - } - } - - // @Patoke todo: wrap - virtual void STDMETHODCALLTYPE CSGetShaderResources( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews, - _Out_writes_opt_(NumViews) ID3D11ShaderResourceView** ppShaderResourceViews) - { - m_realDeviceCtx->CSGetShaderResources(StartSlot, NumViews, ppShaderResourceViews); - } - - // @Patoke todo: wrap - virtual void STDMETHODCALLTYPE CSGetUnorderedAccessViews( - _In_range_(0, D3D11_1_UAV_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_1_UAV_SLOT_COUNT - StartSlot) UINT NumUAVs, - _Out_writes_opt_(NumUAVs) ID3D11UnorderedAccessView** ppUnorderedAccessViews) - { - m_realDeviceCtx->CSGetUnorderedAccessViews(StartSlot, NumUAVs, ppUnorderedAccessViews); - } - - virtual void STDMETHODCALLTYPE CSGetShader( - _Outptr_result_maybenull_ ID3D11ComputeShader** ppComputeShader, - _Out_writes_opt_(*pNumClassInstances) ID3D11ClassInstance** ppClassInstances, - _Inout_opt_ UINT* pNumClassInstances) - { - m_realDeviceCtx->CSGetShader(ppComputeShader, ppClassInstances, pNumClassInstances); - } - - virtual void STDMETHODCALLTYPE CSGetSamplers( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers, - _Out_writes_opt_(NumSamplers) ID3D11SamplerState** ppSamplers) - { - m_realDeviceCtx->CSGetSamplers(StartSlot, NumSamplers, ppSamplers); - } - - virtual void STDMETHODCALLTYPE CSGetConstantBuffers( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers) - { - if (ppConstantBuffers != NULL) - { - ID3D11Buffer** unwrappedBuffers = new ID3D11Buffer*[NumBuffers]{0}; - - m_realDeviceCtx->CSGetConstantBuffers(StartSlot, NumBuffers, unwrappedBuffers); - - for (UINT i = 0; i < NumBuffers; ++i) - { - ppConstantBuffers[i] = reinterpret_cast(new - ID3D11BufferWrapper(unwrappedBuffers[i])); - } - } - else - { - m_realDeviceCtx->CSGetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); - } - } - - virtual void STDMETHODCALLTYPE ClearState(void) - { - m_realDeviceCtx->ClearState(); - } - - virtual void STDMETHODCALLTYPE Flush(void) - { - m_realDeviceCtx->Flush(); - } - - virtual D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE GetType(void) - { - return m_realDeviceCtx->GetType(); - } - - virtual UINT STDMETHODCALLTYPE GetContextFlags(void) - { - return m_realDeviceCtx->GetContextFlags(); - } - - virtual HRESULT STDMETHODCALLTYPE FinishCommandList( - BOOL RestoreDeferredContextState, - - _COM_Outptr_opt_ ID3D11CommandList** ppCommandList) - { - return m_realDeviceCtx->FinishCommandList(RestoreDeferredContextState, ppCommandList); - } - - virtual void STDMETHODCALLTYPE CopySubresourceRegion1( - _In_ ID3D11Resource* pDstResource, - _In_ UINT DstSubresource, - _In_ UINT DstX, - _In_ UINT DstY, - _In_ UINT DstZ, - _In_ ID3D11Resource* pSrcResource, - _In_ UINT SrcSubresource, - _In_opt_ const D3D11_BOX* pSrcBox, - _In_ UINT CopyFlags) - { - m_realDeviceCtx->CopySubresourceRegion1( - reinterpret_cast(pDstResource)->m_realResource, DstSubresource, DstX, DstY, - DstZ, reinterpret_cast(pSrcResource)->m_realResource, SrcSubresource, pSrcBox, - CopyFlags); - } - - virtual void STDMETHODCALLTYPE UpdateSubresource1( - _In_ ID3D11Resource* pDstResource, - _In_ UINT DstSubresource, - _In_opt_ const D3D11_BOX* pDstBox, - _In_ const void* pSrcData, - _In_ UINT SrcRowPitch, - _In_ UINT SrcDepthPitch, - _In_ UINT CopyFlags) - { - m_realDeviceCtx->UpdateSubresource1(reinterpret_cast(pDstResource)->m_realResource, - DstSubresource, pDstBox, pSrcData, SrcRowPitch, SrcDepthPitch, - CopyFlags); - } - - virtual void STDMETHODCALLTYPE DiscardResource( - _In_ ID3D11Resource* pResource) - { - m_realDeviceCtx->DiscardResource(reinterpret_cast(pResource)->m_realResource); - } - - // @Patoke todo: unwrap? - virtual void STDMETHODCALLTYPE DiscardView( - _In_ ID3D11View* pResourceView) - { - m_realDeviceCtx->DiscardView(pResourceView); - } - - virtual void STDMETHODCALLTYPE VSSetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers, - _In_reads_opt_(NumBuffers) const UINT* pFirstConstant, - _In_reads_opt_(NumBuffers) const UINT* pNumConstants) - { - m_realDeviceCtx->VSSetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, - pNumConstants); - } - - virtual void STDMETHODCALLTYPE HSSetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers, - _In_reads_opt_(NumBuffers) const UINT* pFirstConstant, - _In_reads_opt_(NumBuffers) const UINT* pNumConstants) - { - m_realDeviceCtx->HSSetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, - pNumConstants); - } - - virtual void STDMETHODCALLTYPE DSSetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers, - _In_reads_opt_(NumBuffers) const UINT* pFirstConstant, - _In_reads_opt_(NumBuffers) const UINT* pNumConstants) - { - m_realDeviceCtx->DSSetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, - pNumConstants); - } - - virtual void STDMETHODCALLTYPE GSSetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers, - _In_reads_opt_(NumBuffers) const UINT* pFirstConstant, - _In_reads_opt_(NumBuffers) const UINT* pNumConstants) - { - m_realDeviceCtx->GSSetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, - pNumConstants); - } - - virtual void STDMETHODCALLTYPE PSSetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers, - _In_reads_opt_(NumBuffers) const UINT* pFirstConstant, - _In_reads_opt_(NumBuffers) const UINT* pNumConstants) - { - m_realDeviceCtx->PSSetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, - pNumConstants); - } - - virtual void STDMETHODCALLTYPE CSSetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers, - _In_reads_opt_(NumBuffers) const UINT* pFirstConstant, - _In_reads_opt_(NumBuffers) const UINT* pNumConstants) - { - m_realDeviceCtx->CSSetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, - pNumConstants); - } - - virtual void STDMETHODCALLTYPE VSGetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers, - _Out_writes_opt_(NumBuffers) UINT* pFirstConstant, - _Out_writes_opt_(NumBuffers) UINT* pNumConstants) - { - m_realDeviceCtx->VSGetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, - pNumConstants); - } - - virtual void STDMETHODCALLTYPE HSGetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers, - _Out_writes_opt_(NumBuffers) UINT* pFirstConstant, - _Out_writes_opt_(NumBuffers) UINT* pNumConstants) - { - m_realDeviceCtx->HSGetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, - pNumConstants); - } - - virtual void STDMETHODCALLTYPE DSGetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers, - _Out_writes_opt_(NumBuffers) UINT* pFirstConstant, - _Out_writes_opt_(NumBuffers) UINT* pNumConstants) - { - m_realDeviceCtx->DSGetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, - pNumConstants); - } - - virtual void STDMETHODCALLTYPE GSGetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers, - _Out_writes_opt_(NumBuffers) UINT* pFirstConstant, - _Out_writes_opt_(NumBuffers) UINT* pNumConstants) - { - m_realDeviceCtx->GSGetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, - pNumConstants); - } - - virtual void STDMETHODCALLTYPE PSGetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers, - _Out_writes_opt_(NumBuffers) UINT* pFirstConstant, - _Out_writes_opt_(NumBuffers) UINT* pNumConstants) - { - m_realDeviceCtx->PSGetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, - pNumConstants); - } - - virtual void STDMETHODCALLTYPE CSGetConstantBuffers1( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot, - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers, - _Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers, - _Out_writes_opt_(NumBuffers) UINT* pFirstConstant, - _Out_writes_opt_(NumBuffers) UINT* pNumConstants) - { - m_realDeviceCtx->CSGetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, - pNumConstants); - } - - virtual void STDMETHODCALLTYPE SwapDeviceContextState( - _In_ ID3DDeviceContextState* pState, - _Outptr_opt_ ID3DDeviceContextState** ppPreviousState) - { - m_realDeviceCtx->SwapDeviceContextState(pState, ppPreviousState); - } - - // @Patoke todo: unwrap? - virtual void STDMETHODCALLTYPE ClearView( - _In_ ID3D11View* pView, - _In_ const FLOAT Color[4], - _In_reads_opt_(NumRects) const D3D11_RECT* pRect, - UINT NumRects) - { - m_realDeviceCtx->ClearView(pView, Color, pRect, NumRects); - } - - // @Patoke todo: unwrap? - virtual void STDMETHODCALLTYPE DiscardView1( - _In_ ID3D11View* pResourceView, - _In_reads_opt_(NumRects) const D3D11_RECT* pRects, - UINT NumRects) - { - m_realDeviceCtx->DiscardView1(pResourceView, pRects, NumRects); - } - - virtual HRESULT STDMETHODCALLTYPE UpdateTileMappings( - _In_ ID3D11Resource* pTiledResource, - _In_ UINT NumTiledResourceRegions, - _In_reads_opt_(NumTiledResourceRegions) const D3D11_TILED_RESOURCE_COORDINATE* - pTiledResourceRegionStartCoordinates, - _In_reads_opt_(NumTiledResourceRegions) const D3D11_TILE_REGION_SIZE* pTiledResourceRegionSizes, - _In_opt_ ID3D11Buffer* pTilePool, - _In_ UINT NumRanges, - _In_reads_opt_(NumRanges) const UINT* pRangeFlags, - _In_reads_opt_(NumRanges) const UINT* pTilePoolStartOffsets, - _In_reads_opt_(NumRanges) const UINT* pRangeTileCounts, - _In_ UINT Flags) - { - return m_realDeviceCtx->UpdateTileMappings( - reinterpret_cast(pTiledResource)->m_realResource, NumTiledResourceRegions, - pTiledResourceRegionStartCoordinates, pTiledResourceRegionSizes, pTilePool, NumRanges, pRangeFlags, - pTilePoolStartOffsets, pRangeTileCounts, Flags); - } - - virtual HRESULT STDMETHODCALLTYPE CopyTileMappings( - _In_ ID3D11Resource* pDestTiledResource, - _In_ const D3D11_TILED_RESOURCE_COORDINATE* pDestRegionStartCoordinate, - _In_ ID3D11Resource* pSourceTiledResource, - _In_ const D3D11_TILED_RESOURCE_COORDINATE* pSourceRegionStartCoordinate, - _In_ const D3D11_TILE_REGION_SIZE* pTileRegionSize, - _In_ UINT Flags) - { - return m_realDeviceCtx->CopyTileMappings( - reinterpret_cast(pDestTiledResource)->m_realResource, - pDestRegionStartCoordinate, - reinterpret_cast(pSourceTiledResource)->m_realResource, - pSourceRegionStartCoordinate, pTileRegionSize, Flags); - } - - virtual void STDMETHODCALLTYPE CopyTiles( - _In_ ID3D11Resource* pTiledResource, - _In_ const D3D11_TILED_RESOURCE_COORDINATE* pTileRegionStartCoordinate, - _In_ const D3D11_TILE_REGION_SIZE* pTileRegionSize, - _In_ ID3D11Buffer* pBuffer, - _In_ UINT64 BufferStartOffsetInBytes, - _In_ UINT Flags) - { - m_realDeviceCtx->CopyTiles(reinterpret_cast(pTiledResource)->m_realResource, - pTileRegionStartCoordinate, pTileRegionSize, pBuffer, BufferStartOffsetInBytes, - Flags); - } - - virtual void STDMETHODCALLTYPE UpdateTiles( - _In_ ID3D11Resource* pDestTiledResource, - _In_ const D3D11_TILED_RESOURCE_COORDINATE* pDestTileRegionStartCoordinate, - _In_ const D3D11_TILE_REGION_SIZE* pDestTileRegionSize, - _In_ const void* pSourceTileData, - _In_ UINT Flags) - { - m_realDeviceCtx->UpdateTiles(reinterpret_cast(pDestTiledResource)->m_realResource, - pDestTileRegionStartCoordinate, pDestTileRegionSize, pSourceTileData, Flags); - } - - virtual HRESULT STDMETHODCALLTYPE ResizeTilePool( - _In_ ID3D11Buffer* pTilePool, - _In_ UINT64 NewSizeInBytes) - { - return m_realDeviceCtx->ResizeTilePool(pTilePool, NewSizeInBytes); - } - - virtual void STDMETHODCALLTYPE TiledResourceBarrier( - _In_opt_ ID3D11DeviceChild* pTiledResourceOrViewAccessBeforeBarrier, - _In_opt_ ID3D11DeviceChild* pTiledResourceOrViewAccessAfterBarrier) - { - m_realDeviceCtx->TiledResourceBarrier( - reinterpret_cast(pTiledResourceOrViewAccessBeforeBarrier)->m_realTarget, - reinterpret_cast(pTiledResourceOrViewAccessAfterBarrier)->m_realTarget); - } - - virtual INT (PIXBeginEvent)( - _In_ LPCWSTR Name) - { - printf("[ID3D11DeviceContextX] PIXBeginEvent NOT IMPLEMENTED\n"); - return 0; - } - - virtual INT (PIXBeginEventEx)( - _In_reads_bytes_(DataSize) const void* pData, - _In_ UINT DataSize) - { - printf("[ID3D11DeviceContextX] PIXBeginEventEx NOT IMPLEMENTED\n"); - return 0; - } - - virtual INT (PIXEndEvent)( - _Inout_ ID3D11DeviceContextX* pDeviceContext) - { - printf("[ID3D11DeviceContextX] PIXEndEvent NOT IMPLEMENTED\n"); - return 0; - } - - virtual void (PIXSetMarker)( - _In_ LPCWSTR Name) - { - printf("[ID3D11DeviceContextX] PIXSetMarker NOT IMPLEMENTED\n"); - } - - virtual void (PIXSetMarkerEx)( - _In_reads_bytes_(DataSize) const void* pData, - _In_ UINT DataSize) - { - printf("[ID3D11DeviceContextX] PIXSetMarkerEx NOT IMPLEMENTED\n"); - } - - virtual BOOL (PIXGetStatus)( - _Inout_ ID3D11DeviceContextX* pDeviceContext) - { - printf("[ID3D11DeviceContextX] PIXGetStatus NOT IMPLEMENTED\n"); - return 0; - } - - virtual HRESULT (PIXGpuCaptureNextFrame)( - _In_ UINT Flags, - _In_z_ LPCWSTR lpOutputFileName) - { - printf("[ID3D11DeviceContextX] PIXGpuCaptureNextFrame NOT IMPLEMENTED\n"); - return E_NOTIMPL; - } - - virtual HRESULT (PIXGpuBeginCapture)( - _In_ UINT Flags, - _In_z_ LPCWSTR lpOutputFileName) - { - printf("[ID3D11DeviceContextX] PIXGpuBeginCapture NOT IMPLEMENTED\n"); - return E_NOTIMPL; - } - - virtual HRESULT (PIXGpuEndCapture)( - _Inout_ ID3D11DeviceContextX* pDeviceContext) - { - printf("[ID3D11DeviceContextX] PIXGpuEndCapture NOT IMPLEMENTED\n"); - return E_NOTIMPL; - } - - virtual void (StartCounters)( - _In_ ID3D11CounterSetX* pCounterSet) - { - printf("[ID3D11DeviceContextX] StartCounters NOT IMPLEMENTED\n"); - } - - virtual void (SampleCounters)( - _In_ ID3D11CounterSampleX* pCounterSample) - { - printf("[ID3D11DeviceContextX] SampleCounters NOT IMPLEMENTED\n"); - } - - virtual void (StopCounters)( - _Inout_ ID3D11DeviceContextX* pDeviceContext) - { - printf("[ID3D11DeviceContextX] StopCounters NOT IMPLEMENTED\n"); - } - - virtual HRESULT (GetCounterData)( - _In_ ID3D11CounterSampleX* pCounterSample, - _Out_ D3D11X_COUNTER_DATA* pData, - _In_ UINT GetCounterDataFlags) - { - printf("[ID3D11DeviceContextX] GetCounterData NOT IMPLEMENTED\n"); - return E_NOTIMPL; - } - - virtual void (FlushGpuCaches)( - _In_ ID3D11Resource* pResource) - { - printf("[ID3D11DeviceContextX] FlushGpuCaches NOT IMPLEMENTED\n"); - } - - virtual void (FlushGpuCacheRange)( - _In_ UINT Flags, - _In_ void* pBaseAddress, - _In_ SIZE_T SizeInBytes) - { - printf("[ID3D11DeviceContextX] FlushGpuCacheRange NOT IMPLEMENTED\n"); - } - - virtual void (InsertWaitUntilIdle)( - _In_ UINT Flags) - { - //printf("[ID3D11DeviceContextX] InsertWaitUntilIdle NOT IMPLEMENTED\n"); - } - - virtual UINT64 (InsertFence)( - _In_ UINT Flags) - { - printf("[ID3D11DeviceContextX] InsertFence NOT IMPLEMENTED\n"); - return 0; - } - - virtual void (InsertWaitOnFence)( - _In_ UINT Flags, - _In_ UINT64 Fence) - { - printf("[ID3D11DeviceContextX] InsertWaitOnFence NOT IMPLEMENTED\n"); - } - - virtual void (RemapConstantBufferInheritance)( - _In_ D3D11_STAGE Stage, - _In_ UINT Slot, - _In_ D3D11_STAGE InheritStage, - _In_ UINT InheritSlot) - { - printf("[ID3D11DeviceContextX] RemapConstantBufferInheritance NOT IMPLEMENTED\n"); - } - - virtual void (RemapShaderResourceInheritance)( - _In_ D3D11_STAGE Stage, - _In_ UINT Slot, - _In_ D3D11_STAGE InheritStage, - _In_ UINT InheritSlot) - { - printf("[ID3D11DeviceContextX] RemapShaderResourceInheritance NOT IMPLEMENTED\n"); - } - - virtual void (RemapSamplerInheritance)( - _In_ D3D11_STAGE Stage, - _In_ UINT Slot, - _In_ D3D11_STAGE InheritStage, - _In_ UINT InheritSlot) - { - printf("[ID3D11DeviceContextX] RemapSamplerInheritance NOT IMPLEMENTED\n"); - } - - virtual void (RemapVertexBufferInheritance)( - _In_ UINT Slot, - _In_ UINT InheritSlot) - { - printf("[ID3D11DeviceContextX] RemapVertexBufferInheritance NOT IMPLEMENTED\n"); - } - - virtual void (PSSetFastConstantBuffer)( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11Buffer* pConstantBuffer) - { - printf("[ID3D11DeviceContextX] PSSetFastConstantBuffer NOT IMPLEMENTED\n"); - } - - virtual void (PSSetFastShaderResource)( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11ShaderResourceView* pShaderResourceView) - { - printf("[ID3D11DeviceContextX] PSSetFastShaderResource NOT IMPLEMENTED\n"); - } - - virtual void (PSSetFastSampler)( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11SamplerState* pSampler) - { - printf("[ID3D11DeviceContextX] PSSetFastSampler NOT IMPLEMENTED\n"); - } - - virtual void (VSSetFastConstantBuffer)( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11Buffer* pConstantBuffer) - { - printf("[ID3D11DeviceContextX] VSSetFastConstantBuffer NOT IMPLEMENTED\n"); - } - - virtual void (VSSetFastShaderResource)( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11ShaderResourceView* pShaderResourceView) - { - printf("[ID3D11DeviceContextX] VSSetFastShaderResource NOT IMPLEMENTED\n"); - } - - virtual void (VSSetFastSampler)( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11SamplerState* pSampler) - { - printf("[ID3D11DeviceContextX] VSSetFastSampler NOT IMPLEMENTED\n"); - } - - virtual void (GSSetFastConstantBuffer)( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11Buffer* pConstantBuffer) - { - printf("[ID3D11DeviceContextX] GSSetFastConstantBuffer NOT IMPLEMENTED\n"); - } - - virtual void (GSSetFastShaderResource)( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11ShaderResourceView* pShaderResourceView) - { - printf("[ID3D11DeviceContextX] GSSetFastShaderResource NOT IMPLEMENTED\n"); - } - - virtual void (GSSetFastSampler)( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11SamplerState* pSampler) - { - printf("[ID3D11DeviceContextX] GSSetFastSampler NOT IMPLEMENTED\n"); - } - - virtual void (CSSetFastConstantBuffer)( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11Buffer* pConstantBuffer) - { - printf("[ID3D11DeviceContextX] CSSetFastConstantBuffer NOT IMPLEMENTED\n"); - } - - virtual void (CSSetFastShaderResource)( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11ShaderResourceView* pShaderResourceView) - { - printf("[ID3D11DeviceContextX] CSSetFastShaderResource NOT IMPLEMENTED\n"); - } - - virtual void (CSSetFastSampler)( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11SamplerState* pSampler) - { - printf("[ID3D11DeviceContextX] CSSetFastSampler NOT IMPLEMENTED\n"); - } - - virtual void (HSSetFastConstantBuffer)( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11Buffer* pConstantBuffer) - { - printf("[ID3D11DeviceContextX] HSSetFastConstantBuffer NOT IMPLEMENTED\n"); - } - - virtual void (HSSetFastShaderResource)( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11ShaderResourceView* pShaderResourceView) - { - printf("[ID3D11DeviceContextX] HSSetFastShaderResource NOT IMPLEMENTED\n"); - } - - virtual void (HSSetFastSampler)( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11SamplerState* pSampler) - { - printf("[ID3D11DeviceContextX] HSSetFastSampler NOT IMPLEMENTED\n"); - } - - virtual void (DSSetFastConstantBuffer)( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11Buffer* pConstantBuffer) - { - printf("[ID3D11DeviceContextX] DSSetFastConstantBuffer NOT IMPLEMENTED\n"); - } - - virtual void (DSSetFastShaderResource)( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11ShaderResourceView* pShaderResourceView) - { - printf("[ID3D11DeviceContextX] DSSetFastShaderResource NOT IMPLEMENTED\n"); - } - - virtual void (DSSetFastSampler)( - _In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11SamplerState* pSampler) - { - printf("[ID3D11DeviceContextX] DSSetFastSampler NOT IMPLEMENTED\n"); - } - - virtual void (IASetFastVertexBuffer)( - _In_range_(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11Buffer* pVertexBuffer, - _In_ UINT Stride) - { - printf("[ID3D11DeviceContextX] IASetFastVertexBuffer NOT IMPLEMENTED\n"); - } - - virtual void (IASetFastIndexBuffer)( - _In_ UINT HardwareIndexFormat, - _In_ ID3D11Buffer* pIndexBuffer) - { - printf("[ID3D11DeviceContextX] IASetFastIndexBuffer NOT IMPLEMENTED\n"); - } - - virtual void (PSSetPlacementConstantBuffer)( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11Buffer* pConstantBuffer, - _In_ void* pBaseAddress) - { - printf("[ID3D11DeviceContextX] PSSetPlacementConstantBuffer NOT IMPLEMENTED\n"); - } - - virtual void (PSSetPlacementShaderResource)( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11ShaderResourceView* pShaderResourceView, - _In_ void* pBaseAddress) - { - printf("[ID3D11DeviceContextX] PSSetPlacementShaderResource NOT IMPLEMENTED\n"); - } - - virtual void (VSSetPlacementConstantBuffer)( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11Buffer* pConstantBuffer, - _In_ void* pBaseAddress) - { - printf("[ID3D11DeviceContextX] VSSetPlacementConstantBuffer NOT IMPLEMENTED\n"); - } - - virtual void (VSSetPlacementShaderResource)( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11ShaderResourceView* pShaderResourceView, - _In_ void* pBaseAddress) - { - printf("[ID3D11DeviceContextX] VSSetPlacementShaderResource NOT IMPLEMENTED\n"); - } - - virtual void (GSSetPlacementConstantBuffer)( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11Buffer* pConstantBuffer, - _In_ void* pBaseAddress) - { - printf("[ID3D11DeviceContextX] GSSetPlacementConstantBuffer NOT IMPLEMENTED\n"); - } - - virtual void (GSSetPlacementShaderResource)( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11ShaderResourceView* pShaderResourceView, - _In_ void* pBaseAddress) - { - printf("[ID3D11DeviceContextX] GSSetPlacementShaderResource NOT IMPLEMENTED\n"); - } - - virtual void (CSSetPlacementConstantBuffer)( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11Buffer* pConstantBuffer, - _In_ void* pBaseAddress) - { - printf("[ID3D11DeviceContextX] CSSetPlacementConstantBuffer NOT IMPLEMENTED\n"); - } - - virtual void (CSSetPlacementShaderResource)( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11ShaderResourceView* pShaderResourceView, - _In_ void* pBaseAddress) - { - printf("[ID3D11DeviceContextX] CSSetPlacementShaderResource NOT IMPLEMENTED\n"); - } - - virtual void (HSSetPlacementConstantBuffer)( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11Buffer* pConstantBuffer, - _In_ void* pBaseAddress) - { - printf("[ID3D11DeviceContextX] HSSetPlacementConstantBuffer NOT IMPLEMENTED\n"); - } - - virtual void (HSSetPlacementShaderResource)( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11ShaderResourceView* pShaderResourceView, - _In_ void* pBaseAddress) - { - printf("[ID3D11DeviceContextX] HSSetPlacementShaderResource NOT IMPLEMENTED\n"); - } - - virtual void (DSSetPlacementConstantBuffer)( - _In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11Buffer* pConstantBuffer, - _In_ void* pBaseAddress) - { - printf("[ID3D11DeviceContextX] DSSetPlacementConstantBuffer NOT IMPLEMENTED\n"); - } - - virtual void (DSSetPlacementShaderResource)( - _In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11ShaderResourceView* pShaderResourceView, - _In_ void* pBaseAddress) - { - printf("[ID3D11DeviceContextX] DSSetPlacementShaderResource NOT IMPLEMENTED\n"); - } - - virtual void (IASetPlacementVertexBuffer)( - _In_range_(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot, - _In_ ID3D11Buffer* pVertexBuffer, - _In_ void* pBaseAddress, - _In_ UINT Stride) - { - printf("[ID3D11DeviceContextX] IASetPlacementVertexBuffer NOT IMPLEMENTED\n"); - } - - virtual void (IASetPlacementIndexBuffer)( - _In_ UINT HardwareIndexFormat, - _In_ ID3D11Buffer* pIndexBuffer, - _In_ void* pBaseAddress) - { - printf("[ID3D11DeviceContextX] IASetPlacementIndexBuffer NOT IMPLEMENTED\n"); - } - - virtual void (HSSetTessellationParameters)( - _In_opt_ const D3D11X_TESSELLATION_PARAMETERS* pTessellationParameters) - { - printf("[ID3D11DeviceContextX] HSSetTessellationParameters NOT IMPLEMENTED\n"); - } - - virtual void (HSGetLastUsedTessellationParameters)( - _Inout_ D3D11X_TESSELLATION_PARAMETERS* pTessellationParameters) - { - printf("[ID3D11DeviceContextX] HSGetLastUsedTessellationParameters NOT IMPLEMENTED\n"); - } - - virtual void (CSEnableAutomaticGpuFlush)( - _In_ BOOL Enable) - { - printf("[ID3D11DeviceContextX] CSEnableAutomaticGpuFlush NOT IMPLEMENTED\n"); - } - - virtual void (GpuSendPipelinedEvent)( - _In_ D3D11X_GPU_PIPELINED_EVENT Event) - { - printf("[ID3D11DeviceContextX] GpuSendPipelinedEvent NOT IMPLEMENTED\n"); - } - - virtual HRESULT (Suspend)( - _In_ UINT Flags) - { - printf("[ID3D11DeviceContextX] Suspend NOT IMPLEMENTED\n"); - return E_NOTIMPL; - } - - virtual HRESULT (Resume)( - _Inout_ ID3D11DeviceContextX* pDeviceContext) - { - printf("[ID3D11DeviceContextX] Resume NOT IMPLEMENTED\n"); - return E_NOTIMPL; - } - - virtual void (BeginCommandListExecution)( - _Inout_ ID3D11DeviceContext* pDeviceContext, - _In_ UINT Flags) - { - printf("[ID3D11DeviceContextX] BeginCommandListExecution NOT IMPLEMENTED\n"); - } - - virtual void (EndCommandListExecution)( - _Inout_ ID3D11DeviceContext* pDeviceContext) - { - printf("[ID3D11DeviceContextX] EndCommandListExecution NOT IMPLEMENTED\n"); - } - - virtual void (SetGraphicsShaderLimits)( - _In_opt_ const D3D11X_GRAPHICS_SHADER_LIMITS* pShaderLimits) - { - printf("[ID3D11DeviceContextX] SetGraphicsShaderLimits NOT IMPLEMENTED\n"); - } - - virtual void (SetComputeShaderLimits)( - _In_opt_ const D3D11X_COMPUTE_SHADER_LIMITS* pShaderLimits) - { - printf("[ID3D11DeviceContextX] SetComputeShaderLimits NOT IMPLEMENTED\n"); - } - - virtual void (SetPredicationBuffer)( - _In_opt_ ID3D11Buffer* pBuffer, - _In_ UINT Offset, - _In_ UINT Flags) - { - printf("[ID3D11DeviceContextX] SetPredicationBuffer NOT IMPLEMENTED\n"); - } - - virtual void (OMSetDepthBounds)( - _Inout_ ID3D11DeviceContextX* pDevice, - _In_ FLOAT min, - _In_ FLOAT max) - { - printf("[ID3D11DeviceContextX] OMSetDepthBounds NOT IMPLEMENTED\n"); - } - - virtual void (OMSetDepthStencilStateX)( - _In_opt_ ID3D11DepthStencilState* pDepthStencilState) - { - printf("[ID3D11DeviceContextX] OMSetDepthStencilStateX NOT IMPLEMENTED\n"); - } - - virtual void (OMSetSampleMask)( - _Inout_ ID3D11DeviceContextX* pDevice, - _In_ UINT64 QuadSampleMask) - { - printf("[ID3D11DeviceContextX] OMSetSampleMask NOT IMPLEMENTED\n"); - } - - virtual UINT32* (MakeCeSpace)( - _Inout_ ID3D11DeviceContextX* pDeviceContext) - { - printf("[ID3D11DeviceContextX] MakeCeSpace NOT IMPLEMENTED\n"); - return nullptr; - } - - virtual void (SetFastResources_Debug)( - _In_ UINT* pTableStart, - _In_ UINT* pTableEnd) - { - printf("[ID3D11DeviceContextX] SetFastResources_Debug NOT IMPLEMENTED\n"); - } - - virtual void (BeginResourceBatch)( - _Out_ void* pBuffer, - _In_ UINT BufferSize) - { - printf("[ID3D11DeviceContextX] BeginResourceBatch NOT IMPLEMENTED\n"); - } - - virtual UINT (EndResourceBatch)( - _Out_opt_ UINT* pSizeNeeded) - { - printf("[ID3D11DeviceContextX] EndResourceBatch NOT IMPLEMENTED\n"); - return 0; - } - - virtual void (SetFastResourcesFromBatch_Debug)( - _In_ void* pBatch, - _In_ UINT Size) - { - printf("[ID3D11DeviceContextX] SetFastResourcesFromBatch_Debug NOT IMPLEMENTED\n"); - } - - virtual void (CSPlaceUnorderedAccessView)( - _In_range_(0, D3D11_1_UAV_SLOT_COUNT - 1) UINT Slot, - _In_ D3D11X_DESCRIPTOR_UNORDERED_ACCESS_VIEW* const pDescriptor, - _In_ UINT64 Offset) - { - printf("[ID3D11DeviceContextX] CSPlaceUnorderedAccessView NOT IMPLEMENTED\n"); - } - - virtual void (WriteValueEndOfPipe)( - _In_ void* pDestination, - _In_ UINT Value, - _In_ UINT Flags) - { - printf("[ID3D11DeviceContextX] WriteValueEndOfPipe NOT IMPLEMENTED\n"); - } - - virtual void (CopyMemoryToMemory)( - _In_ void* pDstAddress, - _In_ void* pSrcAddress, - _In_ SIZE_T SizeBytes) - { - printf("[ID3D11DeviceContextX] CopyMemoryToMemory NOT IMPLEMENTED\n"); - } - - virtual void (FillMemoryWithValue)( - _In_ void* pDstAddress, - _In_ SIZE_T SizeBytes, - _In_ UINT FillValue) - { - printf("[ID3D11DeviceContextX] FillMemoryWithValue NOT IMPLEMENTED\n"); - } - - virtual void (BeginProcessVideoResource)( - _In_ ID3D11Resource* pResource, - _In_ UINT SubResource) - { - printf("[ID3D11DeviceContextX] BeginProcessVideoResource NOT IMPLEMENTED\n"); - } - - virtual void (EndProcessVideoResource)( - _In_ ID3D11Resource* pResource, - _In_ UINT SubResource) - { - printf("[ID3D11DeviceContextX] EndProcessVideoResource NOT IMPLEMENTED\n"); - } - - virtual HRESULT (StartThreadTrace)( - _In_ const D3D11X_THREAD_TRACE_DESC* pDesc, - _In_ void* pDstAddressShaderEngine0, - _In_ void* pDstAddressShaderEngine1, - _In_ SIZE_T BufferSizeBytes) - { - printf("[ID3D11DeviceContextX] StartThreadTrace NOT IMPLEMENTED\n"); - return E_NOTIMPL; - } - - virtual void (StopThreadTrace)( - _In_ void* pDstAddressTraceSize) - { - printf("[ID3D11DeviceContextX] StopThreadTrace NOT IMPLEMENTED\n"); - } - - virtual void (InsertThreadTraceMarker)( - _In_ UINT Marker) - { - printf("[ID3D11DeviceContextX] InsertThreadTraceMarker NOT IMPLEMENTED\n"); - } - - virtual void (IASetPrimitiveResetIndex)( - _In_ UINT ResetIndex) - { - printf("[ID3D11DeviceContextX] IASetPrimitiveResetIndex NOT IMPLEMENTED\n"); - } - - virtual void (SetShaderResourceViewMinLOD)( - _In_ ID3D11ShaderResourceView* pShaderResourceView, - FLOAT MinLOD) - { - printf("[ID3D11DeviceContextX] SetShaderResourceViewMinLOD NOT IMPLEMENTED\n"); - } - - virtual void (InsertWaitOnPresent)( - _In_ UINT Flags, - _In_ ID3D11Resource* pBackBuffer) - { - printf("[ID3D11DeviceContextX] InsertWaitOnPresent NOT IMPLEMENTED\n"); - } - - virtual void (ClearRenderTargetViewX)( - _In_ ID3D11RenderTargetView* pRenderTargetView, - _In_ UINT Flags, - _In_ const FLOAT ColorRGBA[4]) - { - printf("[ID3D11DeviceContextX] ClearRenderTargetViewX NOT IMPLEMENTED\n"); - } - - virtual UINT (GetResourceCompression)( - _In_ ID3D11Resource* pResource) - { - printf("[ID3D11DeviceContextX] GetResourceCompression NOT IMPLEMENTED\n"); - return 0; - } - - virtual UINT (GetResourceCompressionX)( - _In_ const D3D11X_DESCRIPTOR_RESOURCE* pResource) - { - printf("[ID3D11DeviceContextX] GetResourceCompressionX NOT IMPLEMENTED\n"); - return 0; - } - - virtual void (DecompressResource)( - _In_ ID3D11Resource* pDstResource, - _In_ UINT DstSubresource, - _In_opt_ const D3D11X_POINT* pDstPoint, - _In_ ID3D11Resource* pSrcResource, - _In_ UINT SrcSubresource, - _In_opt_ const D3D11X_RECT* pSrcRect, - _In_ DXGI_FORMAT DecompressFormat, - _In_ UINT DecompressFlags) - { - printf("[ID3D11DeviceContextX] DecompressResource NOT IMPLEMENTED\n"); - } - - virtual void (DecompressResourceX)( - _In_ D3D11X_DESCRIPTOR_RESOURCE* pDstResource, - _In_ UINT DstSubresource, - _In_opt_ const D3D11X_POINT* pDstPoint, - _In_ D3D11X_DESCRIPTOR_RESOURCE* pSrcResource, - _In_ UINT SrcSubresource, - _In_opt_ const D3D11X_RECT* pSrcRect, - _In_ D3D11X_FORMAT DecompressFormat, - _In_ UINT DecompressFlags) - { - printf("[ID3D11DeviceContextX] DecompressResourceX NOT IMPLEMENTED\n"); - } - - virtual void (GSSetParameters)( - _In_opt_ const D3D11X_GS_PARAMETERS* pGsParameters) - { - printf("[ID3D11DeviceContextX] GSSetParameters NOT IMPLEMENTED\n"); - } - - virtual void (GSGetLastUsedParameters)( - _Inout_ D3D11X_GS_PARAMETERS* pGsParameters) - { - printf("[ID3D11DeviceContextX] GSGetLastUsedParameters NOT IMPLEMENTED\n"); - } - - virtual void (MultiDrawIndexedInstancedIndirect)( - _In_ UINT PrimitiveCount, - _Inout_ ID3D11Buffer* pBufferForArgs, - _In_ UINT AlignedByteOffsetForArgs, - _In_ UINT StrideByteOffsetForArgs, - _In_ UINT Flags) - { - printf("[ID3D11DeviceContextX] MultiDrawIndexedInstancedIndirect NOT IMPLEMENTED\n"); - } - - virtual void (MultiDrawInstancedIndirect)( - _In_ UINT PrimitiveCount, - _Inout_ ID3D11Buffer* pBufferForArgs, - _In_ UINT AlignedByteOffsetForArgs, - _In_ UINT StrideByteOffsetForArgs, - _In_ UINT Flags) - { - printf("[ID3D11DeviceContextX] MultiDrawInstancedIndirect NOT IMPLEMENTED\n"); - } - - virtual void (MultiDrawIndexedInstancedIndirectAuto)( - _Inout_ ID3D11Buffer* pBufferForPrimitiveCount, - _In_ UINT AlignedByteOffsetForPrimitiveCount, - _Inout_ ID3D11Buffer* pBufferForArgs, - _In_ UINT AlignedByteOffsetForArgs, - _In_ UINT StrideByteOffsetForArgs, - _In_ UINT Flags) - { - printf("[ID3D11DeviceContextX] MultiDrawIndexedInstancedIndirectAuto NOT IMPLEMENTED\n"); - } - - virtual void (MultiDrawInstancedIndirectAuto)( - _Inout_ ID3D11Buffer* pBufferForPrimitiveCount, - _In_ UINT AlignedByteOffsetForPrimitiveCount, - _Inout_ ID3D11Buffer* pBufferForArgs, - _In_ UINT AlignedByteOffsetForArgs, - _In_ UINT StrideByteOffsetForArgs, - _In_ UINT Flags) - { - printf("[ID3D11DeviceContextX] MultiDrawInstancedIndirectAuto NOT IMPLEMENTED\n"); - } - - virtual HRESULT (RSGetMSAASettingsForQuality)( - _Inout_opt_ D3D11X_MSAA_SCAN_CONVERTER_SETTINGS* pMSAASCSettings, - _Inout_opt_ D3D11X_MSAA_EQAA_SETTINGS* pEQAASettings, - _Inout_opt_ D3D11X_MSAA_SAMPLE_PRIORITIES* pCentroidPriorities, - _Inout_opt_ D3D11X_MSAA_SAMPLE_POSITIONS* pSamplePositions, - _In_ UINT LogSampleCount, - _In_ UINT SampleQuality) - { - printf("[ID3D11DeviceContextX] RSGetMSAASettingsForQuality NOT IMPLEMENTED\n"); - return E_NOTIMPL; - } - - virtual void (RSSetScanConverterMSAASettings)( - _In_ const D3D11X_MSAA_SCAN_CONVERTER_SETTINGS* pMSAASCSettings) - { - printf("[ID3D11DeviceContextX] RSSetScanConverterMSAASettings NOT IMPLEMENTED\n"); - } - - virtual void (RSSetEQAASettings)( - _In_ const D3D11X_MSAA_EQAA_SETTINGS* pEQAASettings) - { - printf("[ID3D11DeviceContextX] RSSetEQAASettings NOT IMPLEMENTED\n"); - } - - virtual void (RSSetSamplePositions)( - _In_opt_ const D3D11X_MSAA_SAMPLE_PRIORITIES* pSamplesPriorities, - _In_opt_ const D3D11X_MSAA_SAMPLE_POSITIONS* pSamplePositions) - { - printf("[ID3D11DeviceContextX] RSSetSamplePositions NOT IMPLEMENTED\n"); - } - - virtual void (SetResourceCompression)( - _In_ ID3D11Resource* pResource, - _In_ UINT Compression) - { - printf("[ID3D11DeviceContextX] SetResourceCompression NOT IMPLEMENTED\n"); - } - - virtual void (SetResourceCompressionX)( - _In_ const D3D11X_DESCRIPTOR_RESOURCE* pResource, - _In_ UINT Compression) - { - printf("[ID3D11DeviceContextX] SetResourceCompressionX NOT IMPLEMENTED\n"); - } - - virtual void (SetGDSRange)( - _In_ _D3D11X_GDS_REGION_TYPE RegionType, - _In_ UINT OffsetDwords, - _In_ UINT NumDwords) - { - printf("[ID3D11DeviceContextX] SetGDSRange NOT IMPLEMENTED\n"); - } - - virtual void (WriteGDS)( - _In_ _D3D11X_GDS_REGION_TYPE RegionType, - _In_ UINT OffsetDwords, - _In_ UINT NumDwords, - _In_ const UINT* pCounterValues, - _In_ UINT Flags) - { - printf("[ID3D11DeviceContextX] WriteGDS NOT IMPLEMENTED\n"); - } - - virtual void (ReadGDS)( - _In_ _D3D11X_GDS_REGION_TYPE RegionType, - _In_ UINT OffsetDwords, - _In_ UINT NumDwords, - _Inout_ UINT* pCounterValues, - _In_ UINT Flags) - { - printf("[ID3D11DeviceContextX] ReadGDS NOT IMPLEMENTED\n"); - } - - virtual void (VSSetShaderUserData)( - _In_ UINT StartSlot, - _In_ UINT NumRegisters, - _In_reads_(NumRegisters) const UINT* pData) - { - printf("[ID3D11DeviceContextX] VSSetShaderUserData NOT IMPLEMENTED\n"); - } - - virtual void (HSSetShaderUserData)( - _In_ UINT StartSlot, - _In_ UINT NumRegisters, - _In_reads_(NumRegisters) const UINT* pData) - { - printf("[ID3D11DeviceContextX] HSSetShaderUserData NOT IMPLEMENTED\n"); - } - - virtual void (DSSetShaderUserData)( - _In_ UINT StartSlot, - _In_ UINT NumRegisters, - _In_reads_(NumRegisters) const UINT* pData) - { - printf("[ID3D11DeviceContextX] DSSetShaderUserData NOT IMPLEMENTED\n"); - } - - virtual void (GSSetShaderUserData)( - _In_ UINT StartSlot, - _In_ UINT NumRegisters, - _In_reads_(NumRegisters) const UINT* pData) - { - printf("[ID3D11DeviceContextX] GSSetShaderUserData NOT IMPLEMENTED\n"); - } - - virtual void (PSSetShaderUserData)( - _In_ UINT StartSlot, - _In_ UINT NumRegisters, - _In_reads_(NumRegisters) const UINT* pData) - { - printf("[ID3D11DeviceContextX] PSSetShaderUserData NOT IMPLEMENTED\n"); - } - - virtual void (CSSetShaderUserData)( - _In_ UINT StartSlot, - _In_ UINT NumRegisters, - _In_reads_(NumRegisters) const UINT* pData) - { - printf("[ID3D11DeviceContextX] CSSetShaderUserData NOT IMPLEMENTED\n"); - } - - virtual void (InsertWaitOnMemory)( - _In_ const void* pAddress, - _In_ UINT Flags, - _In_ D3D11_COMPARISON_FUNC ComparisonFunction, - _In_ UINT ReferenceValue, - _In_ UINT Mask) - { - printf("[ID3D11DeviceContextX] InsertWaitOnMemory NOT IMPLEMENTED\n"); - } - - virtual void (WriteTimestampToMemory)( - _In_ void* pDstAddress) - { - printf("[ID3D11DeviceContextX] WriteTimestampToMemory NOT IMPLEMENTED\n"); - } - - virtual void (WriteTimestampToBuffer)( - _In_ ID3D11Buffer* pBuffer, - _In_ UINT OffsetBytes) - { - printf("[ID3D11DeviceContextX] WriteTimestampToBuffer NOT IMPLEMENTED\n"); - } - - virtual void (StoreConstantRam)( - _In_ UINT Flags, - _In_ ID3D11Buffer* pBuffer, - _In_ UINT BufferOffsetInBytes, - _In_ UINT CeRamOffsetInBytes, - _In_ UINT SizeInBytes) - { - printf("[ID3D11DeviceContextX] StoreConstantRam NOT IMPLEMENTED\n"); - } - - virtual void (LoadConstantRam)( - _In_ UINT Flags, - _In_ ID3D11Buffer* pBuffer, - _In_ UINT BufferOffsetInBytes, - _In_ UINT CeRamOffsetInBytes, - _In_ UINT SizeInBytes) - { - printf("[ID3D11DeviceContextX] LoadConstantRam NOT IMPLEMENTED\n"); - } - - virtual void (WriteQuery)( - _In_ D3D11_QUERY QueryType, - _In_ UINT QueryIndex, - _In_ UINT Flags, - _In_ ID3D11Buffer* pBuffer, - _In_ UINT OffsetInBytes, - _In_ UINT StrideInBytes) - { - printf("[ID3D11DeviceContextX] WriteQuery NOT IMPLEMENTED\n"); - } - - virtual void (ResetQuery)( - _In_ D3D11_QUERY QueryType, - _In_ UINT QueryIndex, - _In_ UINT Flags) - { - printf("[ID3D11DeviceContextX] ResetQuery NOT IMPLEMENTED\n"); - } - - virtual void (ConfigureQuery)( - _In_ D3D11_QUERY QueryType, - _In_ const void* pConfiguration, - _In_ UINT ConfigurationSize) - { - printf("[ID3D11DeviceContextX] ConfigureQuery NOT IMPLEMENTED\n"); - } - - virtual void (SetShaderUserData)( - _In_ D3D11X_HW_STAGE ShaderStage, - _In_ UINT StartSlot, - _In_ UINT NumRegisters, - _In_reads_(NumRegisters) const UINT* pData) - { - printf("[ID3D11DeviceContextX] SetShaderUserData NOT IMPLEMENTED\n"); - } - - virtual void (SetPixelShaderDepthForceZOrder)( - _In_ BOOL ForceOrder) - { - printf("[ID3D11DeviceContextX] SetPixelShaderDepthForceZOrder NOT IMPLEMENTED\n"); - } - - virtual void (SetPredicationFromQuery)( - _In_ D3D11_QUERY QueryType, - _In_ ID3D11Buffer* pBuffer, - _In_ UINT OffsetInBytes, - _In_ UINT Flags) - { - printf("[ID3D11DeviceContextX] SetPredicationFromQuery NOT IMPLEMENTED\n"); - } - - virtual void (SetBorderColorPalette)( - _In_ ID3D11Buffer* pBuffer, - _In_ UINT OffsetInBytes, - _In_ UINT Flags) - { - printf("[ID3D11DeviceContextX] SetBorderColorPalette NOT IMPLEMENTED\n"); - } - - virtual void (WriteValueEndOfPipe64)( - _In_ void* pDestination, - _In_ UINT64 Value, - _In_ UINT Flags) - { - printf("[ID3D11DeviceContextX] WriteValueEndOfPipe64 NOT IMPLEMENTED\n"); - } - - virtual void (InsertWaitOnMemory64)( - _In_ const void* pAddress, - _In_ UINT Flags, - _In_ D3D11_COMPARISON_FUNC ComparisonFunction, - _In_ UINT64 ReferenceValue) - { - printf("[ID3D11DeviceContextX] InsertWaitOnMemory64 NOT IMPLEMENTED\n"); - } - - virtual void (LoadConstantRamImmediate)( - _In_ UINT Flags, - _In_ const void* pBuffer, - _In_ UINT CeRamOffsetInBytes, - _In_ UINT SizeInBytes) - { - printf("[ID3D11DeviceContextX] LoadConstantRamImmediate NOT IMPLEMENTED\n"); - } - - virtual void (SetScreenExtentsQuery)( - _In_ UINT Value) - { - printf("[ID3D11DeviceContextX] SetScreenExtentsQuery NOT IMPLEMENTED\n"); - } - - virtual void (CollectScreenExtents)( - _In_ UINT Flags, - _In_ UINT AddressCount, - _In_reads_(AddressCount) const UINT64* pDestinationAddresses, - _In_ USHORT ZMin, - _In_ USHORT ZMax) - { - printf("[ID3D11DeviceContextX] CollectScreenExtents NOT IMPLEMENTED\n"); - } - - virtual void (FillResourceWithValue)( - _In_ ID3D11Resource* pDstResource, - _In_ UINT FillValue) - { - printf("[ID3D11DeviceContextX] FillResourceWithValue NOT IMPLEMENTED\n"); - } - - virtual void (SetDrawBalancing)( - _In_ UINT BalancingMode, - _In_ UINT Flags) - { - printf("[ID3D11DeviceContextX] SetDrawBalancing NOT IMPLEMENTED\n"); - } - - - HRESULT QueryInterface(REFIID riid, void** ppvObject) override - { - // DEBUG - char iidstr[sizeof("{AAAAAAAA-BBBB-CCCC-DDEE-FFGGHHIIJJKK}")]; - OLECHAR iidwstr[sizeof(iidstr)]; - StringFromGUID2(riid, iidwstr, ARRAYSIZE(iidwstr)); - WideCharToMultiByte(CP_UTF8, 0, iidwstr, -1, iidstr, sizeof(iidstr), nullptr, nullptr); - printf("[ID3D11DeviceContextXWrapperX] QueryInterface: %s\n", iidstr); - - if (riid == __uuidof(::ID3D11DeviceContext) || riid == __uuidof(::ID3D11DeviceContext1) || - riid == __uuidof(::ID3D11DeviceContext2) || riid == __uuidof(ID3D11DeviceContextX)) - { - *ppvObject = this; - AddRef(); - return S_OK; - } - - return m_realDeviceCtx->QueryInterface(riid, ppvObject); - } - - ULONG AddRef() override - { - printf("[ID3D11DeviceContextXWrapperX] --> AddRef\n"); - return InterlockedIncrement(&m_RefCount); - } - - ULONG Release() override - { - printf("[ID3D11DeviceContextXWrapperX] --> Release\n"); - ULONG refCount = InterlockedDecrement(&m_RefCount); - if (refCount == 0) - { - m_realDeviceCtx->Release(); - delete this; - } - return refCount; - } - - // @Patoke todo: unwrap? - void GetDevice(ID3D11Device** ppDevice) override - { - // Probably not necessary but just to be sure -AleBlbl - ::ID3D11Device** device = nullptr; - this->m_realDeviceCtx->GetDevice(device); - ppDevice = reinterpret_cast(ppDevice); - } - - HRESULT GetPrivateData(REFGUID guid, UINT* pDataSize, void* pData) override - { - return m_realDeviceCtx->GetPrivateData(guid, pDataSize, pData); - } - - HRESULT SetPrivateData(REFGUID guid, UINT DataSize, const void* pData) override - { - return m_realDeviceCtx->SetPrivateData(guid, DataSize, pData); - } - - HRESULT SetPrivateDataInterface(REFGUID guid, const IUnknown* pData) override - { - return m_realDeviceCtx->SetPrivateDataInterface(guid, pData); - } - - HRESULT SetName(const wchar_t* name) override - { - printf("[ID3D11Texture2DWrapper]: SetName STUB\n"); - return S_OK; - } - - - D3D11XTinyDevice m_TinyDevice; - D3D11XShaderUserDataManagerDraw m_ShaderUserDataManagerDraw; - - union - { - uint8_t m_OutOfLineFlags; - uint32_t m_Reserved[16]; - } DUMMYUNIONNAME; - - std::array m_FUNCTION; - - void InitFunctionsTables() - { - auto virtualPTR = *reinterpret_cast(this); - - for (size_t I = 0; I < m_FUNCTION.size(); I++) - { - m_FUNCTION[I] = virtualPTR[I]; - } - } - - - ::ID3D11DeviceContext2* m_realDeviceCtx; - }; -} diff --git a/dlls/d3d11_x/ID3DX.h b/dlls/d3d11_x/ID3DX.h deleted file mode 100644 index a5d96c0..0000000 --- a/dlls/d3d11_x/ID3DX.h +++ /dev/null @@ -1,167 +0,0 @@ -#pragma once -#include "pch.h" -#include "d3d_x/d3d11_x_device.h" -#include "d3d_x/d3d_x.hpp" - - -namespace d3d11x -{ - - struct D3D11X_DESCRIPTOR_TEXTURE_VIEW - { - union - { - //__m128i Oword[ 2 ]; @Patoke todo: cannot be arsed - unsigned __int64 Qword[ 4 ]; - unsigned int Dword[ 8 ]; - }; - }; - - - - struct ID3D11DeviceChild_X : public IGraphicsUnknown - { - public: ID3D11Device* m_pDevice; - public: void* m_pPrivateData; - public: - virtual void STDMETHODCALLTYPE GetDevice( - /* [annotation] */ - _Outptr_ ID3D11Device * *ppDevice) PURE; - - virtual HRESULT STDMETHODCALLTYPE GetPrivateData( - /* [annotation] */ - _In_ REFGUID guid, - /* [annotation] */ - _Inout_ UINT* pDataSize, - /* [annotation] */ - _Out_writes_bytes_opt_(*pDataSize) void* pData) PURE; - - virtual HRESULT STDMETHODCALLTYPE SetPrivateData( - /* [annotation] */ - _In_ REFGUID guid, - /* [annotation] */ - _In_ UINT DataSize, - /* [annotation] */ - _In_reads_bytes_opt_(DataSize) const void* pData) PURE; - - virtual HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( - /* [annotation] */ - _In_ REFGUID guid, - /* [annotation] */ - _In_opt_ const IUnknown* pData) PURE; - - - // Xbox Extra functions: - virtual HRESULT STDMETHODCALLTYPE SetPrivateDataInterfaceGraphics(const _GUID& name, const IGraphicsUnknown* data) - { - return SetPrivateDataInterface(name, reinterpret_cast(data)); - } - - virtual HRESULT STDMETHODCALLTYPE SetName(const wchar_t* name) PURE; - }; - - - - struct ID3D11Resource_X : public ID3D11DeviceChild_X - { - - virtual void STDMETHODCALLTYPE GetType( - /* [annotation] */ - _Out_ D3D11_RESOURCE_DIMENSION * pResourceDimension) PURE; - - virtual void STDMETHODCALLTYPE SetEvictionPriority( - /* [annotation] */ - _In_ UINT EvictionPriority) PURE; - - virtual UINT STDMETHODCALLTYPE GetEvictionPriority(void) PURE; - // xbox extra function - virtual void STDMETHODCALLTYPE GetDescriptor(D3D11X_DESCRIPTOR_RESOURCE* descriptor) PURE; - }; - - struct ID3D11Texture1D_X : public ID3D11Resource_X - { - - virtual void STDMETHODCALLTYPE GetDesc( - /* [annotation] */ - _Out_ D3D11_TEXTURE1D_DESC* pDesc) PURE; - - }; - - struct ID3D11Texture2D_X : public ID3D11Resource_X - { - - virtual void STDMETHODCALLTYPE GetDesc( - /* [annotation] */ - _Out_ D3D11_TEXTURE2D_DESC* pDesc) PURE; - - }; - - struct ID3D11Texture3D_X : public ID3D11Resource_X - { - - virtual void STDMETHODCALLTYPE GetDesc( - /* [annotation] */ - _Out_ D3D11_TEXTURE3D_DESC* pDesc) PURE; - - }; - - struct ID3D11View_X : ID3D11DeviceChild_X - { - public: - ID3D11Resource* m_pResource; - unsigned int m_Type; - - virtual void STDMETHODCALLTYPE GetResource( - /* [annotation] */ - _Outptr_ ID3D11Resource** ppResource) PURE; - - }; - - struct ID3D11RenderTargetView_X : ID3D11View_X - { - public: - virtual void STDMETHODCALLTYPE GetDesc( - /* [annotation] */ - _Out_ D3D11_RENDER_TARGET_VIEW_DESC* pDesc) PURE; - - }; - - struct ID3D11DepthStencilView_X : ID3D11View_X - { - public: - virtual void STDMETHODCALLTYPE GetDesc( - /* [annotation] */ - _Out_ D3D11_DEPTH_STENCIL_VIEW_DESC* pDesc) PURE; - - }; - - struct ID3D11ShaderResourceView_X : ID3D11View_X - { - public: - virtual void STDMETHODCALLTYPE GetDesc( - /* [annotation] */ - _Out_ D3D11_SHADER_RESOURCE_VIEW_DESC* pDesc) PURE; - - }; - - struct ID3D11UnorderedAccessView_X : ID3D11View_X - { - public: - D3D11X_DESCRIPTOR_TEXTURE_VIEW m_Descriptor; - void* m_pAllocationStart; - - virtual void STDMETHODCALLTYPE GetDesc( - /* [annotation] */ - _Out_ D3D11_UNORDERED_ACCESS_VIEW_DESC* pDesc) PURE; - - }; - - struct ID3D11Buffer_X : ID3D11Resource_X - { - public: - virtual void STDMETHODCALLTYPE GetDesc( - /* [annotation] */ - _Out_ D3D11_BUFFER_DESC* pDesc) = 0; - - }; -} \ No newline at end of file diff --git a/dlls/d3d11_x/IDXGI.h b/dlls/d3d11_x/IDXGI.h deleted file mode 100644 index 20f279e..0000000 --- a/dlls/d3d11_x/IDXGI.h +++ /dev/null @@ -1,285 +0,0 @@ -#pragma once -#include "pch.h" -#include "d3d_x/d3d11_x_device.h" -#include "d3d_x/d3d_x.hpp" -#include - - - -namespace d3d11x -{ - struct IDXGISwapChain1_X; - - - //MIDL_INTERFACE("aec22fb8-76f3-4639-9be0-28eb43a67a2e") - struct IDXGIObject_X : public IGraphicsUnknown - { - /* 0x0000: fields for IGraphicsUnknown */ - /* 0x0010 */ public: void* m_pPrivateData; - - public: - virtual HRESULT STDMETHODCALLTYPE SetPrivateData(_In_ REFGUID Name, UINT DataSize, _In_reads_bytes_(DataSize) const void* pData) PURE; - virtual HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(_In_ REFGUID Name, _In_opt_ const IUnknown* pUnknown) PURE; - /*virtual HRESULT STDMETHODCALLTYPE SetPrivateDataInterfaceGraphics(_In_ REFGUID Name, const IGraphicsUnknown* data) - { - return this->SetPrivateDataInterface(Name, reinterpret_cast(data)); - }*/ - virtual HRESULT STDMETHODCALLTYPE GetPrivateData(_In_ REFGUID Name, _Inout_ UINT* pDataSize, _Out_writes_bytes_(*pDataSize) void* pData) PURE; - virtual HRESULT STDMETHODCALLTYPE GetParent(_In_ REFIID riid, _COM_Outptr_ void** ppParent) PURE; - }; - - - - - // Adapted to Xbox one (look at pdb) - //MIDL_INTERFACE("7b7166ec-21c7-44ae-b21a-c9ae321ae369") - struct IDXGIFactory_X : public IDXGIObject_X - { - public: - - /* 0x0000: fields for IDXGIObject */ - /* 0x0018 */ public: IDXGIAdapter2* m_pAdapter; - - virtual HRESULT STDMETHODCALLTYPE EnumAdapters( - UINT Adapter, - - IDXGIAdapter** ppAdapter) PURE; - - virtual HRESULT STDMETHODCALLTYPE MakeWindowAssociation( - HWND WindowHandle, - UINT Flags) PURE; - - virtual HRESULT STDMETHODCALLTYPE GetWindowAssociation( - HWND* pWindowHandle) PURE; - - virtual HRESULT STDMETHODCALLTYPE CreateSwapChain( - IGraphicsUnknown* pDevice, - DXGI_SWAP_CHAIN_DESC* pDesc, - IDXGISwapChain** ppSwapChain) PURE; - - virtual HRESULT STDMETHODCALLTYPE CreateSoftwareAdapter( - HMODULE Module, - IDXGIAdapter** ppAdapter) PURE; - - }; - - - // Adapted to Xbox one (look at pdb) - //MIDL_INTERFACE("770aae78-f26f-4dba-a829-253c83d1b387") - struct IDXGIFactory1_X : public IDXGIFactory_X - { - public: - virtual HRESULT STDMETHODCALLTYPE EnumAdapters1(UINT Adapter, IDXGIAdapter1** ppAdapter) PURE; - - virtual BOOL STDMETHODCALLTYPE IsCurrent(void) PURE; - }; - - - // Adapted to Xbox one (look at pdb) - //MIDL_INTERFACE("50c83a1c-e072-4c48-87b0-3630fa36a6d0") - struct IDXGIFactory2_X : public IDXGIFactory1_X - { - public: - virtual BOOL STDMETHODCALLTYPE IsWindowedStereoEnabled(void) PURE; - - - - virtual HRESULT STDMETHODCALLTYPE CreateSwapChainForHwnd(IGraphicsUnknown* pDevice, - HWND hWnd, const DXGI_SWAP_CHAIN_DESC1* pDesc, - const DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pFullscreenDesc, - IDXGIOutput* pRestrictToOutput, - IDXGISwapChain1** ppSwapChain) PURE; - - virtual HRESULT STDMETHODCALLTYPE CreateSwapChainForCoreWindow( - IGraphicsUnknown* pDevice, - IUnknown* pWindow, - DXGI_SWAP_CHAIN_DESC1* pDesc, - IDXGIOutput* pRestrictToOutput, - IDXGISwapChain1_X** ppSwapChain) PURE; - - virtual HRESULT STDMETHODCALLTYPE GetSharedResourceAdapterLuid( - HANDLE hResource, - LUID* pLuid) PURE; - - virtual HRESULT STDMETHODCALLTYPE RegisterStereoStatusWindow( - HWND WindowHandle, - UINT wMsg, - DWORD* pdwCookie) PURE; - - virtual HRESULT STDMETHODCALLTYPE RegisterStereoStatusEvent( - HANDLE hEvent, - DWORD* pdwCookie) PURE; - - virtual void STDMETHODCALLTYPE UnregisterStereoStatus( - DWORD dwCookie) PURE; - - virtual HRESULT STDMETHODCALLTYPE RegisterOcclusionStatusWindow( - HWND WindowHandle, - UINT wMsg, - DWORD* pdwCookie) PURE; - - virtual HRESULT STDMETHODCALLTYPE RegisterOcclusionStatusEvent( - HANDLE hEvent, - DWORD* pdwCookie) PURE; - - virtual void STDMETHODCALLTYPE UnregisterOcclusionStatus( - DWORD dwCookie) PURE; - - virtual HRESULT STDMETHODCALLTYPE CreateSwapChainForComposition( - IGraphicsUnknown* pDevice, - const DXGI_SWAP_CHAIN_DESC1* pDesc, - IDXGIOutput* pRestrictToOutput, - IDXGISwapChain1** ppSwapChain) PURE; - - }; - - - struct IDXGIAdapter_X : IDXGIObject_X - { - virtual HRESULT STDMETHODCALLTYPE EnumOutputs(UINT Output, IDXGIOutput** ppOutput) PURE; - - virtual HRESULT STDMETHODCALLTYPE GetDesc(DXGI_ADAPTER_DESC* pDesc) PURE; - - virtual HRESULT STDMETHODCALLTYPE CheckInterfaceSupport(REFGUID InterfaceName, LARGE_INTEGER* pUMDVersion) PURE; - - }; - - struct IDXGIDevice_X : d3d11x::IDXGIObject_X - { - virtual HRESULT STDMETHODCALLTYPE GetAdapter(IDXGIAdapter_X** pAdapter) PURE; - - virtual HRESULT STDMETHODCALLTYPE CreateSurface(const DXGI_SURFACE_DESC* pDesc, UINT NumSurfaces, DXGI_USAGE Usage, - const DXGI_SHARED_RESOURCE* pSharedResource, - _Out_writes_(NumSurfaces) IDXGISurface** ppSurface) PURE; - - virtual HRESULT STDMETHODCALLTYPE QueryResourceResidency( - _In_reads_(NumResources) IGraphicsUnknown** ppResources, - _Out_writes_(NumResources) DXGI_RESIDENCY* pResidencyStatus, - /* [in] */ UINT NumResources) PURE; - - virtual HRESULT STDMETHODCALLTYPE SetGPUThreadPriority( - /* [in] */ INT Priority) PURE; - - virtual HRESULT STDMETHODCALLTYPE GetGPUThreadPriority( - _Out_ INT* pPriority) PURE; - - }; - - - struct IDXGIDeviceSubObject_X : public IDXGIObject_X - { - public: - virtual HRESULT STDMETHODCALLTYPE GetDevice( - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void** ppDevice) = 0; - }; - - - struct IDXGISwapChain_X : public IDXGIDeviceSubObject_X - { - 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; - - }; - - - struct IDXGISwapChain1_X : public IDXGISwapChain_X - { - - virtual HRESULT STDMETHODCALLTYPE GetDesc1( - /* [annotation][out] */ - _Out_ DXGI_SWAP_CHAIN_DESC1 * pDesc) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetFullscreenDesc( - /* [annotation][out] */ - _Out_ DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pDesc) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetHwnd( - /* [annotation][out] */ - _Out_ HWND* pHwnd) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetCoreWindow( - /* [annotation][in] */ - _In_ REFIID refiid, - /* [annotation][out] */ - _COM_Outptr_ void** ppUnk) = 0; - - virtual HRESULT STDMETHODCALLTYPE Present1( - /* [in] */ UINT SyncInterval, - /* [in] */ UINT PresentFlags, - /* [annotation][in] */ - _In_ const DXGI_PRESENT_PARAMETERS* pPresentParameters) = 0; - - virtual BOOL STDMETHODCALLTYPE IsTemporaryMonoSupported(void) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetRestrictToOutput( - /* [annotation][out] */ - _Out_ IDXGIOutput** ppRestrictToOutput) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetBackgroundColor( - /* [annotation][in] */ - _In_ const DXGI_RGBA* pColor) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetBackgroundColor( - /* [annotation][out] */ - _Out_ DXGI_RGBA* pColor) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetRotation( - /* [annotation][in] */ - _In_ DXGI_MODE_ROTATION Rotation) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetRotation( - /* [annotation][out] */ - _Out_ DXGI_MODE_ROTATION* pRotation) = 0; - - }; - -} diff --git a/dlls/d3d11_x/IDXGIAdapterWrapper.cpp b/dlls/d3d11_x/IDXGIAdapterWrapper.cpp deleted file mode 100644 index 6a9f0a6..0000000 --- a/dlls/d3d11_x/IDXGIAdapterWrapper.cpp +++ /dev/null @@ -1,92 +0,0 @@ -#include "pch.h" -#include "IDXGIWrappers.h" - -namespace d3d11x -{ - - - - - HRESULT IDXGIAdapterWrapper::QueryInterface(REFIID riid, void** ppvObject) - { - if (riid == __uuidof(IDXGIAdapter)) - { - *ppvObject = this; - AddRef( ); - return S_OK; - } - - // DEBUG - char iidstr[ sizeof("{AAAAAAAA-BBBB-CCCC-DDEE-FFGGHHIIJJKK}") ]; - OLECHAR iidwstr[ sizeof(iidstr) ]; - StringFromGUID2(riid, iidwstr, ARRAYSIZE(iidwstr)); - WideCharToMultiByte(CP_UTF8, 0, iidwstr, -1, iidstr, sizeof(iidstr), nullptr, nullptr); - printf("[IDXGIDeviceWrapper] QueryInterface: %s\n", iidstr); - - *ppvObject = nullptr; - return E_NOINTERFACE; - } - - ULONG IDXGIAdapterWrapper::AddRef( ) - { - printf("[IDXGIAdapterWrapper] --> AddRef\n"); - return InterlockedIncrement(&m_RefCount); - } - - ULONG IDXGIAdapterWrapper::Release( ) - { - printf("[IDXGIAdapterWrapper] --> Release\n"); - ULONG refCount = InterlockedDecrement(&m_RefCount); - if (refCount == 0) - delete this; - return refCount; - } - - HRESULT __stdcall IDXGIAdapterWrapper::SetPrivateData(REFGUID Name, UINT DataSize, const void* pData) - { - return m_realAdapter->SetPrivateData(Name, DataSize, pData); - } - - HRESULT __stdcall IDXGIAdapterWrapper::SetPrivateDataInterface(REFGUID Name, const IUnknown* pUnknown) - { - return m_realAdapter->SetPrivateDataInterface(Name, pUnknown); - } - - HRESULT __stdcall IDXGIAdapterWrapper::GetPrivateData(REFGUID Name, UINT* pDataSize, void* pData) - { - return m_realAdapter->GetPrivateData(Name, pDataSize, pData); - } - - HRESULT __stdcall IDXGIAdapterWrapper::GetParent(REFIID riid, void** ppParent) - { - if (riid == __uuidof(IDXGIFactory) || - riid == __uuidof(IDXGIFactory1) || - riid == __uuidof(IDXGIFactory2)) - { - IDXGIFactory2* factory = nullptr; - HRESULT hr = m_realAdapter->GetParent(IID_PPV_ARGS(&factory)); - *ppParent = new IDXGIFactoryWrapper(factory); - this->AddRef( ); - return hr; - } - - *ppParent = nullptr; - return E_NOINTERFACE; - } - - HRESULT __stdcall IDXGIAdapterWrapper::EnumOutputs(UINT Output, IDXGIOutput** ppOutput) - { - return m_realAdapter->EnumOutputs(Output, ppOutput); - } - - HRESULT __stdcall IDXGIAdapterWrapper::GetDesc(DXGI_ADAPTER_DESC* pDesc) - { - return m_realAdapter->GetDesc(pDesc); - } - - HRESULT __stdcall IDXGIAdapterWrapper::CheckInterfaceSupport(REFGUID InterfaceName, LARGE_INTEGER* pUMDVersion) - { - return m_realAdapter->CheckInterfaceSupport(InterfaceName, pUMDVersion); - } - -} \ No newline at end of file diff --git a/dlls/d3d11_x/IDXGIDeviceWrapper.cpp b/dlls/d3d11_x/IDXGIDeviceWrapper.cpp deleted file mode 100644 index 1048e7a..0000000 --- a/dlls/d3d11_x/IDXGIDeviceWrapper.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "pch.h" -#include "IDXGIWrappers.h" -#include "../kernelx/utils.h" - -namespace d3d11x -{ - - HRESULT IDXGIDeviceWrapper::QueryInterface(REFIID riid, void** ppvObject) - { - if (riid == __uuidof(IDXGIDevice)) - { - *ppvObject = this; - AddRef( ); - return S_OK; - } - - // DEBUG - char iidstr[ sizeof("{AAAAAAAA-BBBB-CCCC-DDEE-FFGGHHIIJJKK}") ]; - OLECHAR iidwstr[ sizeof(iidstr) ]; - StringFromGUID2(riid, iidwstr, ARRAYSIZE(iidwstr)); - WideCharToMultiByte(CP_UTF8, 0, iidwstr, -1, iidstr, sizeof(iidstr), nullptr, nullptr); - printf("[IDXGIDeviceWrapper] QueryInterface: %s\n", iidstr); - - *ppvObject = nullptr; - return E_NOINTERFACE; - } - - - - - ULONG IDXGIDeviceWrapper::AddRef( ) - { - printf("[IDXGIDeviceWrapper] --> AddRef\n"); - return InterlockedIncrement(&m_RefCount); - } - - ULONG IDXGIDeviceWrapper::Release( ) - { - printf("[IDXGIDeviceWrapper] --> Release\n"); - ULONG refCount = InterlockedDecrement(&m_RefCount); - if (refCount == 0) - delete this; - return refCount; - } - - HRESULT __stdcall IDXGIDeviceWrapper::SetPrivateData(REFGUID Name, UINT DataSize, const void* pData) - { - return m_realDevice->SetPrivateData(Name, DataSize, pData); - } - - HRESULT __stdcall IDXGIDeviceWrapper::SetPrivateDataInterface(REFGUID Name, const IUnknown* pUnknown) - { - return m_realDevice->SetPrivateDataInterface(Name, pUnknown); - } - - HRESULT __stdcall IDXGIDeviceWrapper::GetPrivateData(REFGUID Name, UINT* pDataSize, void* pData) - { - return m_realDevice->GetPrivateData(Name, pDataSize, pData); - } - - HRESULT __stdcall IDXGIDeviceWrapper::GetParent(REFIID riid, void** ppParent) - { - // this should probably check if fails -AleBlbl - HRESULT hr = m_realDevice->GetParent(riid, ppParent); - this->AddRef( ); - - if (IsXboxCallee( )) - { - if (riid == __uuidof(IDXGIAdapter)) - { - *ppParent = new IDXGIAdapterWrapper(reinterpret_cast(*ppParent)); - } - } - return hr; - } - - HRESULT __stdcall IDXGIDeviceWrapper::GetAdapter(IDXGIAdapter_X** pAdapter) - { - IDXGIAdapter* adapter; - HRESULT hr = m_realDevice->GetAdapter(&adapter); - - *pAdapter = new IDXGIAdapterWrapper(adapter); - return hr; - } - - HRESULT __stdcall IDXGIDeviceWrapper::CreateSurface(const DXGI_SURFACE_DESC* pDesc, UINT NumSurfaces, DXGI_USAGE Usage, const DXGI_SHARED_RESOURCE* pSharedResource, IDXGISurface** ppSurface) - { - return m_realDevice->CreateSurface(pDesc, NumSurfaces, Usage, pSharedResource, ppSurface); - } - - HRESULT __stdcall IDXGIDeviceWrapper::QueryResourceResidency(IGraphicsUnknown** ppResources, DXGI_RESIDENCY* pResidencyStatus, UINT NumResources) - { - return m_realDevice->QueryResourceResidency(reinterpret_cast(ppResources), pResidencyStatus, NumResources); - } - - HRESULT __stdcall IDXGIDeviceWrapper::SetGPUThreadPriority(INT Priority) - { - return m_realDevice->SetGPUThreadPriority(Priority); - } - - HRESULT __stdcall IDXGIDeviceWrapper::GetGPUThreadPriority(INT* pPriority) - { - return m_realDevice->GetGPUThreadPriority(pPriority); - } - -} \ No newline at end of file diff --git a/dlls/d3d11_x/IDXGIFactoryWrapper.cpp b/dlls/d3d11_x/IDXGIFactoryWrapper.cpp deleted file mode 100644 index 91e79db..0000000 --- a/dlls/d3d11_x/IDXGIFactoryWrapper.cpp +++ /dev/null @@ -1,213 +0,0 @@ -#include "pch.h" -#include "IDXGIWrappers.h" -#include "ID3DWrappers.h" -#include -#include "../kernelx/CoreWindowWrapperX.h" -#include "overlay/overlay.h" - -#define DXGI_SWAPCHAIN_FLAG_MASK DXGI_SWAP_CHAIN_FLAG_NONPREROTATED | DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH | DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE \ - | DXGI_SWAP_CHAIN_FLAG_RESTRICTED_CONTENT | DXGI_SWAP_CHAIN_FLAG_RESTRICT_SHARED_RESOURCE_DRIVER | DXGI_SWAP_CHAIN_FLAG_DISPLAY_ONLY | DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT \ - | DXGI_SWAP_CHAIN_FLAG_FOREGROUND_LAYER | DXGI_SWAP_CHAIN_FLAG_FULLSCREEN_VIDEO | DXGI_SWAP_CHAIN_FLAG_YUV_VIDEO \ - | DXGI_SWAP_CHAIN_FLAG_HW_PROTECTED | DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING \ - | DXGI_SWAP_CHAIN_FLAG_RESTRICTED_TO_ALL_HOLOGRAPHIC_DISPLAYS - -#define DXGI_SWAPCHAIN_FLAG_MASK DXGI_SWAP_CHAIN_FLAG_NONPREROTATED | DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH | DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE \ - | DXGI_SWAP_CHAIN_FLAG_RESTRICTED_CONTENT | DXGI_SWAP_CHAIN_FLAG_RESTRICT_SHARED_RESOURCE_DRIVER | DXGI_SWAP_CHAIN_FLAG_DISPLAY_ONLY | DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT \ - | DXGI_SWAP_CHAIN_FLAG_FOREGROUND_LAYER | DXGI_SWAP_CHAIN_FLAG_FULLSCREEN_VIDEO | DXGI_SWAP_CHAIN_FLAG_YUV_VIDEO \ - | DXGI_SWAP_CHAIN_FLAG_HW_PROTECTED | DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING \ - | DXGI_SWAP_CHAIN_FLAG_RESTRICTED_TO_ALL_HOLOGRAPHIC_DISPLAYS - -namespace d3d11x -{ - - HRESULT d3d11x::IDXGIFactoryWrapper::QueryInterface(REFIID riid, void** ppvObject) - { - if (riid == __uuidof(IDXGIFactory) || - riid == __uuidof(IDXGIFactory1) || - riid == __uuidof(IDXGIFactory2)) - { - *ppvObject = this; - AddRef( ); - return S_OK; - } - - // DEBUG - char iidstr[ sizeof("{AAAAAAAA-BBBB-CCCC-DDEE-FFGGHHIIJJKK}") ]; - OLECHAR iidwstr[ sizeof(iidstr) ]; - StringFromGUID2(riid, iidwstr, ARRAYSIZE(iidwstr)); - WideCharToMultiByte(CP_UTF8, 0, iidwstr, -1, iidstr, sizeof(iidstr), nullptr, nullptr); - printf("[IDXGIFactoryWrapper] QueryInterface: %s\n", iidstr); - - - *ppvObject = nullptr; - return E_NOINTERFACE; - } - - - - ULONG IDXGIFactoryWrapper::AddRef( ) - { - printf("[IDXGIFactoryWrapper] --> AddRef\n"); - return InterlockedIncrement(&m_RefCount); - } - - ULONG IDXGIFactoryWrapper::Release( ) - { - printf("[IDXGIFactoryWrapper] --> Release\n"); - ULONG refCount = InterlockedDecrement(&m_RefCount); - if (refCount == 0) - delete this; - return refCount; - } - - - - HRESULT __stdcall IDXGIFactoryWrapper::SetPrivateData(REFGUID Name, UINT DataSize, const void* pData) - { - return m_realFactory->SetPrivateData(Name, DataSize, pData); - } - - HRESULT __stdcall IDXGIFactoryWrapper::SetPrivateDataInterface(REFGUID Name, const IUnknown* pUnknown) - { - return m_realFactory->SetPrivateDataInterface(Name, pUnknown); - } - - HRESULT __stdcall IDXGIFactoryWrapper::GetPrivateData(REFGUID Name, UINT* pDataSize, void* pData) - { - return m_realFactory->GetPrivateData(Name, pDataSize, pData); - } - - HRESULT __stdcall IDXGIFactoryWrapper::GetParent(REFIID riid, void** ppParent) - { - return m_realFactory->GetParent(riid, ppParent); - } - - HRESULT __stdcall IDXGIFactoryWrapper::EnumAdapters(UINT Adapter, IDXGIAdapter** ppAdapter) - { - return m_realFactory->EnumAdapters(Adapter, ppAdapter); - } - - HRESULT __stdcall IDXGIFactoryWrapper::MakeWindowAssociation(HWND WindowHandle, UINT Flags) - { - return m_realFactory->MakeWindowAssociation(WindowHandle, Flags); - } - - HRESULT __stdcall IDXGIFactoryWrapper::GetWindowAssociation(HWND* pWindowHandle) - { - return m_realFactory->GetWindowAssociation(pWindowHandle); - } - - HRESULT __stdcall IDXGIFactoryWrapper::CreateSwapChain(IGraphicsUnknown* pDevice, DXGI_SWAP_CHAIN_DESC* pDesc, IDXGISwapChain** ppSwapChain) - { - return m_realFactory->CreateSwapChain(reinterpret_cast(pDevice), pDesc, ppSwapChain); - } - - HRESULT __stdcall IDXGIFactoryWrapper::CreateSoftwareAdapter(HMODULE Module, IDXGIAdapter** ppAdapter) - { - return m_realFactory->CreateSoftwareAdapter(Module, ppAdapter); - } - - HRESULT __stdcall IDXGIFactoryWrapper::EnumAdapters1(UINT Adapter, IDXGIAdapter1** ppAdapter) - { - return m_realFactory->EnumAdapters1(Adapter, ppAdapter); - } - - BOOL __stdcall IDXGIFactoryWrapper::IsCurrent(void) - { - return m_realFactory->IsCurrent( ); - } - - BOOL __stdcall IDXGIFactoryWrapper::IsWindowedStereoEnabled(void) - { - return m_realFactory->IsWindowedStereoEnabled( ); - } - - HRESULT __stdcall IDXGIFactoryWrapper::CreateSwapChainForHwnd(IGraphicsUnknown* pDevice, HWND hWnd, const DXGI_SWAP_CHAIN_DESC1* pDesc, const DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pFullscreenDesc, IDXGIOutput* pRestrictToOutput, IDXGISwapChain1** ppSwapChain) - { - return m_realFactory->CreateSwapChainForHwnd(reinterpret_cast(pDevice), hWnd, pDesc, pFullscreenDesc, pRestrictToOutput, ppSwapChain); - } - - HRESULT __stdcall IDXGIFactoryWrapper::CreateSwapChainForCoreWindow(IGraphicsUnknown* pDevice, IUnknown* pWindow, DXGI_SWAP_CHAIN_DESC1* pDesc, IDXGIOutput* pRestrictToOutput, IDXGISwapChain1_X** ppSwapChain) - { - IDXGISwapChain1* swap = nullptr; - HRESULT hr; - pDesc->Flags &= DXGI_SWAPCHAIN_FLAG_MASK; - pDesc->Scaling = DXGI_SCALING_ASPECT_RATIO_STRETCH; - - if (pWindow == nullptr) - { - ComPtr coreWindowStatic; - RoGetActivationFactory(Wrappers::HStringReference(RuntimeClass_Windows_UI_Core_CoreWindow).Get( ), IID_PPV_ARGS(&coreWindowStatic)); - - ComPtr coreWindow; - coreWindowStatic->GetForCurrentThread(&coreWindow); - - pWindow = coreWindow.Get( ); - - hr = m_realFactory->CreateSwapChainForCoreWindow(reinterpret_cast(pDevice), pWindow, pDesc, pRestrictToOutput, &swap); - - *ppSwapChain = new IDXGISwapChainWrapper(swap); - } - else - { - hr = m_realFactory->CreateSwapChainForCoreWindow(reinterpret_cast(pDevice), reinterpret_cast(pWindow)->m_realWindow, pDesc, pRestrictToOutput, &swap); - *ppSwapChain = new IDXGISwapChainWrapper(swap); - } - - if (WinDurango::g_Overlay == nullptr) - { - ::ID3D11Device2* device; - pDevice->QueryInterface(__uuidof(ID3D11Device), reinterpret_cast(&device)); - device = reinterpret_cast(device)->m_realDevice; - - ::ID3D11DeviceContext* ctx{}; - device->GetImmediateContext(&ctx); - - WinDurango::g_Overlay = new WinDurango::Overlay(device, ctx, reinterpret_cast(*ppSwapChain)->m_realSwapchain); - WinDurango::g_Overlay->Initialize( ); - } - - return hr; - } - - HRESULT __stdcall IDXGIFactoryWrapper::GetSharedResourceAdapterLuid(HANDLE hResource, LUID* pLuid) - { - return m_realFactory->GetSharedResourceAdapterLuid(hResource, pLuid); - } - - HRESULT __stdcall IDXGIFactoryWrapper::RegisterStereoStatusWindow(HWND WindowHandle, UINT wMsg, DWORD* pdwCookie) - { - return m_realFactory->RegisterStereoStatusWindow(WindowHandle, wMsg, pdwCookie); - } - - HRESULT __stdcall IDXGIFactoryWrapper::RegisterStereoStatusEvent(HANDLE hEvent, DWORD* pdwCookie) - { - return m_realFactory->RegisterStereoStatusEvent(hEvent, pdwCookie); - } - - void __stdcall IDXGIFactoryWrapper::UnregisterStereoStatus(DWORD dwCookie) - { - return m_realFactory->UnregisterStereoStatus(dwCookie); - } - - HRESULT __stdcall IDXGIFactoryWrapper::RegisterOcclusionStatusWindow(HWND WindowHandle, UINT wMsg, DWORD* pdwCookie) - { - return m_realFactory->RegisterOcclusionStatusWindow(WindowHandle, wMsg, pdwCookie); - } - - HRESULT __stdcall IDXGIFactoryWrapper::RegisterOcclusionStatusEvent(HANDLE hEvent, DWORD* pdwCookie) - { - return m_realFactory->RegisterOcclusionStatusEvent(hEvent, pdwCookie); - } - - void __stdcall IDXGIFactoryWrapper::UnregisterOcclusionStatus(DWORD dwCookie) - { - return m_realFactory->UnregisterOcclusionStatus(dwCookie); - } - - HRESULT __stdcall IDXGIFactoryWrapper::CreateSwapChainForComposition(IGraphicsUnknown* pDevice, const DXGI_SWAP_CHAIN_DESC1* pDesc, IDXGIOutput* pRestrictToOutput, IDXGISwapChain1** ppSwapChain) - { - return m_realFactory->CreateSwapChainForComposition(reinterpret_cast(pDevice), pDesc, pRestrictToOutput, ppSwapChain); - } - -} diff --git a/dlls/d3d11_x/IDXGISwapChainWrapper.cpp b/dlls/d3d11_x/IDXGISwapChainWrapper.cpp deleted file mode 100644 index 4e06ef5..0000000 --- a/dlls/d3d11_x/IDXGISwapChainWrapper.cpp +++ /dev/null @@ -1,217 +0,0 @@ -#include "pch.h" - -#include -#include - -#include "IDXGIWrappers.h" -#include "ID3DWrappers.h" -#include "overlay/overlay.h" - -namespace d3d11x -{ - // s/o to stackoverflow - template - class frame_rater { - public: - frame_rater( ) : - time_between_frames{ 1 }, - tp{ std::chrono::steady_clock::now( ) } - { - } - - void sleep( ) { - tp += time_between_frames; - std::this_thread::sleep_until(tp); - } - - private: - std::chrono::duration> time_between_frames; - std::chrono::time_point tp; - }; - - inline frame_rater<60> fps60 = {}; - - HRESULT IDXGISwapChainWrapper::QueryInterface(REFIID riid, void** ppvObject) - { - if (riid == __uuidof(IDXGISwapChain1) || riid == __uuidof(IDXGISwapChain)) - { - *ppvObject = this; - AddRef( ); - return S_OK; - } - - // DEBUG - char iidstr[ sizeof("{AAAAAAAA-BBBB-CCCC-DDEE-FFGGHHIIJJKK}") ]; - OLECHAR iidwstr[ sizeof(iidstr) ]; - StringFromGUID2(riid, iidwstr, ARRAYSIZE(iidwstr)); - WideCharToMultiByte(CP_UTF8, 0, iidwstr, -1, iidstr, sizeof(iidstr), nullptr, nullptr); - printf("[IDXGIDeviceWrapper] QueryInterface: %s\n", iidstr); - - *ppvObject = nullptr; - return E_NOINTERFACE; - } - - - ULONG IDXGISwapChainWrapper::AddRef( ) - { - printf("[IDXGISwapChainWrapper] --> AddRef\n"); - return InterlockedIncrement(&m_RefCount); - } - - ULONG IDXGISwapChainWrapper::Release( ) - { - printf("[IDXGISwapChainWrapper] --> Release\n"); - ULONG refCount = InterlockedDecrement(&m_RefCount); - if (refCount == 0) - delete this; - return refCount; - } - - HRESULT __stdcall IDXGISwapChainWrapper::SetPrivateData(REFGUID Name, UINT DataSize, const void* pData) - { - return m_realSwapchain->SetPrivateData(Name, DataSize, pData); - } - - HRESULT __stdcall IDXGISwapChainWrapper::SetPrivateDataInterface(REFGUID Name, const IUnknown* pUnknown) - { - return m_realSwapchain->SetPrivateDataInterface(Name, pUnknown); - } - - HRESULT __stdcall IDXGISwapChainWrapper::GetPrivateData(REFGUID Name, UINT* pDataSize, void* pData) - { - return m_realSwapchain->GetPrivateData(Name, pDataSize, pData); - } - - HRESULT __stdcall IDXGISwapChainWrapper::GetParent(REFIID riid, void** ppParent) - { - return m_realSwapchain->GetParent(riid, ppParent); - } - - HRESULT __stdcall IDXGISwapChainWrapper::GetDevice(REFIID riid, void** ppDevice) - { - return m_realSwapchain->GetDevice(riid, ppDevice); - } - - HRESULT __stdcall IDXGISwapChainWrapper::Present(UINT SyncInterval, UINT Flags) - { - WinDurango::g_Overlay->Present( ); - return m_realSwapchain->Present(SyncInterval, Flags); - } - - HRESULT __stdcall IDXGISwapChainWrapper::GetBuffer(UINT Buffer, REFIID riid, void** ppSurface) - { - if (riid == __uuidof(ID3D11Texture2D)) - { - ID3D11Texture2D* texture2d = nullptr; - HRESULT hr = m_realSwapchain->GetBuffer(Buffer, IID_PPV_ARGS(&texture2d)); - *ppSurface = new ID3D11Texture2DWrapper(texture2d); - this->AddRef( ); - return hr; - } - - *ppSurface = nullptr; - return E_NOINTERFACE; - } - - HRESULT __stdcall IDXGISwapChainWrapper::SetFullscreenState(BOOL Fullscreen, IDXGIOutput* pTarget) - { - return m_realSwapchain->SetFullscreenState(Fullscreen, pTarget); - } - - HRESULT __stdcall IDXGISwapChainWrapper::GetFullscreenState(BOOL* pFullscreen, IDXGIOutput** ppTarget) - { - return m_realSwapchain->GetFullscreenState(pFullscreen, ppTarget); - } - - HRESULT __stdcall IDXGISwapChainWrapper::GetDesc(DXGI_SWAP_CHAIN_DESC* pDesc) - { - return m_realSwapchain->GetDesc(pDesc); - } - - HRESULT __stdcall IDXGISwapChainWrapper::ResizeBuffers(UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags) - { - return m_realSwapchain->ResizeBuffers(BufferCount, Width, Height, NewFormat, SwapChainFlags); - } - - HRESULT __stdcall IDXGISwapChainWrapper::ResizeTarget(const DXGI_MODE_DESC* pNewTargetParameters) - { - return m_realSwapchain->ResizeTarget(pNewTargetParameters); - } - - HRESULT __stdcall IDXGISwapChainWrapper::GetContainingOutput(IDXGIOutput** ppOutput) - { - return m_realSwapchain->GetContainingOutput(ppOutput); - } - - HRESULT __stdcall IDXGISwapChainWrapper::GetFrameStatistics(DXGI_FRAME_STATISTICS* pStats) - { - return m_realSwapchain->GetFrameStatistics(pStats); - } - - HRESULT __stdcall IDXGISwapChainWrapper::GetLastPresentCount(UINT* pLastPresentCount) - { - return m_realSwapchain->GetLastPresentCount(pLastPresentCount); - } - - HRESULT __stdcall IDXGISwapChainWrapper::GetDesc1(DXGI_SWAP_CHAIN_DESC1* pDesc) - { - return m_realSwapchain->GetDesc1(pDesc); - } - - HRESULT __stdcall IDXGISwapChainWrapper::GetFullscreenDesc(DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pDesc) - { - return m_realSwapchain->GetFullscreenDesc(pDesc); - } - - HRESULT __stdcall IDXGISwapChainWrapper::GetHwnd(HWND* pHwnd) - { - return m_realSwapchain->GetHwnd(pHwnd); - } - - HRESULT __stdcall IDXGISwapChainWrapper::GetCoreWindow(REFIID refiid, void** ppUnk) - { - return m_realSwapchain->GetCoreWindow(refiid, ppUnk); - } - - HRESULT __stdcall IDXGISwapChainWrapper::Present1(UINT SyncInterval, UINT PresentFlags, const DXGI_PRESENT_PARAMETERS* pPresentParameters) - { - WinDurango::g_Overlay->Present( ); - - if (pPresentParameters == nullptr) { - //fps60.sleep( ); - return m_realSwapchain->Present(SyncInterval, PresentFlags); - } - - return m_realSwapchain->Present1(SyncInterval, PresentFlags, pPresentParameters); - } - - BOOL __stdcall IDXGISwapChainWrapper::IsTemporaryMonoSupported(void) - { - return m_realSwapchain->IsTemporaryMonoSupported(); - } - - HRESULT __stdcall IDXGISwapChainWrapper::GetRestrictToOutput(IDXGIOutput** ppRestrictToOutput) - { - return m_realSwapchain->GetRestrictToOutput(ppRestrictToOutput); - } - - HRESULT __stdcall IDXGISwapChainWrapper::SetBackgroundColor(const DXGI_RGBA* pColor) - { - return m_realSwapchain->SetBackgroundColor(pColor); - } - - HRESULT __stdcall IDXGISwapChainWrapper::GetBackgroundColor(DXGI_RGBA* pColor) - { - return m_realSwapchain->GetBackgroundColor(pColor); - } - - HRESULT __stdcall IDXGISwapChainWrapper::SetRotation(DXGI_MODE_ROTATION Rotation) - { - return m_realSwapchain->SetRotation(Rotation); - } - - HRESULT __stdcall IDXGISwapChainWrapper::GetRotation(DXGI_MODE_ROTATION* pRotation) - { - return m_realSwapchain->GetRotation(pRotation); - } -} \ No newline at end of file diff --git a/dlls/d3d11_x/IDXGIWrappers.h b/dlls/d3d11_x/IDXGIWrappers.h deleted file mode 100644 index 6a7e39d..0000000 --- a/dlls/d3d11_x/IDXGIWrappers.h +++ /dev/null @@ -1,323 +0,0 @@ -#pragma once -#include "IDXGI.h" - - -namespace d3d11x -{ - class IDXGIFactoryWrapper : public d3d11x::IDXGIFactory2_X - { - public: - - IDXGIFactoryWrapper(IDXGIFactory2* factory) : m_realFactory(factory) - { - m_RefCount = 1; - } - - - // IGraphicsUnknown - HRESULT QueryInterface(REFIID riid, void** ppvObject) override; - - - - - ULONG AddRef( ) override; - ULONG Release( ) override; - - // IDXGIObject - HRESULT STDMETHODCALLTYPE SetPrivateData(_In_ REFGUID Name, UINT DataSize, _In_reads_bytes_(DataSize) const void* pData) override; - HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(_In_ REFGUID Name, _In_opt_ const IUnknown* pUnknown) override; - HRESULT STDMETHODCALLTYPE GetPrivateData(_In_ REFGUID Name, _Inout_ UINT* pDataSize, _Out_writes_bytes_(*pDataSize) void* pData) override; - HRESULT STDMETHODCALLTYPE GetParent(_In_ REFIID riid, _COM_Outptr_ void** ppParent) override; - - // IDXGIFactory - HRESULT STDMETHODCALLTYPE EnumAdapters( - UINT Adapter, - IDXGIAdapter** ppAdapter) override; - HRESULT STDMETHODCALLTYPE MakeWindowAssociation( - HWND WindowHandle, - UINT Flags) override; - HRESULT STDMETHODCALLTYPE GetWindowAssociation( - HWND* pWindowHandle) override; - HRESULT STDMETHODCALLTYPE CreateSwapChain( - IGraphicsUnknown* pDevice, - DXGI_SWAP_CHAIN_DESC* pDesc, - IDXGISwapChain** ppSwapChain) override; - HRESULT STDMETHODCALLTYPE CreateSoftwareAdapter( - HMODULE Module, - IDXGIAdapter** ppAdapter) override; - - - // IDXGIFactory1 - HRESULT STDMETHODCALLTYPE EnumAdapters1(UINT Adapter, IDXGIAdapter1** ppAdapter) override; - BOOL STDMETHODCALLTYPE IsCurrent(void) override; - - - // IDXGIFactory2 - BOOL STDMETHODCALLTYPE IsWindowedStereoEnabled(void) override; - - HRESULT STDMETHODCALLTYPE CreateSwapChainForHwnd(IGraphicsUnknown* pDevice, - HWND hWnd, const DXGI_SWAP_CHAIN_DESC1* pDesc, - const DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pFullscreenDesc, - IDXGIOutput* pRestrictToOutput, - IDXGISwapChain1** ppSwapChain) override; - - HRESULT STDMETHODCALLTYPE CreateSwapChainForCoreWindow( - IGraphicsUnknown* pDevice, - IUnknown* pWindow, - DXGI_SWAP_CHAIN_DESC1* pDesc, - IDXGIOutput* pRestrictToOutput, - IDXGISwapChain1_X** ppSwapChain) override; - - - HRESULT STDMETHODCALLTYPE GetSharedResourceAdapterLuid( - HANDLE hResource, - LUID* pLuid) override; - HRESULT STDMETHODCALLTYPE RegisterStereoStatusWindow( - HWND WindowHandle, - UINT wMsg, - DWORD* pdwCookie) override; - HRESULT STDMETHODCALLTYPE RegisterStereoStatusEvent( - HANDLE hEvent, - DWORD* pdwCookie) override; - void STDMETHODCALLTYPE UnregisterStereoStatus( - DWORD dwCookie) override; - HRESULT STDMETHODCALLTYPE RegisterOcclusionStatusWindow( - HWND WindowHandle, - UINT wMsg, - DWORD* pdwCookie) override; - HRESULT STDMETHODCALLTYPE RegisterOcclusionStatusEvent( - HANDLE hEvent, - DWORD* pdwCookie) override; - void STDMETHODCALLTYPE UnregisterOcclusionStatus( - DWORD dwCookie) override; - HRESULT STDMETHODCALLTYPE CreateSwapChainForComposition( - IGraphicsUnknown* pDevice, - const DXGI_SWAP_CHAIN_DESC1* pDesc, - IDXGIOutput* pRestrictToOutput, - IDXGISwapChain1** ppSwapChain) override; - - private: - ::IDXGIFactory2* m_realFactory; - }; - - - - class IDXGIAdapterWrapper : public IDXGIAdapter_X - { - public: - - IDXGIAdapterWrapper(IDXGIAdapter* adapter) : m_realAdapter(adapter) - { - m_RefCount = 1; - } - - - - // IGraphicsUnknown - HRESULT QueryInterface(REFIID riid, void** ppvObject) override; - ULONG AddRef( ) override; - ULONG Release( ) override; - - // IDXGIObject - HRESULT STDMETHODCALLTYPE SetPrivateData(_In_ REFGUID Name, UINT DataSize, _In_reads_bytes_(DataSize) const void* pData) override; - HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(_In_ REFGUID Name, _In_opt_ const IUnknown* pUnknown) override; - HRESULT STDMETHODCALLTYPE GetPrivateData(_In_ REFGUID Name, _Inout_ UINT* pDataSize, _Out_writes_bytes_(*pDataSize) void* pData) override; - HRESULT STDMETHODCALLTYPE GetParent(_In_ REFIID riid, _COM_Outptr_ void** ppParent) override; - - HRESULT STDMETHODCALLTYPE EnumOutputs( - UINT Output, - IDXGIOutput** ppOutput) override; - - HRESULT STDMETHODCALLTYPE GetDesc( - DXGI_ADAPTER_DESC* pDesc) override; - - HRESULT STDMETHODCALLTYPE CheckInterfaceSupport( - REFGUID InterfaceName, - LARGE_INTEGER* pUMDVersion) override; - - private: - ::IDXGIAdapter* m_realAdapter; - }; - - class IDXGIDeviceWrapper : public IDXGIDevice_X - { - public: - - IDXGIDeviceWrapper(IDXGIDevice1* device) : m_realDevice(device) - { - m_RefCount = 1; - } - - // IGraphicsUnknown - HRESULT QueryInterface(REFIID riid, void** ppvObject) override; - ULONG AddRef( ) override; - ULONG Release( ) override; - - // IDXGIObject - HRESULT STDMETHODCALLTYPE SetPrivateData(_In_ REFGUID Name, UINT DataSize, _In_reads_bytes_(DataSize) const void* pData) override; - HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(_In_ REFGUID Name, _In_opt_ const IUnknown* pUnknown) override; - HRESULT STDMETHODCALLTYPE GetPrivateData(_In_ REFGUID Name, _Inout_ UINT* pDataSize, _Out_writes_bytes_(*pDataSize) void* pData) override; - HRESULT STDMETHODCALLTYPE GetParent(_In_ REFIID riid, _COM_Outptr_ void** ppParent) override; - - HRESULT STDMETHODCALLTYPE GetAdapter( - _COM_Outptr_ IDXGIAdapter_X** pAdapter) override; - - HRESULT STDMETHODCALLTYPE CreateSurface( - _In_ const DXGI_SURFACE_DESC* pDesc, - UINT NumSurfaces, - DXGI_USAGE Usage, - _In_opt_ const DXGI_SHARED_RESOURCE* pSharedResource, - _Out_writes_(NumSurfaces) IDXGISurface** ppSurface) override; - - HRESULT STDMETHODCALLTYPE QueryResourceResidency( - _In_reads_(NumResources) IGraphicsUnknown** ppResources, - _Out_writes_(NumResources) DXGI_RESIDENCY* pResidencyStatus, - UINT NumResources) override; - - HRESULT STDMETHODCALLTYPE SetGPUThreadPriority( - INT Priority) override; - - HRESULT STDMETHODCALLTYPE GetGPUThreadPriority( - _Out_ INT* pPriority) override; - - private: - ::IDXGIDevice* m_realDevice; - }; - - - - - class IDXGISwapChainWrapper : public IDXGISwapChain1_X - { - public: - - IDXGISwapChainWrapper(IDXGISwapChain1* swapchain) : m_realSwapchain(swapchain) - { - m_RefCount = 1; - } - - // IGraphicsUnknown - HRESULT QueryInterface(REFIID riid, void** ppvObject) override; - ULONG AddRef( ) override; - ULONG Release( ) override; - - // IDXGIObject - HRESULT STDMETHODCALLTYPE SetPrivateData(_In_ REFGUID Name, UINT DataSize, _In_reads_bytes_(DataSize) const void* pData) override; - HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(_In_ REFGUID Name, _In_opt_ const IUnknown* pUnknown) override; - HRESULT STDMETHODCALLTYPE GetPrivateData(_In_ REFGUID Name, _Inout_ UINT* pDataSize, _Out_writes_bytes_(*pDataSize) void* pData) override; - HRESULT STDMETHODCALLTYPE GetParent(_In_ REFIID riid, _COM_Outptr_ void** ppParent) override; - - // IDXGIDeviceSubObject - HRESULT STDMETHODCALLTYPE GetDevice( - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][retval][out] */ - _COM_Outptr_ void** ppDevice) override; - - - // IDXGISwapChain - HRESULT STDMETHODCALLTYPE Present( - /* [in] */ UINT SyncInterval, - /* [in] */ UINT Flags) override; - - HRESULT STDMETHODCALLTYPE GetBuffer( - /* [in] */ UINT Buffer, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][out][in] */ - _COM_Outptr_ void** ppSurface) override; - - HRESULT STDMETHODCALLTYPE SetFullscreenState( - /* [in] */ BOOL Fullscreen, - /* [annotation][in] */ - _In_opt_ IDXGIOutput* pTarget) override; - - HRESULT STDMETHODCALLTYPE GetFullscreenState( - /* [annotation][out] */ - _Out_opt_ BOOL* pFullscreen, - /* [annotation][out] */ - _COM_Outptr_opt_result_maybenull_ IDXGIOutput** ppTarget) override; - - HRESULT STDMETHODCALLTYPE GetDesc( - /* [annotation][out] */ - _Out_ DXGI_SWAP_CHAIN_DESC* pDesc) override; - - HRESULT STDMETHODCALLTYPE ResizeBuffers( - /* [in] */ UINT BufferCount, - /* [in] */ UINT Width, - /* [in] */ UINT Height, - /* [in] */ DXGI_FORMAT NewFormat, - /* [in] */ UINT SwapChainFlags) override; - - HRESULT STDMETHODCALLTYPE ResizeTarget( - /* [annotation][in] */ - _In_ const DXGI_MODE_DESC* pNewTargetParameters) override; - - HRESULT STDMETHODCALLTYPE GetContainingOutput( - /* [annotation][out] */ - _COM_Outptr_ IDXGIOutput** ppOutput) override; - - HRESULT STDMETHODCALLTYPE GetFrameStatistics( - /* [annotation][out] */ - _Out_ DXGI_FRAME_STATISTICS* pStats) override; - - HRESULT STDMETHODCALLTYPE GetLastPresentCount( - /* [annotation][out] */ - _Out_ UINT* pLastPresentCount) override; - - - - - HRESULT STDMETHODCALLTYPE GetDesc1( - /* [annotation][out] */ - _Out_ DXGI_SWAP_CHAIN_DESC1* pDesc) override; - - HRESULT STDMETHODCALLTYPE GetFullscreenDesc( - /* [annotation][out] */ - _Out_ DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pDesc) override; - - HRESULT STDMETHODCALLTYPE GetHwnd( - /* [annotation][out] */ - _Out_ HWND* pHwnd) override; - - HRESULT STDMETHODCALLTYPE GetCoreWindow( - /* [annotation][in] */ - _In_ REFIID refiid, - /* [annotation][out] */ - _COM_Outptr_ void** ppUnk) override; - - HRESULT STDMETHODCALLTYPE Present1( - /* [in] */ UINT SyncInterval, - /* [in] */ UINT PresentFlags, - /* [annotation][in] */ - _In_ const DXGI_PRESENT_PARAMETERS* pPresentParameters) override; - - BOOL STDMETHODCALLTYPE IsTemporaryMonoSupported(void) override; - - HRESULT STDMETHODCALLTYPE GetRestrictToOutput( - /* [annotation][out] */ - _Out_ IDXGIOutput** ppRestrictToOutput) override; - - HRESULT STDMETHODCALLTYPE SetBackgroundColor( - /* [annotation][in] */ - _In_ const DXGI_RGBA* pColor)override; - - HRESULT STDMETHODCALLTYPE GetBackgroundColor( - /* [annotation][out] */ - _Out_ DXGI_RGBA* pColor) override; - - HRESULT STDMETHODCALLTYPE SetRotation( - /* [annotation][in] */ - _In_ DXGI_MODE_ROTATION Rotation) override; - - HRESULT STDMETHODCALLTYPE GetRotation( - /* [annotation][out] */ - _Out_ DXGI_MODE_ROTATION* pRotation) override; - - - - public: - IDXGISwapChain1* m_realSwapchain; - }; - -} \ No newline at end of file diff --git a/dlls/d3d11_x/d3d11_x.cpp b/dlls/d3d11_x/d3d11_x.cpp index 9b191a2..5ee181b 100644 --- a/dlls/d3d11_x/d3d11_x.cpp +++ b/dlls/d3d11_x/d3d11_x.cpp @@ -1,13 +1,51 @@ -// ReSharper disable CppInconsistentNaming -// ReSharper disable CppClangTidyClangDiagnosticUnusedFunction -#include "pch.h" - +#include "d3d11_x.h" #include #include - -#include "d3d_x/d3d_x.hpp" -#include "ID3DWrappers.h" #include "overlay/overlay.h" +#include + +#include "device_context_x.h" +#include "device_x.h" + +HRESULT CreateDevice(UINT Flags, wdi::ID3D11Device** ppDevice, wdi::ID3D11DeviceContext** ppImmediateContext) +{ + D3D_FEATURE_LEVEL featurelevels[] = { + D3D_FEATURE_LEVEL_11_1, + D3D_FEATURE_LEVEL_11_0, + }; + + ID3D11Device2* device2{}; + ID3D11DeviceContext2* device_context2{}; + + auto flags = Flags & CREATE_DEVICE_FLAG_MASK; + +#ifdef _DEBUG + flags |= D3D11_CREATE_DEVICE_DEBUG; +#endif + + HRESULT hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, flags, featurelevels, _ARRAYSIZE(featurelevels), D3D11_SDK_VERSION, reinterpret_cast(ppDevice), NULL, reinterpret_cast(ppImmediateContext)); + if (SUCCEEDED(hr)) + { + // get dx11.2 feature level, since that's what dx11.x inherits from + if (ppDevice != nullptr) + { + (*ppDevice)->QueryInterface(IID_PPV_ARGS(&device2)); + *ppDevice = reinterpret_cast(new wd::device_x(device2)); + } + + if (ppImmediateContext != nullptr) + { + (*ppImmediateContext)->QueryInterface(IID_PPV_ARGS(&device_context2)); + *ppImmediateContext = reinterpret_cast(new wd::device_context_x(device_context2)); + } + } + else + { + printf("failed to assign wrapped device, result code 0x%X, error code 0x%X\n", hr, GetLastError( )); + } + + return hr; +} HRESULT _stdcall D3DQuerySEQCounters_X(D3D_SEQ_COUNTER_DATA* pData) { @@ -142,9 +180,9 @@ HRESULT __stdcall D3D11CreateDevice_X( _In_reads_opt_(FeatureLevels) CONST D3D_FEATURE_LEVEL* pFeatureLevels, UINT FeatureLevels, UINT SDKVersion, - _Out_opt_ d3d11x::ID3D11Device** ppDevice, + _Out_opt_ wdi::ID3D11Device** ppDevice, _Out_opt_ D3D_FEATURE_LEVEL* pFeatureLevel, - _Out_opt_ d3d11x::ID3D11DeviceContext** ppImmediateContext) + _Out_opt_ wdi::ID3D11DeviceContext** ppImmediateContext) { printf("!!! Game is trying to initialize D3D11 through NORMAL D3D11 !!!\n"); printf("SDK Version: %d\n", SDKVersion); @@ -164,67 +202,28 @@ HRESULT __stdcall D3D11CreateDevice_X( ID3D11DeviceContext2* device_context2{}; auto flags = Flags & CREATE_DEVICE_FLAG_MASK; #ifdef _DEBUG - //flags |= D3D11_CREATE_DEVICE_DEBUG; + flags |= D3D11_CREATE_DEVICE_DEBUG; #endif - HRESULT hr = D3D11CreateDevice(pAdapter, DriverType, Software, flags, featurelevels, _ARRAYSIZE(featurelevels), SDKVersion, (ID3D11Device**)ppDevice, pFeatureLevel, (ID3D11DeviceContext**)ppImmediateContext); - + HRESULT hr = D3D11CreateDevice(pAdapter, DriverType, Software, flags, featurelevels, _ARRAYSIZE(featurelevels), SDKVersion, (ID3D11Device**) ppDevice, pFeatureLevel, (ID3D11DeviceContext**) ppImmediateContext); - if (SUCCEEDED(hr)) + + if (SUCCEEDED(hr)) { // get dx11.2 feature level, since that's what dx11.x inherits from - if (ppDevice != nullptr) + if (ppDevice != nullptr) { (*ppDevice)->QueryInterface(IID_PPV_ARGS(&device2)); - *ppDevice = reinterpret_cast(new d3d11x::D3D11DeviceXWrapperX(device2)); + *ppDevice = reinterpret_cast(new wd::device_x(device2)); } if (ppImmediateContext != nullptr) { (*ppImmediateContext)->QueryInterface(IID_PPV_ARGS(&device_context2)); - *ppImmediateContext = reinterpret_cast(new d3d11x::ID3D11DeviceContextXWrapper(device_context2)); + *ppImmediateContext = reinterpret_cast(new wd::device_context_x(device_context2)); } } else - { - printf("failed to assign wrapped device, result code 0x%X, error code 0x%X\n", hr, GetLastError()); - } - - return hr; -} - -HRESULT __stdcall D3D11XCreateDeviceX_X( - _In_ const D3D11X_CREATE_DEVICE_PARAMETERS* pParameters, - _Out_opt_ d3d11x::ID3D11Device** ppDevice, - _Out_opt_ d3d11x::ID3D11DeviceContext** ppImmediateContext) -{ - printf("!!! Game is trying to initialize D3D11 through D3D11X !!!"); - printf("SDK Version: %d\n", pParameters->Version); - - D3D_FEATURE_LEVEL featurelevels[] = { - D3D_FEATURE_LEVEL_11_1, - D3D_FEATURE_LEVEL_11_0, - }; - ID3D11Device2* device2{}; - ID3D11DeviceContext2* device_context2{}; - - auto flags = pParameters->Flags & CREATE_DEVICE_FLAG_MASK; -#ifdef _DEBUG - //flags |= D3D11_CREATE_DEVICE_DEBUG; -#endif - - HRESULT hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, 0, flags, featurelevels, _ARRAYSIZE(featurelevels), D3D11_SDK_VERSION, reinterpret_cast(ppDevice), NULL, reinterpret_cast(ppImmediateContext)); - if (SUCCEEDED(hr)) - { - // get dx11.2 feature level, since that's what dx11.x inherits from - // MAYBE-TODO: VS doesn't like this line due to ppDevice not having a clear value. Maybe check if ppDevice is valid before deref. - (*ppDevice)->QueryInterface(IID_PPV_ARGS(&device2)); - (*ppImmediateContext)->QueryInterface(IID_PPV_ARGS(&device_context2)); - - *ppDevice = reinterpret_cast(new d3d11x::D3D11DeviceXWrapperX(device2)); - *ppImmediateContext = reinterpret_cast(new d3d11x::ID3D11DeviceContextXWrapper(device_context2)); - } - else { printf("failed to assign wrapped device, result code 0x%X, error code 0x%X\n", hr, GetLastError( )); } @@ -232,6 +231,17 @@ HRESULT __stdcall D3D11XCreateDeviceX_X( return hr; } +HRESULT __stdcall D3D11XCreateDeviceX_X( + _In_ const D3D11X_CREATE_DEVICE_PARAMETERS* pParameters, + _Out_opt_ wdi::ID3D11Device** ppDevice, + _Out_opt_ wdi::ID3D11DeviceContext** ppImmediateContext) +{ + printf("!!! Game is trying to initialize D3D11 through D3D11X !!!"); + printf("SDK Version: %d\n", pParameters->Version); + + return CreateDevice(pParameters->Flags, ppDevice, ppImmediateContext); +} + HRESULT __stdcall D3D11CreateDeviceAndSwapChain_X( _In_opt_ IDXGIAdapter* pAdapter, D3D_DRIVER_TYPE DriverType, @@ -251,6 +261,8 @@ HRESULT __stdcall D3D11CreateDeviceAndSwapChain_X( return D3D11CreateDeviceAndSwapChain(pAdapter, DriverType, Software, Flags, pFeatureLevels, FeatureLevels, SDKVersion, pSwapChainDesc, ppSwapChain, ppDevice, pFeatureLevel, ppImmediateContext); } + + std::mutex g_NotifyMutex; // this function exists for other WinDurango dlls to notify the graphics component of an action diff --git a/dlls/d3d11_x/d3d11_x.h b/dlls/d3d11_x/d3d11_x.h index 633c73f..7dcb166 100644 --- a/dlls/d3d11_x/d3d11_x.h +++ b/dlls/d3d11_x/d3d11_x.h @@ -2,8 +2,10 @@ #ifndef D3D11_X #define D3D11_X +#include +#include + #include "dxgi1_5.h" -#include "d3d_x/d3d_x.hpp" // remove all XBOX only flags passed to CreateDevice #define CREATE_DEVICE_FLAG_MASK (D3D11_CREATE_DEVICE_SINGLETHREADED | D3D11_CREATE_DEVICE_DEBUG | D3D11_CREATE_DEVICE_SWITCH_TO_REF | \ @@ -117,7 +119,46 @@ extern "C" const GUID DXGI_DEBUG_ALL; DEFINE_GUID(DXGI_DEBUG_DX, 0x35cdd7fc, 0x13b2, 0x421d, 0xa5, 0xd7, 0x7e, 0x44, 0x51, 0x28, 0x7d, 0x64); DEFINE_GUID(DXGI_DEBUG_DXGI, 0x25cddaa4, 0xb1c6, 0x47e1, 0xac, 0x3e, 0x98, 0x87, 0x5b, 0x5a, 0x2e, 0x2a); DEFINE_GUID(DXGI_DEBUG_APP, 0x6cd6e01, 0x4219, 0x4ebd, 0x87, 0x9, 0x27, 0xed, 0x23, 0x36, 0xc, 0x62); - DEFINE_GUID(DXGI_DEBUG_D3D11, 0x4b99317b, 0xac39, 0x4aa6, 0xbb, 0xb, 0xba, 0xa0, 0x47, 0x84, 0x79, 0x8f); +#define DX_MAJOR 2 +#define DX_MINOR 18 + +#define MAKEINTVERSION(major, minor) (((0LL + (major)) << 48) | ((0LL + (minor)) << 32)) +#define DX_VERSION (((0LL + (DX_MAJOR)) << 48) | ((0LL + (DX_MINOR)) << 32)) + +#define D3DDECL_UUID(Uuid) __declspec(uuid(#Uuid)) +#define D3DINTERFACE(Name, Guid0, Guid1, Guid2, Guid3, Guid4, \ + Guid5, Guid6, Guid7, Guid8, Guid9, Guid10) \ + class D3DDECL_UUID(Guid0-Guid1-Guid2-Guid3##Guid4-Guid5##Guid6##Guid7##Guid8##Guid9##Guid10) Name + +#define TRACE_INTERFACE_NOT_HANDLED(class_name) \ + char iidstr[ sizeof("{AAAAAAAA-BBBB-CCCC-DDEE-FFGGHHIIJJKK}") ]; \ + OLECHAR iidwstr[ sizeof(iidstr) ]; \ + StringFromGUID2(riid, iidwstr, ARRAYSIZE(iidwstr)); \ + WideCharToMultiByte(CP_UTF8, 0, iidwstr, -1, iidstr, sizeof(iidstr), nullptr, nullptr); \ + MessageBoxA(NULL, std::format("[{}] INTERFACE NOT HANDLED: {}", class_name, iidstr).c_str(), "WD - d3d11_x", MB_OK) \ + +#define IGU_DEFINE_REF \ + ULONG AddRef( ) override { \ + wrapped_interface->AddRef( ); \ + return InterlockedIncrement(&m_RefCount); \ + } \ + \ + ULONG Release( ) override { \ + ULONG refCount = InterlockedDecrement(&m_RefCount); \ + wrapped_interface->Release( ); \ + \ + if (refCount == 0) \ + { \ + wrapped_interface->Release( ); \ + delete this; \ + } \ + \ + return refCount; \ + } \ + +#define TRACE_NOT_IMPLEMENTED(class_name) \ + MessageBoxA(NULL, std::format("[{}] NOT IMPLEMENTED\n{} - line {}", class_name, __FILE__, __LINE__).c_str(), "WD - d3d11_x", MB_OK) \ + #endif \ No newline at end of file diff --git a/dlls/d3d11_x/d3d11_x.vcxproj b/dlls/d3d11_x/d3d11_x.vcxproj index b7b6e63..6ac3e33 100644 --- a/dlls/d3d11_x/d3d11_x.vcxproj +++ b/dlls/d3d11_x/d3d11_x.vcxproj @@ -57,9 +57,9 @@ true _DEBUG;D3D11X_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - Use + NotUsing pch.h - stdcpp17 + stdcpp20 Windows @@ -77,8 +77,9 @@ true NDEBUG;D3D11X_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - Use + NotUsing pch.h + stdcpp20 Windows @@ -86,10 +87,35 @@ true true false - d3d11.lib;%(AdditionalDependencies);runtimeobject.lib + d3d10.lib;d3d11.lib;dxgi.lib;%(AdditionalDependencies);runtimeobject.lib Exports.def + + + + + + + + + + + + + + + + + + + + + + + + + @@ -100,66 +126,18 @@ - - - - - - - - + + + + + + + + + - - - - - NotUsing - NotUsing - - - NotUsing - NotUsing - - - NotUsing - NotUsing - - - NotUsing - NotUsing - - - NotUsing - NotUsing - - - NotUsing - NotUsing - - - NotUsing - NotUsing - - - - - - - - - - - - - - - - Create - Create - - - - + + diff --git a/dlls/d3d11_x/d3d11_x.vcxproj.filters b/dlls/d3d11_x/d3d11_x.vcxproj.filters index 548326d..c878ba1 100644 --- a/dlls/d3d11_x/d3d11_x.vcxproj.filters +++ b/dlls/d3d11_x/d3d11_x.vcxproj.filters @@ -1,156 +1,161 @@  - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {21a7221a-d303-4d64-98fa-eb1ef76f3c17} - - - {a66d9c88-9c40-410e-8899-f02975549067} - - - {cc2a8930-4142-49f7-9b17-f71e472520ed} - - - {93367b01-f957-4ef5-82c7-4aab1139fc9c} - + + - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files\IDXGI - - - Header Files\ID3D - - - Header Files\ID3D - - - Header Files\ID3D - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Header Files\IDXGI - - - Source Files\IDXGI - - - Source Files\IDXGI - - - Source Files\IDXGI - - - Source Files\ID3D - - - Source Files\IDXGI - - - Source Files\ID3D - - - Source Files - - - Source Files\ID3D - - - Source Files - + + - Source Files + imgui - Source Files + imgui - Source Files + imgui - Source Files + imgui - Source Files + imgui - Source Files + imgui - Source Files + imgui + + wrappers\device_context_x + + + wrappers\graphics_unknown + + + wrappers\device_x + + + wrappers\dxgi_factory + + + wrappers\dxgi_swapchain + + + wrappers\dxgi_adapter + + + wrappers\dxgi_device + + + wrappers\device_child_x + + + overlay + + - + + + imgui + + + imgui + + + imgui + + + imgui + + + imgui + + + imgui + + + imgui + + + imgui + + + wrappers\graphics_unknown + + + wrappers\device_x + + + wrappers\dxgi_factory + + + wrappers\dxgi_swapchain + + + wrappers\dxgi_adapter + + + wrappers\dxgi_device + + + wrappers\device_child_x + + + wrappers\device_context_x + + + wrappers\shared + + + wrappers\shared + + + overlay + + + wrappers\shared + + + + + {05dbf885-3dd2-475f-8171-033a782575c9} + + + {39b32424-9e02-45ef-aa1d-35d2c826c195} + + + {1a6f44de-5d28-438f-979d-fa49751b49b1} + + + {8b45d36f-f82a-42a4-9ab4-49cd5f4e84f5} + + + {fa3c5ff2-f1d3-47ab-b788-aeae8b5b1fa3} + + + {779f96ac-8cf1-454a-b925-af90d267f050} + + + {04a867f6-7f1f-46a0-90ee-c8b5406ecb04} + + + {4da0bfed-551b-45f1-81fc-f183c0e9d847} + + + {2afc72a9-22d2-49a6-a611-f539527d3e1c} + + + {e284d976-b304-4e1e-98ef-7a22d8eeaa8d} + + + {a326eddd-f6a8-4e01-bd0b-6c5b91adf983} + + + {c54987f8-e8bd-47e3-8940-2740f44a8f49} + \ No newline at end of file diff --git a/dlls/d3d11_x/d3d_x/d3d11_x_device.cpp b/dlls/d3d11_x/d3d_x/d3d11_x_device.cpp deleted file mode 100644 index f4dd4ec..0000000 --- a/dlls/d3d11_x/d3d_x/d3d11_x_device.cpp +++ /dev/null @@ -1,478 +0,0 @@ -#include "pch.h" -#include "d3d11_x_device.h" -#include "d3d_x.hpp" -#include "../IDXGIWrappers.h" -#include "../ID3DWrappers.h" - -#pragma region ID3D11DeviceX - -// QueryInterface need to be in the cpp file because of circular dependency for IDXGIDeviceWrapper :} - -#define TEXTURE_MISCFLAGS_MASK (D3D11_RESOURCE_MISC_GENERATE_MIPS | D3D11_RESOURCE_MISC_SHARED | D3D11_RESOURCE_MISC_TEXTURECUBE | \ - D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS | D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS | D3D11_RESOURCE_MISC_BUFFER_STRUCTURED | \ - D3D11_RESOURCE_MISC_RESOURCE_CLAMP | D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX | D3D11_RESOURCE_MISC_GDI_COMPATIBLE | \ - D3D11_RESOURCE_MISC_SHARED_NTHANDLE | D3D11_RESOURCE_MISC_RESTRICTED_CONTENT | D3D11_RESOURCE_MISC_RESTRICT_SHARED_RESOURCE | \ - D3D11_RESOURCE_MISC_RESTRICT_SHARED_RESOURCE_DRIVER | D3D11_RESOURCE_MISC_GUARDED | \ - D3D11_RESOURCE_MISC_TILED | D3D11_RESOURCE_MISC_HW_PROTECTED | D3D11_RESOURCE_MISC_SHARED_DISPLAYABLE | D3D11_RESOURCE_MISC_SHARED_EXCLUSIVE_WRITER) - -#define ERROR_LOG_FUNC() if(FAILED(hr)) { printf("[%s] hresult fail 0x%X\n", __func__, hr); } -#define ERROR_LOG_HRES(res) printf("[%s] hresult fail 0x%X\n", __func__, res); - -HRESULT d3d11x::D3D11DeviceXWrapperX::QueryInterface(REFIID riid, void** ppvObject) -{ - // note from unixian: for debugging purposes - char iidstr[ sizeof("{AAAAAAAA-BBBB-CCCC-DDEE-FFGGHHIIJJKK}") ]; - OLECHAR iidwstr[ sizeof(iidstr) ]; - StringFromGUID2(riid, iidwstr, ARRAYSIZE(iidwstr)); - WideCharToMultiByte(CP_UTF8, 0, iidwstr, -1, iidstr, sizeof(iidstr), nullptr, nullptr); - printf("[D3D11DeviceXWrapperX] QueryInterface: %s\n", iidstr); - - if (riid == __uuidof(ID3D11DeviceX) || riid == __uuidof(ID3D11Device2) || - riid == __uuidof(ID3D11Device1) || riid == __uuidof(ID3D11Device)) - { - *ppvObject = static_cast(this); - AddRef( ); - return S_OK; - } - else if (riid == __uuidof(ID3D11PerformanceDeviceX)) - { - *ppvObject = reinterpret_cast(this); - AddRef( ); - return S_OK; - } - - if (riid == __uuidof(IDXGIDevice) || - riid == __uuidof(IDXGIDevice1)) - { - HRESULT hr = m_realDevice->QueryInterface(__uuidof(IDXGIDevice1), ppvObject); - *ppvObject = new IDXGIDeviceWrapper(static_cast(*ppvObject)); - return S_OK; - } - - return m_realDevice->QueryInterface(riid, ppvObject); -} - -HRESULT d3d11x::D3D11DeviceXWrapperX::CreateTexture1D( - const D3D11_TEXTURE1D_DESC* pDesc, - const D3D11_SUBRESOURCE_DATA* pInitialData, - ID3D11Texture1D_X** ppTexture1D) { - - ID3D11Texture1D* texture1d = nullptr; - HRESULT hr = m_realDevice->CreateTexture1D(pDesc, pInitialData, &texture1d); - - printf("[CreateTexture1D] created texture at 0x%llX\n", texture1d); - - ERROR_LOG_FUNC( ); - if (ppTexture1D != nullptr) - { - *ppTexture1D = SUCCEEDED(hr) ? new ID3D11Texture1DWrapper(texture1d) : nullptr; - } - - return hr; -} - -HRESULT d3d11x::D3D11DeviceXWrapperX::CreateTexture2D( - D3D11_TEXTURE2D_DESC* pDesc, - const D3D11_SUBRESOURCE_DATA* pInitialData, - ID3D11Texture2D_X** ppTexture2D) { - - ID3D11Texture2D* texture2d = nullptr; - pDesc->MiscFlags &= TEXTURE_MISCFLAGS_MASK; // remove all flags that are xbox-one only flags - - if (pDesc->Usage == D3D11_USAGE_DYNAMIC) - pDesc->CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - - HRESULT hr = m_realDevice->CreateTexture2D(pDesc, pInitialData, &texture2d); - - printf("[CreateTexture2D] created texture at 0x%llX\n", texture2d); - - ERROR_LOG_FUNC( ); - if (ppTexture2D != nullptr) - { - *ppTexture2D = SUCCEEDED(hr) ? new ID3D11Texture2DWrapper(texture2d) : nullptr; - } - - return hr; -} - -HRESULT d3d11x::D3D11DeviceXWrapperX::CreateTexture3D( - const D3D11_TEXTURE3D_DESC* pDesc, - const D3D11_SUBRESOURCE_DATA* pInitialData, - ID3D11Texture3D_X** ppTexture3D) { - - ID3D11Texture3D* texture3d = nullptr; - HRESULT hr = m_realDevice->CreateTexture3D(pDesc, pInitialData, &texture3d); - - printf("[CreateTexture3D] created texture at 0x%llX\n", texture3d); - - ERROR_LOG_FUNC( ); - if (ppTexture3D != nullptr) - { - *ppTexture3D = SUCCEEDED(hr) ? new ID3D11Texture3DWrapper(texture3d) : nullptr; - } - - return hr; -} - -HRESULT d3d11x::D3D11DeviceXWrapperX::CreateShaderResourceView( - ID3D11Resource* pResource, - const D3D11_SHADER_RESOURCE_VIEW_DESC* pDesc, - ID3D11ShaderResourceView_X** ppSRView) { - - ::ID3D11ShaderResourceView* target = nullptr; - HRESULT hr = m_realDevice->CreateShaderResourceView(reinterpret_cast(pResource)->m_realResource, pDesc, &target); - - ERROR_LOG_FUNC( ); - if (ppSRView != nullptr) - { - *ppSRView = SUCCEEDED(hr) ? reinterpret_cast(new ID3D11ShaderResourceViewWrapper(target)) - : nullptr; - } - - return hr; -} - -HRESULT d3d11x::D3D11DeviceXWrapperX::CreateUnorderedAccessView( - ID3D11Resource* pResource, - const D3D11_UNORDERED_ACCESS_VIEW_DESC* pDesc, - ID3D11UnorderedAccessView_X** ppUAView) { - - ::ID3D11UnorderedAccessView* target = nullptr; - HRESULT hr = m_realDevice->CreateUnorderedAccessView(reinterpret_cast(pResource)->m_realResource, pDesc, &target); - - ERROR_LOG_FUNC( ); - if (ppUAView != nullptr) - { - *ppUAView = SUCCEEDED(hr) ? reinterpret_cast(new ID3D11UnorderedAccessViewWrapper(target)) - : nullptr; - } - - return hr; -} - -HRESULT d3d11x::D3D11DeviceXWrapperX::CreateRenderTargetView( - ID3D11Resource* pResource, - const D3D11_RENDER_TARGET_VIEW_DESC* pDesc, - ID3D11RenderTargetView_X** ppRTView) { - - ::ID3D11RenderTargetView* target = nullptr; - HRESULT hr = m_realDevice->CreateRenderTargetView(reinterpret_cast(pResource)->m_realResource, pDesc, &target); - - ERROR_LOG_FUNC( ); - if (ppRTView != nullptr) - { - *ppRTView = SUCCEEDED(hr) ? reinterpret_cast(new ID3D11RenderTargetViewWrapper(target)) - : nullptr; - } - - return hr; -} - -HRESULT d3d11x::D3D11DeviceXWrapperX::CreateDepthStencilView( - ID3D11Resource* pResource, - const D3D11_DEPTH_STENCIL_VIEW_DESC* pDesc, - ID3D11DepthStencilView_X** ppDepthStencilView) { - - ::ID3D11DepthStencilView* target = nullptr; - HRESULT hr = m_realDevice->CreateDepthStencilView(reinterpret_cast(pResource)->m_realResource, pDesc, &target); - - ERROR_LOG_FUNC( ); - if (ppDepthStencilView != nullptr) - { - *ppDepthStencilView = SUCCEEDED(hr) ? reinterpret_cast(new ID3D11DepthStencilViewWrapper(target)) - : nullptr; - } - - return hr; -} - -void d3d11x::D3D11DeviceXWrapperX::GetImmediateContext(ID3D11DeviceContext** ppImmediateContext) -{ - ::ID3D11DeviceContext* ctx{}; - m_realDevice->GetImmediateContext(&ctx); - - if (!ctx) return; - - ::ID3D11DeviceContext2* ctx2{}; - ctx->QueryInterface(IID_PPV_ARGS(&ctx2)); - - *ppImmediateContext = reinterpret_cast(new d3d11x::ID3D11DeviceContextXWrapper(ctx2)); -} - -HRESULT d3d11x::D3D11DeviceXWrapperX::CreateDeferredContext(UINT ContextFlags, d3d11x::ID3D11DeviceContext** ppDeferredContext) -{ - ::ID3D11DeviceContext* ctx{}; - HRESULT hr = m_realDevice->CreateDeferredContext(ContextFlags, &ctx); - - ERROR_LOG_FUNC( ); - if (ppDeferredContext != nullptr && SUCCEEDED(hr)) - { - ::ID3D11DeviceContext2* ctx2{}; - ctx->QueryInterface(IID_PPV_ARGS(&ctx2)); - - *ppDeferredContext = reinterpret_cast(new d3d11x::ID3D11DeviceContextXWrapper(ctx2)); - } - - return hr; -} - -HRESULT d3d11x::D3D11DeviceXWrapperX::CreateBuffer( - const D3D11_BUFFER_DESC* pDesc, - const D3D11_SUBRESOURCE_DATA* pInitialData, - d3d11x::ID3D11Buffer_X** ppBuffer) -{ - ID3D11Buffer* buffer = nullptr; - HRESULT hr = m_realDevice->CreateBuffer(pDesc, pInitialData, &buffer); - - ERROR_LOG_FUNC( ); - if (ppBuffer != nullptr) - { - *ppBuffer = SUCCEEDED(hr) ? new ID3D11BufferWrapper(buffer) : nullptr; - } - - return hr; -} - - -void d3d11x::D3D11DeviceXWrapperX::GetImmediateContextX( - _Out_ ID3D11DeviceContextX** ppImmediateContextX) -{ - printf("[D3D11DeviceXWrapperX] GetImmediateContextX"); -} - -HRESULT d3d11x::D3D11DeviceXWrapperX::CreateCounterSet( - _In_ const D3D11X_COUNTER_SET_DESC* pCounterSetDesc, - _Out_opt_ ID3D11CounterSetX** ppCounterSet) -{ - printf("[D3D11DeviceXWrapperX] CreateCounterSet"); - return E_NOTIMPL; -} - -HRESULT d3d11x::D3D11DeviceXWrapperX::CreateCounterSample( - _Out_opt_ ID3D11CounterSampleX** ppCounterSample) -{ - printf("[D3D11DeviceXWrapperX] CreateCounterSample"); - return E_NOTIMPL; -} - -HRESULT d3d11x::D3D11DeviceXWrapperX::SetDriverHint( - _In_ UINT Feature, - _In_ UINT Value) -{ - printf("[D3D11DeviceXWrapperX] SetDriverHint"); - return E_NOTIMPL; -} - -HRESULT d3d11x::D3D11DeviceXWrapperX::CreateDmaEngineContext( - _In_ const D3D11_DMA_ENGINE_CONTEXT_DESC* pDmaEngineContextDesc, - _Out_ d3d11x::ID3D11DmaEngineContextX** ppDmaDeviceContext) -{ - printf("[D3D11DeviceXWrapperX] CreateDmaEngineContext"); - return E_NOTIMPL; -} - -BOOL d3d11x::D3D11DeviceXWrapperX::IsFencePending(UINT64 Fence) -{ - printf("[D3D11DeviceXWrapperX] IsFencePending"); - return E_NOTIMPL; -} - -BOOL d3d11x::D3D11DeviceXWrapperX::IsResourcePending( - _In_ ID3D11Resource* pResource) -{ - printf("[D3D11DeviceXWrapperX] IsResourcePending"); - return E_NOTIMPL; -} - -HRESULT d3d11x::D3D11DeviceXWrapperX::CreatePlacementBuffer( - _In_ const D3D11_BUFFER_DESC* pDesc, - _In_ void* pAddress, - _Out_opt_ ID3D11Buffer** ppBuffer) -{ - printf("[D3D11DeviceXWrapperX] CreatePlacementBuffer"); - return E_NOTIMPL; -} - -HRESULT d3d11x::D3D11DeviceXWrapperX::CreatePlacementTexture1D( - _In_ const D3D11_TEXTURE1D_DESC* pDesc, - _In_ UINT TileModeIndex, - _In_ UINT Pitch, - _In_ void* pAddress, - _Out_opt_ ID3D11Texture1D** ppTexture1D) -{ - printf("[D3D11DeviceXWrapperX] CreatePlacementTexture1D"); - return E_NOTIMPL; -} - -HRESULT d3d11x::D3D11DeviceXWrapperX::CreatePlacementTexture2D( - _In_ const D3D11_TEXTURE2D_DESC* pDesc, - _In_ UINT TileModeIndex, - _In_ UINT Pitch, - _In_ void* pAddress, - _Out_opt_ ID3D11Texture2D** ppTexture2D) -{ - printf("[D3D11DeviceXWrapperX] CreatePlacementTexture2D"); - return E_NOTIMPL; -} - -HRESULT d3d11x::D3D11DeviceXWrapperX::CreatePlacementTexture3D( - _In_ const D3D11_TEXTURE3D_DESC* pDesc, - _In_ UINT TileModeIndex, - _In_ UINT Pitch, - _In_ void* pAddress, - _Out_opt_ ID3D11Texture3D** ppTexture3D) -{ - printf("[D3D11DeviceXWrapperX] CreatePlacementTexture3D"); - return E_NOTIMPL; -} - -void d3d11x::D3D11DeviceXWrapperX::GetTimestamps( - _Out_ UINT64* pGpuTimestamp, - _Out_ UINT64* pCpuRdtscTimestamp) -{ - printf("[D3D11DeviceXWrapperX] GetTimestamps"); -} - -HRESULT d3d11x::D3D11DeviceXWrapperX::CreateSamplerStateX( - _In_ const d3d11x::D3D11X_SAMPLER_DESC* pSamplerDesc, - _Out_opt_ ID3D11SamplerState** ppSamplerState) -{ - printf("[D3D11DeviceXWrapperX] CreateSamplerStateX"); - return E_NOTIMPL; -} - -HRESULT d3d11x::D3D11DeviceXWrapperX::CreateDeferredContextX( - UINT ContextFlags, - _Out_ d3d11x::ID3D11DeviceContextX** ppDeferredContext) -{ - printf("[D3D11DeviceXWrapperX] CreateDeferredContextX"); - return E_NOTIMPL; -} - -void d3d11x::D3D11DeviceXWrapperX::GarbageCollect( - _In_ UINT Flags) -{ - printf("[D3D11DeviceXWrapperX] GarbageCollect"); -} - -HRESULT d3d11x::D3D11DeviceXWrapperX::CreateDepthStencilStateX( - _In_ const D3D11_DEPTH_STENCIL_DESC* pDepthStencilStateDescX, - _Out_opt_ ID3D11DepthStencilState** ppDepthStencilState) -{ - printf("[D3D11DeviceXWrapperX] CreateDepthStencilStateX"); - return E_NOTIMPL; -} - -HRESULT d3d11x::D3D11DeviceXWrapperX::CreatePlacementRenderableTexture2D( - _In_ const D3D11_TEXTURE2D_DESC* pDesc, - _In_ UINT TileModeIndex, - _In_ UINT Pitch, - _In_ const D3D11X_RENDERABLE_TEXTURE_ADDRESSES* pAddresses, - _Out_opt_ ID3D11Texture2D** ppTexture2D) -{ - printf("[D3D11DeviceXWrapperX] CreatePlacementRenderableTexture2D"); - return E_NOTIMPL; -} - -void d3d11x::D3D11DeviceXWrapperX::GetDriverStatistics( - _In_ UINT StructSize, - _Out_ D3D11X_DRIVER_STATISTICS* pStatistics) -{ - printf("[D3D11DeviceXWrapperX] GetDriverStatistics"); -} - -HRESULT d3d11x::D3D11DeviceXWrapperX::CreateComputeContextX( - _In_ const d3d11x::D3D11_COMPUTE_CONTEXT_DESC* pComputeContextDesc, - _Out_ d3d11x::ID3D11ComputeContextX** ppComputeContext) -{ - printf("[D3D11DeviceXWrapperX] CreateComputeContextX"); - return E_NOTIMPL; -} - -void d3d11x::D3D11DeviceXWrapperX::ComposeShaderResourceView( - _In_ const D3D11X_DESCRIPTOR_RESOURCE* pDescriptorResource, - _In_opt_ const d3d11x::D3D11X_RESOURCE_VIEW_DESC* pViewDesc, - _Out_ d3d11x::D3D11X_DESCRIPTOR_SHADER_RESOURCE_VIEW* pDescriptorSrv) -{ - printf("[D3D11DeviceXWrapperX] ComposeShaderResourceView"); -} - -void d3d11x::D3D11DeviceXWrapperX::ComposeUnorderedAccessView( - _In_ const D3D11X_DESCRIPTOR_RESOURCE* pDescriptorResource, - _In_opt_ const D3D11X_RESOURCE_VIEW_DESC* pViewDesc, - _Out_ d3d11x::D3D11X_DESCRIPTOR_UNORDERED_ACCESS_VIEW* pDescriptorUav) -{ - printf("[D3D11DeviceXWrapperX] ComposeUnorderedAccessView"); -} - -void d3d11x::D3D11DeviceXWrapperX::ComposeConstantBufferView( - _In_ const D3D11X_DESCRIPTOR_RESOURCE* pDescriptorResource, - _In_opt_ const D3D11X_RESOURCE_VIEW_DESC* pViewDesc, - _Out_ D3D11X_DESCRIPTOR_CONSTANT_BUFFER_VIEW* pDescriptorCb) -{ - printf("[D3D11DeviceXWrapperX] ComposeConstantBufferView"); -} - -void d3d11x::D3D11DeviceXWrapperX::ComposeVertexBufferView( - _In_ const D3D11X_DESCRIPTOR_RESOURCE* pDescriptorResource, - _In_opt_ const D3D11X_RESOURCE_VIEW_DESC* pViewDesc, - _Out_ D3D11X_DESCRIPTOR_VERTEX_BUFFER_VIEW* pDescriptorVb) -{ - printf("[D3D11DeviceXWrapperX] ComposeVertexBufferView"); -} - -void d3d11x::D3D11DeviceXWrapperX::ComposeSamplerState( - _In_opt_ const d3d11x::D3D11X_SAMPLER_STATE_DESC* pSamplerDesc, - _Out_ d3d11x::D3D11X_DESCRIPTOR_SAMPLER_STATE* pDescriptorSamplerState) -{ - printf("[D3D11DeviceXWrapperX] ComposeSamplerState"); -} - -void d3d11x::D3D11DeviceXWrapperX::PlaceSwapChainView( - _In_ ID3D11Resource* pSwapChainBuffer, - _Inout_ ID3D11View* pView) -{ - printf("[D3D11DeviceXWrapperX] PlaceSwapChainView"); -} - -void d3d11x::D3D11DeviceXWrapperX::SetDebugFlags( - _In_ UINT Flags) -{ - printf("[D3D11DeviceXWrapperX] SetDebugFlags"); -} - -UINT d3d11x::D3D11DeviceXWrapperX::GetDebugFlags( ) -{ - printf("[D3D11DeviceXWrapperX] GetDebugFlags"); - return {}; -} - -void d3d11x::D3D11DeviceXWrapperX::SetHangCallbacks( - _In_ d3d11x::D3D11XHANGBEGINCALLBACK pBeginCallback, - _In_ d3d11x::D3D11XHANGPRINTCALLBACK pPrintCallback, - _In_ d3d11x::D3D11XHANGDUMPCALLBACK pDumpCallback) -{ - printf("[D3D11DeviceXWrapperX] SetHangCallbacks"); -} - -void d3d11x::D3D11DeviceXWrapperX::ReportGpuHang( - _In_ UINT Flags) -{ - printf("[D3D11DeviceXWrapperX] ReportGpuHang"); -} - -HRESULT d3d11x::D3D11DeviceXWrapperX::SetGpuMemoryPriority( - _In_ UINT Priority) -{ - printf("[D3D11DeviceXWrapperX] SetGpuMemoryPriority"); - return E_NOTIMPL; -} - -void d3d11x::D3D11DeviceXWrapperX::GetGpuHardwareConfiguration( - _Out_ d3d11x::D3D11X_GPU_HARDWARE_CONFIGURATION* pGpuHardwareConfiguration) -{ - static d3d11x::D3D11X_GPU_HARDWARE_CONFIGURATION dummyHardwareConfig = { 0, D3D11X_HARDWARE_VERSION_XBOX_ONE, 0 }; - printf("[D3D11DeviceXWrapperX] GetGpuHardwareConfiguration\n"); - *pGpuHardwareConfiguration = dummyHardwareConfig; -} -#pragma endregion \ No newline at end of file diff --git a/dlls/d3d11_x/d3d_x/d3d11_x_device.h b/dlls/d3d11_x/d3d_x/d3d11_x_device.h deleted file mode 100644 index 6ace7d0..0000000 --- a/dlls/d3d11_x/d3d_x/d3d11_x_device.h +++ /dev/null @@ -1,820 +0,0 @@ -#pragma once -#include -#include -#include -#include - -// thanks to Zombie for the idea -#define DX_MAJOR 2 -#define DX_MINOR 18 - -#define MAKEINTVERSION(major, minor) (((0LL + (major)) << 48) | ((0LL + (minor)) << 32)) -#define DX_VERSION (((0LL + (DX_MAJOR)) << 48) | ((0LL + (DX_MINOR)) << 32)) - -#define D3DDECL_UUID(Uuid) __declspec(uuid(#Uuid)) -#define D3DINTERFACE(Name, Guid0, Guid1, Guid2, Guid3, Guid4, \ - Guid5, Guid6, Guid7, Guid8, Guid9, Guid10) \ - class D3DDECL_UUID(Guid0-Guid1-Guid2-Guid3##Guid4-Guid5##Guid6##Guid7##Guid8##Guid9##Guid10) Name - -namespace d3d11x -{ - D3DINTERFACE(IGraphicsUnknown, aceeea63, e0a9, 4a1c, bb, ec, 71, b2, f4, 85, f7, 58) - { - public: - -#if !defined(DX_VERSION) || DX_VERSION >= MAKEINTVERSION(2, 18) - ULONG m_DeviceIndex : 3; - ULONG m_PrivateDataPresent : 1; - ULONG m_Reserved : 28; -#endif - -#if !defined(DX_VERSION) || DX_VERSION >= MAKEINTVERSION(1, 1) - ULONG m_RefCount; -#endif - - virtual HRESULT QueryInterface(REFIID riid, void** ppvObject) = 0; - virtual ULONG AddRef( ) = 0; - virtual ULONG Release( ) = 0; - }; - - class GraphicsUnknownWrapperX : public IGraphicsUnknown - { - public: - GraphicsUnknownWrapperX(IUnknown* pUnknown) - { - m_RefCount = 1; - m_pUnknown = pUnknown; - } - - GraphicsUnknownWrapperX( ) - { - m_RefCount = 1; - m_pUnknown = nullptr; - } - - HRESULT QueryInterface(REFIID riid, void** ppvObject) override - { - // note from unixian: for debugging purposes - char iidstr[ sizeof("{AAAAAAAA-BBBB-CCCC-DDEE-FFGGHHIIJJKK}") ]; - OLECHAR iidwstr[ sizeof(iidstr) ]; - StringFromGUID2(riid, iidwstr, ARRAYSIZE(iidwstr)); - WideCharToMultiByte(CP_UTF8, 0, iidwstr, -1, iidstr, sizeof(iidstr), nullptr, nullptr); - printf("[GraphicsUnknownWrapperX] QueryInterface: %s\n", iidstr); - - if (m_pUnknown) - return m_pUnknown->QueryInterface(riid, ppvObject); - - *ppvObject = nullptr; - return E_NOINTERFACE; - } - - ULONG AddRef( ) override - { - if (m_pUnknown) - return m_pUnknown->AddRef( ); - - return InterlockedIncrement(&m_RefCount); - } - - ULONG Release( ) override - { - ULONG refCount = InterlockedDecrement(&m_RefCount); - - if (m_pUnknown) - m_pUnknown->Release( ); - - if (refCount == 0) - { - delete this; - } - return refCount; - } - - private: - IUnknown* m_pUnknown; - }; - - // Wrappers - class ID3D11Buffer_X; - class ID3D11BufferWrapper; - class ID3D11RenderTargetView_X; - class ID3D11UnorderedAccessView_X; - class ID3D11ShaderResourceView_X; - class ID3D11DepthStencilView_X; - class ID3D11RenderTargetViewWrapper; - class IDXGIDeviceWrapper; - class ID3D11Texture2DWrapper; - class ID3D11Texture1D_X; - class ID3D11Texture2D_X; - class ID3D11Texture3D_X; - - // D3D11.X forward declarations - class IGraphicsUnknown; - class ID3D11DeviceContext; - class ID3D11DeviceContextX; - class ID3D11CounterSetX; - class ID3D11CounterSampleX; - class ID3D11DmaEngineContextX; - class ID3D11ComputeContextX; - struct D3D11X_COUNTER_SET_DESC; - struct D3D11X_DESCRIPTOR_RESOURCE; - struct D3D11_DMA_ENGINE_CONTEXT_DESC; - struct D3D11X_SAMPLER_DESC; - struct D3D11X_RENDERABLE_TEXTURE_ADDRESSES; - struct D3D11X_DRIVER_STATISTICS; - struct D3D11_COMPUTE_CONTEXT_DESC; - struct D3D11X_RESOURCE_VIEW_DESC; - struct D3D11X_DESCRIPTOR_SHADER_RESOURCE_VIEW; - struct D3D11X_DESCRIPTOR_UNORDERED_ACCESS_VIEW; - struct D3D11X_DESCRIPTOR_CONSTANT_BUFFER_VIEW; - struct D3D11X_DESCRIPTOR_VERTEX_BUFFER_VIEW; - struct D3D11X_SAMPLER_STATE_DESC; - struct D3D11X_DESCRIPTOR_SAMPLER_STATE; - typedef enum D3D11X_HARDWARE_VERSION - { - D3D11X_HARDWARE_VERSION_XBOX_ONE = 0, - D3D11X_HARDWARE_VERSION_XBOX_ONE_S = 1, - D3D11X_HARDWARE_VERSION_XBOX_ONE_X = 2, - D3D11X_HARDWARE_VERSION_XBOX_ONE_X_DEVKIT = 3 - } D3D11X_HARDWARE_VERSION; - struct D3D11X_GPU_HARDWARE_CONFIGURATION { - UINT64 GpuFrequency; - D3D11X_HARDWARE_VERSION HardwareVersion; - UINT32 GpuCuCount; - }; - - - typedef UINT(*D3D11XHANGBEGINCALLBACK) (UINT64 Flags); - typedef void (*D3D11XHANGPRINTCALLBACK) (const CHAR* strLine); - typedef void (*D3D11XHANGDUMPCALLBACK) (const WCHAR* strFileName); - - D3DINTERFACE(ID3D11Device, db6f6ddb, ac77, 4e88, 82, 53, 81, 9d, f9, bb, f1, 40) : public IGraphicsUnknown - { - public: - UINT m_CreationFlags; - - virtual HRESULT CreateBuffer(_In_ const D3D11_BUFFER_DESC* pDesc, - _In_opt_ const D3D11_SUBRESOURCE_DATA* pInitialData, - _Out_opt_ d3d11x::ID3D11Buffer_X** ppBuffer) = 0; - - virtual HRESULT CreateTexture1D(_In_ const D3D11_TEXTURE1D_DESC* pDesc, - _In_reads_opt_(_Inexpressible_(pDesc->MipLevels* pDesc->ArraySize)) const D3D11_SUBRESOURCE_DATA* pInitialData, - _Out_opt_ ID3D11Texture1D_X** ppTexture1D) = 0; - - virtual HRESULT CreateTexture2D(_In_ D3D11_TEXTURE2D_DESC* pDesc, - _In_reads_opt_(_Inexpressible_(pDesc->MipLevels* pDesc->ArraySize)) const D3D11_SUBRESOURCE_DATA* pInitialData, - _Out_opt_ ID3D11Texture2D_X** ppTexture2D) = 0; - - virtual HRESULT CreateTexture3D(_In_ const D3D11_TEXTURE3D_DESC* pDesc, - _In_reads_opt_(_Inexpressible_(pDesc->MipLevels)) const D3D11_SUBRESOURCE_DATA* pInitialData, - _Out_opt_ ID3D11Texture3D_X** ppTexture3D) = 0; - - virtual HRESULT CreateShaderResourceView(_In_ ID3D11Resource* pResource, - _In_opt_ const D3D11_SHADER_RESOURCE_VIEW_DESC* pDesc, - _Out_opt_ ID3D11ShaderResourceView_X** ppSRView) = 0; - - virtual HRESULT CreateUnorderedAccessView(_In_ ID3D11Resource* pResource, - _In_opt_ const D3D11_UNORDERED_ACCESS_VIEW_DESC* pDesc, - _Out_opt_ ID3D11UnorderedAccessView_X** ppUAView) = 0; - - virtual HRESULT CreateRenderTargetView(_In_ ID3D11Resource* pResource, - _In_opt_ const D3D11_RENDER_TARGET_VIEW_DESC* pDesc, - _Out_opt_ ID3D11RenderTargetView_X** ppRTView) = 0; - - virtual HRESULT CreateDepthStencilView( - _In_ ID3D11Resource* pResource, - _In_opt_ const D3D11_DEPTH_STENCIL_VIEW_DESC* pDesc, - _Out_opt_ ID3D11DepthStencilView_X** ppDepthStencilView) = 0; - - virtual HRESULT CreateInputLayout( - _In_reads_(NumElements) const D3D11_INPUT_ELEMENT_DESC * pInputElementDescs, - _In_range_(0, D3D11_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT) UINT NumElements, - _In_ const void* pShaderBytecodeWithInputSignature, - _In_ SIZE_T BytecodeLength, - _Out_opt_ ID3D11InputLayout * *ppInputLayout) = 0; - - virtual HRESULT CreateVertexShader( - _In_ const void* pShaderBytecode, - _In_ SIZE_T BytecodeLength, - _In_opt_ ID3D11ClassLinkage* pClassLinkage, - _Out_opt_ ID3D11VertexShader** ppVertexShader) = 0; - - virtual HRESULT CreateGeometryShader( - _In_ const void* pShaderBytecode, - _In_ SIZE_T BytecodeLength, - _In_opt_ ID3D11ClassLinkage* pClassLinkage, - _Out_opt_ ID3D11GeometryShader** ppGeometryShader) = 0; - - virtual HRESULT CreateGeometryShaderWithStreamOutput( - _In_ const void* pShaderBytecode, - _In_ SIZE_T BytecodeLength, - _In_reads_opt_(NumEntries) const D3D11_SO_DECLARATION_ENTRY* pSODeclaration, - _In_range_(0, D3D11_SO_STREAM_COUNT* D3D11_SO_OUTPUT_COMPONENT_COUNT) UINT NumEntries, - _In_reads_opt_(NumStrides) const UINT* pBufferStrides, - _In_range_(0, D3D11_SO_BUFFER_SLOT_COUNT) UINT NumStrides, - _In_ UINT RasterizedStream, - _In_opt_ ID3D11ClassLinkage* pClassLinkage, - _Out_opt_ ID3D11GeometryShader** ppGeometryShader) = 0; - - virtual HRESULT CreatePixelShader( - _In_ const void* pShaderBytecode, - _In_ SIZE_T BytecodeLength, - _In_opt_ ID3D11ClassLinkage* pClassLinkage, - _Out_opt_ ID3D11PixelShader** ppPixelShader) = 0; - - virtual HRESULT CreateHullShader( - _In_ const void* pShaderBytecode, - _In_ SIZE_T BytecodeLength, - _In_opt_ ID3D11ClassLinkage* pClassLinkage, - _Out_opt_ ID3D11HullShader** ppHullShader) = 0; - - virtual HRESULT CreateDomainShader( - _In_ const void* pShaderBytecode, - _In_ SIZE_T BytecodeLength, - _In_opt_ ID3D11ClassLinkage* pClassLinkage, - _Out_opt_ ID3D11DomainShader** ppDomainShader) = 0; - - virtual HRESULT CreateComputeShader( - _In_ const void* pShaderBytecode, - _In_ SIZE_T BytecodeLength, - _In_opt_ ID3D11ClassLinkage* pClassLinkage, - _Out_opt_ ID3D11ComputeShader** ppComputeShader) = 0; - - virtual HRESULT CreateClassLinkage( - _Out_ ID3D11ClassLinkage** ppLinkage) = 0; - - virtual HRESULT CreateBlendState( - _In_ const D3D11_BLEND_DESC* pBlendStateDesc, - _Out_opt_ ID3D11BlendState** ppBlendState) = 0; - - virtual HRESULT CreateDepthStencilState( - _In_ const D3D11_DEPTH_STENCIL_DESC* pDepthStencilDesc, - _Out_opt_ ID3D11DepthStencilState** ppDepthStencilState) = 0; - - virtual HRESULT CreateRasterizerState( - _In_ const D3D11_RASTERIZER_DESC* pRasterizerDesc, - _Out_opt_ ID3D11RasterizerState** ppRasterizerState) = 0; - - virtual HRESULT CreateSamplerState( - _In_ const D3D11_SAMPLER_DESC* pSamplerDesc, - _Out_opt_ ID3D11SamplerState** ppSamplerState) = 0; - - virtual HRESULT CreateQuery( - _In_ const D3D11_QUERY_DESC* pQueryDesc, - _Out_opt_ ID3D11Query** ppQuery) = 0; - - virtual HRESULT CreatePredicate( - _In_ const D3D11_QUERY_DESC* pPredicateDesc, - _Out_opt_ ID3D11Predicate** ppPredicate) = 0; - - virtual HRESULT CreateCounter( - _In_ const D3D11_COUNTER_DESC* pCounterDesc, - _Out_opt_ ID3D11Counter** ppCounter) = 0; - - virtual HRESULT CreateDeferredContext(UINT ContextFlags, _Out_opt_ d3d11x::ID3D11DeviceContext** ppDeferredContext) = 0; - - virtual HRESULT OpenSharedResource( - _In_ HANDLE hResource, - _In_ REFIID ReturnedInterface, - _Out_opt_ void** ppResource) = 0; - - virtual HRESULT CheckFormatSupport( - _In_ DXGI_FORMAT Format, - _Out_ UINT* pFormatSupport) = 0; - - virtual HRESULT CheckMultisampleQualityLevels( - _In_ DXGI_FORMAT Format, - _In_ UINT SampleCount, - _Out_ UINT* pNumQualityLevels) = 0; - - virtual void CheckCounterInfo(_Out_ D3D11_COUNTER_INFO* pCounterInfo) = 0; - - virtual HRESULT CheckCounter( - _In_ const D3D11_COUNTER_DESC* pDesc, - _Out_ D3D11_COUNTER_TYPE* pType, - _Out_ UINT* pActiveCounters, - _Out_writes_opt_(*pNameLength) LPSTR szName, - _Inout_opt_ UINT* pNameLength, - _Out_writes_opt_(*pUnitsLength) LPSTR szUnits, - _Inout_opt_ UINT* pUnitsLength, - _Out_writes_opt_(*pDescriptionLength) LPSTR szDescription, - _Inout_opt_ UINT* pDescriptionLength) = 0; - - virtual HRESULT CheckFeatureSupport( - D3D11_FEATURE Feature, - _Out_writes_bytes_(FeatureSupportDataSize) void* pFeatureSupportData, - UINT FeatureSupportDataSize) = 0; - - virtual HRESULT GetPrivateData( - _In_ REFGUID guid, - _Inout_ UINT* pDataSize, - _Out_writes_bytes_opt_(*pDataSize) void* pData) = 0; - - virtual HRESULT SetPrivateData(_In_ REFGUID guid, _In_ UINT DataSize, _In_reads_bytes_opt_(DataSize) const void* pData)= 0; - - virtual HRESULT SetPrivateDataInterface(_In_ REFGUID guid, _In_opt_ const IUnknown* pData) = 0; - - virtual HRESULT SetPrivateDataInterfaceGraphics(_In_ REFGUID guid, _In_opt_ const IGraphicsUnknown* pData) = 0; - - virtual D3D_FEATURE_LEVEL GetFeatureLevel( ) = 0; - - virtual UINT GetCreationFlags( ) = 0; - - virtual HRESULT GetDeviceRemovedReason( ) = 0; - - virtual void GetImmediateContext(ID3D11DeviceContext** ppImmediateContext) = 0; - - virtual HRESULT SetExceptionMode(UINT RaiseFlags) = 0; - - virtual UINT GetExceptionMode( ) = 0; - }; - - D3DINTERFACE(ID3D11Device1, a04bfb29, 08ef, 43d6, a4, 9c, a9, bd, bd, cb, e6, 86) : public ID3D11Device{ - public: - virtual void GetImmediateContext1(_Out_ ::ID3D11DeviceContext1** ppImmediateContext) = 0; - - virtual HRESULT CreateDeferredContext1( - UINT ContextFlags, - _Out_ ::ID3D11DeviceContext1** ppDeferredContext) = 0; - - virtual HRESULT CreateBlendState1( - _In_ const D3D11_BLEND_DESC1* pBlendStateDesc, - _Out_opt_ ID3D11BlendState1** ppBlendState) = 0; - - virtual HRESULT CreateRasterizerState1( - _In_ const D3D11_RASTERIZER_DESC1* pRasterizerDesc, - _Out_opt_ ID3D11RasterizerState1** ppRasterizerState) = 0; - - virtual HRESULT CreateDeviceContextState( - UINT Flags, - _In_reads_(FeatureLevels) const D3D_FEATURE_LEVEL* pFeatureLevels, - UINT FeatureLevels, - UINT SDKVersion, - REFIID EmulatedInterface, - _Out_opt_ D3D_FEATURE_LEVEL* pChosenFeatureLevel, - _Out_opt_ ID3DDeviceContextState** ppContextState) = 0; - - virtual HRESULT OpenSharedResource1( - _In_ HANDLE hResource, - _In_ REFIID ReturnedInterface, - _Out_ void** ppResource) = 0; - - virtual HRESULT OpenSharedResourceByName( - _In_ LPCWSTR lpName, - _In_ DWORD dwDesiredAccess, - _In_ REFIID ReturnedInterface, - _Out_ void** ppResource) = 0; - }; - - D3DINTERFACE(ID3D11Device2, 9d06dffa, d1e5, 4d07, 83, a8, 1b, b1, 23, f2, f8, 41) : public ID3D11Device1 { - - virtual void GetImmediateContext2( - _Out_ ::ID3D11DeviceContext2** ppImmediateContext) = 0; - - virtual HRESULT CreateDeferredContext2( - UINT ContextFlags, - _Out_ ::ID3D11DeviceContext2** ppDeferredContext) = 0; - - virtual void GetResourceTiling( - _In_ ID3D11Resource* pTiledResource, - _Out_opt_ UINT* pNumTilesForEntireResource, - _Out_opt_ D3D11_PACKED_MIP_DESC* pPackedMipDesc, - _Out_opt_ D3D11_TILE_SHAPE* pStandardTileShapeForNonPackedMips, - _Inout_opt_ UINT* pNumSubresourceTilings, - _In_ UINT FirstSubresourceTilingToGet, - _Out_writes_(*pNumSubresourceTilings) D3D11_SUBRESOURCE_TILING* pSubresourceTilingsForNonPackedMips) = 0; - - virtual HRESULT CheckMultisampleQualityLevels1( - _In_ DXGI_FORMAT Format, - _In_ UINT SampleCount, - _In_ UINT Flags, - _Out_ UINT* pNumQualityLevels) = 0; - }; - - D3DINTERFACE(ID3D11DeviceX, 177700f9, 876a, 4436, b3, 68, 36, a6, 04, f8, 2c, ef) : public ID3D11Device2 - { - public: - virtual void GetImmediateContextX(ID3D11DeviceContextX**) = 0; - virtual HRESULT CreateCounterSet(const D3D11X_COUNTER_SET_DESC*, ID3D11CounterSetX**) = 0; - virtual HRESULT CreateCounterSample(ID3D11CounterSampleX**) = 0; - virtual HRESULT SetDriverHint(unsigned int, unsigned int) = 0; - virtual HRESULT CreateDmaEngineContext(const D3D11_DMA_ENGINE_CONTEXT_DESC*, ID3D11DmaEngineContextX**) = 0; - virtual int IsFencePending(unsigned __int64) = 0; - virtual int IsResourcePending(ID3D11Resource*) = 0; - virtual HRESULT CreatePlacementBuffer(const D3D11_BUFFER_DESC*, void*, ID3D11Buffer**) = 0; - virtual HRESULT CreatePlacementTexture1D(const D3D11_TEXTURE1D_DESC*, unsigned int, unsigned int, void*, ID3D11Texture1D**) = 0; - virtual HRESULT CreatePlacementTexture2D(const D3D11_TEXTURE2D_DESC*, unsigned int, unsigned int, void*, ID3D11Texture2D**) = 0; - virtual HRESULT CreatePlacementTexture3D(const D3D11_TEXTURE3D_DESC*, unsigned int, unsigned int, void*, ID3D11Texture3D**) = 0; - virtual void GetTimestamps(unsigned __int64*, unsigned __int64*) = 0; - virtual HRESULT CreateSamplerStateX(const D3D11X_SAMPLER_DESC*, ID3D11SamplerState**) = 0; - virtual HRESULT CreateDeferredContextX(unsigned int, ID3D11DeviceContextX**) = 0; - virtual void GarbageCollect(unsigned int) = 0; - virtual HRESULT CreateDepthStencilStateX(const D3D11_DEPTH_STENCIL_DESC*, ID3D11DepthStencilState**) = 0; - virtual HRESULT CreatePlacementRenderableTexture2D(const D3D11_TEXTURE2D_DESC*, unsigned int, unsigned int, const D3D11X_RENDERABLE_TEXTURE_ADDRESSES*, ID3D11Texture2D**) = 0; - virtual void GetDriverStatistics(unsigned int, D3D11X_DRIVER_STATISTICS*) = 0; - virtual HRESULT CreateComputeContextX(const D3D11_COMPUTE_CONTEXT_DESC*, ID3D11ComputeContextX**) = 0; - virtual void ComposeShaderResourceView(const D3D11X_DESCRIPTOR_RESOURCE*, const D3D11X_RESOURCE_VIEW_DESC*, D3D11X_DESCRIPTOR_SHADER_RESOURCE_VIEW*) = 0; - virtual void ComposeUnorderedAccessView(const D3D11X_DESCRIPTOR_RESOURCE*, const D3D11X_RESOURCE_VIEW_DESC*, D3D11X_DESCRIPTOR_UNORDERED_ACCESS_VIEW*) = 0; - virtual void ComposeConstantBufferView(const D3D11X_DESCRIPTOR_RESOURCE*, const D3D11X_RESOURCE_VIEW_DESC*, D3D11X_DESCRIPTOR_CONSTANT_BUFFER_VIEW*) = 0; - virtual void ComposeVertexBufferView(const D3D11X_DESCRIPTOR_RESOURCE*, const D3D11X_RESOURCE_VIEW_DESC*, D3D11X_DESCRIPTOR_VERTEX_BUFFER_VIEW*) = 0; - virtual void ComposeSamplerState(const D3D11X_SAMPLER_STATE_DESC*, D3D11X_DESCRIPTOR_SAMPLER_STATE*) = 0; - virtual void PlaceSwapChainView(ID3D11Resource*, ID3D11View*) = 0; - virtual void SetDebugFlags(unsigned int) = 0; - virtual unsigned int GetDebugFlags( ) = 0; - virtual void SetHangCallbacks(D3D11XHANGBEGINCALLBACK, D3D11XHANGPRINTCALLBACK, D3D11XHANGDUMPCALLBACK) = 0; - virtual void ReportGpuHang(unsigned int) = 0; - virtual HRESULT SetGpuMemoryPriority(unsigned int) = 0; - virtual void GetGpuHardwareConfiguration(D3D11X_GPU_HARDWARE_CONFIGURATION*) = 0; - }; - - class D3D11DeviceXWrapperX : public ID3D11DeviceX - { - public: - explicit D3D11DeviceXWrapperX(::ID3D11Device2* pDevice) - { - m_realDevice = pDevice; - m_RefCount = 1; - } - - HRESULT QueryInterface(REFIID riid, void** ppvObject) override; - - - ULONG AddRef( ) override - { - printf("[D3D11DeviceXWrapperX] AddRef\n"); - InterlockedIncrement(&m_RefCount); - return m_realDevice->AddRef( ); - } - - ULONG Release( ) override - { - ULONG refCount = InterlockedDecrement(&m_RefCount); - m_realDevice->Release( ); - printf("[D3D11DeviceXWrapperX] Release\n"); - if (refCount == 0) - { - printf("[D3D11DeviceXWrapperX] Release | refCount == 0, class being deleted.\n"); - delete this; - } - return refCount; - } - - // ID3D11Device - - HRESULT SetPrivateDataInterfaceGraphics(const GUID& guid, const IGraphicsUnknown* pData) override - { - return m_realDevice->SetPrivateDataInterface(guid, (IUnknown*)pData); - } - - HRESULT CreateBuffer( - const D3D11_BUFFER_DESC* pDesc, - const D3D11_SUBRESOURCE_DATA* pInitialData, - d3d11x::ID3D11Buffer_X** ppBuffer) override; - - HRESULT CreateTexture1D( - const D3D11_TEXTURE1D_DESC* pDesc, - const D3D11_SUBRESOURCE_DATA* pInitialData, - ID3D11Texture1D_X** ppTexture1D) override; - - HRESULT CreateTexture2D( - D3D11_TEXTURE2D_DESC* pDesc, - const D3D11_SUBRESOURCE_DATA* pInitialData, - ID3D11Texture2D_X** ppTexture2D) override; - - HRESULT CreateTexture3D( - const D3D11_TEXTURE3D_DESC* pDesc, - const D3D11_SUBRESOURCE_DATA* pInitialData, - ID3D11Texture3D_X** ppTexture3D) override; - - HRESULT CreateShaderResourceView( - ID3D11Resource* pResource, - const D3D11_SHADER_RESOURCE_VIEW_DESC* pDesc, - ID3D11ShaderResourceView_X** ppSRView) override; - - HRESULT CreateUnorderedAccessView( - ID3D11Resource* pResource, - const D3D11_UNORDERED_ACCESS_VIEW_DESC* pDesc, - ID3D11UnorderedAccessView_X** ppUAView) override; - - HRESULT CreateRenderTargetView(ID3D11Resource* pResource, - const D3D11_RENDER_TARGET_VIEW_DESC* pDesc, - ID3D11RenderTargetView_X** ppRTView) override; - - HRESULT CreateDepthStencilView( - ID3D11Resource* pResource, - const D3D11_DEPTH_STENCIL_VIEW_DESC* pDesc, - ID3D11DepthStencilView_X** ppDepthStencilView) override; - - HRESULT CreateInputLayout( - const D3D11_INPUT_ELEMENT_DESC* pInputElementDescs, - UINT NumElements, - const void* pShaderBytecodeWithInputSignature, - SIZE_T BytecodeLength, - ID3D11InputLayout** ppInputLayout) override { - return m_realDevice->CreateInputLayout(pInputElementDescs, NumElements, pShaderBytecodeWithInputSignature, BytecodeLength, ppInputLayout); - } - - HRESULT CreateVertexShader( - const void* pShaderBytecode, - SIZE_T BytecodeLength, - ID3D11ClassLinkage* pClassLinkage, - ID3D11VertexShader** ppVertexShader) override { - return m_realDevice->CreateVertexShader(pShaderBytecode, BytecodeLength, pClassLinkage, ppVertexShader); - } - - HRESULT CreateGeometryShader( - const void* pShaderBytecode, - SIZE_T BytecodeLength, - ID3D11ClassLinkage* pClassLinkage, - ID3D11GeometryShader** ppGeometryShader) override { - return m_realDevice->CreateGeometryShader(pShaderBytecode, BytecodeLength, pClassLinkage, ppGeometryShader); - } - - HRESULT CreateGeometryShaderWithStreamOutput( - const void* pShaderBytecode, - SIZE_T BytecodeLength, - const D3D11_SO_DECLARATION_ENTRY* pSODeclaration, - UINT NumEntries, - const UINT* pBufferStrides, - UINT NumStrides, - UINT RasterizedStream, - ID3D11ClassLinkage* pClassLinkage, - ID3D11GeometryShader** ppGeometryShader) override { - return m_realDevice->CreateGeometryShaderWithStreamOutput(pShaderBytecode, BytecodeLength, pSODeclaration, NumEntries, pBufferStrides, NumStrides, RasterizedStream, pClassLinkage, ppGeometryShader); - } - - HRESULT CreatePixelShader( - const void* pShaderBytecode, - SIZE_T BytecodeLength, - ID3D11ClassLinkage* pClassLinkage, - ID3D11PixelShader** ppPixelShader) override { - return m_realDevice->CreatePixelShader(pShaderBytecode, BytecodeLength, pClassLinkage, ppPixelShader); - } - - HRESULT CreateHullShader( - const void* pShaderBytecode, - SIZE_T BytecodeLength, - ID3D11ClassLinkage* pClassLinkage, - ID3D11HullShader** ppHullShader) override { - return m_realDevice->CreateHullShader(pShaderBytecode, BytecodeLength, pClassLinkage, ppHullShader); - } - - HRESULT CreateDomainShader( - const void* pShaderBytecode, - SIZE_T BytecodeLength, - ID3D11ClassLinkage* pClassLinkage, - ID3D11DomainShader** ppDomainShader) override { - return m_realDevice->CreateDomainShader(pShaderBytecode, BytecodeLength, pClassLinkage, ppDomainShader); - } - - HRESULT CreateComputeShader( - const void* pShaderBytecode, - SIZE_T BytecodeLength, - ID3D11ClassLinkage* pClassLinkage, - ID3D11ComputeShader** ppComputeShader) override { - return m_realDevice->CreateComputeShader(pShaderBytecode, BytecodeLength, pClassLinkage, ppComputeShader); - } - - HRESULT CreateClassLinkage( - ID3D11ClassLinkage** ppLinkage) override { - return m_realDevice->CreateClassLinkage(ppLinkage); - } - - HRESULT CreateBlendState( - const D3D11_BLEND_DESC* pBlendStateDesc, - ID3D11BlendState** ppBlendState) override { - return m_realDevice->CreateBlendState(pBlendStateDesc, ppBlendState); - } - - HRESULT CreateDepthStencilState( - const D3D11_DEPTH_STENCIL_DESC* pDepthStencilDesc, - ID3D11DepthStencilState** ppDepthStencilState) override { - return m_realDevice->CreateDepthStencilState(pDepthStencilDesc, ppDepthStencilState); - } - - HRESULT CreateRasterizerState( - const D3D11_RASTERIZER_DESC* pRasterizerDesc, - ID3D11RasterizerState** ppRasterizerState) override { - return m_realDevice->CreateRasterizerState(pRasterizerDesc, ppRasterizerState); - } - - HRESULT CreateSamplerState( - const D3D11_SAMPLER_DESC* pSamplerDesc, - ID3D11SamplerState** ppSamplerState) override { - return m_realDevice->CreateSamplerState(pSamplerDesc, ppSamplerState); - } - - HRESULT CreateQuery( - const D3D11_QUERY_DESC* pQueryDesc, - ID3D11Query** ppQuery) override { - return m_realDevice->CreateQuery(pQueryDesc, ppQuery); - } - - HRESULT CreatePredicate( - const D3D11_QUERY_DESC* pPredicateDesc, - ID3D11Predicate** ppPredicate) override { - return m_realDevice->CreatePredicate(pPredicateDesc, ppPredicate); - } - - HRESULT CreateCounter( - const D3D11_COUNTER_DESC* pCounterDesc, - ID3D11Counter** ppCounter) override { - return m_realDevice->CreateCounter(pCounterDesc, ppCounter); - } - - // @Patoke todo: unwrap - // @Aleblbl done, check cpp file - HRESULT CreateDeferredContext( - UINT ContextFlags, d3d11x::ID3D11DeviceContext** ppDeferredContext) override; - - HRESULT OpenSharedResource( - HANDLE hResource, - REFIID ReturnedInterface, - void** ppResource) override { - return m_realDevice->OpenSharedResource(hResource, ReturnedInterface, ppResource); - } - - HRESULT CheckFormatSupport( - DXGI_FORMAT Format, - UINT* pFormatSupport) override { - return m_realDevice->CheckFormatSupport(Format, pFormatSupport); - } - - HRESULT CheckMultisampleQualityLevels( - DXGI_FORMAT Format, - UINT SampleCount, - UINT* pNumQualityLevels) override { - return m_realDevice->CheckMultisampleQualityLevels(Format, SampleCount, pNumQualityLevels); - } - - void CheckCounterInfo( - D3D11_COUNTER_INFO* pCounterInfo) override { - m_realDevice->CheckCounterInfo(pCounterInfo); - } - - HRESULT CheckCounter( - const D3D11_COUNTER_DESC* pDesc, - D3D11_COUNTER_TYPE* pType, - UINT* pActiveCounters, - LPSTR szName, - UINT* pNameLength, - LPSTR szUnits, - UINT* pUnitsLength, - LPSTR szDescription, - UINT* pDescriptionLength) override { - return m_realDevice->CheckCounter(pDesc, pType, pActiveCounters, szName, pNameLength, szUnits, pUnitsLength, szDescription, pDescriptionLength); - } - - HRESULT CheckFeatureSupport( - D3D11_FEATURE Feature, - void* pFeatureSupportData, - UINT FeatureSupportDataSize) override { - return m_realDevice->CheckFeatureSupport(Feature, pFeatureSupportData, FeatureSupportDataSize); - } - - HRESULT GetPrivateData( - REFGUID guid, - UINT* pDataSize, - void* pData) override { - return m_realDevice->GetPrivateData(guid, pDataSize, pData); - } - - HRESULT SetPrivateData( - REFGUID guid, - UINT DataSize, - const void* pData) override { - return m_realDevice->SetPrivateData(guid, DataSize, pData); - } - - HRESULT SetPrivateDataInterface( - REFGUID guid, - const IUnknown* pData) override { - return m_realDevice->SetPrivateDataInterface(guid, pData); - } - - D3D_FEATURE_LEVEL GetFeatureLevel(void) override { - return m_realDevice->GetFeatureLevel( ); - } - - UINT GetCreationFlags(void) override { - return m_realDevice->GetCreationFlags( ); - } - - HRESULT GetDeviceRemovedReason(void) override { - return m_realDevice->GetDeviceRemovedReason( ); - } - - // @Patoke todo: unwrap - // @Aleblbl don :} (check cpp file) - void GetImmediateContext(ID3D11DeviceContext** ppImmediateContext) override; - - HRESULT SetExceptionMode( - UINT RaiseFlags) override { - return m_realDevice->SetExceptionMode(RaiseFlags); - } - - UINT GetExceptionMode(void) override { return m_realDevice->GetExceptionMode( ); } - - - // ID3D11Device1 - // @Patoke todo: unwrap - void GetImmediateContext1(::ID3D11DeviceContext1** ppImmediateContext) override { - m_realDevice->GetImmediateContext1(ppImmediateContext); - } - - // @Patoke todo: unwrap - HRESULT CreateDeferredContext1(UINT ContextFlags, ::ID3D11DeviceContext1** ppDeferredContext) override { - return m_realDevice->CreateDeferredContext1(ContextFlags, ppDeferredContext); - } - - HRESULT CreateBlendState1(const D3D11_BLEND_DESC1* pBlendStateDesc, ID3D11BlendState1** ppBlendState) override { - return m_realDevice->CreateBlendState1(pBlendStateDesc, ppBlendState); - } - - HRESULT CreateRasterizerState1(const D3D11_RASTERIZER_DESC1* pRasterizerDesc, ID3D11RasterizerState1** ppRasterizerState) override { - return m_realDevice->CreateRasterizerState1(pRasterizerDesc, ppRasterizerState); - } - - HRESULT CreateDeviceContextState(UINT Flags, const D3D_FEATURE_LEVEL* pFeatureLevels, UINT FeatureLevels, UINT SDKVersion, REFIID EmulatedInterface, D3D_FEATURE_LEVEL* pChosenFeatureLevel, ID3DDeviceContextState** ppContextState) override { - return m_realDevice->CreateDeviceContextState(Flags, pFeatureLevels, FeatureLevels, SDKVersion, EmulatedInterface, pChosenFeatureLevel, ppContextState); - } - - HRESULT OpenSharedResource1(HANDLE hResource, REFIID returnedInterface, void** ppResource) override { - return m_realDevice->OpenSharedResource1(hResource, returnedInterface, ppResource); - } - - HRESULT OpenSharedResourceByName(LPCWSTR lpName, DWORD dwDesiredAccess, REFIID returnedInterface, void** ppResource) override { - return m_realDevice->OpenSharedResourceByName(lpName, dwDesiredAccess, returnedInterface, ppResource); - } - - // ID3D11Device2 - // @Patoke todo: unwrap - void GetImmediateContext2(::ID3D11DeviceContext2** ppImmediateContext) override - { - m_realDevice->GetImmediateContext2(ppImmediateContext); - } - - // @Patoke todo: unwrap - HRESULT CreateDeferredContext2(UINT ContextFlags, ::ID3D11DeviceContext2** ppDeferredContext) override - { - return m_realDevice->CreateDeferredContext2(ContextFlags, ppDeferredContext); - } - - void GetResourceTiling(ID3D11Resource* pTiledResource, UINT* pNumTilesForEntireResource, - D3D11_PACKED_MIP_DESC* pPackedMipDesc, D3D11_TILE_SHAPE* pStandardTileShapeForNonPackedMips, - UINT* pNumSubresourceTilings, UINT FirstSubresourceTilingToGet, D3D11_SUBRESOURCE_TILING* pSubresourceTilingsForNonPackedMips) override - { - m_realDevice->GetResourceTiling(pTiledResource, pNumTilesForEntireResource, - pPackedMipDesc, pStandardTileShapeForNonPackedMips, pNumSubresourceTilings, - FirstSubresourceTilingToGet, pSubresourceTilingsForNonPackedMips); - } - - HRESULT CheckMultisampleQualityLevels1(DXGI_FORMAT Format, UINT SampleCount, UINT Flags, UINT* pNumQualityLevels) override - { - return m_realDevice->CheckMultisampleQualityLevels1(Format, SampleCount, Flags, pNumQualityLevels); - } - - // ID3D11DeviceX - void GetImmediateContextX(ID3D11DeviceContextX**) override; - HRESULT CreateCounterSet(const D3D11X_COUNTER_SET_DESC*, ID3D11CounterSetX**) override; - HRESULT CreateCounterSample(ID3D11CounterSampleX**) override; - HRESULT SetDriverHint(UINT Feature, UINT Value) override; - HRESULT CreateDmaEngineContext(const D3D11_DMA_ENGINE_CONTEXT_DESC*, ID3D11DmaEngineContextX**) override; - int IsFencePending(UINT64) override; - int IsResourcePending(ID3D11Resource*) override; - HRESULT CreatePlacementBuffer(const D3D11_BUFFER_DESC*, void*, ID3D11Buffer**) override; - HRESULT CreatePlacementTexture1D(const D3D11_TEXTURE1D_DESC*, UINT, UINT, void*, ID3D11Texture1D**) override; - HRESULT CreatePlacementTexture2D(const D3D11_TEXTURE2D_DESC*, UINT, UINT, void*, ID3D11Texture2D**) override; - HRESULT CreatePlacementTexture3D(const D3D11_TEXTURE3D_DESC*, UINT, UINT, void*, ID3D11Texture3D**) override; - void GetTimestamps(UINT64*, UINT64*) override; - HRESULT CreateSamplerStateX(const D3D11X_SAMPLER_DESC*, ID3D11SamplerState**) override; - HRESULT CreateDeferredContextX(UINT, ID3D11DeviceContextX**) override; - void GarbageCollect(UINT) override; - HRESULT CreateDepthStencilStateX(const D3D11_DEPTH_STENCIL_DESC*, ID3D11DepthStencilState**) override; - HRESULT CreatePlacementRenderableTexture2D(const D3D11_TEXTURE2D_DESC*, UINT, UINT, const D3D11X_RENDERABLE_TEXTURE_ADDRESSES*, ID3D11Texture2D**) override; - void GetDriverStatistics(UINT, D3D11X_DRIVER_STATISTICS*) override; - HRESULT CreateComputeContextX(const D3D11_COMPUTE_CONTEXT_DESC*, ID3D11ComputeContextX**) override; - void ComposeShaderResourceView(const D3D11X_DESCRIPTOR_RESOURCE*, const D3D11X_RESOURCE_VIEW_DESC*, D3D11X_DESCRIPTOR_SHADER_RESOURCE_VIEW*) override; - void ComposeUnorderedAccessView(const D3D11X_DESCRIPTOR_RESOURCE*, const D3D11X_RESOURCE_VIEW_DESC*, D3D11X_DESCRIPTOR_UNORDERED_ACCESS_VIEW*) override; - void ComposeConstantBufferView(const D3D11X_DESCRIPTOR_RESOURCE*, const D3D11X_RESOURCE_VIEW_DESC*, D3D11X_DESCRIPTOR_CONSTANT_BUFFER_VIEW*) override; - void ComposeVertexBufferView(const D3D11X_DESCRIPTOR_RESOURCE*, const D3D11X_RESOURCE_VIEW_DESC*, D3D11X_DESCRIPTOR_VERTEX_BUFFER_VIEW*) override; - void ComposeSamplerState(const D3D11X_SAMPLER_STATE_DESC*, D3D11X_DESCRIPTOR_SAMPLER_STATE*) override; - void PlaceSwapChainView(ID3D11Resource*, ID3D11View*) override; - void SetDebugFlags(UINT) override; - unsigned int GetDebugFlags( ) override; - void SetHangCallbacks(D3D11XHANGBEGINCALLBACK, D3D11XHANGPRINTCALLBACK, D3D11XHANGDUMPCALLBACK) override; - void ReportGpuHang(UINT) override; - HRESULT SetGpuMemoryPriority(UINT) override; - void GetGpuHardwareConfiguration(D3D11X_GPU_HARDWARE_CONFIGURATION*) override; - - public: - ::ID3D11Device2* m_realDevice; - }; - - - MIDL_INTERFACE("88671610-712E-4F1E-84AB-01B5948BD373") - ID3D11PerformanceDeviceX : ID3D11DeviceX - { - // yea this is just empty lol - }; -} \ No newline at end of file diff --git a/dlls/d3d11_x/d3d_x/d3d_x.hpp b/dlls/d3d11_x/d3d_x/d3d_x.hpp deleted file mode 100644 index d6845ad..0000000 --- a/dlls/d3d11_x/d3d_x/d3d_x.hpp +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once -#include "d3d11_x_device.h" - -// @Patoke todo: add more stuff here? \ No newline at end of file diff --git a/dlls/d3d11_x/device_child_x.cpp b/dlls/d3d11_x/device_child_x.cpp new file mode 100644 index 0000000..7262a65 --- /dev/null +++ b/dlls/d3d11_x/device_child_x.cpp @@ -0,0 +1 @@ +#include "device_child_x.h" diff --git a/dlls/d3d11_x/device_child_x.h b/dlls/d3d11_x/device_child_x.h new file mode 100644 index 0000000..0448d99 --- /dev/null +++ b/dlls/d3d11_x/device_child_x.h @@ -0,0 +1,63 @@ +#pragma once +#include +#include + +#include "d3d11_x.h" +#include "graphics_unknown.h" + +namespace wdi +{ + D3DINTERFACE(ID3D11DeviceChild, 1841e5c8, 16b0, 489b, bc, c8, 44, cf, b0, d5, de, ae) : public wd::graphics_unknown { + ID3D11Device* m_pDevice; + void* m_pPrivateData; + + // @Patoke todo: make this access wdi::ID3D11Device instead, this is a temporary fix + virtual void STDMETHODCALLTYPE GetDevice(::ID3D11Device** ppDevice) = 0; + virtual HRESULT STDMETHODCALLTYPE GetPrivateData(REFGUID guid, UINT* pDataSize, void* pData) = 0; + virtual HRESULT STDMETHODCALLTYPE SetPrivateData(REFGUID guid, UINT DataSize, const void* pData) = 0; + virtual HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(REFGUID guid, const IUnknown* pData) = 0; + virtual HRESULT STDMETHODCALLTYPE SetPrivateDataInterfaceGraphics(REFGUID guid, const IGraphicsUnknown* pData) = 0; + virtual HRESULT STDMETHODCALLTYPE SetName(LPCWSTR pName) = 0; + }; +} + +namespace wd +{ + class device_child_x : wdi::ID3D11DeviceChild + { + public: + device_child_x(::ID3D11DeviceChild* device_child) : wrapped_interface(device_child) { wrapped_interface->AddRef( ); } + + void STDMETHODCALLTYPE GetDevice(ID3D11Device** ppDevice) override + { + printf("WARN: device_child_x::GetDevice returns a PC device!!\n"); + wrapped_interface->GetDevice(ppDevice); + } + + HRESULT STDMETHODCALLTYPE GetPrivateData(REFGUID guid, UINT* pDataSize, void* pData) override + { + return wrapped_interface->GetPrivateData(guid, pDataSize, pData); + } + + HRESULT STDMETHODCALLTYPE SetPrivateData(REFGUID guid, UINT DataSize, const void* pData) override + { + return wrapped_interface->SetPrivateData(guid, DataSize, pData); + } + + HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(REFGUID guid, const IUnknown* pData) override + { + return wrapped_interface->SetPrivateDataInterface(guid, pData); + } + + HRESULT STDMETHODCALLTYPE SetPrivateDataInterfaceGraphics(REFGUID guid, const IGraphicsUnknown* pData) override + { + TRACE_NOT_IMPLEMENTED("device_child_x"); + return E_NOTIMPL; + } + + private: + ::ID3D11DeviceChild* wrapped_interface; + }; +} + + diff --git a/dlls/d3d11_x/device_context_x.cpp b/dlls/d3d11_x/device_context_x.cpp new file mode 100644 index 0000000..022fddd --- /dev/null +++ b/dlls/d3d11_x/device_context_x.cpp @@ -0,0 +1,1806 @@ +#include +#include +#include "device_context_x.h" +#include + +#include "view.hpp" + +void wd::device_context_x::GetDevice(ID3D11Device** ppDevice) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_context_x::GetPrivateData(const GUID& guid, UINT* pDataSize, void* pData) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_context_x::SetPrivateData(const GUID& guid, UINT DataSize, const void* pData) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_context_x::SetPrivateDataInterface(const GUID& guid, const IUnknown* pData) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_context_x::SetPrivateDataInterfaceGraphics(const GUID& guid, const IGraphicsUnknown* pData) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_context_x::SetName(LPCWSTR pName) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::VSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppConstantBuffers) +{ + if (ppConstantBuffers != nullptr && *ppConstantBuffers != nullptr) + { + ID3D11Buffer* modifiedBuffers[ D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT ]; + for (UINT i = 0; i < NumBuffers; ++i) + { + modifiedBuffers[ i ] = reinterpret_cast(ppConstantBuffers[ i ])->wrapped_interface; + } + wrapped_interface->VSSetConstantBuffers(StartSlot, NumBuffers, modifiedBuffers); + } + else + { + wrapped_interface->VSSetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); + } +} + +void wd::device_context_x::Draw(UINT VertexCount, UINT StartVertexLocation) +{ + ProcessDirtyFlags( ); + wrapped_interface->Draw(VertexCount, StartVertexLocation); +} + +HRESULT wd::device_context_x::Map(ID3D11Resource* pResource, UINT Subresource, D3D11_MAP MapType, UINT MapFlags, + D3D11_MAPPED_SUBRESOURCE* pMappedResource) +{ + return wrapped_interface->Map(reinterpret_cast(pResource)->wrapped_interface, Subresource, MapType, MapFlags, pMappedResource); +} + +void wd::device_context_x::Unmap(ID3D11Resource* pResource, UINT Subresource) +{ + wrapped_interface->Unmap(reinterpret_cast(pResource)->wrapped_interface, Subresource); +} + +void wd::device_context_x::PSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppConstantBuffers) +{ + if (ppConstantBuffers != nullptr && *ppConstantBuffers != nullptr) + { + ID3D11Buffer* modifiedBuffers[ D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT ]; + for (UINT i = 0; i < NumBuffers; ++i) + { + modifiedBuffers[ i ] = reinterpret_cast(ppConstantBuffers[ i ])->wrapped_interface; + } + wrapped_interface->PSSetConstantBuffers(StartSlot, NumBuffers, modifiedBuffers); + } + else + { + wrapped_interface->PSSetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); + } +} + +void wd::device_context_x::IASetInputLayout(ID3D11InputLayout* pInputLayout) +{ + wrapped_interface->IASetInputLayout(pInputLayout); +} + +void wd::device_context_x::IASetVertexBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppVertexBuffers, + const UINT* pStrides, const UINT* pOffsets) +{ + if (NumBuffers > D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT - StartSlot) + { + printf("WARN: device_context_x::IASetVertexBuffers: NumBuffers > D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT - StartSlot\n"); + return; + } + + if (ppVertexBuffers != NULL) + { + ID3D11Buffer* modifiedBuffers[ D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT ]; + for (UINT i = 0; i < NumBuffers; i++) + { + if (ppVertexBuffers[ i ] == nullptr) + modifiedBuffers[ i ] = nullptr; + else + modifiedBuffers[ i ] = reinterpret_cast(ppVertexBuffers[ i ])->wrapped_interface; + } + + wrapped_interface->IASetVertexBuffers(StartSlot, NumBuffers, modifiedBuffers, pStrides, pOffsets); + } + else + { + wrapped_interface->IASetVertexBuffers(StartSlot, NumBuffers, ppVertexBuffers, pStrides, pOffsets); + } +} + +void wd::device_context_x::GSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppConstantBuffers) +{ + wrapped_interface->GSSetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); +} + +void wd::device_context_x::GSSetShader(ID3D11GeometryShader* pShader) +{ + wrapped_interface->GSSetShader(pShader, nullptr, 0); +} + +void wd::device_context_x::VSSetShaderResources(ID3D11ShaderResourceView* const* ppShaderResourceViews, UINT StartSlot, + UINT PacketHeader) +{ + UINT NumViews = (PacketHeader >> 19) + 1; + + if (ppShaderResourceViews != NULL) + { + ID3D11ShaderResourceView* modifiedViews[ D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT ]; + + for (UINT i = 0; i < NumViews; i++) + { + if (ppShaderResourceViews[ i ] == nullptr) + modifiedViews[ i ] = nullptr; + else + modifiedViews[ i ] = reinterpret_cast(ppShaderResourceViews[ i ])->wrapped_interface; + } + wrapped_interface->VSSetShaderResources(StartSlot, NumViews, modifiedViews); + } + else { + wrapped_interface->VSSetShaderResources(StartSlot, NumViews, ppShaderResourceViews); + } +} + +void wd::device_context_x::GSSetShaderResources(ID3D11ShaderResourceView* const* ppShaderResourceViews, UINT StartSlot, + UINT PacketHeader) +{ + UINT NumViews = (PacketHeader >> 19) + 1; + + if (ppShaderResourceViews != NULL) + { + ID3D11ShaderResourceView* modifiedViews[ D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT ]; + + for (UINT i = 0; i < NumViews; i++) + { + if (ppShaderResourceViews[ i ] == nullptr) + modifiedViews[ i ] = nullptr; + else + modifiedViews[ i ] = reinterpret_cast(ppShaderResourceViews[ i ])->wrapped_interface; + } + wrapped_interface->GSSetShaderResources(StartSlot, NumViews, modifiedViews); + } + else + { + wrapped_interface->GSSetShaderResources(StartSlot, NumViews, ppShaderResourceViews); + } +} + +void wd::device_context_x::DrawAuto() +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::HSSetShaderResources(ID3D11ShaderResourceView* const* ppShaderResourceViews, UINT StartSlot, + UINT PacketHeader) +{ + UINT NumViews = (PacketHeader >> 19) + 1; + + if (ppShaderResourceViews != NULL) + { + ID3D11ShaderResourceView* modifiedViews[ D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT ]; + + for (UINT i = 0; i < NumViews; i++) + { + if (ppShaderResourceViews[ i ] == nullptr) + modifiedViews[ i ] = nullptr; + else + modifiedViews[ i ] = reinterpret_cast(ppShaderResourceViews[ i ])->wrapped_interface; + } + wrapped_interface->HSSetShaderResources(StartSlot, NumViews, modifiedViews); + } + else + { + wrapped_interface->HSSetShaderResources(StartSlot, NumViews, ppShaderResourceViews); + } +} + +void wd::device_context_x::HSSetShader(ID3D11HullShader* pHullShader) +{ + wrapped_interface->HSSetShader(pHullShader, nullptr, 0); +} + +void wd::device_context_x::DSSetShaderResources(ID3D11ShaderResourceView* const* ppShaderResourceViews, UINT StartSlot, + UINT PacketHeader) +{ + UINT NumViews = (PacketHeader >> 19) + 1; + + if (ppShaderResourceViews != NULL) + { + ID3D11ShaderResourceView* modifiedViews[ D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT ]; + + for (UINT i = 0; i < NumViews; i++) + { + if (ppShaderResourceViews[ i ] == nullptr) + modifiedViews[ i ] = nullptr; + else + modifiedViews[ i ] = reinterpret_cast(ppShaderResourceViews[ i ])->wrapped_interface; + } + wrapped_interface->DSSetShaderResources(StartSlot, NumViews, modifiedViews); + } + else + { + wrapped_interface->DSSetShaderResources(StartSlot, NumViews, ppShaderResourceViews); + } +} + +void wd::device_context_x::DSSetShader(ID3D11DomainShader* pDomainShader) +{ + wrapped_interface->DSSetShader(pDomainShader, nullptr, 0); +} + +void wd::device_context_x::CSSetShaderResources(ID3D11ShaderResourceView* const* ppShaderResourceViews, UINT StartSlot, + UINT PacketHeader) +{ + + UINT NumViews = (PacketHeader >> 19) + 1; + + if (ppShaderResourceViews != NULL) + { + ID3D11ShaderResourceView* modifiedViews[ D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT ]; + + for (UINT i = 0; i < NumViews; i++) + { + if (ppShaderResourceViews[ i ] == nullptr) + modifiedViews[ i ] = nullptr; + else + modifiedViews[ i ] = reinterpret_cast(ppShaderResourceViews[ i ])->wrapped_interface; + } + wrapped_interface->CSSetShaderResources(StartSlot, NumViews, modifiedViews); + } + else + { + wrapped_interface->CSSetShaderResources(StartSlot, NumViews, ppShaderResourceViews); + } +} + +void wd::device_context_x::CSSetShader(ID3D11ComputeShader* pComputeShader) +{ + wrapped_interface->CSSetShader(pComputeShader, nullptr, 0); +} + +void wd::device_context_x::VSSetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState* const* ppSamplers) +{ + wrapped_interface->VSSetSamplers(StartSlot, NumSamplers, ppSamplers); +} + +void wd::device_context_x::Begin(ID3D11Asynchronous* pAsync) +{ + wrapped_interface->Begin(pAsync); +} + +void wd::device_context_x::End(ID3D11Asynchronous* pAsync) +{ + wrapped_interface->End(pAsync); +} + +HRESULT wd::device_context_x::GetData(ID3D11Asynchronous* pAsync, void* pData, UINT DataSize, UINT GetDataFlags) +{ + return wrapped_interface->GetData(pAsync, pData, DataSize, GetDataFlags); +} + +void wd::device_context_x::SetPredication(ID3D11Predicate* pPredicate, BOOL PredicateValue) +{ + wrapped_interface->SetPredication(pPredicate, PredicateValue); +} + +void wd::device_context_x::GSSetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState* const* ppSamplers) +{ + wrapped_interface->GSSetSamplers(StartSlot, NumSamplers, ppSamplers); +} + +void wd::device_context_x::OMSetRenderTargets(UINT NumViews, ID3D11RenderTargetView* const* ppRenderTargetViews, + ID3D11DepthStencilView* pDepthStencilView) +{ + auto* depthStencilView = pDepthStencilView; + if (depthStencilView != nullptr) + depthStencilView = reinterpret_cast(pDepthStencilView)->wrapped_interface; + + if (ppRenderTargetViews != NULL) + { + ID3D11RenderTargetView* modifiedViews[ D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT ]; + for (UINT i = 0; i < NumViews; i++) + { + if (ppRenderTargetViews[ i ] == nullptr) + modifiedViews[ i ] = nullptr; + else + modifiedViews[ i ] = reinterpret_cast(ppRenderTargetViews[ i ])->wrapped_interface; + } + wrapped_interface->OMSetRenderTargets(NumViews, modifiedViews, depthStencilView); + } + else + { + wrapped_interface->OMSetRenderTargets(NumViews, ppRenderTargetViews, depthStencilView); + } +} + +void wd::device_context_x::OMSetRenderTargetsAndUnorderedAccessViews(UINT NumRTVs, + ID3D11RenderTargetView* const* ppRenderTargetViews, ID3D11DepthStencilView* pDepthStencilView, UINT UAVStartSlot, + UINT NumUAVs, ID3D11UnorderedAccessView* const* ppUnorderedAccessViews, const UINT* pUAVInitialCounts) +{ + wrapped_interface->OMSetRenderTargetsAndUnorderedAccessViews(NumRTVs, ppRenderTargetViews, pDepthStencilView, + UAVStartSlot, NumUAVs, ppUnorderedAccessViews, + pUAVInitialCounts); +} + +void wd::device_context_x::OMSetBlendState(ID3D11BlendState* pBlendState, const FLOAT BlendFactor[4], UINT SampleMask) +{ + wrapped_interface->OMSetBlendState(pBlendState, BlendFactor, SampleMask); +} + +void wd::device_context_x::OMSetDepthStencilState(ID3D11DepthStencilState* pDepthStencilState, UINT StencilRef) +{ + wrapped_interface->OMSetDepthStencilState(pDepthStencilState, StencilRef); +} + +void wd::device_context_x::SOSetTargets(UINT NumBuffers, ID3D11Buffer* const* ppSOTargets, const UINT* pOffsets) +{ + wrapped_interface->SOSetTargets(NumBuffers, ppSOTargets, pOffsets); +} + +void wd::device_context_x::DrawIndexedInstancedIndirect(ID3D11Buffer* pBufferForArgs, UINT AlignedByteOffsetForArgs) +{ + wrapped_interface->DrawIndexedInstancedIndirect(pBufferForArgs, AlignedByteOffsetForArgs); +} + +void wd::device_context_x::DrawInstancedIndirect(ID3D11Buffer* pBufferForArgs, UINT AlignedByteOffsetForArgs) +{ + wrapped_interface->DrawInstancedIndirect(pBufferForArgs, AlignedByteOffsetForArgs); +} + +void wd::device_context_x::Dispatch(UINT ThreadGroupCountX, UINT ThreadGroupCountY, UINT ThreadGroupCountZ) +{ + wrapped_interface->Dispatch(ThreadGroupCountX, ThreadGroupCountY, ThreadGroupCountZ); +} + +void wd::device_context_x::DispatchIndirect(ID3D11Buffer* pBufferForArgs, UINT AlignedByteOffsetForArgs) +{ + wrapped_interface->DispatchIndirect(pBufferForArgs, AlignedByteOffsetForArgs); +} + +void wd::device_context_x::RSSetState(ID3D11RasterizerState* pRasterizerState) +{ + wrapped_interface->RSSetState(pRasterizerState); +} + +void wd::device_context_x::RSSetViewports(UINT NumViewports, const D3D11_VIEWPORT* pViewports) +{ + wrapped_interface->RSSetViewports(NumViewports, pViewports); +} + +void wd::device_context_x::RSSetScissorRects(UINT NumRects, const D3D11_RECT* pRects) +{ + wrapped_interface->RSSetScissorRects(NumRects, pRects); +} + +void wd::device_context_x::CopySubresourceRegion(ID3D11Resource* pDstResource, UINT DstSubresource, UINT DstX, + UINT DstY, UINT DstZ, ID3D11Resource* pSrcResource, UINT SrcSubresource, const D3D11_BOX* pSrcBox) +{ + wrapped_interface->CopySubresourceRegion(reinterpret_cast(pDstResource)->wrapped_interface, DstSubresource, DstX, DstY, DstZ, reinterpret_cast(pSrcResource)->wrapped_interface, + SrcSubresource, pSrcBox); +} + +void wd::device_context_x::CopyResource(ID3D11Resource* pDstResource, ID3D11Resource* pSrcResource) +{ + wrapped_interface->CopyResource(reinterpret_cast(pDstResource)->wrapped_interface, reinterpret_cast(pSrcResource)->wrapped_interface); +} + +void wd::device_context_x::UpdateSubresource(ID3D11Resource* pDstResource, UINT DstSubresource, + const D3D11_BOX* pDstBox, const void* pSrcData, UINT SrcRowPitch, UINT SrcDepthPitch) +{ + wrapped_interface->UpdateSubresource(reinterpret_cast(pDstResource)->wrapped_interface, DstSubresource, pDstBox, pSrcData, SrcRowPitch, + SrcDepthPitch); +} + +void wd::device_context_x::CopyStructureCount(ID3D11Buffer* pDstBuffer, UINT DstAlignedByteOffset, + ID3D11UnorderedAccessView* pSrcView) +{ + wrapped_interface->CopyStructureCount(pDstBuffer, DstAlignedByteOffset, pSrcView); +} + +void wd::device_context_x::ClearRenderTargetView(ID3D11RenderTargetView* pRenderTargetView, const FLOAT ColorRGBA[4]) +{ + wrapped_interface->ClearRenderTargetView(pRenderTargetView, ColorRGBA); +} + +void wd::device_context_x::ClearUnorderedAccessViewUint(ID3D11UnorderedAccessView* pUnorderedAccessView, + const UINT Values[4]) +{ + wrapped_interface->ClearUnorderedAccessViewUint(pUnorderedAccessView, Values); +} + +void wd::device_context_x::ClearUnorderedAccessViewFloat(ID3D11UnorderedAccessView* pUnorderedAccessView, + const FLOAT Values[4]) +{ + wrapped_interface->ClearUnorderedAccessViewFloat(pUnorderedAccessView, Values); +} + +void wd::device_context_x::ClearDepthStencilView(ID3D11DepthStencilView* pDepthStencilView, UINT ClearFlags, + FLOAT Depth, UINT8 Stencil) +{ + wrapped_interface->ClearDepthStencilView(pDepthStencilView, ClearFlags, Depth, Stencil); +} + +void wd::device_context_x::GenerateMips(ID3D11ShaderResourceView* pShaderResourceView) +{ + wrapped_interface->GenerateMips(pShaderResourceView); +} + +void wd::device_context_x::SetResourceMinLOD(ID3D11Resource* pResource, FLOAT MinLOD) +{ + wrapped_interface->SetResourceMinLOD(reinterpret_cast(pResource)->wrapped_interface, MinLOD); +} + +FLOAT wd::device_context_x::GetResourceMinLOD(ID3D11Resource* pResource) +{ + return wrapped_interface->GetResourceMinLOD(reinterpret_cast(pResource)->wrapped_interface); +} + +void wd::device_context_x::ResolveSubresource(ID3D11Resource* pDstResource, UINT DstSubresource, + ID3D11Resource* pSrcResource, UINT SrcSubresource, DXGI_FORMAT Format) +{ + wrapped_interface->ResolveSubresource(reinterpret_cast(pDstResource)->wrapped_interface, DstSubresource, reinterpret_cast(pSrcResource)->wrapped_interface, SrcSubresource, Format); +} + +void wd::device_context_x::ExecuteCommandList(ID3D11CommandList* pCommandList, BOOL RestoreContextState) +{ + wrapped_interface->ExecuteCommandList(pCommandList, RestoreContextState); +} + +void wd::device_context_x::HSSetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState* const* ppSamplers) +{ + wrapped_interface->HSSetSamplers(StartSlot, NumSamplers, ppSamplers); +} + +void wd::device_context_x::HSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppConstantBuffers) +{ + if (ppConstantBuffers != nullptr && *ppConstantBuffers != nullptr) + { + ID3D11Buffer* modifiedBuffers[ D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT ]; + for (UINT i = 0; i < NumBuffers; ++i) + { + modifiedBuffers[ i ] = reinterpret_cast(ppConstantBuffers[ i ])->wrapped_interface; + } + wrapped_interface->HSSetConstantBuffers(StartSlot, NumBuffers, modifiedBuffers); + } + else + { + wrapped_interface->HSSetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); + } +} + +void wd::device_context_x::DSSetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState* const* ppSamplers) +{ + wrapped_interface->DSSetSamplers(StartSlot, NumSamplers, ppSamplers); +} + +void wd::device_context_x::DSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppConstantBuffers) +{ + if (ppConstantBuffers != nullptr && *ppConstantBuffers != nullptr) + { + ID3D11Buffer* modifiedBuffers[ D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT ]; + for (UINT i = 0; i < NumBuffers; ++i) + { + modifiedBuffers[ i ] = reinterpret_cast(ppConstantBuffers[ i ])->wrapped_interface; + } + wrapped_interface->DSSetConstantBuffers(StartSlot, NumBuffers, modifiedBuffers); + } + else { + wrapped_interface->DSSetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); + } +} + +void wd::device_context_x::CSSetUnorderedAccessViews(UINT StartSlot, UINT NumUAVs, + ID3D11UnorderedAccessView* const* ppUnorderedAccessViews, const UINT* pUAVInitialCounts) +{ + wrapped_interface->CSSetUnorderedAccessViews(StartSlot, NumUAVs, ppUnorderedAccessViews, pUAVInitialCounts); +} + +void wd::device_context_x::CSSetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState* const* ppSamplers) +{ + wrapped_interface->CSSetSamplers(StartSlot, NumSamplers, ppSamplers); +} + +void wd::device_context_x::CSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppConstantBuffers) +{ + if (ppConstantBuffers != nullptr && *ppConstantBuffers != nullptr) + { + ID3D11Buffer* modifiedBuffers[ D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT ]; + for (UINT i = 0; i < NumBuffers; ++i) { + modifiedBuffers[ i ] = reinterpret_cast(ppConstantBuffers[ i ])->wrapped_interface; + } + wrapped_interface->CSSetConstantBuffers(StartSlot, NumBuffers, modifiedBuffers); + } + else + { + wrapped_interface->CSSetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); + } +} + +void wd::device_context_x::VSGetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers) +{ + if (ppConstantBuffers != NULL) + { + ID3D11Buffer* unwrappedBuffers[ D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT ]; + + wrapped_interface->VSGetConstantBuffers(StartSlot, NumBuffers, unwrappedBuffers); + + for (UINT i = 0; i < NumBuffers; ++i) { + ppConstantBuffers[ i ] = reinterpret_cast(new wd::buffer(unwrappedBuffers[ i ])); + } + } + else + { + wrapped_interface->VSGetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); + } +} + +void wd::device_context_x::PSGetShaderResources(UINT StartSlot, UINT NumViews, + ID3D11ShaderResourceView** ppShaderResourceViews) +{ + wrapped_interface->PSGetShaderResources(StartSlot, NumViews, ppShaderResourceViews); +} + +void wd::device_context_x::PSGetShader(ID3D11PixelShader** ppPixelShader, ID3D11ClassInstance** ppClassInstances, + UINT* pNumClassInstances) +{ + wrapped_interface->PSGetShader(ppPixelShader, ppClassInstances, pNumClassInstances); +} + +void wd::device_context_x::PSGetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers) +{ + wrapped_interface->PSGetSamplers(StartSlot, NumSamplers, ppSamplers); +} + +void wd::device_context_x::VSGetShader(ID3D11VertexShader** ppVertexShader, ID3D11ClassInstance** ppClassInstances, + UINT* pNumClassInstances) +{ + wrapped_interface->VSGetShader(ppVertexShader, ppClassInstances, pNumClassInstances); +} + +void wd::device_context_x::PSGetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers) +{ + if (ppConstantBuffers != NULL) + { + ID3D11Buffer* unwrappedBuffers[ D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT ]; + + wrapped_interface->PSGetConstantBuffers(StartSlot, NumBuffers, unwrappedBuffers); + + for (UINT i = 0; i < NumBuffers; ++i) + { + ppConstantBuffers[ i ] = reinterpret_cast(new wd::buffer(unwrappedBuffers[ i ])); + } + } + else + { + wrapped_interface->PSGetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); + } +} + +void wd::device_context_x::IAGetInputLayout(ID3D11InputLayout** ppInputLayout) +{ + wrapped_interface->IAGetInputLayout(ppInputLayout); +} + +void wd::device_context_x::IAGetVertexBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppVertexBuffers, + UINT* pStrides, UINT* pOffsets) +{ + if (ppVertexBuffers != NULL) + { + ID3D11Buffer* unwrappedBuffers[ D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT ]; + + wrapped_interface->IAGetVertexBuffers(StartSlot, NumBuffers, unwrappedBuffers, pStrides, pOffsets); + + for (UINT i = 0; i < NumBuffers; ++i) + { + ppVertexBuffers[ i ] = reinterpret_cast(new wd::buffer(unwrappedBuffers[ i ])); + } + } + else + { + wrapped_interface->IAGetVertexBuffers(StartSlot, NumBuffers, ppVertexBuffers, pStrides, pOffsets); + } +} + +void wd::device_context_x::IAGetIndexBuffer(ID3D11Buffer** pIndexBuffer, DXGI_FORMAT* Format, UINT* Offset) +{ + wrapped_interface->IAGetIndexBuffer(pIndexBuffer, Format, Offset); + + if (pIndexBuffer != nullptr) + { + *pIndexBuffer = pIndexBuffer + ? reinterpret_cast(new wd::buffer(*pIndexBuffer)) + : nullptr; + } +} + +void wd::device_context_x::GSGetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers) +{ + if (ppConstantBuffers != NULL) + { + ID3D11Buffer* unwrappedBuffers[ D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT ]; + + wrapped_interface->GSGetConstantBuffers(StartSlot, NumBuffers, unwrappedBuffers); + + for (UINT i = 0; i < NumBuffers; ++i) + { + ppConstantBuffers[ i ] = reinterpret_cast(new wd::buffer(unwrappedBuffers[ i ])); + } + } + else + { + wrapped_interface->GSGetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); + } +} + +void wd::device_context_x::GSGetShader(ID3D11GeometryShader** ppGeometryShader, ID3D11ClassInstance** ppClassInstances, + UINT* pNumClassInstances) +{ + wrapped_interface->GSGetShader(ppGeometryShader, ppClassInstances, pNumClassInstances); +} + +void wd::device_context_x::IAGetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY* pTopology) +{ + wrapped_interface->IAGetPrimitiveTopology(pTopology); +} + +void wd::device_context_x::VSGetShaderResources(UINT StartSlot, UINT NumViews, + ID3D11ShaderResourceView** ppShaderResourceViews) +{ + wrapped_interface->VSGetShaderResources(StartSlot, NumViews, ppShaderResourceViews); +} + +void wd::device_context_x::VSGetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers) +{ + wrapped_interface->VSGetSamplers(StartSlot, NumSamplers, ppSamplers); +} + +void wd::device_context_x::GetPredication(ID3D11Predicate** ppPredicate, BOOL* pPredicateValue) +{ + wrapped_interface->GetPredication(ppPredicate, pPredicateValue); +} + +void wd::device_context_x::GSGetShaderResources(UINT StartSlot, UINT NumViews, + ID3D11ShaderResourceView** ppShaderResourceViews) +{ + wrapped_interface->GSGetShaderResources(StartSlot, NumViews, ppShaderResourceViews); +} + +void wd::device_context_x::GSGetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers) +{ + wrapped_interface->GSGetSamplers(StartSlot, NumSamplers, ppSamplers); +} + +void wd::device_context_x::OMGetRenderTargets(UINT NumViews, ID3D11RenderTargetView** ppRenderTargetViews, + ID3D11DepthStencilView** ppDepthStencilView) +{ + ::ID3D11RenderTargetView* target = nullptr; + ::ID3D11DepthStencilView* depth = nullptr; + wrapped_interface->OMGetRenderTargets(NumViews, &target, &depth); + + if (ppRenderTargetViews != nullptr) + { + *ppRenderTargetViews = ppRenderTargetViews + ? reinterpret_cast(new + render_target_view(target)) + : nullptr; + } + + if (ppDepthStencilView != nullptr) + { + *ppDepthStencilView = ppDepthStencilView + ? reinterpret_cast(new + depth_stencil_view(depth)) + : nullptr; + } +} + +void wd::device_context_x::OMGetRenderTargetsAndUnorderedAccessViews(UINT NumRTVs, + ID3D11RenderTargetView** ppRenderTargetViews, ID3D11DepthStencilView** ppDepthStencilView, UINT UAVStartSlot, + UINT NumUAVs, ID3D11UnorderedAccessView** ppUnorderedAccessViews) +{ + wrapped_interface->OMGetRenderTargetsAndUnorderedAccessViews(NumRTVs, ppRenderTargetViews, ppDepthStencilView, + UAVStartSlot, NumUAVs, ppUnorderedAccessViews); +} + +void wd::device_context_x::OMGetBlendState(ID3D11BlendState** ppBlendState, FLOAT BlendFactor[4], UINT* pSampleMask) +{ + wrapped_interface->OMGetBlendState(ppBlendState, BlendFactor, pSampleMask); +} + +void wd::device_context_x::OMGetDepthStencilState(ID3D11DepthStencilState** ppDepthStencilState, UINT* pStencilRef) +{ + wrapped_interface->OMGetDepthStencilState(ppDepthStencilState, pStencilRef); +} + +void wd::device_context_x::SOGetTargets(UINT NumBuffers, ID3D11Buffer** ppSOTargets) +{ + wrapped_interface->SOGetTargets(NumBuffers, ppSOTargets); +} + +void wd::device_context_x::RSGetState(ID3D11RasterizerState** ppRasterizerState) +{ + wrapped_interface->RSGetState(ppRasterizerState); +} + +void wd::device_context_x::RSGetViewports(UINT* pNumViewports, D3D11_VIEWPORT* pViewports) +{ + wrapped_interface->RSGetViewports(pNumViewports, pViewports); +} + +void wd::device_context_x::RSGetScissorRects(UINT* pNumRects, D3D11_RECT* pRects) +{ + wrapped_interface->RSGetScissorRects(pNumRects, pRects); +} + +void wd::device_context_x::HSGetShaderResources(UINT StartSlot, UINT NumViews, + ID3D11ShaderResourceView** ppShaderResourceViews) +{ + wrapped_interface->HSGetShaderResources(StartSlot, NumViews, ppShaderResourceViews); +} + +void wd::device_context_x::HSGetShader(ID3D11HullShader** ppHullShader, ID3D11ClassInstance** ppClassInstances, + UINT* pNumClassInstances) +{ + wrapped_interface->HSGetShader(ppHullShader, ppClassInstances, pNumClassInstances); +} + +void wd::device_context_x::HSGetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers) +{ + wrapped_interface->HSGetSamplers(StartSlot, NumSamplers, ppSamplers); +} + +void wd::device_context_x::HSGetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers) +{ + wrapped_interface->HSGetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); +} + +void wd::device_context_x::DSGetShaderResources(UINT StartSlot, UINT NumViews, + ID3D11ShaderResourceView** ppShaderResourceViews) +{ + wrapped_interface->DSGetShaderResources(StartSlot, NumViews, ppShaderResourceViews); +} + +void wd::device_context_x::DSGetShader(ID3D11DomainShader** ppDomainShader, ID3D11ClassInstance** ppClassInstances, + UINT* pNumClassInstances) +{ + wrapped_interface->DSGetShader(ppDomainShader, ppClassInstances, pNumClassInstances); +} + +void wd::device_context_x::DSGetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers) +{ + wrapped_interface->DSGetSamplers(StartSlot, NumSamplers, ppSamplers); +} + +void wd::device_context_x::DSGetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers) +{ + wrapped_interface->DSGetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); +} + +void wd::device_context_x::CSGetShaderResources(UINT StartSlot, UINT NumViews, + ID3D11ShaderResourceView** ppShaderResourceViews) +{ + wrapped_interface->CSGetShaderResources(StartSlot, NumViews, ppShaderResourceViews); +} + +void wd::device_context_x::CSGetUnorderedAccessViews(UINT StartSlot, UINT NumUAVs, + ID3D11UnorderedAccessView** ppUnorderedAccessViews) +{ + wrapped_interface->CSGetUnorderedAccessViews(StartSlot, NumUAVs, ppUnorderedAccessViews); +} + +void wd::device_context_x::CSGetShader(ID3D11ComputeShader** ppComputeShader, ID3D11ClassInstance** ppClassInstances, + UINT* pNumClassInstances) +{ + wrapped_interface->CSGetShader(ppComputeShader, ppClassInstances, pNumClassInstances); +} + +void wd::device_context_x::CSGetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers) +{ + wrapped_interface->CSGetSamplers(StartSlot, NumSamplers, ppSamplers); +} + +void wd::device_context_x::CSGetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers) +{ + wrapped_interface->CSGetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); +} + +void wd::device_context_x::ClearState() +{ + wrapped_interface->ClearState(); +} + +void wd::device_context_x::Flush() +{ + wrapped_interface->Flush(); +} + +D3D11_DEVICE_CONTEXT_TYPE wd::device_context_x::GetType() +{ + return wrapped_interface->GetType(); +} + +UINT wd::device_context_x::GetContextFlags() +{ + return wrapped_interface->GetContextFlags(); +} + +HRESULT wd::device_context_x::FinishCommandList(BOOL RestoreDeferredContextState, ID3D11CommandList** ppCommandList) +{ + return wrapped_interface->FinishCommandList(RestoreDeferredContextState, ppCommandList); +} + +void wd::device_context_x::CopySubresourceRegion1(ID3D11Resource* pDstResource, UINT DstSubresource, UINT DstX, + UINT DstY, UINT DstZ, ID3D11Resource* pSrcResource, UINT SrcSubresource, const D3D11_BOX* pSrcBox, UINT CopyFlags) +{ + wrapped_interface->CopySubresourceRegion1(reinterpret_cast(pDstResource)->wrapped_interface, DstSubresource, DstX, DstY, DstZ, reinterpret_cast(pSrcResource)->wrapped_interface, + SrcSubresource, pSrcBox, CopyFlags); +} + +void wd::device_context_x::UpdateSubresource1(ID3D11Resource* pDstResource, UINT DstSubresource, + const D3D11_BOX* pDstBox, const void* pSrcData, UINT SrcRowPitch, UINT SrcDepthPitch, UINT CopyFlags) +{ + wrapped_interface->UpdateSubresource1(reinterpret_cast(pDstResource)->wrapped_interface, DstSubresource, pDstBox, pSrcData, SrcRowPitch, + SrcDepthPitch, CopyFlags); +} + +void wd::device_context_x::DiscardResource(ID3D11Resource* pResource) +{ + wrapped_interface->DiscardResource(reinterpret_cast(pResource)->wrapped_interface); +} + +void wd::device_context_x::DiscardView(ID3D11View* pResourceView) +{ + wrapped_interface->DiscardView(pResourceView); +} + +void wd::device_context_x::VSSetConstantBuffers1(UINT StartSlot, UINT NumBuffers, + ID3D11Buffer* const* ppConstantBuffers, const UINT* pFirstConstant, const UINT* pNumConstants) +{ + wrapped_interface->VSSetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, pNumConstants); +} + +void wd::device_context_x::HSSetConstantBuffers1(UINT StartSlot, UINT NumBuffers, + ID3D11Buffer* const* ppConstantBuffers, const UINT* pFirstConstant, const UINT* pNumConstants) +{ + wrapped_interface-> + HSSetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, pNumConstants); +} + +void wd::device_context_x::DSSetConstantBuffers1(UINT StartSlot, UINT NumBuffers, + ID3D11Buffer* const* ppConstantBuffers, const UINT* pFirstConstant, const UINT* pNumConstants) +{ + wrapped_interface-> + DSSetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, pNumConstants); +} + +void wd::device_context_x::GSSetConstantBuffers1(UINT StartSlot, UINT NumBuffers, + ID3D11Buffer* const* ppConstantBuffers, const UINT* pFirstConstant, const UINT* pNumConstants) +{ + wrapped_interface-> + GSSetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, pNumConstants); +} + +void wd::device_context_x::PSSetConstantBuffers1(UINT StartSlot, UINT NumBuffers, + ID3D11Buffer* const* ppConstantBuffers, const UINT* pFirstConstant, const UINT* pNumConstants) +{ + wrapped_interface-> + PSSetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, pNumConstants); +} + +void wd::device_context_x::CSSetConstantBuffers1(UINT StartSlot, UINT NumBuffers, + ID3D11Buffer* const* ppConstantBuffers, const UINT* pFirstConstant, const UINT* pNumConstants) +{ + wrapped_interface-> + CSSetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, pNumConstants); +} + +void wd::device_context_x::VSGetConstantBuffers1(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers, + UINT* pFirstConstant, UINT* pNumConstants) +{ + wrapped_interface-> + VSGetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, pNumConstants); +} + +void wd::device_context_x::HSGetConstantBuffers1(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers, + UINT* pFirstConstant, UINT* pNumConstants) +{ + wrapped_interface-> + HSGetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, pNumConstants); +} + +void wd::device_context_x::DSGetConstantBuffers1(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers, + UINT* pFirstConstant, UINT* pNumConstants) +{ + wrapped_interface-> + DSGetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, pNumConstants); +} + +void wd::device_context_x::GSGetConstantBuffers1(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers, + UINT* pFirstConstant, UINT* pNumConstants) +{ + wrapped_interface-> + GSGetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, pNumConstants); +} + +void wd::device_context_x::PSGetConstantBuffers1(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers, + UINT* pFirstConstant, UINT* pNumConstants) +{ + wrapped_interface-> + PSGetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, pNumConstants); +} + +void wd::device_context_x::CSGetConstantBuffers1(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers, + UINT* pFirstConstant, UINT* pNumConstants) +{ + wrapped_interface-> + CSGetConstantBuffers1(StartSlot, NumBuffers, ppConstantBuffers, pFirstConstant, pNumConstants); +} + +void wd::device_context_x::SwapDeviceContextState(ID3DDeviceContextState* pState, + ID3DDeviceContextState** ppPreviousState) +{ + wrapped_interface->SwapDeviceContextState(pState, ppPreviousState); +} + +void wd::device_context_x::ClearView(ID3D11View* pView, const FLOAT Color[4], const D3D11_RECT* pRect, UINT NumRects) +{ + wrapped_interface->ClearView(pView, Color, pRect, NumRects); +} + +void wd::device_context_x::DiscardView1(ID3D11View* pResourceView, const D3D11_RECT* pRects, UINT NumRects) +{ + wrapped_interface->DiscardView1(pResourceView, pRects, NumRects); +} + +HRESULT wd::device_context_x::UpdateTileMappings(ID3D11Resource* pTiledResource, UINT NumTiledResourceRegions, + const D3D11_TILED_RESOURCE_COORDINATE* pTiledResourceRegionStartCoordinates, + const D3D11_TILE_REGION_SIZE* pTiledResourceRegionSizes, ID3D11Buffer* pTilePool, UINT NumRanges, + const UINT* pRangeFlags, const UINT* pTilePoolStartOffsets, const UINT* pRangeTileCounts, UINT Flags) +{ + return wrapped_interface->UpdateTileMappings(reinterpret_cast(pTiledResource)->wrapped_interface, NumTiledResourceRegions, + pTiledResourceRegionStartCoordinates, + pTiledResourceRegionSizes, pTilePool, NumRanges, pRangeFlags, + pTilePoolStartOffsets, + pRangeTileCounts, Flags); +} + +HRESULT wd::device_context_x::CopyTileMappings(ID3D11Resource* pDestTiledResource, + const D3D11_TILED_RESOURCE_COORDINATE* pDestRegionStartCoordinate, ID3D11Resource* pSourceTiledResource, + const D3D11_TILED_RESOURCE_COORDINATE* pSourceRegionStartCoordinate, const D3D11_TILE_REGION_SIZE* pTileRegionSize, + UINT Flags) +{ + return wrapped_interface->CopyTileMappings(reinterpret_cast(pDestTiledResource)->wrapped_interface, pDestRegionStartCoordinate, reinterpret_cast(pSourceTiledResource)->wrapped_interface, + pSourceRegionStartCoordinate, + pTileRegionSize, Flags); +} + +void wd::device_context_x::CopyTiles(ID3D11Resource* pTiledResource, + const D3D11_TILED_RESOURCE_COORDINATE* pTileRegionStartCoordinate, const D3D11_TILE_REGION_SIZE* pTileRegionSize, + ID3D11Buffer* pBuffer, UINT64 BufferStartOffsetInBytes, UINT Flags) +{ + wrapped_interface->CopyTiles(reinterpret_cast(pTiledResource)->wrapped_interface, pTileRegionStartCoordinate, pTileRegionSize, pBuffer, + BufferStartOffsetInBytes, Flags); +} + +void wd::device_context_x::UpdateTiles(ID3D11Resource* pDestTiledResource, + const D3D11_TILED_RESOURCE_COORDINATE* pDestTileRegionStartCoordinate, + const D3D11_TILE_REGION_SIZE* pDestTileRegionSize, const void* pSourceTileData, UINT Flags) +{ + wrapped_interface->UpdateTiles(reinterpret_cast(pDestTiledResource)->wrapped_interface, pDestTileRegionStartCoordinate, pDestTileRegionSize, + pSourceTileData, Flags); +} + +HRESULT wd::device_context_x::ResizeTilePool(ID3D11Buffer* pTilePool, UINT64 NewSizeInBytes) +{ + return wrapped_interface->ResizeTilePool(pTilePool, NewSizeInBytes); +} + +void wd::device_context_x::TiledResourceBarrier(ID3D11DeviceChild* pTiledResourceOrViewAccessBeforeBarrier, + ID3D11DeviceChild* pTiledResourceOrViewAccessAfterBarrier) +{ + throw std::logic_error("Not implemented"); + //wrapped_interface->TiledResourceBarrier(pTiledResourceOrViewAccessBeforeBarrier, + // pTiledResourceOrViewAccessAfterBarrier); +} + +INT wd::device_context_x::PIXBeginEvent(LPCWSTR Name) +{ + throw std::logic_error("Not implemented"); +} + +INT wd::device_context_x::PIXBeginEventEx(const void* pData, UINT DataSize) +{ + throw std::logic_error("Not implemented"); +} + +INT wd::device_context_x::PIXEndEvent() +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::PIXSetMarker(LPCWSTR Name) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::PIXSetMarkerEx(const void* pData, UINT DataSize) +{ + throw std::logic_error("Not implemented"); +} + +BOOL wd::device_context_x::PIXGetStatus() +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_context_x::PIXGpuCaptureNextFrame(UINT Flags, LPCWSTR lpOutputFileName) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_context_x::PIXGpuBeginCapture(UINT Flags, LPCWSTR lpOutputFileName) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_context_x::PIXGpuEndCapture() +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::StartCounters(wdi::ID3D11CounterSetX* pCounterSet) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::SampleCounters(wdi::ID3D11CounterSampleX* pCounterSample) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::StopCounters() +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_context_x::GetCounterData(wdi::ID3D11CounterSampleX* pCounterSample, wdi::D3D11X_COUNTER_DATA* pData, + UINT GetCounterDataFlags) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::FlushGpuCaches(ID3D11Resource* pResource) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::FlushGpuCacheRange(UINT Flags, void* pBaseAddress, SIZE_T SizeInBytes) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::InsertWaitUntilIdle(UINT Flags) +{ + // FIXME: implement, stubbing this seems to be fine for now +} + +UINT64 wd::device_context_x::InsertFence(UINT Flags) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::InsertWaitOnFence(UINT Flags, UINT64 Fence) +{ + // FIXME: implement, stubbing this seems to be fine for now +} + +void wd::device_context_x::RemapConstantBufferInheritance(wdi::D3D11_STAGE Stage, UINT Slot, + wdi::D3D11_STAGE InheritStage, UINT InheritSlot) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::RemapShaderResourceInheritance(wdi::D3D11_STAGE Stage, UINT Slot, + wdi::D3D11_STAGE InheritStage, UINT InheritSlot) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::RemapSamplerInheritance(wdi::D3D11_STAGE Stage, UINT Slot, wdi::D3D11_STAGE InheritStage, + UINT InheritSlot) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::RemapVertexBufferInheritance(UINT Slot, UINT InheritSlot) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::PSSetFastConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::PSSetFastShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::PSSetFastSampler(UINT Slot, ID3D11SamplerState* pSampler) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::VSSetFastConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::VSSetFastShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::VSSetFastSampler(UINT Slot, ID3D11SamplerState* pSampler) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::GSSetFastConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::GSSetFastShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::GSSetFastSampler(UINT Slot, ID3D11SamplerState* pSampler) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::CSSetFastConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::CSSetFastShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::CSSetFastSampler(UINT Slot, ID3D11SamplerState* pSampler) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::HSSetFastConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::HSSetFastShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::HSSetFastSampler(UINT Slot, ID3D11SamplerState* pSampler) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::DSSetFastConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::DSSetFastShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::DSSetFastSampler(UINT Slot, ID3D11SamplerState* pSampler) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::IASetFastVertexBuffer(UINT Slot, ID3D11Buffer* pVertexBuffer, UINT Stride) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::IASetFastIndexBuffer(UINT HardwareIndexFormat, ID3D11Buffer* pIndexBuffer) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::PSSetPlacementConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer, void* pBaseAddress) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::PSSetPlacementShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView, + void* pBaseAddress) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::VSSetPlacementConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer, void* pBaseAddress) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::VSSetPlacementShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView, + void* pBaseAddress) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::GSSetPlacementConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer, void* pBaseAddress) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::GSSetPlacementShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView, + void* pBaseAddress) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::CSSetPlacementConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer, void* pBaseAddress) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::CSSetPlacementShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView, + void* pBaseAddress) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::HSSetPlacementConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer, void* pBaseAddress) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::HSSetPlacementShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView, + void* pBaseAddress) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::DSSetPlacementConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer, void* pBaseAddress) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::DSSetPlacementShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView, + void* pBaseAddress) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::IASetPlacementVertexBuffer(UINT Slot, ID3D11Buffer* pVertexBuffer, void* pBaseAddress, + UINT Stride) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::IASetPlacementIndexBuffer(UINT HardwareIndexFormat, ID3D11Buffer* pIndexBuffer, + void* pBaseAddress) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::HSSetTessellationParameters( + const wdi::D3D11X_TESSELLATION_PARAMETERS* pTessellationParameters) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::HSGetLastUsedTessellationParameters( + wdi::D3D11X_TESSELLATION_PARAMETERS* pTessellationParameters) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::CSEnableAutomaticGpuFlush(BOOL Enable) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::GpuSendPipelinedEvent(wdi::D3D11X_GPU_PIPELINED_EVENT Event) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_context_x::Suspend(UINT Flags) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_context_x::Resume() +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::BeginCommandListExecution(UINT Flags) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::EndCommandListExecution() +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::SetGraphicsShaderLimits(const wdi::D3D11X_GRAPHICS_SHADER_LIMITS* pShaderLimits) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::SetComputeShaderLimits(const wdi::D3D11X_COMPUTE_SHADER_LIMITS* pShaderLimits) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::SetPredicationBuffer(ID3D11Buffer* pBuffer, UINT Offset, UINT Flags) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::OMSetDepthBounds(FLOAT min, FLOAT max) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::OMSetDepthStencilStateX(ID3D11DepthStencilState* pDepthStencilState) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::OMSetSampleMask(UINT64 QuadSampleMask) +{ + throw std::logic_error("Not implemented"); +} + +UINT32* wd::device_context_x::MakeCeSpace() +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::SetFastResources_Debug(UINT* pTableStart, UINT* pTableEnd) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::BeginResourceBatch(void* pBuffer, UINT BufferSize) +{ + throw std::logic_error("Not implemented"); +} + +UINT wd::device_context_x::EndResourceBatch(UINT* pSizeNeeded) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::SetFastResourcesFromBatch_Debug(void* pBatch, UINT Size) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::CSPlaceUnorderedAccessView(UINT Slot, + wdi::D3D11X_DESCRIPTOR_UNORDERED_ACCESS_VIEW* const pDescriptor, UINT64 Offset) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::WriteValueEndOfPipe(void* pDestination, UINT Value, UINT Flags) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::CopyMemoryToMemory(void* pDstAddress, void* pSrcAddress, SIZE_T SizeBytes) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::FillMemoryWithValue(void* pDstAddress, SIZE_T SizeBytes, UINT FillValue) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::BeginProcessVideoResource(ID3D11Resource* pResource, UINT SubResource) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::EndProcessVideoResource(ID3D11Resource* pResource, UINT SubResource) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_context_x::StartThreadTrace(const wdi::D3D11X_THREAD_TRACE_DESC* pDesc, + void* pDstAddressShaderEngine0, void* pDstAddressShaderEngine1, SIZE_T BufferSizeBytes) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::StopThreadTrace(void* pDstAddressTraceSize) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::InsertThreadTraceMarker(UINT Marker) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::IASetPrimitiveResetIndex(UINT ResetIndex) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::SetShaderResourceViewMinLOD(ID3D11ShaderResourceView* pShaderResourceView, FLOAT MinLOD) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::InsertWaitOnPresent(UINT Flags, ID3D11Resource* pBackBuffer) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::ClearRenderTargetViewX(ID3D11RenderTargetView* pRenderTargetView, UINT Flags, + const FLOAT ColorRGBA[4]) +{ + throw std::logic_error("Not implemented"); +} + +UINT wd::device_context_x::GetResourceCompression(ID3D11Resource* pResource) +{ + throw std::logic_error("Not implemented"); +} + +UINT wd::device_context_x::GetResourceCompressionX(const wdi::D3D11X_DESCRIPTOR_RESOURCE* pResource) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::DecompressResource(ID3D11Resource* pDstResource, UINT DstSubresource, + const wdi::D3D11X_POINT* pDstPoint, ID3D11Resource* pSrcResource, UINT SrcSubresource, + const wdi::D3D11X_RECT* pSrcRect, DXGI_FORMAT DecompressFormat, UINT DecompressFlags) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::DecompressResourceX(wdi::D3D11X_DESCRIPTOR_RESOURCE* pDstResource, UINT DstSubresource, + const wdi::D3D11X_POINT* pDstPoint, wdi::D3D11X_DESCRIPTOR_RESOURCE* pSrcResource, UINT SrcSubresource, + const wdi::D3D11X_RECT* pSrcRect, wdi::D3D11X_FORMAT DecompressFormat, UINT DecompressFlags) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::GSSetParameters(const wdi::D3D11X_GS_PARAMETERS* pGsParameters) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::GSGetLastUsedParameters(wdi::D3D11X_GS_PARAMETERS* pGsParameters) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::MultiDrawIndexedInstancedIndirect(UINT PrimitiveCount, ID3D11Buffer* pBufferForArgs, + UINT AlignedByteOffsetForArgs, UINT StrideByteOffsetForArgs, UINT Flags) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::MultiDrawInstancedIndirect(UINT PrimitiveCount, ID3D11Buffer* pBufferForArgs, + UINT AlignedByteOffsetForArgs, UINT StrideByteOffsetForArgs, UINT Flags) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::MultiDrawIndexedInstancedIndirectAuto(ID3D11Buffer* pBufferForPrimitiveCount, + UINT AlignedByteOffsetForPrimitiveCount, ID3D11Buffer* pBufferForArgs, UINT AlignedByteOffsetForArgs, + UINT StrideByteOffsetForArgs, UINT Flags) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::MultiDrawInstancedIndirectAuto(ID3D11Buffer* pBufferForPrimitiveCount, + UINT AlignedByteOffsetForPrimitiveCount, ID3D11Buffer* pBufferForArgs, UINT AlignedByteOffsetForArgs, + UINT StrideByteOffsetForArgs, UINT Flags) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_context_x::RSGetMSAASettingsForQuality(wdi::D3D11X_MSAA_SCAN_CONVERTER_SETTINGS* pMSAASCSettings, + wdi::D3D11X_MSAA_EQAA_SETTINGS* pEQAASettings, wdi::D3D11X_MSAA_SAMPLE_PRIORITIES* pCentroidPriorities, + wdi::D3D11X_MSAA_SAMPLE_POSITIONS* pSamplePositions, UINT LogSampleCount, UINT SampleQuality) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::RSSetScanConverterMSAASettings( + const wdi::D3D11X_MSAA_SCAN_CONVERTER_SETTINGS* pMSAASCSettings) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::RSSetEQAASettings(const wdi::D3D11X_MSAA_EQAA_SETTINGS* pEQAASettings) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::RSSetSamplePositions(const wdi::D3D11X_MSAA_SAMPLE_PRIORITIES* pSamplesPriorities, + const wdi::D3D11X_MSAA_SAMPLE_POSITIONS* pSamplePositions) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::SetResourceCompression(ID3D11Resource* pResource, UINT Compression) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::SetResourceCompressionX(const wdi::D3D11X_DESCRIPTOR_RESOURCE* pResource, UINT Compression) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::SetGDSRange(wdi::D3D11X_GDS_REGION_TYPE RegionType, UINT OffsetDwords, UINT NumDwords) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::WriteGDS(wdi::D3D11X_GDS_REGION_TYPE RegionType, UINT OffsetDwords, UINT NumDwords, + const UINT* pCounterValues, UINT Flags) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::ReadGDS(wdi::D3D11X_GDS_REGION_TYPE RegionType, UINT OffsetDwords, UINT NumDwords, + UINT* pCounterValues, UINT Flags) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::VSSetShaderUserData(UINT StartSlot, UINT NumRegisters, const UINT* pData) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::HSSetShaderUserData(UINT StartSlot, UINT NumRegisters, const UINT* pData) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::DSSetShaderUserData(UINT StartSlot, UINT NumRegisters, const UINT* pData) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::GSSetShaderUserData(UINT StartSlot, UINT NumRegisters, const UINT* pData) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::PSSetShaderUserData(UINT StartSlot, UINT NumRegisters, const UINT* pData) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::CSSetShaderUserData(UINT StartSlot, UINT NumRegisters, const UINT* pData) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::InsertWaitOnMemory(const void* pAddress, UINT Flags, + D3D11_COMPARISON_FUNC ComparisonFunction, UINT ReferenceValue, UINT Mask) +{ + // FIXME: implement, stubbing this seems to be fine for now +} + +void wd::device_context_x::WriteTimestampToMemory(void* pDstAddress) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::WriteTimestampToBuffer(ID3D11Buffer* pBuffer, UINT OffsetBytes) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::StoreConstantRam(UINT Flags, ID3D11Buffer* pBuffer, UINT BufferOffsetInBytes, + UINT CeRamOffsetInBytes, UINT SizeInBytes) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::LoadConstantRam(UINT Flags, ID3D11Buffer* pBuffer, UINT BufferOffsetInBytes, + UINT CeRamOffsetInBytes, UINT SizeInBytes) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::WriteQuery(D3D11_QUERY QueryType, UINT QueryIndex, UINT Flags, ID3D11Buffer* pBuffer, + UINT OffsetInBytes, UINT StrideInBytes) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::ResetQuery(D3D11_QUERY QueryType, UINT QueryIndex, UINT Flags) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::ConfigureQuery(D3D11_QUERY QueryType, const void* pConfiguration, UINT ConfigurationSize) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::SetShaderUserData(wdi::D3D11X_HW_STAGE ShaderStage, UINT StartSlot, UINT NumRegisters, + const UINT* pData) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::SetPixelShaderDepthForceZOrder(BOOL ForceOrder) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::SetPredicationFromQuery(D3D11_QUERY QueryType, ID3D11Buffer* pBuffer, UINT OffsetInBytes, + UINT Flags) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::SetBorderColorPalette(ID3D11Buffer* pBuffer, UINT OffsetInBytes, UINT Flags) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::WriteValueEndOfPipe64(void* pDestination, UINT64 Value, UINT Flags) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::InsertWaitOnMemory64(const void* pAddress, UINT Flags, + D3D11_COMPARISON_FUNC ComparisonFunction, UINT64 ReferenceValue) +{ + // FIXME: implement, stubbing this seems to be fine for now +} + +void wd::device_context_x::LoadConstantRamImmediate(UINT Flags, const void* pBuffer, UINT CeRamOffsetInBytes, + UINT SizeInBytes) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::SetScreenExtentsQuery(UINT Value) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::CollectScreenExtents(UINT Flags, UINT AddressCount, const UINT64* pDestinationAddresses, + USHORT ZMin, USHORT ZMax) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::FillResourceWithValue(ID3D11Resource* pDstResource, UINT FillValue) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::SetDrawBalancing(UINT BalancingMode, UINT Flags) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_context_x::PSSetShaderResources(ID3D11ShaderResourceView* const* ppShaderResourceViews, UINT StartSlot, + UINT PacketHeader) +{ + UINT NumViews = (PacketHeader >> 19) + 1; + + if (ppShaderResourceViews != NULL) + { + ID3D11ShaderResourceView* modifiedViews[ D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT ]; + + for (UINT i = 0; i < NumViews; i++) + { + if (ppShaderResourceViews[ i ] == nullptr) + modifiedViews[ i ] = nullptr; + else + modifiedViews[ i ] = reinterpret_cast(ppShaderResourceViews[ i ])->wrapped_interface; + } + wrapped_interface->PSSetShaderResources(StartSlot, NumViews, modifiedViews); + } + else + { + wrapped_interface->PSSetShaderResources(StartSlot, NumViews, ppShaderResourceViews); + } +} + +void wd::device_context_x::PSSetShader(ID3D11PixelShader* pPixelShader) +{ + wrapped_interface->PSSetShader(pPixelShader, nullptr, 0); +} + +void wd::device_context_x::PSSetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState* const* ppSamplers) +{ + wrapped_interface->PSSetSamplers(StartSlot, NumSamplers, ppSamplers); +} + +void wd::device_context_x::VSSetShader(ID3D11VertexShader* pVertexShader) +{ + wrapped_interface->VSSetShader(pVertexShader, nullptr, 0); +} + +void wd::device_context_x::DrawIndexed(UINT64 StartIndexLocationAndIndexCount, INT BaseVertexLocation) +{ + UINT StartIndexLocation = static_cast(StartIndexLocationAndIndexCount & 0xFFFFFFFF); + UINT IndexCount = static_cast((StartIndexLocationAndIndexCount >> 32) & 0xFFFFFFFF); + + ProcessDirtyFlags( ); + wrapped_interface->DrawIndexed(IndexCount, StartIndexLocation, BaseVertexLocation); +} + +// this function changes prototype on different sdk versions +void wd::device_context_x::IASetIndexBuffer(UINT HardwareIndexFormat, ID3D11Buffer* pIndexBuffer, UINT Offset) +{ + DXGI_FORMAT Format = HardwareIndexFormat == 1 ? DXGI_FORMAT_R32_UINT : DXGI_FORMAT_R16_UINT; + + if (pIndexBuffer == nullptr) + { + return wrapped_interface->IASetIndexBuffer(pIndexBuffer, Format, Offset); + } + + wrapped_interface->IASetIndexBuffer(reinterpret_cast(pIndexBuffer)->wrapped_interface, Format, Offset); +} + +void wd::device_context_x::DrawIndexedInstanced(UINT64 StartIndexLocationAndIndexCountPerInstance, + UINT64 BaseVertexLocationAndStartInstanceLocation, UINT InstanceCount) +{ + UINT StartIndexLocation = static_cast(StartIndexLocationAndIndexCountPerInstance & 0xFFFFFFFF); + UINT IndexCountPerInstance = static_cast((StartIndexLocationAndIndexCountPerInstance >> 32) & + 0xFFFFFFFF); + + UINT BaseVertexLocation = static_cast(BaseVertexLocationAndStartInstanceLocation & 0xFFFFFFFF); + UINT StartInstanceLocation = static_cast((BaseVertexLocationAndStartInstanceLocation >> 32) & + 0xFFFFFFFF); + + ProcessDirtyFlags( ); + wrapped_interface->DrawIndexedInstanced(IndexCountPerInstance, InstanceCount, StartIndexLocation, + BaseVertexLocation, StartInstanceLocation); +} + +void wd::device_context_x::DrawInstanced(UINT VertexCountPerInstance, + UINT64 StartVertexLocationAndStartInstanceLocation, UINT InstanceCount) +{ + UINT StartVertexLocation = static_cast(StartVertexLocationAndStartInstanceLocation & 0xFFFFFFFF); + UINT StartInstanceLocation = static_cast((StartVertexLocationAndStartInstanceLocation >> 32) & + 0xFFFFFFFF); + + ProcessDirtyFlags( ); + wrapped_interface->DrawInstanced(VertexCountPerInstance, InstanceCount, StartVertexLocation, + StartInstanceLocation); +} diff --git a/dlls/d3d11_x/device_context_x.h b/dlls/d3d11_x/device_context_x.h new file mode 100644 index 0000000..643a899 --- /dev/null +++ b/dlls/d3d11_x/device_context_x.h @@ -0,0 +1,1079 @@ +#pragma once +#include +#include + +#include "device_child_x.h" +#include "device_x.h" + +static std::map D3D11X_HARDWARE_TO_TOPOLOGY_MAP = { + {0x000001ffc0009e00, 0}, {0x000003ffc0009e00, 1}, {0x000005ffc0009e00, 2}, {0x000007ffc0009e00, 3}, + {0x000009ffc0009e00, 4}, {0x00000dffc0009e00, 5}, {0x00000bffc0009e00, 6}, {0x000001ffc0009e00, 7}, + {0x000001ffc0009e00, 8}, {0x000001ffc0009e00, 9}, {0x0000157fc0009e00, 10}, {0x0000177fc0009e00, 11}, + {0x0000197fc0009e00, 12}, {0x00001b7fc0009e00, 13}, {0x00001dffc0009e00, 14}, {0x00001fffc0009e00, 15}, + {0x000021ffc0009e00, 16}, {0x000023ffc0009e00, 17}, {0x000025ffc0009e00, 18}, {0x000027ffc0009e00, 19}, + {0x000029ffc0009e00, 20}, {0x00002bffc0009e00, 21}, {0x00002dffc0009e00, 22}, {0x00002fffc0009e00, 23}, + {0x000031ffc0009e00, 24}, {0x000033ffc0009e00, 25}, {0x000035ffc0009e00, 26}, {0x000037ffc0009e00, 27}, + {0x000039ffc0009e00, 28}, {0x000001ffc0009e00, 29}, {0x000001ffc0009e00, 30}, {0x000001ffc0009e00, 31}, + {0x000001ffc0009e00, 32}, {0x001013ffc0009e00, 33}, {0x0020137fc0009e00, 34}, {0x00301354c0009e00, 35}, + {0x0040133fc0009e00, 36}, {0x00501332c0009e00, 37}, {0x00601329c0009e00, 38}, {0x00701323c0009e00, 39}, + {0x0080131fc0009e00, 40}, {0x0090131bc0009e00, 41}, {0x00a01318c0009e00, 42}, {0x00b01316c0009e00, 43}, + {0x00c01314c0009e00, 44}, {0x00d01312c0009e00, 45}, {0x00e01311c0009e00, 46}, {0x00f01310c0009e00, 47}, + {0x0100130fc0009e00, 48}, {0x0110130ec0009e00, 49}, {0x0120130dc0009e00, 50}, {0x0130130cc0009e00, 51}, + {0x0140130bc0009e00, 52}, {0x0150130bc0009e00, 53}, {0x0160130ac0009e00, 54}, {0x0170130ac0009e00, 55}, + {0x01801309c0009e00, 56}, {0x01901309c0009e00, 57}, {0x01a01308c0009e00, 58}, {0x01b01308c0009e00, 59}, + {0x01c01308c0009e00, 60}, {0x01d01307c0009e00, 61}, {0x01e01307c0009e00, 62}, {0x01f01307c0009e00, 63}, + {0x02001307c0009e00, 64} +}; + +namespace wdi +{ + #pragma region struct_defs + typedef enum _D3D11X_GDS_REGION_TYPE + { + D3D11X_GDS_REGION_PS = 0, + D3D11X_GDS_REGION_CS = 1 + } D3D11X_GDS_REGION_TYPE; + + typedef struct D3D11X_COUNTER_DATA + { + UINT Size; + UINT Version; + + UINT64 GRBM[ 2 ][ 1 ]; + UINT64 SRBM[ 2 ][ 1 ]; + UINT64 CPF[ 2 ][ 1 ]; + UINT64 CPG[ 2 ][ 1 ]; + UINT64 CPC[ 2 ][ 1 ]; + UINT64 CB[ 4 ][ 8 ]; // only 4 instances on Durango + UINT64 DB[ 4 ][ 8 ]; // only 4 instances on Durango + UINT64 SU[ 4 ][ 4 ]; // only 2 instances on Durango + UINT64 SC[ 8 ][ 4 ]; // only 2 instances on Durango + UINT64 SX[ 8 ][ 4 ]; // only 2 instances on Durango + UINT64 SPI[ 4 ][ 4 ]; // only 2 instances on Durango + UINT64 SQ[ 16 ][ 4 ]; // only 2 instances on Durango + UINT64 TA[ 5 ][ 40 ]; // only 12 instances on Durango + UINT64 TD[ 2 ][ 40 ]; // only 12 instances on Durango + UINT64 TCP[ 8 ][ 40 ]; // only 12 instances on Durango + UINT64 TCC[ 4 ][ 8 ]; // only 4 instances on Durango + UINT64 TCA[ 4 ][ 2 ]; + UINT64 GDS[ 4 ][ 1 ]; + UINT64 VGT[ 4 ][ 4 ]; // only 2 instances on Durango + UINT64 IA[ 4 ][ 2 ]; // only 1 instances on Durango + UINT64 WD[ 4 ][ 1 ]; + UINT64 MC_MCB_L1TLB[ 4 ][ 1 ]; + UINT64 MC_HV_MCB_L1TLB[ 4 ][ 1 ]; + UINT64 MC_MCD_L1TLB[ 4 ][ 2 ]; + UINT64 MC_HV_MCD_L1TLB[ 4 ][ 2 ]; + UINT64 MC_L2TLB[ 2 ][ 1 ]; + UINT64 MC_HV_L2TLB[ 2 ][ 1 ]; + UINT64 MC_ARB[ 4 ][ 6 ]; // only 2 instances on Durango + UINT64 MC_CITF[ 4 ][ 4 ]; // only 2 instances on Duragno + UINT64 MC_HUB[ 4 ][ 1 ]; + UINT64 GRN[ 4 ][ 1 ]; // only 1 instance on Druango + UINT64 GRN1[ 4 ][ 1 ]; // not valid on Durango + UINT64 GRN2[ 4 ][ 1 ]; // not valid on Durango + } D3D11X_COUNTER_DATA; + + typedef enum D3D11_STAGE : UINT + { + D3D11_STAGE_VS = 0, + D3D11_STAGE_HS = 1, + D3D11_STAGE_DS = 2, + D3D11_STAGE_GS = 3, + D3D11_STAGE_PS = 4, + D3D11_STAGE_CS = 5 + } D3D11_STAGE; + + typedef struct D3D11X_TESSELLATION_PARAMETERS + { + UINT Size; + UINT Flags; + UINT PatchesPerThreadgroup; + float TfThreshold; + UINT DsWaveThreshold; + } D3D11X_TESSELLATION_PARAMETERS; + + typedef enum D3D11X_GPU_PIPELINED_EVENT + { + D3D11X_GPU_PIPELINED_EVENT_STREAMOUT_FLUSH = 0x0000001f, // Flush stream out caches + D3D11X_GPU_PIPELINED_EVENT_FLUSH_AND_INV_CB_PIXEL_DATA = 0x00000031, // Flush Color Block data + D3D11X_GPU_PIPELINED_EVENT_DB_CACHE_FLUSH_AND_INV = 0x0000002a, // Flush Depth Block data + D3D11X_GPU_PIPELINED_EVENT_FLUSH_AND_INV_CB_META = 0x0000002e, // Flush Color Block metadata + D3D11X_GPU_PIPELINED_EVENT_FLUSH_AND_INV_DB_META = 0x0000002c, // Flush Depth Block metadata + D3D11X_GPU_PIPELINED_EVENT_CS_PARTIAL_FLUSH = 0x00000407, // Ensure all CS finished running before dispatching new CS + D3D11X_GPU_PIPELINED_EVENT_VS_PARTIAL_FLUSH = 0x0000040f, // Ensure all VS finished running before dispatching new VS + D3D11X_GPU_PIPELINED_EVENT_PS_PARTIAL_FLUSH = 0x00000410, // Ensure all PS finished running before dispatching new PS + D3D11X_GPU_PIPELINED_EVENT_PFP_SYNC_ME = 0x80000001, // Synchronize command processor PFP with ME + + } D3D11X_GPU_PIPELINED_EVENT; + + struct D3D11X_GRAPHICS_SHADER_LIMITS + { + UINT MaxWavesWithLateAllocParameterCache; + + UINT VSDisableCuMask; + // Note: HS must run in the same CU as VS, so it has no mask of its own. + UINT DSDisableCuMask; + UINT GSDisableCuMask; + UINT PSDisableCuMask; + + UINT VSMaxWaves; + UINT HSMaxWaves; + UINT DSMaxWaves; + UINT GSMaxWaves; + UINT PSMaxWaves; + + UINT VSMaxWavesForCuLocking; + UINT HSMaxWavesForCuLocking; + UINT DSMaxWavesForCuLocking; + UINT GSMaxWavesForCuLocking; + UINT PSMaxWavesForCuLocking; + }; + + enum D3D11X_SHADER_CS_SIMD_WALK_ALGORITHM : UINT + { + D3D11X_SHADER_CS_SIMD_WALK_ALGORITHM_DEFAULT = 0, + D3D11X_SHADER_CS_SIMD_WALK_ALGORITHM_GLOBAL_BALANCED = 1, // Walk the SIMDs across CUs but maintaining a balanced distribution per CU. + D3D11X_SHADER_CS_SIMD_WALK_ALGORITHM_GLOBAL_STRICT = 2, // Walk the SIMDs across CUs disregarding wave distribution within each CU. + D3D11X_SHADER_CS_SIMD_WALK_ALGORITHM_PER_CU = 3, // Walk SIMDs independently for each CU. + }; + + struct D3D11X_COMPUTE_SHADER_LIMITS + { + UINT DisableCuMask[ 2 ]; + UINT MaxWaves; + UINT MaxThreadgroupsPerCu; + UINT MaxWavesForCuLocking; + UINT NumThreadgroupsWalkedPerCu; + D3D11X_SHADER_CS_SIMD_WALK_ALGORITHM SimdWalkAlgorithm; + }; + + typedef enum D3D11X_THREAD_TRACE_SCOPE + { + D3D11X_THREAD_TRACE_SCOPE_TITLE_ONLY = 0, + D3D11X_THREAD_TRACE_SCOPE_SYSTEM_WIDE = 1, + D3D11X_THREAD_TRACE_SCOPE_SYSTEM_AND_DETAILED_TITLE = 2, + } D3D11X_THREAD_TRACE_SCOPE; + + typedef enum D3D11X_THREAD_TRACE_PIPELINE_ENABLE + { + D3D11X_THREAD_TRACE_PIPELINE_ENABLE_NONE = 0x00000000, // Don't trace threads of this type + D3D11X_THREAD_TRACE_PIPELINE_ENABLE_ALL = 0x00000001, // Trace target-CU details for all threads of this type when tracing is enabled + } D3D11X_THREAD_TRACE_PIPELINE_ENABLE; + + struct D3D11X_THREAD_TRACE_DESC + { + BOOL PipelineFlushBeforeAndAfter; + UINT TargetComputeUnitIndex; + D3D11X_THREAD_TRACE_SCOPE TraceScope; + BOOL AllowSamplingGpuStalls; + D3D11X_THREAD_TRACE_PIPELINE_ENABLE PsEnable; + D3D11X_THREAD_TRACE_PIPELINE_ENABLE VsEnable; + D3D11X_THREAD_TRACE_PIPELINE_ENABLE GsEnable; + D3D11X_THREAD_TRACE_PIPELINE_ENABLE EsEnable; + D3D11X_THREAD_TRACE_PIPELINE_ENABLE HsEnable; + D3D11X_THREAD_TRACE_PIPELINE_ENABLE LsEnable; + D3D11X_THREAD_TRACE_PIPELINE_ENABLE CsEnable; + USHORT TokenMask; + USHORT InstructionMask; + BYTE RegisterMask; + }; + + typedef struct D3D11X_GS_PARAMETERS + { + UINT Size; + UINT Flags; + UINT VerticesPerSubgroup; + UINT PrimitivesPerSubgroup; + float VerticesPerPrimitiveRatio; + UINT LdsAllocationLimit; + } D3D11X_GS_PARAMETERS; + + typedef struct _D3D11X_MSAA_SCAN_CONVERTER_SETTINGS + { + UINT NumSamplesMsaaLog2 : 3; + UINT MaxSampleDistanceInSubpixels : 4; + UINT NumSamplesMsaaExposedToPSLog2 : 3; + UINT DetailToExposedMode : 2; + UINT ApplyMaskAfterCentroid : 1; + } D3D11X_MSAA_SCAN_CONVERTER_SETTINGS; + + typedef POINT D3D11X_POINT; + + typedef struct _D3D11X_MSAA_EQAA_SETTINGS + { + UINT MaxAnchorSamplesLog2 : 3; + UINT NumSamplesForPSIterationLog2 : 3; + UINT NumSamplesForMaskExportLog2 : 3; + UINT NumSamplesForAlphaToMaskLog2 : 3; + UINT HightQualityIntersections : 1; + UINT InterpolateCompZ : 1; + UINT InterpolateSrcZ : 1; + UINT StaticAnchorAssociations : 1; + UINT OverrasterizationAmount : 3; + UINT EnablePostZOverrasterization : 1; + } D3D11X_MSAA_EQAA_SETTINGS; + + typedef struct _D3D11X_MSAA_SAMPLE_PRIORITIES + { + BYTE CentroidPriorities[ 16 ]; + } D3D11X_MSAA_SAMPLE_PRIORITIES; + + typedef struct _D3D11X_MSAA_SAMPLE_POSITIONS + { + INT8 SampleLocs00[ 16 ][ 2 ]; // Sample positions stored as one byte per component, X then Y + INT8 SampleLocs10[ 16 ][ 2 ]; // There are up to 16 possible sample positions per pixel + INT8 SampleLocs01[ 16 ][ 2 ]; // They can be set differently for each pixel in a 2x2 quad + INT8 SampleLocs11[ 16 ][ 2 ]; + } D3D11X_MSAA_SAMPLE_POSITIONS; + + typedef D3D11_RECT D3D11X_RECT; + + typedef struct D3D11X_FORMAT + { + union + { + struct + { + // these are some other enum, too lazy to import them + UINT DataFormat; + UINT NumberFormat; + }; + UINT32 Dword[ 2 ]; + UINT64 Qword; + }; + } D3D11X_FORMAT; + + typedef enum D3D11X_HW_STAGE : UINT + { + D3D11X_HW_STAGE_PS = 0, + D3D11X_HW_STAGE_VS = 1, + D3D11X_HW_STAGE_GS = 2, + D3D11X_HW_STAGE_ES = 3, + D3D11X_HW_STAGE_HS = 4, + D3D11X_HW_STAGE_LS = 5, + D3D11X_HW_STAGE_CS = 6, + } D3D11X_HW_STAGE; + #pragma endregion + + // FIXME: handle different versions of the SDK for this class + D3DINTERFACE(ID3D11DeviceContext, c0bfa96c, e089, 44fb, 8e, af, 26, f8, 79, 61, 90, da) : public ID3D11DeviceChild { + public: + virtual void (VSSetConstantBuffers)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers) = 0; + virtual void (PSSetShaderResources)(ID3D11ShaderResourceView* const* ppShaderResourceViews,_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot,_In_ UINT PacketHeader) = 0; + virtual void (PSSetShader)(_In_opt_ ID3D11PixelShader* pPixelShader) = 0; + virtual void (PSSetSamplers)(_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers,_In_reads_opt_(NumSamplers) ID3D11SamplerState* const* ppSamplers) = 0; + virtual void (VSSetShader)(_In_opt_ ID3D11VertexShader* pVertexShader) = 0; + virtual void (DrawIndexed)(_In_ UINT64 StartIndexLocationAndIndexCount,_In_ INT BaseVertexLocation) = 0; + virtual void (Draw)(_In_ UINT VertexCount,_In_ UINT StartVertexLocation) = 0; + virtual HRESULT(Map)(_In_ ID3D11Resource* pResource,_In_ UINT Subresource,_In_ D3D11_MAP MapType,_In_ UINT MapFlags,_Out_ D3D11_MAPPED_SUBRESOURCE* pMappedResource) = 0; + virtual void (Unmap)(_In_ ID3D11Resource* pResource,_In_ UINT Subresource) = 0; + virtual void (PSSetConstantBuffers)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers) = 0; + virtual void (IASetInputLayout)(_In_opt_ ID3D11InputLayout* pInputLayout) = 0; + virtual void (IASetVertexBuffers)(_In_range_(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumBuffers,_In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppVertexBuffers,_In_reads_opt_(NumBuffers) const UINT* pStrides,_In_reads_opt_(NumBuffers) const UINT* pOffsets) = 0; + virtual void (IASetIndexBuffer)(_In_ UINT HardwareIndexFormat,_In_opt_ ID3D11Buffer* pIndexBuffer,_In_ UINT Offset) = 0; + virtual void (DrawIndexedInstanced)(_In_ UINT64 StartIndexLocationAndIndexCountPerInstance,_In_ UINT64 BaseVertexLocationAndStartInstanceLocation,_In_ UINT InstanceCount) = 0; + virtual void (DrawInstanced)(_In_ UINT VertexCountPerInstance,_In_ UINT64 StartVertexLocationAndStartInstanceLocation,_In_ UINT InstanceCount) = 0; + virtual void (GSSetConstantBuffers)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers) = 0; + virtual void (GSSetShader)(_In_opt_ ID3D11GeometryShader* pShader) = 0; + virtual void (VSSetShaderResources)(ID3D11ShaderResourceView* const* ppShaderResourceViews,_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot,_In_ UINT PacketHeader) = 0; + virtual void (VSSetSamplers)(_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers,_In_reads_opt_(NumSamplers) ID3D11SamplerState* const* ppSamplers) = 0; + virtual void (Begin)(_In_ ID3D11Asynchronous* pAsync) = 0; + virtual void (End)(_In_ ID3D11Asynchronous* pAsync) = 0; + virtual HRESULT(GetData)(_In_ ID3D11Asynchronous* pAsync,_Out_writes_bytes_opt_(DataSize) void* pData,_In_ UINT DataSize,_In_ UINT GetDataFlags) = 0; + virtual void (SetPredication)(_In_opt_ ID3D11Predicate* pPredicate,_In_ BOOL PredicateValue) = 0; + virtual void (GSSetShaderResources)(ID3D11ShaderResourceView* const* ppShaderResourceViews,_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot,_In_ UINT PacketHeader) = 0; + virtual void (GSSetSamplers)(_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers,_In_reads_opt_(NumSamplers) ID3D11SamplerState* const* ppSamplers) = 0; + virtual void (OMSetRenderTargets)(_In_range_(0, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT) UINT NumViews,_In_reads_opt_(NumViews) ID3D11RenderTargetView* const* ppRenderTargetViews,_In_opt_ ID3D11DepthStencilView* pDepthStencilView) = 0; + virtual void (OMSetRenderTargetsAndUnorderedAccessViews)(_In_ UINT NumRTVs,_In_reads_opt_(NumRTVs) ID3D11RenderTargetView* const* ppRenderTargetViews,_In_opt_ ID3D11DepthStencilView* pDepthStencilView,_In_range_(0, D3D11_1_UAV_SLOT_COUNT - 1) UINT UAVStartSlot,_In_ UINT NumUAVs,_In_reads_opt_(NumUAVs) ID3D11UnorderedAccessView* const* ppUnorderedAccessViews,_In_reads_opt_(NumUAVs) const UINT* pUAVInitialCounts) = 0; + virtual void (OMSetBlendState)(_In_opt_ ID3D11BlendState* pBlendState,_In_opt_ const FLOAT BlendFactor[ 4 ],_In_ UINT SampleMask) = 0; + virtual void (OMSetDepthStencilState)(_In_opt_ ID3D11DepthStencilState* pDepthStencilState,_In_ UINT StencilRef) = 0; + virtual void (SOSetTargets)(_In_range_(0, D3D11_SO_BUFFER_SLOT_COUNT) UINT NumBuffers,_In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppSOTargets,_In_reads_opt_(NumBuffers) const UINT* pOffsets) = 0; + virtual void (DrawAuto)( ) = 0; + virtual void (DrawIndexedInstancedIndirect)(_In_ ID3D11Buffer* pBufferForArgs,_In_ UINT AlignedByteOffsetForArgs) = 0; + virtual void (DrawInstancedIndirect)(_In_ ID3D11Buffer* pBufferForArgs,_In_ UINT AlignedByteOffsetForArgs) = 0; + virtual void (Dispatch)(_In_ UINT ThreadGroupCountX,_In_ UINT ThreadGroupCountY,_In_ UINT ThreadGroupCountZ) = 0; + virtual void (DispatchIndirect)(_In_ ID3D11Buffer* pBufferForArgs,_In_ UINT AlignedByteOffsetForArgs) = 0; + virtual void (RSSetState)(_In_opt_ ID3D11RasterizerState* pRasterizerState) = 0; + virtual void (RSSetViewports)(_In_range_(0, D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumViewports,_In_reads_opt_(NumViewports) const D3D11_VIEWPORT* pViewports) = 0; + virtual void (RSSetScissorRects)(_In_range_(0, D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumRects,_In_reads_opt_(NumRects) const D3D11_RECT* pRects) = 0; + virtual void (CopySubresourceRegion)(_In_ ID3D11Resource* pDstResource,_In_ UINT DstSubresource,_In_ UINT DstX,_In_ UINT DstY,_In_ UINT DstZ,_In_ ID3D11Resource* pSrcResource,_In_ UINT SrcSubresource,_In_opt_ const D3D11_BOX* pSrcBox) = 0; + virtual void (CopyResource)(_In_ ID3D11Resource* pDstResource,_In_ ID3D11Resource* pSrcResource) = 0; + virtual void (UpdateSubresource)(_In_ ID3D11Resource* pDstResource,_In_ UINT DstSubresource,_In_opt_ const D3D11_BOX* pDstBox,_In_ const void* pSrcData,_In_ UINT SrcRowPitch,_In_ UINT SrcDepthPitch) = 0; + virtual void (CopyStructureCount)(_In_ ID3D11Buffer* pDstBuffer,_In_ UINT DstAlignedByteOffset,_In_ ID3D11UnorderedAccessView* pSrcView) = 0; + virtual void (ClearRenderTargetView)(_In_ ID3D11RenderTargetView* pRenderTargetView,_In_ const FLOAT ColorRGBA[ 4 ]) = 0; + virtual void (ClearUnorderedAccessViewUint)(_In_ ID3D11UnorderedAccessView* pUnorderedAccessView,_In_ const UINT Values[ 4 ]) = 0; + virtual void (ClearUnorderedAccessViewFloat)(_In_ ID3D11UnorderedAccessView* pUnorderedAccessView,_In_ const FLOAT Values[ 4 ]) = 0; + virtual void (ClearDepthStencilView)(_In_ ID3D11DepthStencilView* pDepthStencilView,_In_ UINT ClearFlags,_In_ FLOAT Depth,_In_ UINT8 Stencil) = 0; + virtual void (GenerateMips)(_In_ ID3D11ShaderResourceView* pShaderResourceView) = 0; + virtual void (SetResourceMinLOD)(_In_ ID3D11Resource* pResource,FLOAT MinLOD) = 0; + virtual FLOAT(GetResourceMinLOD)(_In_ ID3D11Resource* pResource) = 0; + virtual void (ResolveSubresource)(_In_ ID3D11Resource* pDstResource,_In_ UINT DstSubresource,_In_ ID3D11Resource* pSrcResource,_In_ UINT SrcSubresource,_In_ DXGI_FORMAT Format) = 0; + virtual void (ExecuteCommandList)(_In_ ID3D11CommandList* pCommandList,BOOL RestoreContextState) = 0; + virtual void (HSSetShaderResources)(ID3D11ShaderResourceView* const* ppShaderResourceViews,_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot,_In_ UINT PacketHeader) = 0; + virtual void (HSSetShader)(_In_opt_ ID3D11HullShader* pHullShader) = 0; + virtual void (HSSetSamplers)(_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers,_In_reads_opt_(NumSamplers) ID3D11SamplerState* const* ppSamplers) = 0; + virtual void (HSSetConstantBuffers)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers) = 0; + virtual void (DSSetShaderResources)(ID3D11ShaderResourceView* const* ppShaderResourceViews,_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot,_In_ UINT PacketHeader) = 0; + virtual void (DSSetShader)(_In_opt_ ID3D11DomainShader* pDomainShader) = 0; + virtual void (DSSetSamplers)(_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers,_In_reads_opt_(NumSamplers) ID3D11SamplerState* const* ppSamplers) = 0; + virtual void (DSSetConstantBuffers)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers) = 0; + virtual void (CSSetShaderResources)(ID3D11ShaderResourceView* const* ppShaderResourceViews,_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot,_In_ UINT PacketHeader) = 0; + virtual void (CSSetUnorderedAccessViews)(_In_range_(0, D3D11_1_UAV_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_1_UAV_SLOT_COUNT - StartSlot) UINT NumUAVs,_In_reads_opt_(NumUAVs) ID3D11UnorderedAccessView* const* ppUnorderedAccessViews,_In_reads_opt_(NumUAVs) const UINT* pUAVInitialCounts) = 0; + virtual void (CSSetShader)(_In_opt_ ID3D11ComputeShader* pComputeShader) = 0; + virtual void (CSSetSamplers)(_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers,_In_reads_opt_(NumSamplers) ID3D11SamplerState* const* ppSamplers) = 0; + virtual void (CSSetConstantBuffers)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers) = 0; + virtual void (VSGetConstantBuffers)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers) = 0; + virtual void (PSGetShaderResources)(_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews,_Out_writes_opt_(NumViews) ID3D11ShaderResourceView** ppShaderResourceViews) = 0; + virtual void (PSGetShader)(_Out_ ID3D11PixelShader** ppPixelShader,_Out_writes_opt_(*pNumClassInstances) ID3D11ClassInstance** ppClassInstances,_Inout_opt_ UINT* pNumClassInstances) = 0; + virtual void (PSGetSamplers)(_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers,_Out_writes_opt_(NumSamplers) ID3D11SamplerState** ppSamplers) = 0; + virtual void (VSGetShader)(_Out_ ID3D11VertexShader** ppVertexShader,_Out_writes_opt_(*pNumClassInstances) ID3D11ClassInstance** ppClassInstances,_Inout_opt_ UINT* pNumClassInstances) = 0; + virtual void (PSGetConstantBuffers)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers) = 0; + virtual void (IAGetInputLayout)(_Out_ ID3D11InputLayout** ppInputLayout) = 0; + virtual void (IAGetVertexBuffers)(_In_range_(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumBuffers,_Out_writes_opt_(NumBuffers) ID3D11Buffer** ppVertexBuffers,_Out_writes_opt_(NumBuffers) UINT* pStrides,_Out_writes_opt_(NumBuffers) UINT* pOffsets) = 0; + virtual void (IAGetIndexBuffer)(_Out_opt_ ID3D11Buffer** pIndexBuffer,_Out_opt_ DXGI_FORMAT* Format,_Out_opt_ UINT* Offset) = 0; + virtual void (GSGetConstantBuffers)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers) = 0; + virtual void (GSGetShader)(_Out_ ID3D11GeometryShader** ppGeometryShader,_Out_writes_opt_(*pNumClassInstances) ID3D11ClassInstance** ppClassInstances,_Inout_opt_ UINT* pNumClassInstances) = 0; + virtual void (IAGetPrimitiveTopology)(_Out_ D3D11_PRIMITIVE_TOPOLOGY* pTopology) = 0; + virtual void (VSGetShaderResources)(_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews,_Out_writes_opt_(NumViews) ID3D11ShaderResourceView** ppShaderResourceViews) = 0; + virtual void (VSGetSamplers)(_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers,_Out_writes_opt_(NumSamplers) ID3D11SamplerState** ppSamplers) = 0; + virtual void (GetPredication)(_Out_opt_ ID3D11Predicate** ppPredicate,_Out_opt_ BOOL* pPredicateValue) = 0; + virtual void (GSGetShaderResources)(_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews,_Out_writes_opt_(NumViews) ID3D11ShaderResourceView** ppShaderResourceViews) = 0; + virtual void (GSGetSamplers)(_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers,_Out_writes_opt_(NumSamplers) ID3D11SamplerState** ppSamplers) = 0; + virtual void (OMGetRenderTargets)(_In_range_(0, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT) UINT NumViews,_Out_writes_opt_(NumViews) ID3D11RenderTargetView** ppRenderTargetViews,_Out_opt_ ID3D11DepthStencilView** ppDepthStencilView) = 0; + virtual void (OMGetRenderTargetsAndUnorderedAccessViews)(_In_range_(0, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT) UINT NumRTVs,_Out_writes_opt_(NumRTVs) ID3D11RenderTargetView** ppRenderTargetViews,_Out_opt_ ID3D11DepthStencilView** ppDepthStencilView,_In_range_(0, D3D11_PS_CS_UAV_REGISTER_COUNT - 1) UINT UAVStartSlot,_In_range_(0, D3D11_PS_CS_UAV_REGISTER_COUNT - UAVStartSlot) UINT NumUAVs,_Out_writes_opt_(NumUAVs) ID3D11UnorderedAccessView** ppUnorderedAccessViews) = 0; + virtual void (OMGetBlendState)(_Out_opt_ ID3D11BlendState** ppBlendState,_Out_writes_all_opt_(4) FLOAT BlendFactor[ 4 ],_Out_opt_ UINT* pSampleMask) = 0; + virtual void (OMGetDepthStencilState)(_Out_opt_ ID3D11DepthStencilState** ppDepthStencilState,_Out_opt_ UINT* pStencilRef) = 0; + virtual void (SOGetTargets)(_In_range_(0, D3D11_SO_BUFFER_SLOT_COUNT) UINT NumBuffers,_Out_writes_opt_(NumBuffers) ID3D11Buffer** ppSOTargets) = 0; + virtual void (RSGetState)(_Out_ ID3D11RasterizerState** ppRasterizerState) = 0; + virtual void (RSGetViewports)(_Inout_ /*_range(0, D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE )*/ UINT* pNumViewports,_Out_writes_opt_(*pNumViewports) D3D11_VIEWPORT* pViewports) = 0; + virtual void (RSGetScissorRects)(_Inout_ /*_range(0, D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE )*/ UINT* pNumRects,_Out_writes_opt_(*pNumRects) D3D11_RECT* pRects) = 0; + virtual void (HSGetShaderResources)(_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews,_Out_writes_opt_(NumViews) ID3D11ShaderResourceView** ppShaderResourceViews) = 0; + virtual void (HSGetShader)(_Out_ ID3D11HullShader** ppHullShader,_Out_writes_opt_(*pNumClassInstances) ID3D11ClassInstance** ppClassInstances,_Inout_opt_ UINT* pNumClassInstances) = 0; + virtual void (HSGetSamplers)(_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers,_Out_writes_opt_(NumSamplers) ID3D11SamplerState** ppSamplers) = 0; + virtual void (HSGetConstantBuffers)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers) = 0; + virtual void (DSGetShaderResources)(_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews,_Out_writes_opt_(NumViews) ID3D11ShaderResourceView** ppShaderResourceViews) = 0; + virtual void (DSGetShader)(_Out_ ID3D11DomainShader** ppDomainShader,_Out_writes_opt_(*pNumClassInstances) ID3D11ClassInstance** ppClassInstances,_Inout_opt_ UINT* pNumClassInstances) = 0; + virtual void (DSGetSamplers)(_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers,_Out_writes_opt_(NumSamplers) ID3D11SamplerState** ppSamplers) = 0; + virtual void (DSGetConstantBuffers)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers) = 0; + virtual void (CSGetShaderResources)(_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - StartSlot) UINT NumViews,_Out_writes_opt_(NumViews) ID3D11ShaderResourceView** ppShaderResourceViews) = 0; + virtual void (CSGetUnorderedAccessViews)(_In_range_(0, D3D11_PS_CS_UAV_REGISTER_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_PS_CS_UAV_REGISTER_COUNT - StartSlot) UINT NumUAVs,_Out_writes_opt_(NumUAVs) ID3D11UnorderedAccessView** ppUnorderedAccessViews) = 0; + virtual void (CSGetShader)(_Out_ ID3D11ComputeShader** ppComputeShader,_Out_writes_opt_(*pNumClassInstances) ID3D11ClassInstance** ppClassInstances,_Inout_opt_ UINT* pNumClassInstances) = 0; + virtual void (CSGetSamplers)(_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - StartSlot) UINT NumSamplers,_Out_writes_opt_(NumSamplers) ID3D11SamplerState** ppSamplers) = 0; + virtual void (CSGetConstantBuffers)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers) = 0; + virtual void (ClearState)( ) = 0; + virtual void (Flush)( ) = 0; + virtual D3D11_DEVICE_CONTEXT_TYPE(GetType)() = 0; + virtual UINT(GetContextFlags)() = 0; + virtual HRESULT(FinishCommandList)(BOOL RestoreDeferredContextState,_Out_opt_ ID3D11CommandList** ppCommandList) = 0; + }; + + // this class remains the same for all versions of d3d11.x + D3DINTERFACE(ID3D11DeviceContext1, bb2c6faa, b5fb, 4082, 8e, 6b, 38, 8b, 8c, fa, 90, e1) : public ID3D11DeviceContext { + public: + virtual void (CopySubresourceRegion1)(_In_ ID3D11Resource* pDstResource,_In_ UINT DstSubresource,_In_ UINT DstX,_In_ UINT DstY,_In_ UINT DstZ,_In_ ID3D11Resource* pSrcResource,_In_ UINT SrcSubresource,_In_opt_ const D3D11_BOX* pSrcBox,_In_ UINT CopyFlags) = 0; + virtual void (UpdateSubresource1)(_In_ ID3D11Resource* pDstResource,_In_ UINT DstSubresource,_In_opt_ const D3D11_BOX* pDstBox,_In_ const void* pSrcData,_In_ UINT SrcRowPitch,_In_ UINT SrcDepthPitch,_In_ UINT CopyFlags) = 0; + virtual void (DiscardResource)(_In_ ID3D11Resource* pResource) = 0; + virtual void (DiscardView)(_In_ ID3D11View* pResourceView) = 0; + virtual void (VSSetConstantBuffers1)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers,_In_reads_opt_(NumBuffers) const UINT* pFirstConstant,_In_reads_opt_(NumBuffers) const UINT* pNumConstants) = 0; + virtual void (HSSetConstantBuffers1)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers,_In_reads_opt_(NumBuffers) const UINT* pFirstConstant,_In_reads_opt_(NumBuffers) const UINT* pNumConstants) = 0; + virtual void (DSSetConstantBuffers1)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers,_In_reads_opt_(NumBuffers) const UINT* pFirstConstant,_In_reads_opt_(NumBuffers) const UINT* pNumConstants) = 0; + virtual void (GSSetConstantBuffers1)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers,_In_reads_opt_(NumBuffers) const UINT* pFirstConstant,_In_reads_opt_(NumBuffers) const UINT* pNumConstants) = 0; + virtual void (PSSetConstantBuffers1)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers,_In_reads_opt_(NumBuffers) const UINT* pFirstConstant,_In_reads_opt_(NumBuffers) const UINT* pNumConstants) = 0; + virtual void (CSSetConstantBuffers1)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_In_reads_opt_(NumBuffers) ID3D11Buffer* const* ppConstantBuffers,_In_reads_opt_(NumBuffers) const UINT* pFirstConstant,_In_reads_opt_(NumBuffers) const UINT* pNumConstants) = 0; + virtual void (VSGetConstantBuffers1)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers,_Out_writes_opt_(NumBuffers) UINT* pFirstConstant,_Out_writes_opt_(NumBuffers) UINT* pNumConstants) = 0; + virtual void (HSGetConstantBuffers1)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers,_Out_writes_opt_(NumBuffers) UINT* pFirstConstant,_Out_writes_opt_(NumBuffers) UINT* pNumConstants) = 0; + virtual void (DSGetConstantBuffers1)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers,_Out_writes_opt_(NumBuffers) UINT* pFirstConstant,_Out_writes_opt_(NumBuffers) UINT* pNumConstants) = 0; + virtual void (GSGetConstantBuffers1)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers,_Out_writes_opt_(NumBuffers) UINT* pFirstConstant,_Out_writes_opt_(NumBuffers) UINT* pNumConstants) = 0; + virtual void (PSGetConstantBuffers1)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers,_Out_writes_opt_(NumBuffers) UINT* pFirstConstant,_Out_writes_opt_(NumBuffers) UINT* pNumConstants) = 0; + virtual void (CSGetConstantBuffers1)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT StartSlot,_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot) UINT NumBuffers,_Out_writes_opt_(NumBuffers) ID3D11Buffer** ppConstantBuffers,_Out_writes_opt_(NumBuffers) UINT* pFirstConstant,_Out_writes_opt_(NumBuffers) UINT* pNumConstants) = 0; + virtual void (SwapDeviceContextState)(_In_ ID3DDeviceContextState* pState,_Out_opt_ ID3DDeviceContextState** ppPreviousState) = 0; + virtual void (ClearView)(_In_ ID3D11View* pView,_In_ const FLOAT Color[ 4 ],_In_reads_opt_(NumRects) const D3D11_RECT* pRect,UINT NumRects) = 0; + virtual void (DiscardView1)(_In_ ID3D11View* pResourceView,_In_reads_opt_(NumRects) const D3D11_RECT* pRects,UINT NumRects) = 0; + }; + + D3DINTERFACE(ID3D11DeviceContext2, 420d5b32, b90c, 4da4, be, f0, 35, 9f, 6a, 24, a8, 3a) : public ID3D11DeviceContext1 { + public: + virtual HRESULT(UpdateTileMappings)(_In_ ID3D11Resource* pTiledResource,_In_ UINT NumTiledResourceRegions,_In_reads_opt_(NumTiledResourceRegions) const D3D11_TILED_RESOURCE_COORDINATE* pTiledResourceRegionStartCoordinates,_In_reads_opt_(NumTiledResourceRegions) const D3D11_TILE_REGION_SIZE* pTiledResourceRegionSizes,_In_opt_ ID3D11Buffer* pTilePool,_In_ UINT NumRanges,_In_reads_opt_(NumRanges) const UINT* pRangeFlags,_In_reads_opt_(NumRanges) const UINT* pTilePoolStartOffsets,_In_reads_opt_(NumRanges) const UINT* pRangeTileCounts,_In_ UINT Flags) = 0; + virtual HRESULT(CopyTileMappings)(_In_ ID3D11Resource* pDestTiledResource,_In_ const D3D11_TILED_RESOURCE_COORDINATE* pDestRegionStartCoordinate,_In_ ID3D11Resource* pSourceTiledResource,_In_ const D3D11_TILED_RESOURCE_COORDINATE* pSourceRegionStartCoordinate,_In_ const D3D11_TILE_REGION_SIZE* pTileRegionSize,_In_ UINT Flags) = 0; + virtual void (CopyTiles)(_In_ ID3D11Resource* pTiledResource,_In_ const D3D11_TILED_RESOURCE_COORDINATE* pTileRegionStartCoordinate,_In_ const D3D11_TILE_REGION_SIZE* pTileRegionSize,_In_ ID3D11Buffer* pBuffer,_In_ UINT64 BufferStartOffsetInBytes,_In_ UINT Flags) = 0; + virtual void (UpdateTiles)(_In_ ID3D11Resource* pDestTiledResource,_In_ const D3D11_TILED_RESOURCE_COORDINATE* pDestTileRegionStartCoordinate,_In_ const D3D11_TILE_REGION_SIZE* pDestTileRegionSize,_In_ const void* pSourceTileData,_In_ UINT Flags) = 0; + virtual HRESULT(ResizeTilePool)(_In_ ID3D11Buffer* pTilePool,_In_ UINT64 NewSizeInBytes) = 0; + virtual void (TiledResourceBarrier)(_In_opt_ ID3D11DeviceChild* pTiledResourceOrViewAccessBeforeBarrier,_In_opt_ ID3D11DeviceChild* pTiledResourceOrViewAccessAfterBarrier) = 0; + }; + + // FIXME: handle different versions of the SDK for this class + D3DINTERFACE(ID3D11DeviceContextX, 48800095, 7134, 4be7, 91, 86, b8, 6b, ec, b2, 64, 77) : public ID3D11DeviceContext2 { + public: + virtual INT(PIXBeginEvent)(_In_ LPCWSTR Name) = 0; + virtual INT(PIXBeginEventEx)(_In_reads_bytes_(DataSize) const void* pData,_In_ UINT DataSize) = 0; + virtual INT(PIXEndEvent)() = 0; + virtual void (PIXSetMarker)(_In_ LPCWSTR Name) = 0; + virtual void (PIXSetMarkerEx)(_In_reads_bytes_(DataSize) const void* pData,_In_ UINT DataSize) = 0; + virtual BOOL(PIXGetStatus)() = 0; + virtual HRESULT(PIXGpuCaptureNextFrame)(_In_ UINT Flags,_In_z_ LPCWSTR lpOutputFileName) = 0; + virtual HRESULT(PIXGpuBeginCapture)(_In_ UINT Flags,_In_z_ LPCWSTR lpOutputFileName) = 0; + virtual HRESULT(PIXGpuEndCapture)() = 0; + virtual void (StartCounters)(_In_ ID3D11CounterSetX* pCounterSet) = 0; + virtual void (SampleCounters)(_In_ ID3D11CounterSampleX* pCounterSample) = 0; + virtual void (StopCounters)( ) = 0; + virtual HRESULT(GetCounterData)(_In_ ID3D11CounterSampleX* pCounterSample,_Out_ D3D11X_COUNTER_DATA* pData,_In_ UINT GetCounterDataFlags) = 0; + virtual void (FlushGpuCaches)(_In_ ID3D11Resource* pResource) = 0; + virtual void (FlushGpuCacheRange)(_In_ UINT Flags,_In_ void* pBaseAddress,_In_ SIZE_T SizeInBytes) = 0; + virtual void (InsertWaitUntilIdle)(_In_ UINT Flags) = 0; + virtual UINT64(InsertFence)(_In_ UINT Flags) = 0; + virtual void (InsertWaitOnFence)(_In_ UINT Flags,_In_ UINT64 Fence) = 0; + virtual void (RemapConstantBufferInheritance)(_In_ D3D11_STAGE Stage,_In_ UINT Slot,_In_ D3D11_STAGE InheritStage,_In_ UINT InheritSlot) = 0; + virtual void (RemapShaderResourceInheritance)(_In_ D3D11_STAGE Stage,_In_ UINT Slot,_In_ D3D11_STAGE InheritStage,_In_ UINT InheritSlot) = 0; + virtual void (RemapSamplerInheritance)(_In_ D3D11_STAGE Stage,_In_ UINT Slot,_In_ D3D11_STAGE InheritStage,_In_ UINT InheritSlot) = 0; + virtual void (RemapVertexBufferInheritance)(_In_ UINT Slot,_In_ UINT InheritSlot) = 0; + virtual void (PSSetFastConstantBuffer)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11Buffer* pConstantBuffer) = 0; + virtual void (PSSetFastShaderResource)(_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11ShaderResourceView* pShaderResourceView) = 0; + virtual void (PSSetFastSampler)(_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11SamplerState* pSampler) = 0; + virtual void (VSSetFastConstantBuffer)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11Buffer* pConstantBuffer) = 0; + virtual void (VSSetFastShaderResource)(_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11ShaderResourceView* pShaderResourceView) = 0; + virtual void (VSSetFastSampler)(_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11SamplerState* pSampler) = 0; + virtual void (GSSetFastConstantBuffer)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11Buffer* pConstantBuffer) = 0; + virtual void (GSSetFastShaderResource)(_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11ShaderResourceView* pShaderResourceView) = 0; + virtual void (GSSetFastSampler)(_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11SamplerState* pSampler) = 0; + virtual void (CSSetFastConstantBuffer)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11Buffer* pConstantBuffer) = 0; + virtual void (CSSetFastShaderResource)(_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11ShaderResourceView* pShaderResourceView) = 0; + virtual void (CSSetFastSampler)(_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11SamplerState* pSampler) = 0; + virtual void (HSSetFastConstantBuffer)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11Buffer* pConstantBuffer) = 0; + virtual void (HSSetFastShaderResource)(_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11ShaderResourceView* pShaderResourceView) = 0; + virtual void (HSSetFastSampler)(_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11SamplerState* pSampler) = 0; + virtual void (DSSetFastConstantBuffer)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11Buffer* pConstantBuffer) = 0; + virtual void (DSSetFastShaderResource)(_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11ShaderResourceView* pShaderResourceView) = 0; + virtual void (DSSetFastSampler)(_In_range_(0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11SamplerState* pSampler) = 0; + virtual void (IASetFastVertexBuffer)(_In_range_(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11Buffer* pVertexBuffer,_In_ UINT Stride) = 0; + virtual void (IASetFastIndexBuffer)(_In_ UINT HardwareIndexFormat,_In_ ID3D11Buffer* pIndexBuffer) = 0; + virtual void (PSSetPlacementConstantBuffer)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11Buffer* pConstantBuffer,_In_ void* pBaseAddress) = 0; + virtual void (PSSetPlacementShaderResource)(_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11ShaderResourceView* pShaderResourceView,_In_ void* pBaseAddress) = 0; + virtual void (VSSetPlacementConstantBuffer)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11Buffer* pConstantBuffer,_In_ void* pBaseAddress) = 0; + virtual void (VSSetPlacementShaderResource)(_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11ShaderResourceView* pShaderResourceView,_In_ void* pBaseAddress) = 0; + virtual void (GSSetPlacementConstantBuffer)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11Buffer* pConstantBuffer,_In_ void* pBaseAddress) = 0; + virtual void (GSSetPlacementShaderResource)(_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11ShaderResourceView* pShaderResourceView,_In_ void* pBaseAddress) = 0; + virtual void (CSSetPlacementConstantBuffer)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11Buffer* pConstantBuffer,_In_ void* pBaseAddress) = 0; + virtual void (CSSetPlacementShaderResource)(_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11ShaderResourceView* pShaderResourceView,_In_ void* pBaseAddress) = 0; + virtual void (HSSetPlacementConstantBuffer)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11Buffer* pConstantBuffer,_In_ void* pBaseAddress) = 0; + virtual void (HSSetPlacementShaderResource)(_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11ShaderResourceView* pShaderResourceView,_In_ void* pBaseAddress) = 0; + virtual void (DSSetPlacementConstantBuffer)(_In_range_(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11Buffer* pConstantBuffer,_In_ void* pBaseAddress) = 0; + virtual void (DSSetPlacementShaderResource)(_In_range_(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11ShaderResourceView* pShaderResourceView,_In_ void* pBaseAddress) = 0; + virtual void (IASetPlacementVertexBuffer)(_In_range_(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT - 1) UINT Slot,_In_ ID3D11Buffer* pVertexBuffer,_In_ void* pBaseAddress,_In_ UINT Stride) = 0; + virtual void (IASetPlacementIndexBuffer)(_In_ UINT HardwareIndexFormat,_In_ ID3D11Buffer* pIndexBuffer,_In_ void* pBaseAddress) = 0; + virtual void (HSSetTessellationParameters)(_In_opt_ const D3D11X_TESSELLATION_PARAMETERS* pTessellationParameters) = 0; + virtual void (HSGetLastUsedTessellationParameters)(_Inout_ D3D11X_TESSELLATION_PARAMETERS* pTessellationParameters) = 0; + virtual void (CSEnableAutomaticGpuFlush)(_In_ BOOL Enable) = 0; + virtual void (GpuSendPipelinedEvent)(_In_ D3D11X_GPU_PIPELINED_EVENT Event) = 0; + virtual HRESULT(Suspend)(_In_ UINT Flags) = 0; + virtual HRESULT(Resume)() = 0; + virtual void (BeginCommandListExecution)(_In_ UINT Flags) = 0; + virtual void (EndCommandListExecution)( ) = 0; + virtual void (SetGraphicsShaderLimits)(_In_opt_ const D3D11X_GRAPHICS_SHADER_LIMITS* pShaderLimits) = 0; + virtual void (SetComputeShaderLimits)(_In_opt_ const D3D11X_COMPUTE_SHADER_LIMITS* pShaderLimits) = 0; + virtual void (SetPredicationBuffer)(_In_opt_ ID3D11Buffer* pBuffer,_In_ UINT Offset,_In_ UINT Flags) = 0; + virtual void (OMSetDepthBounds)(_In_ FLOAT min,_In_ FLOAT max) = 0; + virtual void (OMSetDepthStencilStateX)(_In_opt_ ID3D11DepthStencilState* pDepthStencilState) = 0; + virtual void (OMSetSampleMask)(_In_ UINT64 QuadSampleMask) = 0; + virtual UINT32* (MakeCeSpace) () = 0; + virtual void (SetFastResources_Debug)(_In_ UINT* pTableStart,_In_ UINT* pTableEnd) = 0; + virtual void (BeginResourceBatch)(_Out_ void* pBuffer,_In_ UINT BufferSize) = 0; + virtual UINT(EndResourceBatch)(_Out_opt_ UINT* pSizeNeeded) = 0; + virtual void (SetFastResourcesFromBatch_Debug)(_In_ void* pBatch,_In_ UINT Size) = 0; \ + virtual void (CSPlaceUnorderedAccessView)(_In_range_(0, D3D11_1_UAV_SLOT_COUNT - 1) UINT Slot,_In_ D3D11X_DESCRIPTOR_UNORDERED_ACCESS_VIEW* const pDescriptor,_In_ UINT64 Offset) = 0; + virtual void (WriteValueEndOfPipe)(_In_ void* pDestination,_In_ UINT Value,_In_ UINT Flags) = 0; + virtual void (CopyMemoryToMemory)(_In_ void* pDstAddress,_In_ void* pSrcAddress,_In_ SIZE_T SizeBytes) = 0; + virtual void (FillMemoryWithValue)(_In_ void* pDstAddress,_In_ SIZE_T SizeBytes,_In_ UINT FillValue) = 0; + virtual void (BeginProcessVideoResource)(_In_ ID3D11Resource* pResource,_In_ UINT SubResource) = 0; + virtual void (EndProcessVideoResource)(_In_ ID3D11Resource* pResource,_In_ UINT SubResource) = 0; + virtual HRESULT(StartThreadTrace)(_In_ const D3D11X_THREAD_TRACE_DESC* pDesc,_In_ void* pDstAddressShaderEngine0,_In_ void* pDstAddressShaderEngine1,_In_ SIZE_T BufferSizeBytes) = 0; + virtual void (StopThreadTrace)(_In_ void* pDstAddressTraceSize) = 0; + virtual void (InsertThreadTraceMarker)(_In_ UINT Marker) = 0; + virtual void (IASetPrimitiveResetIndex)(_In_ UINT ResetIndex) = 0; + virtual void (SetShaderResourceViewMinLOD)(_In_ ID3D11ShaderResourceView* pShaderResourceView,FLOAT MinLOD) = 0; + virtual void (InsertWaitOnPresent)(_In_ UINT Flags,_In_ ID3D11Resource* pBackBuffer) = 0; + virtual void (ClearRenderTargetViewX)(_In_ ID3D11RenderTargetView* pRenderTargetView,_In_ UINT Flags,_In_ const FLOAT ColorRGBA[ 4 ]) = 0; + virtual UINT(GetResourceCompression)(_In_ ID3D11Resource* pResource) = 0; + virtual UINT(GetResourceCompressionX)(_In_ const D3D11X_DESCRIPTOR_RESOURCE* pResource) = 0; + virtual void (DecompressResource)(_In_ ID3D11Resource* pDstResource,_In_ UINT DstSubresource,_In_opt_ const D3D11X_POINT* pDstPoint,_In_ ID3D11Resource* pSrcResource,_In_ UINT SrcSubresource,_In_opt_ const D3D11X_RECT* pSrcRect,_In_ DXGI_FORMAT DecompressFormat,_In_ UINT DecompressFlags) = 0; + virtual void (DecompressResourceX)(_In_ D3D11X_DESCRIPTOR_RESOURCE* pDstResource,_In_ UINT DstSubresource,_In_opt_ const D3D11X_POINT* pDstPoint,_In_ D3D11X_DESCRIPTOR_RESOURCE* pSrcResource,_In_ UINT SrcSubresource,_In_opt_ const D3D11X_RECT* pSrcRect,_In_ D3D11X_FORMAT DecompressFormat,_In_ UINT DecompressFlags) = 0; + virtual void (GSSetParameters)(_In_opt_ const D3D11X_GS_PARAMETERS* pGsParameters) = 0; + virtual void (GSGetLastUsedParameters)(_Inout_ D3D11X_GS_PARAMETERS* pGsParameters) = 0; + virtual void (MultiDrawIndexedInstancedIndirect)(_In_ UINT PrimitiveCount,_Inout_ ID3D11Buffer* pBufferForArgs,_In_ UINT AlignedByteOffsetForArgs,_In_ UINT StrideByteOffsetForArgs,_In_ UINT Flags) = 0; \ + virtual void (MultiDrawInstancedIndirect)(_In_ UINT PrimitiveCount,_Inout_ ID3D11Buffer* pBufferForArgs,_In_ UINT AlignedByteOffsetForArgs,_In_ UINT StrideByteOffsetForArgs,_In_ UINT Flags) = 0; + virtual void (MultiDrawIndexedInstancedIndirectAuto)(_Inout_ ID3D11Buffer* pBufferForPrimitiveCount,_In_ UINT AlignedByteOffsetForPrimitiveCount,_Inout_ ID3D11Buffer* pBufferForArgs,_In_ UINT AlignedByteOffsetForArgs,_In_ UINT StrideByteOffsetForArgs,_In_ UINT Flags) = 0; + virtual void (MultiDrawInstancedIndirectAuto)(_Inout_ ID3D11Buffer* pBufferForPrimitiveCount,_In_ UINT AlignedByteOffsetForPrimitiveCount,_Inout_ ID3D11Buffer* pBufferForArgs,_In_ UINT AlignedByteOffsetForArgs,_In_ UINT StrideByteOffsetForArgs,_In_ UINT Flags) = 0; + virtual HRESULT(RSGetMSAASettingsForQuality)(_Inout_opt_ D3D11X_MSAA_SCAN_CONVERTER_SETTINGS* pMSAASCSettings,_Inout_opt_ D3D11X_MSAA_EQAA_SETTINGS* pEQAASettings,_Inout_opt_ D3D11X_MSAA_SAMPLE_PRIORITIES* pCentroidPriorities,_Inout_opt_ D3D11X_MSAA_SAMPLE_POSITIONS* pSamplePositions,_In_ UINT LogSampleCount,_In_ UINT SampleQuality) = 0; + virtual void (RSSetScanConverterMSAASettings)(_In_ const D3D11X_MSAA_SCAN_CONVERTER_SETTINGS* pMSAASCSettings) = 0; + virtual void (RSSetEQAASettings)(_In_ const D3D11X_MSAA_EQAA_SETTINGS* pEQAASettings) = 0; + virtual void (RSSetSamplePositions)(_In_opt_ const D3D11X_MSAA_SAMPLE_PRIORITIES* pSamplesPriorities,_In_opt_ const D3D11X_MSAA_SAMPLE_POSITIONS* pSamplePositions) = 0; + virtual void (SetResourceCompression)(_In_ ID3D11Resource* pResource,_In_ UINT Compression) = 0; + virtual void (SetResourceCompressionX)(_In_ const D3D11X_DESCRIPTOR_RESOURCE* pResource,_In_ UINT Compression) = 0; + virtual void (SetGDSRange)(_In_ D3D11X_GDS_REGION_TYPE RegionType,_In_ UINT OffsetDwords,_In_ UINT NumDwords) = 0; + virtual void (WriteGDS)(_In_ D3D11X_GDS_REGION_TYPE RegionType,_In_ UINT OffsetDwords,_In_ UINT NumDwords,_In_ const UINT* pCounterValues,_In_ UINT Flags) = 0; + virtual void (ReadGDS)(_In_ D3D11X_GDS_REGION_TYPE RegionType,_In_ UINT OffsetDwords,_In_ UINT NumDwords,_Inout_ UINT* pCounterValues,_In_ UINT Flags) = 0; + virtual void (VSSetShaderUserData)(_In_ UINT StartSlot,_In_ UINT NumRegisters,_In_reads_(NumRegisters) const UINT* pData) = 0; + virtual void (HSSetShaderUserData)(_In_ UINT StartSlot,_In_ UINT NumRegisters,_In_reads_(NumRegisters) const UINT* pData) = 0; + virtual void (DSSetShaderUserData)(_In_ UINT StartSlot,_In_ UINT NumRegisters,_In_reads_(NumRegisters) const UINT* pData) = 0; + virtual void (GSSetShaderUserData)(_In_ UINT StartSlot,_In_ UINT NumRegisters,_In_reads_(NumRegisters) const UINT* pData) = 0; + virtual void (PSSetShaderUserData)(_In_ UINT StartSlot,_In_ UINT NumRegisters,_In_reads_(NumRegisters) const UINT* pData) = 0; + virtual void (CSSetShaderUserData)(_In_ UINT StartSlot,_In_ UINT NumRegisters,_In_reads_(NumRegisters) const UINT* pData) = 0; + virtual void (InsertWaitOnMemory)(_In_ const void* pAddress,_In_ UINT Flags,_In_ D3D11_COMPARISON_FUNC ComparisonFunction,_In_ UINT ReferenceValue,_In_ UINT Mask) = 0; + virtual void (WriteTimestampToMemory)(_In_ void* pDstAddress) = 0; + virtual void (WriteTimestampToBuffer)(_In_ ID3D11Buffer* pBuffer,_In_ UINT OffsetBytes) = 0; + virtual void (StoreConstantRam)(_In_ UINT Flags,_In_ ID3D11Buffer* pBuffer,_In_ UINT BufferOffsetInBytes,_In_ UINT CeRamOffsetInBytes,_In_ UINT SizeInBytes) = 0; + virtual void (LoadConstantRam)(_In_ UINT Flags,_In_ ID3D11Buffer* pBuffer,_In_ UINT BufferOffsetInBytes,_In_ UINT CeRamOffsetInBytes,_In_ UINT SizeInBytes) = 0; + virtual void (WriteQuery)(_In_ D3D11_QUERY QueryType,_In_ UINT QueryIndex,_In_ UINT Flags,_In_ ID3D11Buffer* pBuffer,_In_ UINT OffsetInBytes,_In_ UINT StrideInBytes) = 0; + virtual void (ResetQuery)(_In_ D3D11_QUERY QueryType,_In_ UINT QueryIndex,_In_ UINT Flags) = 0; + virtual void (ConfigureQuery)(_In_ D3D11_QUERY QueryType,_In_ const void* pConfiguration,_In_ UINT ConfigurationSize) = 0; + virtual void (SetShaderUserData)(_In_ D3D11X_HW_STAGE ShaderStage,_In_ UINT StartSlot,_In_ UINT NumRegisters,_In_reads_(NumRegisters) const UINT* pData) = 0; + virtual void (SetPixelShaderDepthForceZOrder)(_In_ BOOL ForceOrder) = 0; + virtual void (SetPredicationFromQuery)(_In_ D3D11_QUERY QueryType,_In_ ID3D11Buffer* pBuffer,_In_ UINT OffsetInBytes,_In_ UINT Flags) = 0; + virtual void (SetBorderColorPalette)(_In_ ID3D11Buffer* pBuffer,_In_ UINT OffsetInBytes,_In_ UINT Flags) = 0; + virtual void (WriteValueEndOfPipe64)(_In_ void* pDestination,_In_ UINT64 Value,_In_ UINT Flags) = 0; + virtual void (InsertWaitOnMemory64)(_In_ const void* pAddress,_In_ UINT Flags,_In_ D3D11_COMPARISON_FUNC ComparisonFunction,_In_ UINT64 ReferenceValue) = 0; + virtual void (LoadConstantRamImmediate)(_In_ UINT Flags,_In_ const void* pBuffer,_In_ UINT CeRamOffsetInBytes,_In_ UINT SizeInBytes) = 0; + virtual void (SetScreenExtentsQuery)(_In_ UINT Value) = 0; + virtual void (CollectScreenExtents)(_In_ UINT Flags,_In_ UINT AddressCount,_In_reads_(AddressCount) const UINT64* pDestinationAddresses,_In_ USHORT ZMin,_In_ USHORT ZMax) = 0; + virtual void (FillResourceWithValue)(_In_ ID3D11Resource* pDstResource,_In_ UINT FillValue) = 0; + virtual void (SetDrawBalancing)(_In_ UINT BalancingMode,_In_ UINT Flags) = 0; + }; + + D3DINTERFACE(ID3D11UserDefinedAnnotationX, b2daad8b, 03d4, 4dbf, 95, eb, 32, ab, 4b, 63, d0, ab) { + + }; +} + +namespace wd +{ + struct D3D11XShaderUserDataManagerDraw + { + // Dirty flags are used for state that is handled by D3D in a deferred fashion at + // Draw/Dispatch time. Flags use the D3D11X_DIRTYFLAGS enumerant. + UINT32 m_DirtyFlags; + + // Reserved. + UINT32 m_Reserved1; + + // Hardware encoded primitive topology: + UINT64 m_Topology; + + // Pointer to the currently set input layout (if any): + ID3D11InputLayout* m_pInputLayout; + + // Pointer to the currently set vertex shader (if any): + ID3D11VertexShader* m_pVs; + + // Pointer to the currently set pixel shader (if any): + ID3D11PixelShader* m_pPs; + + // Reserved space: + UINT32 m_Reserved2[ 128 ]; + }; + + struct D3D11XTinyDevice + { + // Number of dwords by which pCeBiasedLimit is biased downward from the true limit: + static const UINT32 BiasDwordCount = 70; + + // Minimum number of dwords that is available after calling MakeCeSpace: + static const UINT32 MakeCeSpaceDwordCount = 1024; + + // Reserved space: + UINT32 m_Reserved1[ 8 ]; + + // Points to the current location in the resource batch being recorded: + UINT32* m_pBatchCurrent; + + // Points to the end of the writable batch buffer: + UINT32* m_pBatchLimit; + + // Points to the location in the indirect buffer or command list currently being constructed + // where the next GPU Constant Engine command will be added: + UINT32* m_pCeCurrent; + + // Points to the end of the current Constant Engine segment biased down by BiasDwordCount dwords. + // If pCeRing <= pCeBiasedLimit then it's guaranteed that there are at least 64 dwords + // of room left in the ring buffer. If pCeRing > pCeBiasedLimit then MakeCeSpace() must be + // called before any more data can be added: + UINT32* m_pCeBiasedLimit; + + // Points to the end of the current Constant Engine segment with no bias: + UINT32* m_pCeLimit; + + // Reserved space: + UINT32 m_Reserved2[ 64 ]; + }; + + class device_context_x : public wdi::ID3D11DeviceContextX + { + public: + device_context_x(::ID3D11DeviceContext2* wrapped_interface) : wrapped_interface(wrapped_interface) + { + populate_function_tables( ); + wrapped_interface->AddRef( ); + } + + private: + // even though these don't conform to our naming convention, we keep them b/c their origin + D3D11XTinyDevice m_TinyDevice; + D3D11XShaderUserDataManagerDraw m_ShaderUserDataManagerDraw; + + union + { + uint8_t m_OutOfLineFlags; + uint32_t m_Reserved[ 16 ]; + } DUMMYUNIONNAME; + + std::array function_table; + + void populate_function_tables( ) + { + auto v_ptr = *reinterpret_cast(this); + + for (size_t i = 0; i < function_table.size( ); i++) + function_table[ i ] = v_ptr[ i ]; + } + + IGU_DEFINE_REF + + HRESULT QueryInterface(const IID& riid, void** ppvObject) override + { + if (riid == __uuidof(wdi::ID3D11DeviceContext) || riid == __uuidof(wdi::ID3D11DeviceContext1) || + riid == __uuidof(wdi::ID3D11DeviceContext2) || riid == __uuidof(wdi::ID3D11DeviceContextX) || + riid == __uuidof(wdi::ID3D11UserDefinedAnnotationX)) + { + *ppvObject = this; + AddRef( ); + return S_OK; + } + + if (riid == __uuidof(wdi::IGraphicsUnwrap)) + { + *ppvObject = wrapped_interface; + return S_OK; + } + + TRACE_INTERFACE_NOT_HANDLED("device_context_x"); + *ppvObject = nullptr; + return E_NOINTERFACE; + } + + void GetDevice(ID3D11Device** ppDevice) override; + HRESULT GetPrivateData(const GUID& guid, UINT* pDataSize, void* pData) override; + HRESULT SetPrivateData(const GUID& guid, UINT DataSize, const void* pData) override; + HRESULT SetPrivateDataInterface(const GUID& guid, const IUnknown* pData) override; + HRESULT SetPrivateDataInterfaceGraphics(const GUID& guid, const IGraphicsUnknown* pData) override; + HRESULT SetName(LPCWSTR pName) override; + + public: + void ProcessDirtyFlags() + { + // 0x46 = topology dirty flag + if (m_ShaderUserDataManagerDraw.m_DirtyFlags & 0x46) + { + m_ShaderUserDataManagerDraw.m_DirtyFlags &= ~0x46; + int topology = D3D11X_HARDWARE_TO_TOPOLOGY_MAP.at(m_ShaderUserDataManagerDraw.m_Topology); + if (topology == 6 || topology == 17 || topology == 18 || topology == 19 || topology == 20) + printf("WARN: device_context_x::ProcessDirtyFlags: unsupported topology %d\n", topology); + + wrapped_interface->IASetPrimitiveTopology(static_cast(topology)); + } + + // 0x89 = input layout dirty flag + if (m_ShaderUserDataManagerDraw.m_DirtyFlags & 0x89) + { + m_ShaderUserDataManagerDraw.m_DirtyFlags &= ~0x89; + wrapped_interface->IASetInputLayout(m_ShaderUserDataManagerDraw.m_pInputLayout); + } + + // 0x91 = vertex shader dirty flag + if (m_ShaderUserDataManagerDraw.m_DirtyFlags & 0x91) + { + m_ShaderUserDataManagerDraw.m_DirtyFlags &= ~0x91; + wrapped_interface->VSSetShader(m_ShaderUserDataManagerDraw.m_pVs, nullptr, 0); + } + + // 0x121 = pixel shader dirty flag + if (m_ShaderUserDataManagerDraw.m_DirtyFlags & 0x121) + { + m_ShaderUserDataManagerDraw.m_DirtyFlags &= ~0x121; + wrapped_interface->PSSetShader(m_ShaderUserDataManagerDraw.m_pPs, nullptr, 0); + } + } + + void VSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppConstantBuffers) override; + void Draw(UINT VertexCount, UINT StartVertexLocation) override; + HRESULT Map(ID3D11Resource* pResource, UINT Subresource, D3D11_MAP MapType, UINT MapFlags, + D3D11_MAPPED_SUBRESOURCE* pMappedResource) override; + void Unmap(ID3D11Resource* pResource, UINT Subresource) override; + void PSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppConstantBuffers) override; + void IASetInputLayout(ID3D11InputLayout* pInputLayout) override; + void IASetVertexBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppVertexBuffers, + const UINT* pStrides, const UINT* pOffsets) override; + void VSSetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState* const* ppSamplers) override; + void Begin(ID3D11Asynchronous* pAsync) override; + void End(ID3D11Asynchronous* pAsync) override; + HRESULT GetData(ID3D11Asynchronous* pAsync, void* pData, UINT DataSize, UINT GetDataFlags) override; + void SetPredication(ID3D11Predicate* pPredicate, BOOL PredicateValue) override; + void GSSetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState* const* ppSamplers) override; + void OMSetRenderTargets(UINT NumViews, ID3D11RenderTargetView* const* ppRenderTargetViews, + ID3D11DepthStencilView* pDepthStencilView) override; + void OMSetRenderTargetsAndUnorderedAccessViews(UINT NumRTVs, ID3D11RenderTargetView* const* ppRenderTargetViews, + ID3D11DepthStencilView* pDepthStencilView, UINT UAVStartSlot, UINT NumUAVs, + ID3D11UnorderedAccessView* const* ppUnorderedAccessViews, const UINT* pUAVInitialCounts) override; + void OMSetBlendState(ID3D11BlendState* pBlendState, const FLOAT BlendFactor[4], UINT SampleMask) override; + void OMSetDepthStencilState(ID3D11DepthStencilState* pDepthStencilState, UINT StencilRef) override; + void SOSetTargets(UINT NumBuffers, ID3D11Buffer* const* ppSOTargets, const UINT* pOffsets) override; + void DrawIndexedInstancedIndirect(ID3D11Buffer* pBufferForArgs, UINT AlignedByteOffsetForArgs) override; + void DrawInstancedIndirect(ID3D11Buffer* pBufferForArgs, UINT AlignedByteOffsetForArgs) override; + void Dispatch(UINT ThreadGroupCountX, UINT ThreadGroupCountY, UINT ThreadGroupCountZ) override; + void DispatchIndirect(ID3D11Buffer* pBufferForArgs, UINT AlignedByteOffsetForArgs) override; + void RSSetState(ID3D11RasterizerState* pRasterizerState) override; + void RSSetViewports(UINT NumViewports, const D3D11_VIEWPORT* pViewports) override; + void RSSetScissorRects(UINT NumRects, const D3D11_RECT* pRects) override; + void CopySubresourceRegion(ID3D11Resource* pDstResource, UINT DstSubresource, UINT DstX, UINT DstY, UINT DstZ, + ID3D11Resource* pSrcResource, UINT SrcSubresource, const D3D11_BOX* pSrcBox) override; + void CopyResource(ID3D11Resource* pDstResource, ID3D11Resource* pSrcResource) override; + void UpdateSubresource(ID3D11Resource* pDstResource, UINT DstSubresource, const D3D11_BOX* pDstBox, + const void* pSrcData, UINT SrcRowPitch, UINT SrcDepthPitch) override; + void CopyStructureCount(ID3D11Buffer* pDstBuffer, UINT DstAlignedByteOffset, + ID3D11UnorderedAccessView* pSrcView) override; + void ClearRenderTargetView(ID3D11RenderTargetView* pRenderTargetView, const FLOAT ColorRGBA[4]) override; + void ClearUnorderedAccessViewUint(ID3D11UnorderedAccessView* pUnorderedAccessView, + const UINT Values[4]) override; + void ClearUnorderedAccessViewFloat(ID3D11UnorderedAccessView* pUnorderedAccessView, + const FLOAT Values[4]) override; + void ClearDepthStencilView(ID3D11DepthStencilView* pDepthStencilView, UINT ClearFlags, FLOAT Depth, + UINT8 Stencil) override; + void GenerateMips(ID3D11ShaderResourceView* pShaderResourceView) override; + void SetResourceMinLOD(ID3D11Resource* pResource, FLOAT MinLOD) override; + FLOAT GetResourceMinLOD(ID3D11Resource* pResource) override; + void ResolveSubresource(ID3D11Resource* pDstResource, UINT DstSubresource, ID3D11Resource* pSrcResource, + UINT SrcSubresource, DXGI_FORMAT Format) override; + void ExecuteCommandList(ID3D11CommandList* pCommandList, BOOL RestoreContextState) override; + void HSSetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState* const* ppSamplers) override; + void HSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppConstantBuffers) override; + void DSSetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState* const* ppSamplers) override; + void DSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppConstantBuffers) override; + void CSSetUnorderedAccessViews(UINT StartSlot, UINT NumUAVs, + ID3D11UnorderedAccessView* const* ppUnorderedAccessViews, const UINT* pUAVInitialCounts) override; + void CSSetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState* const* ppSamplers) override; + void CSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppConstantBuffers) override; + void VSGetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers) override; + void PSGetShaderResources(UINT StartSlot, UINT NumViews, + ID3D11ShaderResourceView** ppShaderResourceViews) override; + void PSGetShader(ID3D11PixelShader** ppPixelShader, ID3D11ClassInstance** ppClassInstances, + UINT* pNumClassInstances) override; + void PSGetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers) override; + void VSGetShader(ID3D11VertexShader** ppVertexShader, ID3D11ClassInstance** ppClassInstances, + UINT* pNumClassInstances) override; + void PSGetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers) override; + void IAGetInputLayout(ID3D11InputLayout** ppInputLayout) override; + void IAGetVertexBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppVertexBuffers, UINT* pStrides, + UINT* pOffsets) override; + void IAGetIndexBuffer(ID3D11Buffer** pIndexBuffer, DXGI_FORMAT* Format, UINT* Offset) override; + void GSGetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers) override; + void GSGetShader(ID3D11GeometryShader** ppGeometryShader, ID3D11ClassInstance** ppClassInstances, + UINT* pNumClassInstances) override; + void IAGetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY* pTopology) override; + void VSGetShaderResources(UINT StartSlot, UINT NumViews, + ID3D11ShaderResourceView** ppShaderResourceViews) override; + void VSGetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers) override; + void GetPredication(ID3D11Predicate** ppPredicate, BOOL* pPredicateValue) override; + void GSGetShaderResources(UINT StartSlot, UINT NumViews, + ID3D11ShaderResourceView** ppShaderResourceViews) override; + void GSGetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers) override; + void OMGetRenderTargets(UINT NumViews, ID3D11RenderTargetView** ppRenderTargetViews, + ID3D11DepthStencilView** ppDepthStencilView) override; + void OMGetRenderTargetsAndUnorderedAccessViews(UINT NumRTVs, ID3D11RenderTargetView** ppRenderTargetViews, + ID3D11DepthStencilView** ppDepthStencilView, UINT UAVStartSlot, UINT NumUAVs, + ID3D11UnorderedAccessView** ppUnorderedAccessViews) override; + void OMGetBlendState(ID3D11BlendState** ppBlendState, FLOAT BlendFactor[4], UINT* pSampleMask) override; + void OMGetDepthStencilState(ID3D11DepthStencilState** ppDepthStencilState, UINT* pStencilRef) override; + void SOGetTargets(UINT NumBuffers, ID3D11Buffer** ppSOTargets) override; + void RSGetState(ID3D11RasterizerState** ppRasterizerState) override; + void RSGetViewports(UINT* pNumViewports, D3D11_VIEWPORT* pViewports) override; + void RSGetScissorRects(UINT* pNumRects, D3D11_RECT* pRects) override; + void HSGetShaderResources(UINT StartSlot, UINT NumViews, + ID3D11ShaderResourceView** ppShaderResourceViews) override; + void HSGetShader(ID3D11HullShader** ppHullShader, ID3D11ClassInstance** ppClassInstances, + UINT* pNumClassInstances) override; + void HSGetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers) override; + void HSGetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers) override; + void DSGetShaderResources(UINT StartSlot, UINT NumViews, + ID3D11ShaderResourceView** ppShaderResourceViews) override; + void DSGetShader(ID3D11DomainShader** ppDomainShader, ID3D11ClassInstance** ppClassInstances, + UINT* pNumClassInstances) override; + void DSGetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers) override; + void DSGetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers) override; + void CSGetShaderResources(UINT StartSlot, UINT NumViews, + ID3D11ShaderResourceView** ppShaderResourceViews) override; + void CSGetUnorderedAccessViews(UINT StartSlot, UINT NumUAVs, + ID3D11UnorderedAccessView** ppUnorderedAccessViews) override; + void CSGetShader(ID3D11ComputeShader** ppComputeShader, ID3D11ClassInstance** ppClassInstances, + UINT* pNumClassInstances) override; + void CSGetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState** ppSamplers) override; + void CSGetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers) override; + void ClearState() override; + void Flush() override; + D3D11_DEVICE_CONTEXT_TYPE GetType() override; + UINT GetContextFlags() override; + HRESULT FinishCommandList(BOOL RestoreDeferredContextState, ID3D11CommandList** ppCommandList) override; + void CopySubresourceRegion1(ID3D11Resource* pDstResource, UINT DstSubresource, UINT DstX, UINT DstY, UINT DstZ, + ID3D11Resource* pSrcResource, UINT SrcSubresource, const D3D11_BOX* pSrcBox, UINT CopyFlags) override; + void UpdateSubresource1(ID3D11Resource* pDstResource, UINT DstSubresource, const D3D11_BOX* pDstBox, + const void* pSrcData, UINT SrcRowPitch, UINT SrcDepthPitch, UINT CopyFlags) override; + void DiscardResource(ID3D11Resource* pResource) override; + void DiscardView(ID3D11View* pResourceView) override; + void VSSetConstantBuffers1(UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppConstantBuffers, + const UINT* pFirstConstant, const UINT* pNumConstants) override; + void HSSetConstantBuffers1(UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppConstantBuffers, + const UINT* pFirstConstant, const UINT* pNumConstants) override; + void DSSetConstantBuffers1(UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppConstantBuffers, + const UINT* pFirstConstant, const UINT* pNumConstants) override; + void GSSetConstantBuffers1(UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppConstantBuffers, + const UINT* pFirstConstant, const UINT* pNumConstants) override; + void PSSetConstantBuffers1(UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppConstantBuffers, + const UINT* pFirstConstant, const UINT* pNumConstants) override; + void CSSetConstantBuffers1(UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppConstantBuffers, + const UINT* pFirstConstant, const UINT* pNumConstants) override; + void VSGetConstantBuffers1(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers, + UINT* pFirstConstant, UINT* pNumConstants) override; + void HSGetConstantBuffers1(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers, + UINT* pFirstConstant, UINT* pNumConstants) override; + void DSGetConstantBuffers1(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers, + UINT* pFirstConstant, UINT* pNumConstants) override; + void GSGetConstantBuffers1(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers, + UINT* pFirstConstant, UINT* pNumConstants) override; + void PSGetConstantBuffers1(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers, + UINT* pFirstConstant, UINT* pNumConstants) override; + void CSGetConstantBuffers1(UINT StartSlot, UINT NumBuffers, ID3D11Buffer** ppConstantBuffers, + UINT* pFirstConstant, UINT* pNumConstants) override; + void SwapDeviceContextState(ID3DDeviceContextState* pState, ID3DDeviceContextState** ppPreviousState) override; + void ClearView(ID3D11View* pView, const FLOAT Color[4], const D3D11_RECT* pRect, UINT NumRects) override; + void DiscardView1(ID3D11View* pResourceView, const D3D11_RECT* pRects, UINT NumRects) override; + HRESULT UpdateTileMappings(ID3D11Resource* pTiledResource, UINT NumTiledResourceRegions, + const D3D11_TILED_RESOURCE_COORDINATE* pTiledResourceRegionStartCoordinates, + const D3D11_TILE_REGION_SIZE* pTiledResourceRegionSizes, ID3D11Buffer* pTilePool, UINT NumRanges, + const UINT* pRangeFlags, const UINT* pTilePoolStartOffsets, const UINT* pRangeTileCounts, + UINT Flags) override; + HRESULT CopyTileMappings(ID3D11Resource* pDestTiledResource, + const D3D11_TILED_RESOURCE_COORDINATE* pDestRegionStartCoordinate, ID3D11Resource* pSourceTiledResource, + const D3D11_TILED_RESOURCE_COORDINATE* pSourceRegionStartCoordinate, + const D3D11_TILE_REGION_SIZE* pTileRegionSize, UINT Flags) override; + void CopyTiles(ID3D11Resource* pTiledResource, + const D3D11_TILED_RESOURCE_COORDINATE* pTileRegionStartCoordinate, + const D3D11_TILE_REGION_SIZE* pTileRegionSize, ID3D11Buffer* pBuffer, UINT64 BufferStartOffsetInBytes, + UINT Flags) override; + void UpdateTiles(ID3D11Resource* pDestTiledResource, + const D3D11_TILED_RESOURCE_COORDINATE* pDestTileRegionStartCoordinate, + const D3D11_TILE_REGION_SIZE* pDestTileRegionSize, const void* pSourceTileData, UINT Flags) override; + HRESULT ResizeTilePool(ID3D11Buffer* pTilePool, UINT64 NewSizeInBytes) override; + void TiledResourceBarrier(ID3D11DeviceChild* pTiledResourceOrViewAccessBeforeBarrier, + ID3D11DeviceChild* pTiledResourceOrViewAccessAfterBarrier) override; + INT PIXBeginEvent(LPCWSTR Name) override; + INT PIXBeginEventEx(const void* pData, UINT DataSize) override; + INT PIXEndEvent() override; + void PIXSetMarker(LPCWSTR Name) override; + void PIXSetMarkerEx(const void* pData, UINT DataSize) override; + BOOL PIXGetStatus() override; + HRESULT PIXGpuCaptureNextFrame(UINT Flags, LPCWSTR lpOutputFileName) override; + HRESULT PIXGpuBeginCapture(UINT Flags, LPCWSTR lpOutputFileName) override; + HRESULT PIXGpuEndCapture() override; + void StartCounters(wdi::ID3D11CounterSetX* pCounterSet) override; + void SampleCounters(wdi::ID3D11CounterSampleX* pCounterSample) override; + void StopCounters() override; + HRESULT GetCounterData(wdi::ID3D11CounterSampleX* pCounterSample, wdi::D3D11X_COUNTER_DATA* pData, + UINT GetCounterDataFlags) override; + void FlushGpuCaches(ID3D11Resource* pResource) override; + void FlushGpuCacheRange(UINT Flags, void* pBaseAddress, SIZE_T SizeInBytes) override; + void InsertWaitUntilIdle(UINT Flags) override; + UINT64 InsertFence(UINT Flags) override; + void InsertWaitOnFence(UINT Flags, UINT64 Fence) override; + void RemapConstantBufferInheritance(wdi::D3D11_STAGE Stage, UINT Slot, wdi::D3D11_STAGE InheritStage, + UINT InheritSlot) override; + void RemapShaderResourceInheritance(wdi::D3D11_STAGE Stage, UINT Slot, wdi::D3D11_STAGE InheritStage, + UINT InheritSlot) override; + void RemapSamplerInheritance(wdi::D3D11_STAGE Stage, UINT Slot, wdi::D3D11_STAGE InheritStage, + UINT InheritSlot) override; + void RemapVertexBufferInheritance(UINT Slot, UINT InheritSlot) override; + void PSSetFastConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer) override; + void PSSetFastShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView) override; + void PSSetFastSampler(UINT Slot, ID3D11SamplerState* pSampler) override; + void VSSetFastConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer) override; + void VSSetFastShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView) override; + void VSSetFastSampler(UINT Slot, ID3D11SamplerState* pSampler) override; + void GSSetFastConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer) override; + void GSSetFastShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView) override; + void GSSetFastSampler(UINT Slot, ID3D11SamplerState* pSampler) override; + void CSSetFastConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer) override; + void CSSetFastShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView) override; + void CSSetFastSampler(UINT Slot, ID3D11SamplerState* pSampler) override; + void HSSetFastConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer) override; + void HSSetFastShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView) override; + void HSSetFastSampler(UINT Slot, ID3D11SamplerState* pSampler) override; + void DSSetFastConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer) override; + void DSSetFastShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView) override; + void DSSetFastSampler(UINT Slot, ID3D11SamplerState* pSampler) override; + void IASetFastVertexBuffer(UINT Slot, ID3D11Buffer* pVertexBuffer, UINT Stride) override; + void IASetFastIndexBuffer(UINT HardwareIndexFormat, ID3D11Buffer* pIndexBuffer) override; + void PSSetPlacementConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer, void* pBaseAddress) override; + void PSSetPlacementShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView, + void* pBaseAddress) override; + void VSSetPlacementConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer, void* pBaseAddress) override; + void VSSetPlacementShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView, + void* pBaseAddress) override; + void GSSetPlacementConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer, void* pBaseAddress) override; + void GSSetPlacementShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView, + void* pBaseAddress) override; + void CSSetPlacementConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer, void* pBaseAddress) override; + void CSSetPlacementShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView, + void* pBaseAddress) override; + void HSSetPlacementConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer, void* pBaseAddress) override; + void HSSetPlacementShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView, + void* pBaseAddress) override; + void DSSetPlacementConstantBuffer(UINT Slot, ID3D11Buffer* pConstantBuffer, void* pBaseAddress) override; + void DSSetPlacementShaderResource(UINT Slot, ID3D11ShaderResourceView* pShaderResourceView, + void* pBaseAddress) override; + void IASetPlacementVertexBuffer(UINT Slot, ID3D11Buffer* pVertexBuffer, void* pBaseAddress, + UINT Stride) override; + void IASetPlacementIndexBuffer(UINT HardwareIndexFormat, ID3D11Buffer* pIndexBuffer, + void* pBaseAddress) override; + void HSSetTessellationParameters(const wdi::D3D11X_TESSELLATION_PARAMETERS* pTessellationParameters) override; + void HSGetLastUsedTessellationParameters(wdi::D3D11X_TESSELLATION_PARAMETERS* pTessellationParameters) override; + void CSEnableAutomaticGpuFlush(BOOL Enable) override; + void GpuSendPipelinedEvent(wdi::D3D11X_GPU_PIPELINED_EVENT Event) override; + HRESULT Suspend(UINT Flags) override; + HRESULT Resume() override; + void BeginCommandListExecution(UINT Flags) override; + void EndCommandListExecution() override; + void SetGraphicsShaderLimits(const wdi::D3D11X_GRAPHICS_SHADER_LIMITS* pShaderLimits) override; + void SetComputeShaderLimits(const wdi::D3D11X_COMPUTE_SHADER_LIMITS* pShaderLimits) override; + void SetPredicationBuffer(ID3D11Buffer* pBuffer, UINT Offset, UINT Flags) override; + void OMSetDepthBounds(FLOAT min, FLOAT max) override; + void OMSetDepthStencilStateX(ID3D11DepthStencilState* pDepthStencilState) override; + void OMSetSampleMask(UINT64 QuadSampleMask) override; + UINT32* MakeCeSpace() override; + void SetFastResources_Debug(UINT* pTableStart, UINT* pTableEnd) override; + void BeginResourceBatch(void* pBuffer, UINT BufferSize) override; + UINT EndResourceBatch(UINT* pSizeNeeded) override; + void SetFastResourcesFromBatch_Debug(void* pBatch, UINT Size) override; + void CSPlaceUnorderedAccessView(UINT Slot, wdi::D3D11X_DESCRIPTOR_UNORDERED_ACCESS_VIEW* const pDescriptor, + UINT64 Offset) override; + void WriteValueEndOfPipe(void* pDestination, UINT Value, UINT Flags) override; + void CopyMemoryToMemory(void* pDstAddress, void* pSrcAddress, SIZE_T SizeBytes) override; + void FillMemoryWithValue(void* pDstAddress, SIZE_T SizeBytes, UINT FillValue) override; + void BeginProcessVideoResource(ID3D11Resource* pResource, UINT SubResource) override; + void EndProcessVideoResource(ID3D11Resource* pResource, UINT SubResource) override; + HRESULT StartThreadTrace(const wdi::D3D11X_THREAD_TRACE_DESC* pDesc, void* pDstAddressShaderEngine0, + void* pDstAddressShaderEngine1, SIZE_T BufferSizeBytes) override; + void StopThreadTrace(void* pDstAddressTraceSize) override; + void InsertThreadTraceMarker(UINT Marker) override; + void IASetPrimitiveResetIndex(UINT ResetIndex) override; + void SetShaderResourceViewMinLOD(ID3D11ShaderResourceView* pShaderResourceView, FLOAT MinLOD) override; + void InsertWaitOnPresent(UINT Flags, ID3D11Resource* pBackBuffer) override; + void ClearRenderTargetViewX(ID3D11RenderTargetView* pRenderTargetView, UINT Flags, + const FLOAT ColorRGBA[4]) override; + UINT GetResourceCompression(ID3D11Resource* pResource) override; + UINT GetResourceCompressionX(const wdi::D3D11X_DESCRIPTOR_RESOURCE* pResource) override; + void DecompressResource(ID3D11Resource* pDstResource, UINT DstSubresource, const wdi::D3D11X_POINT* pDstPoint, + ID3D11Resource* pSrcResource, UINT SrcSubresource, const wdi::D3D11X_RECT* pSrcRect, + DXGI_FORMAT DecompressFormat, UINT DecompressFlags) override; + void DecompressResourceX(wdi::D3D11X_DESCRIPTOR_RESOURCE* pDstResource, UINT DstSubresource, + const wdi::D3D11X_POINT* pDstPoint, wdi::D3D11X_DESCRIPTOR_RESOURCE* pSrcResource, UINT SrcSubresource, + const wdi::D3D11X_RECT* pSrcRect, wdi::D3D11X_FORMAT DecompressFormat, UINT DecompressFlags) override; + void GSSetParameters(const wdi::D3D11X_GS_PARAMETERS* pGsParameters) override; + void GSGetLastUsedParameters(wdi::D3D11X_GS_PARAMETERS* pGsParameters) override; + void MultiDrawIndexedInstancedIndirect(UINT PrimitiveCount, ID3D11Buffer* pBufferForArgs, + UINT AlignedByteOffsetForArgs, UINT StrideByteOffsetForArgs, UINT Flags) override; + void MultiDrawInstancedIndirect(UINT PrimitiveCount, ID3D11Buffer* pBufferForArgs, + UINT AlignedByteOffsetForArgs, UINT StrideByteOffsetForArgs, UINT Flags) override; + void MultiDrawIndexedInstancedIndirectAuto(ID3D11Buffer* pBufferForPrimitiveCount, + UINT AlignedByteOffsetForPrimitiveCount, ID3D11Buffer* pBufferForArgs, UINT AlignedByteOffsetForArgs, + UINT StrideByteOffsetForArgs, UINT Flags) override; + void MultiDrawInstancedIndirectAuto(ID3D11Buffer* pBufferForPrimitiveCount, + UINT AlignedByteOffsetForPrimitiveCount, ID3D11Buffer* pBufferForArgs, UINT AlignedByteOffsetForArgs, + UINT StrideByteOffsetForArgs, UINT Flags) override; + HRESULT RSGetMSAASettingsForQuality(wdi::D3D11X_MSAA_SCAN_CONVERTER_SETTINGS* pMSAASCSettings, + wdi::D3D11X_MSAA_EQAA_SETTINGS* pEQAASettings, wdi::D3D11X_MSAA_SAMPLE_PRIORITIES* pCentroidPriorities, + wdi::D3D11X_MSAA_SAMPLE_POSITIONS* pSamplePositions, UINT LogSampleCount, UINT SampleQuality) override; + void RSSetScanConverterMSAASettings(const wdi::D3D11X_MSAA_SCAN_CONVERTER_SETTINGS* pMSAASCSettings) override; + void RSSetEQAASettings(const wdi::D3D11X_MSAA_EQAA_SETTINGS* pEQAASettings) override; + void RSSetSamplePositions(const wdi::D3D11X_MSAA_SAMPLE_PRIORITIES* pSamplesPriorities, + const wdi::D3D11X_MSAA_SAMPLE_POSITIONS* pSamplePositions) override; + void SetResourceCompression(ID3D11Resource* pResource, UINT Compression) override; + void SetResourceCompressionX(const wdi::D3D11X_DESCRIPTOR_RESOURCE* pResource, UINT Compression) override; + void SetGDSRange(wdi::D3D11X_GDS_REGION_TYPE RegionType, UINT OffsetDwords, UINT NumDwords) override; + void WriteGDS(wdi::D3D11X_GDS_REGION_TYPE RegionType, UINT OffsetDwords, UINT NumDwords, + const UINT* pCounterValues, UINT Flags) override; + void ReadGDS(wdi::D3D11X_GDS_REGION_TYPE RegionType, UINT OffsetDwords, UINT NumDwords, UINT* pCounterValues, + UINT Flags) override; + void VSSetShaderUserData(UINT StartSlot, UINT NumRegisters, const UINT* pData) override; + void HSSetShaderUserData(UINT StartSlot, UINT NumRegisters, const UINT* pData) override; + void DSSetShaderUserData(UINT StartSlot, UINT NumRegisters, const UINT* pData) override; + void GSSetShaderUserData(UINT StartSlot, UINT NumRegisters, const UINT* pData) override; + void PSSetShaderUserData(UINT StartSlot, UINT NumRegisters, const UINT* pData) override; + void CSSetShaderUserData(UINT StartSlot, UINT NumRegisters, const UINT* pData) override; + void InsertWaitOnMemory(const void* pAddress, UINT Flags, D3D11_COMPARISON_FUNC ComparisonFunction, + UINT ReferenceValue, UINT Mask) override; + void WriteTimestampToMemory(void* pDstAddress) override; + void WriteTimestampToBuffer(ID3D11Buffer* pBuffer, UINT OffsetBytes) override; + void StoreConstantRam(UINT Flags, ID3D11Buffer* pBuffer, UINT BufferOffsetInBytes, UINT CeRamOffsetInBytes, + UINT SizeInBytes) override; + void LoadConstantRam(UINT Flags, ID3D11Buffer* pBuffer, UINT BufferOffsetInBytes, UINT CeRamOffsetInBytes, + UINT SizeInBytes) override; + void WriteQuery(D3D11_QUERY QueryType, UINT QueryIndex, UINT Flags, ID3D11Buffer* pBuffer, UINT OffsetInBytes, + UINT StrideInBytes) override; + void ResetQuery(D3D11_QUERY QueryType, UINT QueryIndex, UINT Flags) override; + void ConfigureQuery(D3D11_QUERY QueryType, const void* pConfiguration, UINT ConfigurationSize) override; + void SetShaderUserData(wdi::D3D11X_HW_STAGE ShaderStage, UINT StartSlot, UINT NumRegisters, + const UINT* pData) override; + void SetPixelShaderDepthForceZOrder(BOOL ForceOrder) override; + void SetPredicationFromQuery(D3D11_QUERY QueryType, ID3D11Buffer* pBuffer, UINT OffsetInBytes, + UINT Flags) override; + void SetBorderColorPalette(ID3D11Buffer* pBuffer, UINT OffsetInBytes, UINT Flags) override; + void WriteValueEndOfPipe64(void* pDestination, UINT64 Value, UINT Flags) override; + void InsertWaitOnMemory64(const void* pAddress, UINT Flags, D3D11_COMPARISON_FUNC ComparisonFunction, + UINT64 ReferenceValue) override; + void LoadConstantRamImmediate(UINT Flags, const void* pBuffer, UINT CeRamOffsetInBytes, + UINT SizeInBytes) override; + void SetScreenExtentsQuery(UINT Value) override; + void CollectScreenExtents(UINT Flags, UINT AddressCount, const UINT64* pDestinationAddresses, USHORT ZMin, + USHORT ZMax) override; + void FillResourceWithValue(ID3D11Resource* pDstResource, UINT FillValue) override; + void SetDrawBalancing(UINT BalancingMode, UINT Flags) override; + void PSSetShaderResources(ID3D11ShaderResourceView* const* ppShaderResourceViews, UINT StartSlot, + UINT PacketHeader) override; + void PSSetShader(ID3D11PixelShader* pPixelShader) override; + void PSSetSamplers(UINT StartSlot, UINT NumSamplers, ID3D11SamplerState* const* ppSamplers) override; + void VSSetShader(ID3D11VertexShader* pVertexShader) override; + void DrawIndexed(UINT64 StartIndexLocationAndIndexCount, INT BaseVertexLocation) override; + void IASetIndexBuffer(UINT HardwareIndexFormat, ID3D11Buffer* pIndexBuffer, UINT Offset) override; + void DrawIndexedInstanced(UINT64 StartIndexLocationAndIndexCountPerInstance, + UINT64 BaseVertexLocationAndStartInstanceLocation, UINT InstanceCount) override; + void DrawInstanced(UINT VertexCountPerInstance, UINT64 StartVertexLocationAndStartInstanceLocation, + UINT InstanceCount) override; + void GSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppConstantBuffers) override; + void GSSetShader(ID3D11GeometryShader* pShader) override; + void VSSetShaderResources(ID3D11ShaderResourceView* const* ppShaderResourceViews, UINT StartSlot, + UINT PacketHeader) override; + void GSSetShaderResources(ID3D11ShaderResourceView* const* ppShaderResourceViews, UINT StartSlot, + UINT PacketHeader) override; + void DrawAuto() override; + void HSSetShaderResources(ID3D11ShaderResourceView* const* ppShaderResourceViews, UINT StartSlot, + UINT PacketHeader) override; + void HSSetShader(ID3D11HullShader* pHullShader) override; + void DSSetShaderResources(ID3D11ShaderResourceView* const* ppShaderResourceViews, UINT StartSlot, + UINT PacketHeader) override; + void DSSetShader(ID3D11DomainShader* pDomainShader) override; + void CSSetShaderResources(ID3D11ShaderResourceView* const* ppShaderResourceViews, UINT StartSlot, + UINT PacketHeader) override; + void CSSetShader(ID3D11ComputeShader* pComputeShader) override; + + private: + ::ID3D11DeviceContext2* wrapped_interface; + }; +} + + diff --git a/dlls/d3d11_x/device_x.cpp b/dlls/d3d11_x/device_x.cpp new file mode 100644 index 0000000..460c06d --- /dev/null +++ b/dlls/d3d11_x/device_x.cpp @@ -0,0 +1,345 @@ +#include "device_x.h" +#include +#include "resource.hpp" +#include "view.hpp" + +HRESULT wd::device_x::CreateBuffer(const D3D11_BUFFER_DESC* pDesc, const D3D11_SUBRESOURCE_DATA* pInitialData, + ID3D11Buffer** ppBuffer) +{ + ID3D11Buffer* buffer = nullptr; + HRESULT hr = wrapped_interface->CreateBuffer(pDesc, pInitialData, &buffer); + + if (ppBuffer != nullptr) + { + *ppBuffer = SUCCEEDED(hr) ? reinterpret_cast(new wd::buffer(buffer)) : nullptr; + } + + return hr; +} + +HRESULT wd::device_x::CreateTexture1D(const D3D11_TEXTURE1D_DESC* pDesc, const D3D11_SUBRESOURCE_DATA* pInitialData, + ID3D11Texture1D** ppTexture1D) +{ + ID3D11Texture1D* texture1d = nullptr; + HRESULT hr = wrapped_interface->CreateTexture1D(pDesc, pInitialData, &texture1d); + + printf("[CreateTexture1D] created texture at 0x%llX\n", texture1d); + + if (ppTexture1D != nullptr) + { + *ppTexture1D = SUCCEEDED(hr) ? reinterpret_cast(new texture_1d(texture1d)) : nullptr; + } + + return hr; +} + +HRESULT wd::device_x::CreateTexture2D(const D3D11_TEXTURE2D_DESC* pDesc, const D3D11_SUBRESOURCE_DATA* pInitialData, + ID3D11Texture2D** ppTexture2D) +{ + ID3D11Texture2D* texture2d = nullptr; + HRESULT hr = wrapped_interface->CreateTexture2D(pDesc, pInitialData, &texture2d); + + printf("[CreateTexture2D] created texture at 0x%llX\n", texture2d); + + if (ppTexture2D != nullptr) + { + *ppTexture2D = SUCCEEDED(hr) ? reinterpret_cast(new texture_2d(texture2d)) : nullptr; + } + + return hr; +} + +HRESULT wd::device_x::CreateTexture3D(const D3D11_TEXTURE3D_DESC* pDesc, const D3D11_SUBRESOURCE_DATA* pInitialData, + ID3D11Texture3D** ppTexture3D) +{ + ID3D11Texture3D* texture3d = nullptr; + HRESULT hr = wrapped_interface->CreateTexture3D(pDesc, pInitialData, &texture3d); + + printf("[CreateTexture3D] created texture at 0x%llX\n", texture3d); + + if (ppTexture3D != nullptr) + { + *ppTexture3D = SUCCEEDED(hr) ? reinterpret_cast(new texture_3d(texture3d)) : nullptr; + } + + return hr; +} + +HRESULT wd::device_x::CreateShaderResourceView(ID3D11Resource* pResource, const D3D11_SHADER_RESOURCE_VIEW_DESC* pDesc, + ID3D11ShaderResourceView** ppSRView) +{ + ::ID3D11ShaderResourceView* target = nullptr; + HRESULT hr = wrapped_interface->CreateShaderResourceView(reinterpret_cast(pResource)->wrapped_interface, pDesc, &target); + + if (ppSRView != nullptr) + { + *ppSRView = SUCCEEDED(hr) ? reinterpret_cast(new shader_resource_view(target)) + : nullptr; + } + + return hr; +} + +HRESULT wd::device_x::CreateUnorderedAccessView(ID3D11Resource* pResource, + const D3D11_UNORDERED_ACCESS_VIEW_DESC* pDesc, ID3D11UnorderedAccessView** ppUAView) +{ + ::ID3D11UnorderedAccessView* target = nullptr; + HRESULT hr = wrapped_interface->CreateUnorderedAccessView(reinterpret_cast(pResource)->wrapped_interface, pDesc, &target); + + if (ppUAView != nullptr) + { + *ppUAView = SUCCEEDED(hr) ? reinterpret_cast(new unordered_access_view(target)) + : nullptr; + } + + return hr; +} + +HRESULT wd::device_x::CreateRenderTargetView(ID3D11Resource* pResource, const D3D11_RENDER_TARGET_VIEW_DESC* pDesc, + ID3D11RenderTargetView** ppRTView) +{ + ::ID3D11RenderTargetView* target = nullptr; + HRESULT hr = wrapped_interface->CreateRenderTargetView(reinterpret_cast(pResource)->wrapped_interface, pDesc, &target); + + if (ppRTView != nullptr) + { + *ppRTView = SUCCEEDED(hr) ? reinterpret_cast(new wd::render_target_view(target)) + : nullptr; + } + + return hr; +} + +HRESULT wd::device_x::CreateDepthStencilView(ID3D11Resource* pResource, const D3D11_DEPTH_STENCIL_VIEW_DESC* pDesc, + ID3D11DepthStencilView** ppDepthStencilView) +{ + ::ID3D11DepthStencilView* target = nullptr; + HRESULT hr = wrapped_interface->CreateDepthStencilView(reinterpret_cast(pResource)->wrapped_interface, pDesc, &target); + + if (ppDepthStencilView != nullptr) + { + *ppDepthStencilView = SUCCEEDED(hr) ? reinterpret_cast(new depth_stencil_view(target)) + : nullptr; + } + + return hr; +} + +HRESULT wd::device_x::CreateDeferredContext(UINT ContextFlags, ID3D11DeviceContext** ppDeferredContext) +{ + ::ID3D11DeviceContext* ctx{}; + HRESULT hr = wrapped_interface->CreateDeferredContext(ContextFlags, &ctx); + + if (ppDeferredContext != nullptr && SUCCEEDED(hr)) + { + ::ID3D11DeviceContext2* ctx2{}; + ctx->QueryInterface(IID_PPV_ARGS(&ctx2)); + + *ppDeferredContext = reinterpret_cast(new device_context_x(ctx2)); + } + + return hr; +} + +void wd::device_x::GetImmediateContext(ID3D11DeviceContext** ppImmediateContext) +{ + ::ID3D11DeviceContext* ctx{}; + wrapped_interface->GetImmediateContext(&ctx); + + if (!ctx) return; + + ::ID3D11DeviceContext2* ctx2{}; + ctx->QueryInterface(IID_PPV_ARGS(&ctx2)); + + *ppImmediateContext = reinterpret_cast(new device_context_x(ctx2)); +} + +HRESULT wd::device_x::CreateDeferredContext1(UINT ContextFlags, ID3D11DeviceContext1** ppDeferredContext) +{ + printf("WARN: CreateDeferredContext1 is not implemented\n"); + return wrapped_interface->CreateDeferredContext1(ContextFlags, ppDeferredContext); +} + +HRESULT wd::device_x::CreateDeferredContext2(UINT ContextFlags, ID3D11DeviceContext2** ppDeferredContext) +{ + printf("WARN: CreateDeferredContext2 is not implemented\n"); + return wrapped_interface->CreateDeferredContext2(ContextFlags, ppDeferredContext); +} + +void wd::device_x::GetImmediateContextX(wdi::ID3D11DeviceContextX** ppImmediateContextX) +{ + printf("WARN: GetImmediateContextX is not implemented\n"); + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_x::CreateCounterSet(const wdi::D3D11X_COUNTER_SET_DESC* pCounterSetDesc, + wdi::ID3D11CounterSetX** ppCounterSet) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_x::CreateCounterSample(wdi::ID3D11CounterSampleX** ppCounterSample) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_x::SetDriverHint(UINT Feature, UINT Value) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_x::CreateDmaEngineContext(const wdi::D3D11_DMA_ENGINE_CONTEXT_DESC* pDmaEngineContextDesc, + wdi::ID3D11DmaEngineContextX** ppDmaDeviceContext) +{ + throw std::logic_error("Not implemented"); +} + +BOOL wd::device_x::IsFencePending(UINT64 Fence) +{ + throw std::logic_error("Not implemented"); +} + +BOOL wd::device_x::IsResourcePending(ID3D11Resource* pResource) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_x::CreatePlacementBuffer(const D3D11_BUFFER_DESC* pDesc, void* pVirtualAddress, + ID3D11Buffer** ppBuffer) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_x::CreatePlacementTexture1D(const D3D11_TEXTURE1D_DESC* pDesc, UINT TileModeIndex, UINT Pitch, + void* pVirtualAddress, ID3D11Texture1D** ppTexture1D) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_x::CreatePlacementTexture2D(const D3D11_TEXTURE2D_DESC* pDesc, UINT TileModeIndex, UINT Pitch, + void* pVirtualAddress, ID3D11Texture2D** ppTexture2D) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_x::CreatePlacementTexture3D(const D3D11_TEXTURE3D_DESC* pDesc, UINT TileModeIndex, UINT Pitch, + void* pVirtualAddress, ID3D11Texture3D** ppTexture3D) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_x::GetTimestamps(UINT64* pGpuTimestamp, UINT64* pCpuRdtscTimestamp) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_x::CreateSamplerStateX(const wdi::D3D11X_SAMPLER_DESC* pSamplerDesc, + ID3D11SamplerState** ppSamplerState) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_x::CreateDeferredContextX(UINT Flags, wdi::ID3D11DeviceContextX** ppDeferredContext) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_x::GarbageCollect(UINT Flags) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_x::CreateDepthStencilStateX(const D3D11_DEPTH_STENCIL_DESC* pDepthStencilStateDesc, + ID3D11DepthStencilState** ppDepthStencilState) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_x::CreatePlacementRenderableTexture2D(const D3D11_TEXTURE2D_DESC* pDesc, UINT TileModeIndex, + UINT Pitch, + const wdi::D3D11X_RENDERABLE_TEXTURE_ADDRESSES* pAddresses, + ID3D11Texture2D** ppTexture2D) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_x::GetDriverStatistics(UINT StructSize, wdi::D3D11X_DRIVER_STATISTICS* pStatistics) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_x::CreateComputeContextX(const wdi::D3D11_COMPUTE_CONTEXT_DESC* pComputeContextDesc, + wdi::ID3D11ComputeContextX** ppComputeContext) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_x::ComposeShaderResourceView(const wdi::D3D11X_DESCRIPTOR_RESOURCE* pDescriptorResource, + const wdi::D3D11X_RESOURCE_VIEW_DESC* pViewDesc, + wdi::D3D11X_DESCRIPTOR_SHADER_RESOURCE_VIEW* pDescriptorSrv) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_x::ComposeUnorderedAccessView(const wdi::D3D11X_DESCRIPTOR_RESOURCE* pDescriptorResource, + const wdi::D3D11X_RESOURCE_VIEW_DESC* pViewDesc, + wdi::D3D11X_DESCRIPTOR_UNORDERED_ACCESS_VIEW* pDescriptorUav) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_x::ComposeConstantBufferView(const wdi::D3D11X_DESCRIPTOR_RESOURCE* pDescriptorResource, + const wdi::D3D11X_RESOURCE_VIEW_DESC* pViewDesc, + wdi::D3D11X_DESCRIPTOR_CONSTANT_BUFFER_VIEW* pDescriptorCb) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_x::ComposeVertexBufferView(const wdi::D3D11X_DESCRIPTOR_RESOURCE* pDescriptorResource, + const wdi::D3D11X_RESOURCE_VIEW_DESC* pViewDesc, + wdi::D3D11X_DESCRIPTOR_VERTEX_BUFFER_VIEW* pDescriptorVb) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_x::ComposeSamplerState(const wdi::D3D11X_SAMPLER_STATE_DESC* pSamplerDesc, + wdi::D3D11X_DESCRIPTOR_SAMPLER_STATE* pDescriptorSamplerState) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_x::PlaceSwapChainView(ID3D11Resource* pSwapChainBuffer, ID3D11View* pView) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_x::SetDebugFlags(UINT Flags) +{ + throw std::logic_error("Not implemented"); +} + +UINT wd::device_x::GetDebugFlags( ) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_x::SetHangCallbacks(wdi::D3D11XHANGBEGINCALLBACK pBeginCallback, wdi::D3D11XHANGPRINTCALLBACK pPrintCallback, + wdi::D3D11XHANGDUMPCALLBACK pDumpCallback) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_x::ReportGpuHang(UINT Flags) +{ + throw std::logic_error("Not implemented"); +} + +HRESULT wd::device_x::SetGpuMemoryPriority(UINT Priority) +{ + throw std::logic_error("Not implemented"); +} + +void wd::device_x::GetGpuHardwareConfiguration(wdi::D3D11X_GPU_HARDWARE_CONFIGURATION* pGpuHardwareConfiguration) +{ + throw std::logic_error("Not implemented"); +} diff --git a/dlls/d3d11_x/device_x.h b/dlls/d3d11_x/device_x.h new file mode 100644 index 0000000..ce2b6a2 --- /dev/null +++ b/dlls/d3d11_x/device_x.h @@ -0,0 +1,580 @@ +#pragma once +#include +#include +#include +#include "graphics_unknown.h" +#include +#include +#include "dxgi_device.h" + +namespace wdi +{ + class ID3D11DeviceContextX; + struct D3D11X_COUNTER_SET_DESC; + struct D3D11X_DESCRIPTOR_RESOURCE; + struct D3D11_DMA_ENGINE_CONTEXT_DESC; + struct D3D11X_SAMPLER_DESC; + struct D3D11X_RENDERABLE_TEXTURE_ADDRESSES; + struct D3D11X_DRIVER_STATISTICS; + struct D3D11_COMPUTE_CONTEXT_DESC; + struct D3D11X_RESOURCE_VIEW_DESC; + struct D3D11X_DESCRIPTOR_SHADER_RESOURCE_VIEW; + struct D3D11X_DESCRIPTOR_UNORDERED_ACCESS_VIEW; + struct D3D11X_DESCRIPTOR_CONSTANT_BUFFER_VIEW; + struct D3D11X_DESCRIPTOR_VERTEX_BUFFER_VIEW; + struct D3D11X_SAMPLER_STATE_DESC; + struct D3D11X_DESCRIPTOR_SAMPLER_STATE; + class ID3D11CounterSetX; + class ID3D11CounterSampleX; + class ID3D11DmaEngineContextX; + class ID3D11ComputeContextX; + + typedef UINT (*D3D11XHANGBEGINCALLBACK)(UINT64 Flags); + typedef void (*D3D11XHANGPRINTCALLBACK)(const CHAR* strLine); + typedef void (*D3D11XHANGDUMPCALLBACK)(const WCHAR* strFileName); + + typedef enum D3D11X_HARDWARE_VERSION + { + D3D11X_HARDWARE_VERSION_XBOX_ONE = 0, + D3D11X_HARDWARE_VERSION_XBOX_ONE_S = 1, + D3D11X_HARDWARE_VERSION_XBOX_ONE_X = 2, + D3D11X_HARDWARE_VERSION_XBOX_ONE_X_DEVKIT = 3 + } D3D11X_HARDWARE_VERSION; + + struct D3D11X_GPU_HARDWARE_CONFIGURATION + { + UINT64 GpuFrequency; + D3D11X_HARDWARE_VERSION HardwareVersion; + UINT32 GpuCuCount; + }; + + D3DINTERFACE(ID3D11Device, db6f6ddb, ac77, 4e88, 82, 53, 81, 9d, f9, bb, f1, 40) : public wd::graphics_unknown + { + public: + UINT m_CreationFlags; + + virtual HRESULT (CreateBuffer)(const D3D11_BUFFER_DESC* pDesc, + const D3D11_SUBRESOURCE_DATA* pInitialData, + ID3D11Buffer** ppBuffer) = 0; + virtual HRESULT (CreateTexture1D)(const D3D11_TEXTURE1D_DESC* pDesc, + _In_reads_opt_(_Inexpressible_(pDesc->MipLevels* pDesc->ArraySize)) const + D3D11_SUBRESOURCE_DATA* pInitialData, + ID3D11Texture1D** ppTexture1D) = 0; + virtual HRESULT (CreateTexture2D)(const D3D11_TEXTURE2D_DESC* pDesc, + _In_reads_opt_(_Inexpressible_(pDesc->MipLevels* pDesc->ArraySize)) const + D3D11_SUBRESOURCE_DATA* pInitialData, + ID3D11Texture2D** ppTexture2D) = 0; + virtual HRESULT (CreateTexture3D)(const D3D11_TEXTURE3D_DESC* pDesc, + _In_reads_opt_(_Inexpressible_(pDesc->MipLevels)) const D3D11_SUBRESOURCE_DATA + * pInitialData, ID3D11Texture3D** ppTexture3D) = 0; + virtual HRESULT (CreateShaderResourceView)(ID3D11Resource* pResource, + const D3D11_SHADER_RESOURCE_VIEW_DESC* pDesc, + ID3D11ShaderResourceView** ppSRView) = 0; + virtual HRESULT (CreateUnorderedAccessView)(ID3D11Resource* pResource, + const D3D11_UNORDERED_ACCESS_VIEW_DESC* pDesc, + ID3D11UnorderedAccessView** ppUAView) = 0; + virtual HRESULT (CreateRenderTargetView)(ID3D11Resource* pResource, + const D3D11_RENDER_TARGET_VIEW_DESC* pDesc, + ID3D11RenderTargetView** ppRTView) = 0; + virtual HRESULT (CreateDepthStencilView)(ID3D11Resource* pResource, + const D3D11_DEPTH_STENCIL_VIEW_DESC* pDesc, + ID3D11DepthStencilView** ppDepthStencilView) = 0; + virtual HRESULT (CreateInputLayout)(_In_reads_(NumElements) const D3D11_INPUT_ELEMENT_DESC* pInputElementDescs, + _In_range_(0, D3D11_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT) UINT + NumElements, + _In_reads_(BytecodeLength) const void* pShaderBytecodeWithInputSignature, + SIZE_T BytecodeLength, ID3D11InputLayout** ppInputLayout) = 0; + virtual HRESULT (CreateVertexShader)(_In_reads_(BytecodeLength) const void* pShaderBytecode, + SIZE_T BytecodeLength, ID3D11ClassLinkage* pClassLinkage, + ID3D11VertexShader** ppVertexShader) = 0; + virtual HRESULT (CreateGeometryShader)( + _In_reads_(BytecodeLength) const void* pShaderBytecode, SIZE_T BytecodeLength, + ID3D11ClassLinkage* pClassLinkage, ID3D11GeometryShader** ppGeometryShader) = 0; + virtual HRESULT (CreateGeometryShaderWithStreamOutput)( + _In_reads_(BytecodeLength) const void* pShaderBytecode, SIZE_T BytecodeLength, + _In_reads_opt_(NumEntries) const D3D11_SO_DECLARATION_ENTRY* pSODeclaration, + _In_range_(0, D3D11_SO_STREAM_COUNT* D3D11_SO_OUTPUT_COMPONENT_COUNT) UINT NumEntries, + _In_reads_opt_(NumStrides) const UINT* pBufferStrides, + _In_range_(0, D3D11_SO_BUFFER_SLOT_COUNT) UINT NumStrides, UINT RasterizedStream, + ID3D11ClassLinkage* pClassLinkage, ID3D11GeometryShader** ppGeometryShader) = 0; + virtual HRESULT (CreatePixelShader)(_In_reads_(BytecodeLength) const void* pShaderBytecode, + SIZE_T BytecodeLength, ID3D11ClassLinkage* pClassLinkage, + ID3D11PixelShader** ppPixelShader) = 0; + virtual HRESULT (CreateHullShader)(_In_reads_(BytecodeLength) const void* pShaderBytecode, + SIZE_T BytecodeLength, ID3D11ClassLinkage* pClassLinkage, + ID3D11HullShader** ppHullShader) = 0; + virtual HRESULT (CreateDomainShader)(_In_reads_(BytecodeLength) const void* pShaderBytecode, + SIZE_T BytecodeLength, ID3D11ClassLinkage* pClassLinkage, + ID3D11DomainShader** ppDomainShader) = 0; + virtual HRESULT (CreateComputeShader)( + _In_reads_(BytecodeLength) const void* pShaderBytecode, SIZE_T BytecodeLength, + ID3D11ClassLinkage* pClassLinkage, ID3D11ComputeShader** ppComputeShader) = 0; + virtual HRESULT (CreateClassLinkage)(ID3D11ClassLinkage** ppLinkage) = 0; + virtual HRESULT (CreateBlendState)(const D3D11_BLEND_DESC* pBlendStateDesc, + ID3D11BlendState** ppBlendState) = 0; + virtual HRESULT (CreateDepthStencilState)(const D3D11_DEPTH_STENCIL_DESC* pDepthStencilDesc, + ID3D11DepthStencilState** ppDepthStencilState) = 0; + virtual HRESULT (CreateRasterizerState)(const D3D11_RASTERIZER_DESC* pRasterizerDesc, + ID3D11RasterizerState** ppRasterizerState) = 0; + virtual HRESULT (CreateSamplerState)(const D3D11_SAMPLER_DESC* pSamplerDesc, + ID3D11SamplerState** ppSamplerState) = 0; + virtual HRESULT (CreateQuery)(const D3D11_QUERY_DESC* pQueryDesc, ID3D11Query** ppQuery) = 0; + virtual HRESULT (CreatePredicate)(const D3D11_QUERY_DESC* pPredicateDesc, + ID3D11Predicate** ppPredicate) = 0; + virtual HRESULT (CreateCounter)(const D3D11_COUNTER_DESC* pCounterDesc, + ID3D11Counter** ppCounter) = 0; + // @Patoke todo: make this access wdi::ID3D11DeviceContext instead, this is a temporary fix + virtual HRESULT (CreateDeferredContext)(UINT ContextFlags, ::ID3D11DeviceContext** ppDeferredContext) = 0; + virtual HRESULT (OpenSharedResource)(HANDLE hResource, REFIID ReturnedInterface, + void** ppResource) = 0; + virtual HRESULT (CheckFormatSupport)(DXGI_FORMAT Format, UINT* pFormatSupport) = 0; + virtual HRESULT (CheckMultisampleQualityLevels)(DXGI_FORMAT Format, UINT SampleCount, + UINT* pNumQualityLevels) = 0; + virtual void (CheckCounterInfo)(D3D11_COUNTER_INFO* pCounterInfo) = 0; + virtual HRESULT (CheckCounter)(const D3D11_COUNTER_DESC* pDesc, D3D11_COUNTER_TYPE* pType, + UINT* pActiveCounters, _Out_writes_opt_(*pNameLength) LPSTR szName, + _Inout_opt_ UINT* pNameLength, _Out_writes_opt_(*pUnitsLength) LPSTR szUnits, + _Inout_opt_ UINT* pUnitsLength, + _Out_writes_opt_(*pDescriptionLength) LPSTR szDescription, + _Inout_opt_ UINT* pDescriptionLength) = 0; + virtual HRESULT (CheckFeatureSupport)(D3D11_FEATURE Feature, + _Out_writes_bytes_(FeatureSupportDataSize) void* pFeatureSupportData, + UINT FeatureSupportDataSize) = 0; + virtual HRESULT (GetPrivateData)(REFGUID guid, UINT* pDataSize, + _Out_writes_bytes_opt_(*pDataSize) void* pData) = 0; + virtual HRESULT (SetPrivateData)(REFGUID guid, UINT DataSize, + _In_reads_bytes_opt_(DataSize) const void* pData) = 0; + virtual HRESULT (SetPrivateDataInterface)(REFGUID guid, const IUnknown* pData) = 0; + virtual HRESULT (SetPrivateDataInterfaceGraphics)(REFGUID guid, const IGraphicsUnknown* pData) = 0; + virtual D3D_FEATURE_LEVEL (GetFeatureLevel)() = 0; + virtual UINT (GetCreationFlags)() = 0; + virtual HRESULT (GetDeviceRemovedReason)() = 0; + // @Patoke todo: make this access wdi::ID3D11DeviceContext instead, this is a temporary fix + virtual void (GetImmediateContext)(::ID3D11DeviceContext** ppImmediateContext) = 0; + virtual HRESULT (SetExceptionMode)(UINT RaiseFlags) = 0; + virtual UINT (GetExceptionMode)() = 0; + }; + + D3DINTERFACE(ID3D11Device1, a04bfb29, 08ef, 43d6, a4, 9c, a9, bd, bd, cb, e6, 86) : public ID3D11Device + { + public: + // @Patoke todo: make this access wdi::ID3D11DeviceContext1 instead, this is a temporary fix + virtual void (GetImmediateContext1)(::ID3D11DeviceContext1** ppImmediateContext) = 0; + // @Patoke todo: make this access wdi::ID3D11DeviceContext1 instead, this is a temporary fix + virtual HRESULT (CreateDeferredContext1)(UINT ContextFlags, ::ID3D11DeviceContext1** ppDeferredContext) = 0; + virtual HRESULT (CreateBlendState1)(const D3D11_BLEND_DESC1* pBlendStateDesc, + ID3D11BlendState1** ppBlendState) = 0; + virtual HRESULT (CreateRasterizerState1)(const D3D11_RASTERIZER_DESC1* pRasterizerDesc, + ID3D11RasterizerState1** ppRasterizerState) = 0; + virtual HRESULT (CreateDeviceContextState)( + UINT Flags,_In_reads_(FeatureLevels) const D3D_FEATURE_LEVEL* pFeatureLevels, UINT FeatureLevels, + UINT SDKVersion,REFIID EmulatedInterface, D3D_FEATURE_LEVEL* pChosenFeatureLevel, + ID3DDeviceContextState** ppContextState) = 0; + virtual HRESULT (OpenSharedResource1)(HANDLE hResource,REFIID ReturnedInterface, + void** ppResource) = 0; + virtual HRESULT (OpenSharedResourceByName)(LPCWSTR lpName, DWORD dwDesiredAccess, + REFIID ReturnedInterface, void** ppResource) = 0; + }; + + D3DINTERFACE(ID3D11Device2, 9d06dffa, d1e5, 4d07, 83, a8, 1b, b1, 23, f2, f8, 41) : public ID3D11Device1 + { + public: + // @Patoke todo: make this access wdi::ID3D11DeviceContext2 instead, this is a temporary fix + virtual void (GetImmediateContext2)(::ID3D11DeviceContext2** ppImmediateContext) = 0; + // @Patoke todo: make this access wdi::ID3D11DeviceContext2 instead, this is a temporary fix + virtual HRESULT (CreateDeferredContext2)(UINT ContextFlags, ::ID3D11DeviceContext2** ppDeferredContext) = 0; + virtual void (GetResourceTiling)(ID3D11Resource* pTiledResource, UINT* pNumTilesForEntireResource, + D3D11_PACKED_MIP_DESC* pPackedMipDesc, + D3D11_TILE_SHAPE* pStandardTileShapeForNonPackedMips, + _Inout_opt_ UINT* pNumSubresourceTilings, UINT FirstSubresourceTilingToGet, + _Out_writes_(*pNumSubresourceTilings) D3D11_SUBRESOURCE_TILING* + pSubresourceTilingsForNonPackedMips) = 0; + virtual HRESULT (CheckMultisampleQualityLevels1)(DXGI_FORMAT Format, UINT SampleCount, UINT Flags, + UINT* pNumQualityLevels) = 0; + }; + + D3DINTERFACE(ID3D11DeviceX, 177700f9, 876a, 4436, b3, 68, 36, a6, 04, f8, 2c, ef) : public ID3D11Device2 + { + public: + virtual void (GetImmediateContextX)(ID3D11DeviceContextX** ppImmediateContextX) = 0; + virtual HRESULT (CreateCounterSet)(const D3D11X_COUNTER_SET_DESC* pCounterSetDesc, + ID3D11CounterSetX** ppCounterSet) = 0; + virtual HRESULT (CreateCounterSample)(ID3D11CounterSampleX** ppCounterSample) = 0; + virtual HRESULT (SetDriverHint)(UINT Feature, UINT Value) = 0; + virtual HRESULT (CreateDmaEngineContext)(const D3D11_DMA_ENGINE_CONTEXT_DESC* pDmaEngineContextDesc, + ID3D11DmaEngineContextX** ppDmaDeviceContext) = 0; + virtual BOOL (IsFencePending)(UINT64 Fence) = 0; + virtual BOOL (IsResourcePending)(ID3D11Resource* pResource) = 0; + virtual HRESULT (CreatePlacementBuffer)(const D3D11_BUFFER_DESC* pDesc, void* pVirtualAddress, + ID3D11Buffer** ppBuffer) = 0; + virtual HRESULT (CreatePlacementTexture1D)(const D3D11_TEXTURE1D_DESC* pDesc, UINT TileModeIndex, UINT Pitch, + void* pVirtualAddress, ID3D11Texture1D** ppTexture1D) = 0; + virtual HRESULT (CreatePlacementTexture2D)(const D3D11_TEXTURE2D_DESC* pDesc, UINT TileModeIndex, UINT Pitch, + void* pVirtualAddress, ID3D11Texture2D** ppTexture2D) = 0; + virtual HRESULT (CreatePlacementTexture3D)(const D3D11_TEXTURE3D_DESC* pDesc, UINT TileModeIndex, UINT Pitch, + void* pVirtualAddress, ID3D11Texture3D** ppTexture3D) = 0; + virtual void (GetTimestamps)(UINT64* pGpuTimestamp, UINT64* pCpuRdtscTimestamp) = 0; + virtual HRESULT (CreateSamplerStateX)(const D3D11X_SAMPLER_DESC* pSamplerDesc, + ID3D11SamplerState** ppSamplerState) = 0; + virtual HRESULT (CreateDeferredContextX)(UINT Flags, ID3D11DeviceContextX** ppDeferredContext) = 0; + virtual void (GarbageCollect)(UINT Flags) = 0; + virtual HRESULT (CreateDepthStencilStateX)(const D3D11_DEPTH_STENCIL_DESC* pDepthStencilStateDesc, + ID3D11DepthStencilState** ppDepthStencilState) = 0; + virtual HRESULT (CreatePlacementRenderableTexture2D)(const D3D11_TEXTURE2D_DESC* pDesc, UINT TileModeIndex, + UINT Pitch, + const D3D11X_RENDERABLE_TEXTURE_ADDRESSES* pAddresses, + ID3D11Texture2D** ppTexture2D) = 0; + virtual void (GetDriverStatistics)(UINT StructSize, D3D11X_DRIVER_STATISTICS* pStatistics) = 0; + virtual HRESULT (CreateComputeContextX)(const D3D11_COMPUTE_CONTEXT_DESC* pComputeContextDesc, + ID3D11ComputeContextX** ppComputeContext) = 0; + virtual void (ComposeShaderResourceView)(const D3D11X_DESCRIPTOR_RESOURCE* pDescriptorResource, + const D3D11X_RESOURCE_VIEW_DESC* pViewDesc, + D3D11X_DESCRIPTOR_SHADER_RESOURCE_VIEW* pDescriptorSrv) = 0; + virtual void (ComposeUnorderedAccessView)(const D3D11X_DESCRIPTOR_RESOURCE* pDescriptorResource, + const D3D11X_RESOURCE_VIEW_DESC* pViewDesc, + D3D11X_DESCRIPTOR_UNORDERED_ACCESS_VIEW* pDescriptorUav) = 0; + virtual void (ComposeConstantBufferView)(const D3D11X_DESCRIPTOR_RESOURCE* pDescriptorResource, + const D3D11X_RESOURCE_VIEW_DESC* pViewDesc, + D3D11X_DESCRIPTOR_CONSTANT_BUFFER_VIEW* pDescriptorCb) = 0; + virtual void (ComposeVertexBufferView)(const D3D11X_DESCRIPTOR_RESOURCE* pDescriptorResource, + const D3D11X_RESOURCE_VIEW_DESC* pViewDesc, + D3D11X_DESCRIPTOR_VERTEX_BUFFER_VIEW* pDescriptorVb) = 0; + virtual void (ComposeSamplerState)(const D3D11X_SAMPLER_STATE_DESC* pSamplerDesc, + D3D11X_DESCRIPTOR_SAMPLER_STATE* pDescriptorSamplerState) = 0; + virtual void (PlaceSwapChainView)(ID3D11Resource* pSwapChainBuffer, ID3D11View* pView) = 0; + virtual void (SetDebugFlags)(UINT Flags) = 0; + virtual UINT (GetDebugFlags)() = 0; + virtual void (SetHangCallbacks)(D3D11XHANGBEGINCALLBACK pBeginCallback, D3D11XHANGPRINTCALLBACK pPrintCallback, + D3D11XHANGDUMPCALLBACK pDumpCallback) = 0; + virtual void (ReportGpuHang)(UINT Flags) = 0; + virtual HRESULT (SetGpuMemoryPriority)(UINT Priority) = 0; + virtual void (GetGpuHardwareConfiguration)(D3D11X_GPU_HARDWARE_CONFIGURATION* pGpuHardwareConfiguration) = 0; + }; +} + +namespace wd +{ + class device_x : public wdi::ID3D11DeviceX + { + public: + device_x(::ID3D11Device2* device) : wrapped_interface(device) { wrapped_interface->AddRef(); } + + IGU_DEFINE_REF + + HRESULT QueryInterface(REFIID riid, void** ppvObject) override + { + if (ppvObject == nullptr) { + return E_POINTER; + } + + if (riid == __uuidof(wdi::ID3D11DeviceX) || riid == __uuidof(wdi::ID3D11Device) || riid == __uuidof(wdi::ID3D11Device1) || riid == __uuidof(wdi::ID3D11Device2)) + { + *ppvObject = static_cast(this); + AddRef( ); + return S_OK; + } + + if (riid == __uuidof(IDXGIDevice) || + riid == __uuidof(IDXGIDevice1)) + { + wrapped_interface->QueryInterface(__uuidof(IDXGIDevice1), ppvObject); + *ppvObject = new dxgi_device(static_cast(*ppvObject)); + return S_OK; + } + + if (riid == __uuidof(wdi::IGraphicsUnwrap)) + { + *ppvObject = wrapped_interface; + return S_OK; + } + + TRACE_INTERFACE_NOT_HANDLED("device_x"); + *ppvObject = nullptr; + return E_NOINTERFACE; + } + + HRESULT CreateBuffer(const D3D11_BUFFER_DESC* pDesc, const D3D11_SUBRESOURCE_DATA* pInitialData, ID3D11Buffer** ppBuffer) override; + + HRESULT CreateTexture1D(const D3D11_TEXTURE1D_DESC* pDesc, const D3D11_SUBRESOURCE_DATA* pInitialData, ID3D11Texture1D** ppTexture1D) override; + + HRESULT CreateTexture2D(const D3D11_TEXTURE2D_DESC* pDesc, const D3D11_SUBRESOURCE_DATA* pInitialData, ID3D11Texture2D** ppTexture2D) override; + + HRESULT CreateTexture3D(const D3D11_TEXTURE3D_DESC* pDesc, const D3D11_SUBRESOURCE_DATA* pInitialData, ID3D11Texture3D** ppTexture3D) override; + + HRESULT CreateShaderResourceView(ID3D11Resource* pResource, const D3D11_SHADER_RESOURCE_VIEW_DESC* pDesc, ID3D11ShaderResourceView** ppSRView) override; + + HRESULT CreateUnorderedAccessView(ID3D11Resource* pResource, const D3D11_UNORDERED_ACCESS_VIEW_DESC* pDesc, ID3D11UnorderedAccessView** ppUAView) override; + + HRESULT CreateRenderTargetView(ID3D11Resource* pResource, const D3D11_RENDER_TARGET_VIEW_DESC* pDesc, ID3D11RenderTargetView** ppRTView) override; + + HRESULT CreateDepthStencilView(ID3D11Resource* pResource, const D3D11_DEPTH_STENCIL_VIEW_DESC* pDesc, ID3D11DepthStencilView** ppDepthStencilView) override; + + HRESULT CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC* pInputElementDescs, UINT NumElements, const void* pShaderBytecodeWithInputSignature, SIZE_T BytecodeLength, ID3D11InputLayout** ppInputLayout) override + { + return wrapped_interface->CreateInputLayout(pInputElementDescs, NumElements, pShaderBytecodeWithInputSignature, BytecodeLength, ppInputLayout); + } + + HRESULT CreateVertexShader(const void* pShaderBytecode, SIZE_T BytecodeLength, ID3D11ClassLinkage* pClassLinkage, ID3D11VertexShader** ppVertexShader) override + { + return wrapped_interface->CreateVertexShader(pShaderBytecode, BytecodeLength, pClassLinkage, ppVertexShader); + } + + HRESULT CreateGeometryShader(const void* pShaderBytecode, SIZE_T BytecodeLength, ID3D11ClassLinkage* pClassLinkage, ID3D11GeometryShader** ppGeometryShader) override + { + return wrapped_interface->CreateGeometryShader(pShaderBytecode, BytecodeLength, pClassLinkage, ppGeometryShader); + } + + HRESULT CreateGeometryShaderWithStreamOutput(const void* pShaderBytecode, SIZE_T BytecodeLength, const D3D11_SO_DECLARATION_ENTRY* pSODeclaration, UINT NumEntries, const UINT* pBufferStrides, UINT NumStrides, UINT RasterizedStream, ID3D11ClassLinkage* pClassLinkage, ID3D11GeometryShader** ppGeometryShader) override + { + return wrapped_interface->CreateGeometryShaderWithStreamOutput(pShaderBytecode, BytecodeLength, pSODeclaration, NumEntries, pBufferStrides, NumStrides, RasterizedStream, pClassLinkage, ppGeometryShader); + } + + HRESULT CreatePixelShader(const void* pShaderBytecode, SIZE_T BytecodeLength, ID3D11ClassLinkage* pClassLinkage, ID3D11PixelShader** ppPixelShader) override + { + return wrapped_interface->CreatePixelShader(pShaderBytecode, BytecodeLength, pClassLinkage, ppPixelShader); + } + + HRESULT CreateHullShader(const void* pShaderBytecode, SIZE_T BytecodeLength, ID3D11ClassLinkage* pClassLinkage, ID3D11HullShader** ppHullShader) override + { + return wrapped_interface->CreateHullShader(pShaderBytecode, BytecodeLength, pClassLinkage, ppHullShader); + } + + HRESULT CreateDomainShader(const void* pShaderBytecode, SIZE_T BytecodeLength, ID3D11ClassLinkage* pClassLinkage, ID3D11DomainShader** ppDomainShader) override + { + return wrapped_interface->CreateDomainShader(pShaderBytecode, BytecodeLength, pClassLinkage, ppDomainShader); + } + + HRESULT CreateComputeShader(const void* pShaderBytecode, SIZE_T BytecodeLength, ID3D11ClassLinkage* pClassLinkage, ID3D11ComputeShader** ppComputeShader) override + { + return wrapped_interface->CreateComputeShader(pShaderBytecode, BytecodeLength, pClassLinkage, ppComputeShader); + } + + HRESULT CreateClassLinkage(ID3D11ClassLinkage** ppLinkage) override + { + return wrapped_interface->CreateClassLinkage(ppLinkage); + } + + HRESULT CreateBlendState(const D3D11_BLEND_DESC* pBlendStateDesc, ID3D11BlendState** ppBlendState) override + { + return wrapped_interface->CreateBlendState(pBlendStateDesc, ppBlendState); + } + + HRESULT CreateDepthStencilState(const D3D11_DEPTH_STENCIL_DESC* pDepthStencilDesc, ID3D11DepthStencilState** ppDepthStencilState) override + { + return wrapped_interface->CreateDepthStencilState(pDepthStencilDesc, ppDepthStencilState); + } + + HRESULT CreateRasterizerState(const D3D11_RASTERIZER_DESC* pRasterizerDesc, ID3D11RasterizerState** ppRasterizerState) override + { + return wrapped_interface->CreateRasterizerState(pRasterizerDesc, ppRasterizerState); + } + + HRESULT CreateSamplerState(const D3D11_SAMPLER_DESC* pSamplerDesc, ID3D11SamplerState** ppSamplerState) override + { + return wrapped_interface->CreateSamplerState(pSamplerDesc, ppSamplerState); + } + + HRESULT CreateQuery(const D3D11_QUERY_DESC* pQueryDesc, ID3D11Query** ppQuery) override + { + return wrapped_interface->CreateQuery(pQueryDesc, ppQuery); + } + + HRESULT CreatePredicate(const D3D11_QUERY_DESC* pPredicateDesc, ID3D11Predicate** ppPredicate) override + { + return wrapped_interface->CreatePredicate(pPredicateDesc, ppPredicate); + } + + HRESULT CreateCounter(const D3D11_COUNTER_DESC* pCounterDesc, ID3D11Counter** ppCounter) override + { + return wrapped_interface->CreateCounter(pCounterDesc, ppCounter); + } + + HRESULT CreateDeferredContext(UINT ContextFlags, ID3D11DeviceContext** ppDeferredContext) override; + + HRESULT OpenSharedResource(HANDLE hResource, REFIID ReturnedInterface, void** ppResource) override + { + return wrapped_interface->OpenSharedResource(hResource, ReturnedInterface, ppResource); + } + + HRESULT CheckFormatSupport(DXGI_FORMAT Format, UINT* pFormatSupport) override + { + return wrapped_interface->CheckFormatSupport(Format, pFormatSupport); + } + + HRESULT CheckMultisampleQualityLevels(DXGI_FORMAT Format, UINT SampleCount, UINT* pNumQualityLevels) override + { + return wrapped_interface->CheckMultisampleQualityLevels(Format, SampleCount, pNumQualityLevels); + } + + void CheckCounterInfo(D3D11_COUNTER_INFO* pCounterInfo) override + { + wrapped_interface->CheckCounterInfo(pCounterInfo); + } + + HRESULT CheckCounter(const D3D11_COUNTER_DESC* pDesc, D3D11_COUNTER_TYPE* pType, UINT* pActiveCounters, LPSTR szName, UINT* pNameLength, LPSTR szUnits, UINT* pUnitsLength, LPSTR szDescription, UINT* pDescriptionLength) override + { + return wrapped_interface->CheckCounter(pDesc, pType, pActiveCounters, szName, pNameLength, szUnits, pUnitsLength, szDescription, pDescriptionLength); + } + + HRESULT CheckFeatureSupport(D3D11_FEATURE Feature, void* pFeatureSupportData, UINT FeatureSupportDataSize) override + { + return wrapped_interface->CheckFeatureSupport(Feature, pFeatureSupportData, FeatureSupportDataSize); + } + + HRESULT GetPrivateData(REFGUID guid, UINT* pDataSize, void* pData) override + { + return wrapped_interface->GetPrivateData(guid, pDataSize, pData); + } + + HRESULT SetPrivateData(REFGUID guid, UINT DataSize, const void* pData) override + { + return wrapped_interface->SetPrivateData(guid, DataSize, pData); + } + + HRESULT SetPrivateDataInterface(REFGUID guid, const IUnknown* pData) override + { + return wrapped_interface->SetPrivateDataInterface(guid, pData); + } + + HRESULT SetPrivateDataInterfaceGraphics(REFGUID guid, const IGraphicsUnknown* pData) override + { + throw std::exception("Not implemented"); + //return wrapped_interface->SetPrivateDataInterfaceGraphics(guid, pData); + } + + D3D_FEATURE_LEVEL GetFeatureLevel( ) override + { + return wrapped_interface->GetFeatureLevel( ); + } + + UINT GetCreationFlags( ) override + { + return wrapped_interface->GetCreationFlags( ); + } + + HRESULT GetDeviceRemovedReason( ) override + { + return wrapped_interface->GetDeviceRemovedReason( ); + } + + void GetImmediateContext(ID3D11DeviceContext** ppImmediateContext) override; + + HRESULT SetExceptionMode(UINT RaiseFlags) override + { + return wrapped_interface->SetExceptionMode(RaiseFlags); + } + + UINT GetExceptionMode( ) override + { + return wrapped_interface->GetExceptionMode( ); + } + + // ID3D11Device1 methods + void GetImmediateContext1(ID3D11DeviceContext1** ppImmediateContext) override + { + wrapped_interface->GetImmediateContext1(ppImmediateContext); + } + + HRESULT CreateDeferredContext1(UINT ContextFlags, ID3D11DeviceContext1** ppDeferredContext) override; + + HRESULT CreateBlendState1(const D3D11_BLEND_DESC1* pBlendStateDesc, ID3D11BlendState1** ppBlendState) override + { + return wrapped_interface->CreateBlendState1(pBlendStateDesc, ppBlendState); + } + + HRESULT CreateRasterizerState1(const D3D11_RASTERIZER_DESC1* pRasterizerDesc, ID3D11RasterizerState1** ppRasterizerState) override + { + return wrapped_interface->CreateRasterizerState1(pRasterizerDesc, ppRasterizerState); + } + + HRESULT CreateDeviceContextState(UINT Flags, const D3D_FEATURE_LEVEL* pFeatureLevels, UINT FeatureLevels, UINT SDKVersion, REFIID EmulatedInterface, D3D_FEATURE_LEVEL* pChosenFeatureLevel, ID3DDeviceContextState** ppContextState) override + { + return wrapped_interface->CreateDeviceContextState(Flags, pFeatureLevels, FeatureLevels, SDKVersion, EmulatedInterface, pChosenFeatureLevel, ppContextState); + } + + HRESULT OpenSharedResource1(HANDLE hResource, REFIID ReturnedInterface, void** ppResource) override + { + return wrapped_interface->OpenSharedResource1(hResource, ReturnedInterface, ppResource); + } + + HRESULT OpenSharedResourceByName(LPCWSTR lpName, DWORD dwDesiredAccess, REFIID ReturnedInterface, void** ppResource) override + { + return wrapped_interface->OpenSharedResourceByName(lpName, dwDesiredAccess, ReturnedInterface, ppResource); + } + + // ID3D11Device2 methods + void GetImmediateContext2(ID3D11DeviceContext2** ppImmediateContext) override + { + wrapped_interface->GetImmediateContext2(ppImmediateContext); + } + + HRESULT CreateDeferredContext2(UINT ContextFlags, ID3D11DeviceContext2** ppDeferredContext) override; + + void GetResourceTiling(ID3D11Resource* pTiledResource, UINT* pNumTilesForEntireResource, D3D11_PACKED_MIP_DESC* pPackedMipDesc, D3D11_TILE_SHAPE* pStandardTileShapeForNonPackedMips, UINT* pNumSubresourceTilings, UINT FirstSubresourceTilingToGet, D3D11_SUBRESOURCE_TILING* pSubresourceTilingsForNonPackedMips) override + { + wrapped_interface->GetResourceTiling(pTiledResource, pNumTilesForEntireResource, pPackedMipDesc, pStandardTileShapeForNonPackedMips, pNumSubresourceTilings, FirstSubresourceTilingToGet, pSubresourceTilingsForNonPackedMips); + } + + HRESULT CheckMultisampleQualityLevels1(DXGI_FORMAT Format, UINT SampleCount, UINT Flags, UINT* pNumQualityLevels) override + { + return wrapped_interface->CheckMultisampleQualityLevels1(Format, SampleCount, Flags, pNumQualityLevels); + } + + // ID3D11DeviceX methods + void GetImmediateContextX(wdi::ID3D11DeviceContextX** ppImmediateContextX) override; + HRESULT CreateCounterSet(const wdi::D3D11X_COUNTER_SET_DESC* pCounterSetDesc, + wdi::ID3D11CounterSetX** ppCounterSet) override; + HRESULT CreateCounterSample(wdi::ID3D11CounterSampleX** ppCounterSample) override; + HRESULT SetDriverHint(UINT Feature, UINT Value) override; + HRESULT CreateDmaEngineContext(const wdi::D3D11_DMA_ENGINE_CONTEXT_DESC* pDmaEngineContextDesc, + wdi::ID3D11DmaEngineContextX** ppDmaDeviceContext) override; + BOOL IsFencePending(UINT64 Fence) override; + BOOL IsResourcePending(ID3D11Resource* pResource) override; + HRESULT CreatePlacementBuffer(const D3D11_BUFFER_DESC* pDesc, void* pVirtualAddress, + ID3D11Buffer** ppBuffer) override; + HRESULT CreatePlacementTexture1D(const D3D11_TEXTURE1D_DESC* pDesc, UINT TileModeIndex, UINT Pitch, + void* pVirtualAddress, ID3D11Texture1D** ppTexture1D) override; + HRESULT CreatePlacementTexture2D(const D3D11_TEXTURE2D_DESC* pDesc, UINT TileModeIndex, UINT Pitch, + void* pVirtualAddress, ID3D11Texture2D** ppTexture2D) override; + HRESULT CreatePlacementTexture3D(const D3D11_TEXTURE3D_DESC* pDesc, UINT TileModeIndex, UINT Pitch, + void* pVirtualAddress, ID3D11Texture3D** ppTexture3D) override; + void GetTimestamps(UINT64* pGpuTimestamp, UINT64* pCpuRdtscTimestamp) override; + HRESULT CreateSamplerStateX(const wdi::D3D11X_SAMPLER_DESC* pSamplerDesc, + ID3D11SamplerState** ppSamplerState) override; + HRESULT CreateDeferredContextX(UINT Flags, wdi::ID3D11DeviceContextX** ppDeferredContext) override; + void GarbageCollect(UINT Flags) override; + HRESULT CreateDepthStencilStateX(const D3D11_DEPTH_STENCIL_DESC* pDepthStencilStateDesc, + ID3D11DepthStencilState** ppDepthStencilState) override; + HRESULT CreatePlacementRenderableTexture2D(const D3D11_TEXTURE2D_DESC* pDesc, UINT TileModeIndex, + UINT Pitch, + const wdi::D3D11X_RENDERABLE_TEXTURE_ADDRESSES* pAddresses, + ID3D11Texture2D** ppTexture2D) override; + void GetDriverStatistics(UINT StructSize, wdi::D3D11X_DRIVER_STATISTICS* pStatistics) override; + HRESULT CreateComputeContextX(const wdi::D3D11_COMPUTE_CONTEXT_DESC* pComputeContextDesc, + wdi::ID3D11ComputeContextX** ppComputeContext) override; + void ComposeShaderResourceView(const wdi::D3D11X_DESCRIPTOR_RESOURCE* pDescriptorResource, + const wdi::D3D11X_RESOURCE_VIEW_DESC* pViewDesc, + wdi::D3D11X_DESCRIPTOR_SHADER_RESOURCE_VIEW* pDescriptorSrv) override; + void ComposeUnorderedAccessView(const wdi::D3D11X_DESCRIPTOR_RESOURCE* pDescriptorResource, + const wdi::D3D11X_RESOURCE_VIEW_DESC* pViewDesc, + wdi::D3D11X_DESCRIPTOR_UNORDERED_ACCESS_VIEW* pDescriptorUav) override; + void ComposeConstantBufferView(const wdi::D3D11X_DESCRIPTOR_RESOURCE* pDescriptorResource, + const wdi::D3D11X_RESOURCE_VIEW_DESC* pViewDesc, + wdi::D3D11X_DESCRIPTOR_CONSTANT_BUFFER_VIEW* pDescriptorCb) override; + void ComposeVertexBufferView(const wdi::D3D11X_DESCRIPTOR_RESOURCE* pDescriptorResource, + const wdi::D3D11X_RESOURCE_VIEW_DESC* pViewDesc, + wdi::D3D11X_DESCRIPTOR_VERTEX_BUFFER_VIEW* pDescriptorVb) override; + void ComposeSamplerState(const wdi::D3D11X_SAMPLER_STATE_DESC* pSamplerDesc, + wdi::D3D11X_DESCRIPTOR_SAMPLER_STATE* pDescriptorSamplerState) override; + void PlaceSwapChainView(ID3D11Resource* pSwapChainBuffer, ID3D11View* pView) override; + void SetDebugFlags(UINT Flags) override; + UINT GetDebugFlags() override; + void SetHangCallbacks(wdi::D3D11XHANGBEGINCALLBACK pBeginCallback, wdi::D3D11XHANGPRINTCALLBACK pPrintCallback, + wdi::D3D11XHANGDUMPCALLBACK pDumpCallback) override; + void ReportGpuHang(UINT Flags) override; + HRESULT SetGpuMemoryPriority(UINT Priority) override; + void GetGpuHardwareConfiguration(wdi::D3D11X_GPU_HARDWARE_CONFIGURATION* pGpuHardwareConfiguration) override; + private: + ::ID3D11Device2* wrapped_interface; + }; +} diff --git a/dlls/d3d11_x/dllmain.cpp b/dlls/d3d11_x/dllmain.cpp index e008d86..cf0dd38 100644 --- a/dlls/d3d11_x/dllmain.cpp +++ b/dlls/d3d11_x/dllmain.cpp @@ -1,9 +1,6 @@ // ReSharper disable CppInconsistentNaming // ReSharper disable CppParameterMayBeConst -#include "pch.h" - -#include - +#include "windows.h" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD forwardReason, LPVOID lpvReserved) { constexpr BOOL result = TRUE; diff --git a/dlls/d3d11_x/dxgi_adapter.cpp b/dlls/d3d11_x/dxgi_adapter.cpp new file mode 100644 index 0000000..2841a76 --- /dev/null +++ b/dlls/d3d11_x/dxgi_adapter.cpp @@ -0,0 +1,36 @@ +#include "dxgi_adapter.h" +#include "dxgi_factory.h" + +HRESULT wd::dxgi_adapter::GetParent(const IID& riid, void** ppParent) +{ + if (riid == __uuidof(IDXGIFactory) || + riid == __uuidof(IDXGIFactory1) || + riid == __uuidof(IDXGIFactory2)) + { + IDXGIFactory2* factory = nullptr; + HRESULT hr = wrapped_interface->GetParent(IID_PPV_ARGS(&factory)); + *ppParent = new dxgi_factory(factory); + this->AddRef( ); + return hr; + } + + TRACE_INTERFACE_NOT_HANDLED("dxgi_adapter"); + *ppParent = nullptr; + return E_NOINTERFACE; +} + +HRESULT wd::dxgi_adapter::EnumOutputs(UINT Output, IDXGIOutput** ppOutput) +{ + return wrapped_interface->EnumOutputs(Output, ppOutput); +} + +HRESULT wd::dxgi_adapter::GetDesc(DXGI_ADAPTER_DESC* pDesc) +{ + return wrapped_interface->GetDesc(pDesc); +} + +HRESULT wd::dxgi_adapter::CheckInterfaceSupport(const GUID& InterfaceName, LARGE_INTEGER* pUMDVersion) +{ + printf("WARN: dxgi_adapter::CheckInterfaceSupport is likely to fail due no support for d3d11.x!!!\n"); + return wrapped_interface->CheckInterfaceSupport(InterfaceName, pUMDVersion); +} diff --git a/dlls/d3d11_x/dxgi_adapter.h b/dlls/d3d11_x/dxgi_adapter.h new file mode 100644 index 0000000..9ea0f41 --- /dev/null +++ b/dlls/d3d11_x/dxgi_adapter.h @@ -0,0 +1,49 @@ +#pragma once +#include "dxgi_object.hpp" + +namespace wdi +{ + D3DINTERFACE(IDXGIAdapter, 2411e7e1, 12ac, 4ccf, bd, 14, 97, 98, e8, 53, 4d, c0) : public wd::dxgi_object { + public: + virtual HRESULT STDMETHODCALLTYPE EnumOutputs(UINT Output, IDXGIOutput** ppOutput) PURE; + virtual HRESULT STDMETHODCALLTYPE GetDesc(DXGI_ADAPTER_DESC* pDesc) PURE; + virtual HRESULT STDMETHODCALLTYPE CheckInterfaceSupport(REFGUID InterfaceName, LARGE_INTEGER* pUMDVersion) PURE; + }; +} + +namespace wd +{ + class dxgi_adapter : public wdi::IDXGIAdapter + { + public: + dxgi_adapter(::IDXGIAdapter* adapter) : wrapped_interface(adapter) { wrapped_interface->AddRef( ); } + + IGU_DEFINE_REF + + HRESULT QueryInterface(const IID& riid, void** ppvObject) override + { + if (riid == __uuidof(wdi::IDXGIAdapter)) + { + *ppvObject = this; + AddRef( ); + return S_OK; + } +\ + if (riid == __uuidof(wdi::IGraphicsUnwrap)) + { + *ppvObject = wrapped_interface; + return S_OK; + } + + TRACE_INTERFACE_NOT_HANDLED("dxgi_adapter"); + *ppvObject = nullptr; + return E_NOINTERFACE; + } + + HRESULT GetParent(const IID& riid, void** ppParent) override; + HRESULT EnumOutputs(UINT Output, IDXGIOutput** ppOutput) override; + HRESULT GetDesc(DXGI_ADAPTER_DESC* pDesc) override; + HRESULT CheckInterfaceSupport(const GUID& InterfaceName, LARGE_INTEGER* pUMDVersion) override; + ::IDXGIAdapter* wrapped_interface; + }; +} diff --git a/dlls/d3d11_x/dxgi_device.cpp b/dlls/d3d11_x/dxgi_device.cpp new file mode 100644 index 0000000..2307839 --- /dev/null +++ b/dlls/d3d11_x/dxgi_device.cpp @@ -0,0 +1,51 @@ +#include "dxgi_device.h" +#include "dxgi_adapter.h" + +HRESULT wd::dxgi_device::GetParent(const IID& riid, void** ppParent) +{ + HRESULT hr = wrapped_interface->GetParent(riid, ppParent); + AddRef( ); + + if (riid == __uuidof(IDXGIAdapter)) { + *ppParent = new dxgi_adapter(static_cast(*ppParent)); + } + + return hr; +} + +HRESULT wd::dxgi_device::SetPrivateData(const GUID& Name, UINT DataSize, const void* pData) +{ + return wrapped_interface->SetPrivateData(Name, DataSize, pData); +} + +HRESULT wd::dxgi_device::GetAdapter(wdi::IDXGIAdapter** pAdapter) +{ + IDXGIAdapter* adapter; + HRESULT hr = wrapped_interface->GetAdapter(&adapter); + + *pAdapter = new dxgi_adapter(adapter); + return hr; +} + +HRESULT wd::dxgi_device::CreateSurface(const DXGI_SURFACE_DESC* pDesc, UINT NumSurfaces, DXGI_USAGE Usage, + const DXGI_SHARED_RESOURCE* pSharedResource, IDXGISurface** ppSurface) +{ + return wrapped_interface->CreateSurface(pDesc, NumSurfaces, Usage, pSharedResource, ppSurface); +} + +HRESULT wd::dxgi_device::QueryResourceResidency(IGraphicsUnknown** ppResources, DXGI_RESIDENCY* pResidencyStatus, + UINT NumResources) +{ + TRACE_NOT_IMPLEMENTED("dxgi_device"); + return E_NOTIMPL; +} + +HRESULT wd::dxgi_device::SetGPUThreadPriority(INT Priority) +{ + return wrapped_interface->SetGPUThreadPriority(Priority); +} + +HRESULT wd::dxgi_device::GetGPUThreadPriority(INT* pPriority) +{ + return wrapped_interface->GetGPUThreadPriority(pPriority); +} diff --git a/dlls/d3d11_x/dxgi_device.h b/dlls/d3d11_x/dxgi_device.h new file mode 100644 index 0000000..1e88c7b --- /dev/null +++ b/dlls/d3d11_x/dxgi_device.h @@ -0,0 +1,72 @@ +#pragma once +#include "dxgi_object.hpp" + +namespace wdi +{ + class IDXGIAdapter; + D3DINTERFACE(IDXGIDevice, 54ec77fa, 1377, 44e6, 8c, 32, 88, fd, 5f, 44, c8, 4c) : public wd::dxgi_object { + public: + virtual HRESULT STDMETHODCALLTYPE GetAdapter(IDXGIAdapter** pAdapter) PURE; + virtual HRESULT STDMETHODCALLTYPE CreateSurface(const DXGI_SURFACE_DESC* pDesc, UINT NumSurfaces, DXGI_USAGE Usage, + const DXGI_SHARED_RESOURCE* pSharedResource, + _Out_writes_(NumSurfaces) IDXGISurface** ppSurface) PURE; + virtual HRESULT STDMETHODCALLTYPE QueryResourceResidency( + _In_reads_(NumResources) IGraphicsUnknown** ppResources, + _Out_writes_(NumResources) DXGI_RESIDENCY* pResidencyStatus, + /* [in] */ UINT NumResources) PURE; + virtual HRESULT STDMETHODCALLTYPE SetGPUThreadPriority( + /* [in] */ INT Priority) PURE; + virtual HRESULT STDMETHODCALLTYPE GetGPUThreadPriority( + _Out_ INT* pPriority) PURE; + }; + + D3DINTERFACE(IDXGIDeviceSubObject, 3d3e0379, f9de, 4d58, bb, 6c, 18, d6, 29, 92, f1, a6) : public wd::dxgi_object + { + virtual HRESULT STDMETHODCALLTYPE GetDevice(REFIID riid, void** ppDevice) = 0; + }; +} + +namespace wd +{ + class dxgi_device : public wdi::IDXGIDevice + { + public: + dxgi_device(::IDXGIDevice* device) : wrapped_interface(device) { wrapped_interface->AddRef( ); } + + IGU_DEFINE_REF + + HRESULT QueryInterface(const IID& riid, void** ppvObject) override + { + if (riid == __uuidof(wdi::IDXGIDevice)) + { + *ppvObject = this; + AddRef( ); + return S_OK; + } + + if (riid == __uuidof(wdi::IGraphicsUnwrap)) + { + *ppvObject = wrapped_interface; + return S_OK; + } + + TRACE_INTERFACE_NOT_HANDLED("dxgi_device"); + *ppvObject = nullptr; + return E_NOINTERFACE; + } + + HRESULT GetParent(const IID& riid, void** ppParent) override; + HRESULT SetPrivateData(const GUID& Name, UINT DataSize, const void* pData) override; + HRESULT GetAdapter(wdi::IDXGIAdapter** pAdapter) override; + HRESULT CreateSurface(const DXGI_SURFACE_DESC* pDesc, UINT NumSurfaces, DXGI_USAGE Usage, + const DXGI_SHARED_RESOURCE* pSharedResource, IDXGISurface** ppSurface) override; + HRESULT QueryResourceResidency(IGraphicsUnknown** ppResources, DXGI_RESIDENCY* pResidencyStatus, + UINT NumResources) override; + HRESULT SetGPUThreadPriority(INT Priority) override; + HRESULT GetGPUThreadPriority(INT* pPriority) override; + + ::IDXGIDevice* wrapped_interface; + }; +} + + diff --git a/dlls/d3d11_x/dxgi_factory.cpp b/dlls/d3d11_x/dxgi_factory.cpp new file mode 100644 index 0000000..2093ab6 --- /dev/null +++ b/dlls/d3d11_x/dxgi_factory.cpp @@ -0,0 +1,150 @@ +#include "dxgi_factory.h" +#include +#include +#include + +#include "dxgi_swapchain.h" +#include "../kernelx/CoreWindowWrapperX.h" + +#define DXGI_SWAPCHAIN_FLAG_MASK DXGI_SWAP_CHAIN_FLAG_NONPREROTATED | DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH | DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE \ + | DXGI_SWAP_CHAIN_FLAG_RESTRICTED_CONTENT | DXGI_SWAP_CHAIN_FLAG_RESTRICT_SHARED_RESOURCE_DRIVER | DXGI_SWAP_CHAIN_FLAG_DISPLAY_ONLY | DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT \ + | DXGI_SWAP_CHAIN_FLAG_FOREGROUND_LAYER | DXGI_SWAP_CHAIN_FLAG_FULLSCREEN_VIDEO | DXGI_SWAP_CHAIN_FLAG_YUV_VIDEO \ + | DXGI_SWAP_CHAIN_FLAG_HW_PROTECTED | DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING \ + | DXGI_SWAP_CHAIN_FLAG_RESTRICTED_TO_ALL_HOLOGRAPHIC_DISPLAYS + +HRESULT wd::dxgi_factory::GetParent(const IID& riid, void** ppParent) +{ + return wrapped_interface->GetParent(riid, ppParent); +} + +HRESULT wd::dxgi_factory::EnumAdapters1(UINT Adapter, IDXGIAdapter1** ppAdapter) +{ + return wrapped_interface->EnumAdapters1(Adapter, ppAdapter); +} + +HRESULT wd::dxgi_factory::CreateSwapChainForComposition(IGraphicsUnknown* pDevice, const DXGI_SWAP_CHAIN_DESC1* pDesc, + IDXGIOutput* pRestrictToOutput, IDXGISwapChain1** ppSwapChain) +{ + return wrapped_interface->CreateSwapChainForComposition(reinterpret_cast(pDevice), pDesc, pRestrictToOutput, ppSwapChain); +} + +HRESULT wd::dxgi_factory::CreateSwapChainForHwnd(IGraphicsUnknown* pDevice, HWND hWnd, + const DXGI_SWAP_CHAIN_DESC1* pDesc, const DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pFullscreenDesc, + IDXGIOutput* pRestrictToOutput, IDXGISwapChain1** ppSwapChain) +{ + return wrapped_interface->CreateSwapChainForHwnd(reinterpret_cast(pDevice), hWnd, pDesc, pFullscreenDesc, pRestrictToOutput, ppSwapChain); +} + +HRESULT wd::dxgi_factory::CreateSwapChainForCoreWindow(IGraphicsUnknown* pDevice, IUnknown* pWindow, + DXGI_SWAP_CHAIN_DESC1* pDesc, IDXGIOutput* pRestrictToOutput, IDXGISwapChain1** ppSwapChain) +{ + IDXGISwapChain1* swap = nullptr; + HRESULT hr; + pDesc->Flags &= DXGI_SWAPCHAIN_FLAG_MASK; + pDesc->Scaling = DXGI_SCALING_ASPECT_RATIO_STRETCH; + + IUnknown* pRealDevice = nullptr; + hr = pDevice->QueryInterface(__uuidof(wdi::IGraphicsUnwrap), (void**)&pRealDevice); + if (FAILED(hr)) + { + printf("CRITICAL: dxgi_factory::CreateSwapChainForCoreWindow -> failed to unwrap device, this is a critical leak!\n"); + return hr; + } + + if (pWindow == nullptr) + { + Microsoft::WRL::ComPtr coreWindowStatic; + RoGetActivationFactory(Microsoft::WRL::Wrappers::HStringReference(RuntimeClass_Windows_UI_Core_CoreWindow).Get( ), IID_PPV_ARGS(&coreWindowStatic)); + + Microsoft::WRL::ComPtr coreWindow; + coreWindowStatic->GetForCurrentThread(&coreWindow); + + pWindow = coreWindow.Get( ); + + hr = wrapped_interface->CreateSwapChainForCoreWindow(pRealDevice, pWindow, pDesc, pRestrictToOutput, &swap); + + *ppSwapChain = reinterpret_cast(new dxgi_swapchain(swap)); + } + else + { + hr = wrapped_interface->CreateSwapChainForCoreWindow(pRealDevice, reinterpret_cast(pWindow)->m_realWindow, pDesc, pRestrictToOutput, &swap); + *ppSwapChain = reinterpret_cast(new dxgi_swapchain(swap)); + } + + // TODO: init overlay + + return hr; +} + +HRESULT wd::dxgi_factory::GetSharedResourceAdapterLuid(HANDLE hResource, LUID* pLuid) +{ + return wrapped_interface->GetSharedResourceAdapterLuid(hResource, pLuid); +} + +HRESULT wd::dxgi_factory::RegisterStereoStatusWindow(HWND WindowHandle, UINT wMsg, DWORD* pdwCookie) +{ + return wrapped_interface->RegisterStereoStatusWindow(WindowHandle, wMsg, pdwCookie); +} + +HRESULT wd::dxgi_factory::RegisterStereoStatusEvent(HANDLE hEvent, DWORD* pdwCookie) +{ + return wrapped_interface->RegisterStereoStatusEvent(hEvent, pdwCookie); +} + +void wd::dxgi_factory::UnregisterStereoStatus(DWORD dwCookie) +{ + wrapped_interface->UnregisterStereoStatus(dwCookie); +} + +HRESULT wd::dxgi_factory::RegisterOcclusionStatusWindow(HWND WindowHandle, UINT wMsg, DWORD* pdwCookie) +{ + return wrapped_interface->RegisterOcclusionStatusWindow(WindowHandle, wMsg, pdwCookie); +} + +HRESULT wd::dxgi_factory::RegisterOcclusionStatusEvent(HANDLE hEvent, DWORD* pdwCookie) +{ + return wrapped_interface->RegisterOcclusionStatusEvent(hEvent, pdwCookie); +} + +void wd::dxgi_factory::UnregisterOcclusionStatus(DWORD dwCookie) +{ + return wrapped_interface->UnregisterOcclusionStatus(dwCookie); +} + +BOOL wd::dxgi_factory::IsCurrent() +{ + return wrapped_interface->IsCurrent( ); +} + +BOOL wd::dxgi_factory::IsWindowedStereoEnabled() +{ + return wrapped_interface->IsWindowedStereoEnabled( ); +} + +HRESULT wd::dxgi_factory::EnumAdapters(UINT Adapter, wdi::IDXGIAdapter** ppAdapter) +{ + printf("WARN: dxgi_factory::EnumAdapters does not wrap IDXGIAdapter!!!\n"); + return wrapped_interface->EnumAdapters(Adapter, reinterpret_cast(ppAdapter)); +} + +HRESULT wd::dxgi_factory::MakeWindowAssociation(HWND WindowHandle, UINT Flags) +{ + return wrapped_interface->MakeWindowAssociation(WindowHandle, Flags); +} + +HRESULT wd::dxgi_factory::GetWindowAssociation(HWND* pWindowHandle) +{ + return wrapped_interface->GetWindowAssociation(pWindowHandle); +} + +HRESULT wd::dxgi_factory::CreateSwapChain(IGraphicsUnknown* pDevice, DXGI_SWAP_CHAIN_DESC* pDesc, + IDXGISwapChain** ppSwapChain) +{ + return wrapped_interface->CreateSwapChain(reinterpret_cast(pDevice), pDesc, ppSwapChain); +} + +HRESULT wd::dxgi_factory::CreateSoftwareAdapter(HMODULE Module, wdi::IDXGIAdapter** ppAdapter) +{ + printf("WARN: dxgi_factory::CreateSoftwareAdapter does not wrap IDXGIAdapter!!!\n"); + return wrapped_interface->CreateSoftwareAdapter(Module, reinterpret_cast(ppAdapter)); +} diff --git a/dlls/d3d11_x/dxgi_factory.h b/dlls/d3d11_x/dxgi_factory.h new file mode 100644 index 0000000..cf05eb3 --- /dev/null +++ b/dlls/d3d11_x/dxgi_factory.h @@ -0,0 +1,155 @@ +#pragma once +#include "dxgi_object.hpp" + +namespace wdi +{ + class IDXGIAdapter; + D3DINTERFACE(IDXGIFactory, 7b7166ec, 21c7, 44ae, b2, 1a, c9, ae, 32, 1a, e3, 69) : public wd::dxgi_object + { + public: + IDXGIAdapter2 * m_pAdapter; + + virtual HRESULT STDMETHODCALLTYPE EnumAdapters( + UINT Adapter, + IDXGIAdapter** ppAdapter) PURE; + + virtual HRESULT STDMETHODCALLTYPE MakeWindowAssociation( + HWND WindowHandle, + UINT Flags) PURE; + + virtual HRESULT STDMETHODCALLTYPE GetWindowAssociation( + HWND* pWindowHandle) PURE; + + virtual HRESULT STDMETHODCALLTYPE CreateSwapChain( + IGraphicsUnknown* pDevice, + DXGI_SWAP_CHAIN_DESC* pDesc, + IDXGISwapChain** ppSwapChain) PURE; + + virtual HRESULT STDMETHODCALLTYPE CreateSoftwareAdapter( + HMODULE Module, + IDXGIAdapter** ppAdapter) PURE; + }; + + D3DINTERFACE(IDXGIFactory1, 770aae78, f26f, 4dba, a8, 29, 25, 3c, 83, d1, b3, 87) : public IDXGIFactory + { + public: + virtual HRESULT STDMETHODCALLTYPE EnumAdapters1( + UINT Adapter, + IDXGIAdapter1** ppAdapter) PURE; + + virtual BOOL STDMETHODCALLTYPE IsCurrent( ) PURE; + }; + + D3DINTERFACE(IDXGIFactory2, 50c83a1c, e072, 4c48, 87, b0, 36, 30, fa, 36, a6, d0) : public IDXGIFactory1 + { + public: + virtual BOOL STDMETHODCALLTYPE IsWindowedStereoEnabled(void) PURE; + + virtual HRESULT STDMETHODCALLTYPE CreateSwapChainForHwnd(IGraphicsUnknown* pDevice, + HWND hWnd, const DXGI_SWAP_CHAIN_DESC1* pDesc, + const DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pFullscreenDesc, + IDXGIOutput* pRestrictToOutput, + IDXGISwapChain1** ppSwapChain) PURE; + + virtual HRESULT STDMETHODCALLTYPE CreateSwapChainForCoreWindow( + IGraphicsUnknown* pDevice, + IUnknown* pWindow, + DXGI_SWAP_CHAIN_DESC1* pDesc, + IDXGIOutput* pRestrictToOutput, + IDXGISwapChain1** ppSwapChain) PURE; + + virtual HRESULT STDMETHODCALLTYPE GetSharedResourceAdapterLuid( + HANDLE hResource, + LUID* pLuid) PURE; + + virtual HRESULT STDMETHODCALLTYPE RegisterStereoStatusWindow( + HWND WindowHandle, + UINT wMsg, + DWORD* pdwCookie) PURE; + + virtual HRESULT STDMETHODCALLTYPE RegisterStereoStatusEvent( + HANDLE hEvent, + DWORD* pdwCookie) PURE; + + virtual void STDMETHODCALLTYPE UnregisterStereoStatus( + DWORD dwCookie) PURE; + + virtual HRESULT STDMETHODCALLTYPE RegisterOcclusionStatusWindow( + HWND WindowHandle, + UINT wMsg, + DWORD* pdwCookie) PURE; + + virtual HRESULT STDMETHODCALLTYPE RegisterOcclusionStatusEvent( + HANDLE hEvent, + DWORD* pdwCookie) PURE; + + virtual void STDMETHODCALLTYPE UnregisterOcclusionStatus( + DWORD dwCookie) PURE; + + virtual HRESULT STDMETHODCALLTYPE CreateSwapChainForComposition( + IGraphicsUnknown* pDevice, + const DXGI_SWAP_CHAIN_DESC1* pDesc, + IDXGIOutput* pRestrictToOutput, + IDXGISwapChain1** ppSwapChain) PURE; + }; +} + +namespace wd { + class dxgi_factory : public wdi::IDXGIFactory2 + { + public: + dxgi_factory(::IDXGIFactory2* factory) : wrapped_interface(factory) { wrapped_interface->AddRef( ); } + + IGU_DEFINE_REF + + HRESULT QueryInterface(const IID& riid, void** ppvObject) override + { + if (riid == __uuidof(wdi::IDXGIFactory) || riid == __uuidof(wdi::IDXGIFactory1) || + riid == __uuidof(wdi::IDXGIFactory2)) + { + *ppvObject = this; + AddRef( ); + return S_OK; + } + + if (riid == __uuidof(wdi::IGraphicsUnwrap)) + { + *ppvObject = wrapped_interface; + return S_OK; + } + + TRACE_INTERFACE_NOT_HANDLED("dxgi_factory"); + *ppvObject = nullptr; + return E_NOINTERFACE; + } + + HRESULT GetParent(const IID& riid, void** ppParent) override; + HRESULT EnumAdapters1(UINT Adapter, IDXGIAdapter1** ppAdapter) override; + HRESULT CreateSwapChainForComposition(IGraphicsUnknown* pDevice, const DXGI_SWAP_CHAIN_DESC1* pDesc, + IDXGIOutput* pRestrictToOutput, IDXGISwapChain1** ppSwapChain) override; + HRESULT CreateSwapChainForHwnd(IGraphicsUnknown* pDevice, HWND hWnd, const DXGI_SWAP_CHAIN_DESC1* pDesc, + const DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pFullscreenDesc, IDXGIOutput* pRestrictToOutput, + IDXGISwapChain1** ppSwapChain) override; + HRESULT CreateSwapChainForCoreWindow(IGraphicsUnknown* pDevice, IUnknown* pWindow, DXGI_SWAP_CHAIN_DESC1* pDesc, + IDXGIOutput* pRestrictToOutput, IDXGISwapChain1** ppSwapChain) override; + HRESULT GetSharedResourceAdapterLuid(HANDLE hResource, LUID* pLuid) override; + HRESULT RegisterStereoStatusWindow(HWND WindowHandle, UINT wMsg, DWORD* pdwCookie) override; + HRESULT RegisterStereoStatusEvent(HANDLE hEvent, DWORD* pdwCookie) override; + void UnregisterStereoStatus(DWORD dwCookie) override; + HRESULT RegisterOcclusionStatusWindow(HWND WindowHandle, UINT wMsg, DWORD* pdwCookie) override; + HRESULT RegisterOcclusionStatusEvent(HANDLE hEvent, DWORD* pdwCookie) override; + void UnregisterOcclusionStatus(DWORD dwCookie) override; + BOOL IsCurrent() override; + BOOL IsWindowedStereoEnabled() override; + HRESULT EnumAdapters(UINT Adapter, wdi::IDXGIAdapter** ppAdapter) override; + HRESULT MakeWindowAssociation(HWND WindowHandle, UINT Flags) override; + HRESULT GetWindowAssociation(HWND* pWindowHandle) override; + HRESULT CreateSwapChain(IGraphicsUnknown* pDevice, DXGI_SWAP_CHAIN_DESC* pDesc, + IDXGISwapChain** ppSwapChain) override; + HRESULT CreateSoftwareAdapter(HMODULE Module, wdi::IDXGIAdapter** ppAdapter) override; + +private: + ::IDXGIFactory2* wrapped_interface; + }; +} + diff --git a/dlls/d3d11_x/dxgi_object.cpp b/dlls/d3d11_x/dxgi_object.cpp new file mode 100644 index 0000000..242c152 --- /dev/null +++ b/dlls/d3d11_x/dxgi_object.cpp @@ -0,0 +1 @@ +#include "dxgi_object.hpp" diff --git a/dlls/d3d11_x/dxgi_object.hpp b/dlls/d3d11_x/dxgi_object.hpp new file mode 100644 index 0000000..85578d2 --- /dev/null +++ b/dlls/d3d11_x/dxgi_object.hpp @@ -0,0 +1,35 @@ +#pragma once +#include "graphics_unknown.h" + +namespace wdi +{ + D3DINTERFACE(IDXGIObject, aec22fb8, 76f3, 4639, 9b, e0, 28, eb, 43, a6, 7a, 2e) : public wd::graphics_unknown { + public: void* m_pPrivateData; + + virtual HRESULT STDMETHODCALLTYPE SetPrivateData(REFGUID Name, UINT DataSize, const void* pData) = 0; + virtual HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(REFGUID Name, const IUnknown* pUnknown) = 0; + virtual HRESULT STDMETHODCALLTYPE GetPrivateData(REFGUID Name, UINT* pDataSize, void* pData) = 0; + virtual HRESULT STDMETHODCALLTYPE GetParent(REFIID riid, void** ppParent) = 0; + }; +} + +namespace wd { + class dxgi_object : public wdi::IDXGIObject + { + public: + HRESULT SetPrivateData(const GUID& Name, UINT DataSize, const void* pData) override { + TRACE_NOT_IMPLEMENTED("dxgi_object"); + return E_NOTIMPL; + } + + HRESULT SetPrivateDataInterface(const GUID& Name, const IUnknown* pUnknown) override { + TRACE_NOT_IMPLEMENTED("dxgi_object"); + return E_NOTIMPL; + } + + HRESULT GetPrivateData(const GUID& Name, UINT* pDataSize, void* pData) override { + TRACE_NOT_IMPLEMENTED("dxgi_object"); + return E_NOTIMPL; + } + }; +} \ No newline at end of file diff --git a/dlls/d3d11_x/dxgi_swapchain.cpp b/dlls/d3d11_x/dxgi_swapchain.cpp new file mode 100644 index 0000000..37762cc --- /dev/null +++ b/dlls/d3d11_x/dxgi_swapchain.cpp @@ -0,0 +1,172 @@ +#include "dxgi_swapchain.h" + +#include "resource.hpp" + +HRESULT wd::dxgi_swapchain::QueryInterface(const IID& riid, void** ppvObject) +{ + if (riid == __uuidof(wdi::IDXGISwapChain1)) + { + *ppvObject = this; + AddRef( ); + return S_OK; + } + + if (riid == __uuidof(wdi::IGraphicsUnwrap)) + { + *ppvObject = wrapped_interface; + return S_OK; + } + + TRACE_INTERFACE_NOT_HANDLED("dxgi_swapchain"); + *ppvObject = nullptr; + return E_NOINTERFACE; +} + +HRESULT wd::dxgi_swapchain::GetParent(const IID& riid, void** ppParent) +{ + return wrapped_interface->GetParent(riid, ppParent); +} + +HRESULT wd::dxgi_swapchain::GetDevice(const IID& riid, void** ppDevice) +{ + return wrapped_interface->GetDevice(riid, ppDevice); +} + +HRESULT wd::dxgi_swapchain::Present(UINT SyncInterval, UINT Flags) +{ + return wrapped_interface->Present(SyncInterval, Flags); +} + +HRESULT wd::dxgi_swapchain::GetBuffer(UINT Buffer, const IID& riid, void** ppSurface) +{ + bool incRef = false; + + if (riid == __uuidof(ID3D11Texture1D)) + { + ID3D11Texture1D* texture1d = nullptr; + HRESULT hr = wrapped_interface->GetBuffer(Buffer, IID_PPV_ARGS(&texture1d)); + *ppSurface = new texture_1d(texture1d); + incRef = true; + } + else if (riid == __uuidof(ID3D11Texture2D)) + { + ID3D11Texture2D* texture2d = nullptr; + HRESULT hr = wrapped_interface->GetBuffer(Buffer, IID_PPV_ARGS(&texture2d)); + *ppSurface = new texture_2d(texture2d); + incRef = true; + } + else if (riid == __uuidof(ID3D11Texture3D)) + { + ID3D11Texture3D* texture3d = nullptr; + HRESULT hr = wrapped_interface->GetBuffer(Buffer, IID_PPV_ARGS(&texture3d)); + *ppSurface = new texture_3d(texture3d); + incRef = true; + } + + if (incRef) + { + AddRef( ); + return S_OK; + } + + TRACE_INTERFACE_NOT_HANDLED("dxgi_swapchain - GetBuffer"); + *ppSurface = nullptr; + return E_NOINTERFACE; +} + +HRESULT wd::dxgi_swapchain::SetFullscreenState(BOOL Fullscreen, IDXGIOutput* pTarget) +{ + return wrapped_interface->SetFullscreenState(Fullscreen, pTarget); +} + +HRESULT wd::dxgi_swapchain::GetFullscreenState(BOOL* pFullscreen, IDXGIOutput** ppTarget) +{ + return wrapped_interface->GetFullscreenState(pFullscreen, ppTarget); +} + +HRESULT wd::dxgi_swapchain::GetDesc(DXGI_SWAP_CHAIN_DESC* pDesc) +{ + return wrapped_interface->GetDesc(pDesc); +} + +HRESULT wd::dxgi_swapchain::ResizeBuffers(UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, + UINT SwapChainFlags) +{ + return wrapped_interface->ResizeBuffers(BufferCount, Width, Height, NewFormat, SwapChainFlags); +} + +HRESULT wd::dxgi_swapchain::ResizeTarget(const DXGI_MODE_DESC* pNewTargetParameters) +{ + return wrapped_interface->ResizeTarget(pNewTargetParameters); +} + +HRESULT wd::dxgi_swapchain::GetContainingOutput(IDXGIOutput** ppOutput) +{ + return wrapped_interface->GetContainingOutput(ppOutput); +} + +HRESULT wd::dxgi_swapchain::GetFrameStatistics(DXGI_FRAME_STATISTICS* pStats) +{ + return wrapped_interface->GetFrameStatistics(pStats); +} + +HRESULT wd::dxgi_swapchain::GetLastPresentCount(UINT* pLastPresentCount) +{ + return wrapped_interface->GetLastPresentCount(pLastPresentCount); +} + +HRESULT wd::dxgi_swapchain::GetDesc1(DXGI_SWAP_CHAIN_DESC1* pDesc) +{ + return wrapped_interface->GetDesc1(pDesc); +} + +HRESULT wd::dxgi_swapchain::GetFullscreenDesc(DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pDesc) +{ + return wrapped_interface->GetFullscreenDesc(pDesc); +} + +HRESULT wd::dxgi_swapchain::GetHwnd(HWND* pHwnd) +{ + return wrapped_interface->GetHwnd(pHwnd); +} + +HRESULT wd::dxgi_swapchain::GetCoreWindow(const IID& refiid, void** ppUnk) +{ + return wrapped_interface->GetCoreWindow(refiid, ppUnk); +} + +HRESULT wd::dxgi_swapchain::Present1(UINT SyncInterval, UINT PresentFlags, + const DXGI_PRESENT_PARAMETERS* pPresentParameters) +{ + return wrapped_interface->Present1(SyncInterval, PresentFlags, pPresentParameters); +} + +BOOL wd::dxgi_swapchain::IsTemporaryMonoSupported() +{ + return wrapped_interface->IsTemporaryMonoSupported( ); +} + +HRESULT wd::dxgi_swapchain::GetRestrictToOutput(IDXGIOutput** ppRestrictToOutput) +{ + return wrapped_interface->GetRestrictToOutput(ppRestrictToOutput); +} + +HRESULT wd::dxgi_swapchain::SetBackgroundColor(const DXGI_RGBA* pColor) +{ + return wrapped_interface->SetBackgroundColor(pColor); +} + +HRESULT wd::dxgi_swapchain::GetBackgroundColor(DXGI_RGBA* pColor) +{ + return wrapped_interface->GetBackgroundColor(pColor); +} + +HRESULT wd::dxgi_swapchain::SetRotation(DXGI_MODE_ROTATION Rotation) +{ + return wrapped_interface->SetRotation(Rotation); +} + +HRESULT wd::dxgi_swapchain::GetRotation(DXGI_MODE_ROTATION* pRotation) +{ + return wrapped_interface->GetRotation(pRotation); +} diff --git a/dlls/d3d11_x/dxgi_swapchain.h b/dlls/d3d11_x/dxgi_swapchain.h new file mode 100644 index 0000000..39171c2 --- /dev/null +++ b/dlls/d3d11_x/dxgi_swapchain.h @@ -0,0 +1,148 @@ +#pragma once +#include "dxgi_device.h" + +namespace wdi +{ + D3DINTERFACE(IDXGISwapChain, 310d36a0, d2e7, 4c0a, aa, 04, 6a, 9d, 23, b8, 88, 6a) : 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; + }; + + D3DINTERFACE(IDXGISwapChain1, 790a45f7, 0d42, 4876, 98, 3a, 0a, 55, cf, e6, f4, aa) : public IDXGISwapChain { + public: + virtual HRESULT STDMETHODCALLTYPE GetDesc1( + /* [annotation][out] */ + _Out_ DXGI_SWAP_CHAIN_DESC1* pDesc) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetFullscreenDesc( + /* [annotation][out] */ + _Out_ DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pDesc) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetHwnd( + /* [annotation][out] */ + _Out_ HWND* pHwnd) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetCoreWindow( + /* [annotation][in] */ + _In_ REFIID refiid, + /* [annotation][out] */ + _COM_Outptr_ void** ppUnk) = 0; + + virtual HRESULT STDMETHODCALLTYPE Present1( + /* [in] */ UINT SyncInterval, + /* [in] */ UINT PresentFlags, + /* [annotation][in] */ + _In_ const DXGI_PRESENT_PARAMETERS* pPresentParameters) = 0; + + virtual BOOL STDMETHODCALLTYPE IsTemporaryMonoSupported(void) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetRestrictToOutput( + /* [annotation][out] */ + _Out_ IDXGIOutput** ppRestrictToOutput) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetBackgroundColor( + /* [annotation][in] */ + _In_ const DXGI_RGBA* pColor) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetBackgroundColor( + /* [annotation][out] */ + _Out_ DXGI_RGBA* pColor) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetRotation( + /* [annotation][in] */ + _In_ DXGI_MODE_ROTATION Rotation) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetRotation( + /* [annotation][out] */ + _Out_ DXGI_MODE_ROTATION* pRotation) = 0; + }; +} + +namespace wd +{ + class dxgi_swapchain : public wdi::IDXGISwapChain1 + { + public: + dxgi_swapchain(::IDXGISwapChain1* swapchain) : wrapped_interface(swapchain) { wrapped_interface->AddRef( ); } + + IGU_DEFINE_REF + + HRESULT QueryInterface(const IID& riid, void** ppvObject) override; + HRESULT GetParent(const IID& riid, void** ppParent) override; + HRESULT GetDevice(const IID& riid, void** ppDevice) override; + HRESULT Present(UINT SyncInterval, UINT Flags) override; + HRESULT GetBuffer(UINT Buffer, const IID& riid, void** ppSurface) override; + HRESULT SetFullscreenState(BOOL Fullscreen, IDXGIOutput* pTarget) override; + HRESULT GetFullscreenState(BOOL* pFullscreen, IDXGIOutput** ppTarget) override; + HRESULT GetDesc(DXGI_SWAP_CHAIN_DESC* pDesc) override; + HRESULT ResizeBuffers(UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, + UINT SwapChainFlags) override; + HRESULT ResizeTarget(const DXGI_MODE_DESC* pNewTargetParameters) override; + HRESULT GetContainingOutput(IDXGIOutput** ppOutput) override; + HRESULT GetFrameStatistics(DXGI_FRAME_STATISTICS* pStats) override; + HRESULT GetLastPresentCount(UINT* pLastPresentCount) override; + HRESULT GetDesc1(DXGI_SWAP_CHAIN_DESC1* pDesc) override; + HRESULT GetFullscreenDesc(DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pDesc) override; + HRESULT GetHwnd(HWND* pHwnd) override; + HRESULT GetCoreWindow(const IID& refiid, void** ppUnk) override; + HRESULT Present1(UINT SyncInterval, UINT PresentFlags, + const DXGI_PRESENT_PARAMETERS* pPresentParameters) override; + BOOL IsTemporaryMonoSupported() override; + HRESULT GetRestrictToOutput(IDXGIOutput** ppRestrictToOutput) override; + HRESULT SetBackgroundColor(const DXGI_RGBA* pColor) override; + HRESULT GetBackgroundColor(DXGI_RGBA* pColor) override; + HRESULT SetRotation(DXGI_MODE_ROTATION Rotation) override; + HRESULT GetRotation(DXGI_MODE_ROTATION* pRotation) override; + + ::IDXGISwapChain1* wrapped_interface; + }; +} + + diff --git a/dlls/d3d11_x/framework.h b/dlls/d3d11_x/framework.h deleted file mode 100644 index 54b83e9..0000000 --- a/dlls/d3d11_x/framework.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files -#include diff --git a/dlls/d3d11_x/graphics_unknown.cpp b/dlls/d3d11_x/graphics_unknown.cpp new file mode 100644 index 0000000..31e9aa6 --- /dev/null +++ b/dlls/d3d11_x/graphics_unknown.cpp @@ -0,0 +1,2 @@ +#include "graphics_unknown.h" +// TODO: see a reason for using a cpp file for this class \ No newline at end of file diff --git a/dlls/d3d11_x/graphics_unknown.h b/dlls/d3d11_x/graphics_unknown.h new file mode 100644 index 0000000..1fc5eee --- /dev/null +++ b/dlls/d3d11_x/graphics_unknown.h @@ -0,0 +1,74 @@ +#pragma once +#include "d3d11_x.h" + +namespace wdi +{ + D3DINTERFACE(IGraphicsUnknown, aceeea63, e0a9, 4a1c, bb, ec, 71, b2, f4, 85, f7, 58) + { + public: +#if !defined(DX_VERSION) || DX_VERSION >= MAKEINTVERSION(2, 18) + ULONG m_DeviceIndex : 3; + ULONG m_PrivateDataPresent : 1; + ULONG m_Reserved : 28; +#endif + +#if !defined(DX_VERSION) || DX_VERSION >= MAKEINTVERSION(1, 1) + ULONG m_RefCount; +#endif + + virtual HRESULT QueryInterface(REFIID riid, void** ppvObject) = 0; + virtual ULONG AddRef( ) = 0; + virtual ULONG Release( ) = 0; + }; + + D3DINTERFACE(IGraphicsUnwrap, bcfaae29, e1a2, 4b9a, aa, fc, 55, b9, ff, 21, fa, 54) + { + + }; +} + +namespace wd +{ + class graphics_unknown : public wdi::IGraphicsUnknown + { + public: + graphics_unknown( ) { + m_RefCount = 1; + } + + ULONG AddRef( ) override + { + return InterlockedIncrement(&m_RefCount); + } + + ULONG Release( ) override + { + ULONG refCount = InterlockedDecrement(&m_RefCount); + if (refCount == 0) { + delete this; + } + return refCount; + } + + HRESULT QueryInterface(REFIID riid, void** ppvObject) override + { + TRACE_NOT_IMPLEMENTED("graphics_unknown"); + + if (ppvObject == nullptr) + { + return E_POINTER; + } + + if (riid == __uuidof(wdi::IGraphicsUnknown)) + { + *ppvObject = static_cast(this); + AddRef( ); + return S_OK; + } + *ppvObject = nullptr; + return E_NOINTERFACE; + } + }; +} + + diff --git a/dlls/d3d11_x/overlay/overlay.cpp b/dlls/d3d11_x/overlay/overlay.cpp index 49ff125..999d4e5 100644 --- a/dlls/d3d11_x/overlay/overlay.cpp +++ b/dlls/d3d11_x/overlay/overlay.cpp @@ -1,5 +1,5 @@ -#include "pch.h" #include "overlay.h" + #include "../../../thirdparty/imgui/imgui.h" #include "../../../thirdparty/imgui/backends/imgui_impl_dx11.h" #include "../../../thirdparty/imgui_impl_uwp.h" diff --git a/dlls/d3d11_x/overlay/overlay.h b/dlls/d3d11_x/overlay/overlay.h index d370a5f..5acdf5b 100644 --- a/dlls/d3d11_x/overlay/overlay.h +++ b/dlls/d3d11_x/overlay/overlay.h @@ -1,4 +1,6 @@ #pragma once +#include +#include namespace WinDurango { diff --git a/dlls/d3d11_x/pch.cpp b/dlls/d3d11_x/pch.cpp deleted file mode 100644 index 64b7eef..0000000 --- a/dlls/d3d11_x/pch.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// pch.cpp: source file corresponding to the pre-compiled header - -#include "pch.h" - -// When you are using pre-compiled headers, this source file is necessary for compilation to succeed. diff --git a/dlls/d3d11_x/pch.h b/dlls/d3d11_x/pch.h deleted file mode 100644 index 935a385..0000000 --- a/dlls/d3d11_x/pch.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef PCH_H -#define PCH_H - -#include - -#include "framework.h" -#include "d3d11_x.h" -#include "dxgi.h" - -#endif //PCH_H \ No newline at end of file diff --git a/dlls/d3d11_x/resource.hpp b/dlls/d3d11_x/resource.hpp new file mode 100644 index 0000000..41db9f7 --- /dev/null +++ b/dlls/d3d11_x/resource.hpp @@ -0,0 +1,435 @@ +#pragma once +#include "device_child_x.h" +#include "device_context_x.h" + +namespace wdi +{ + D3DINTERFACE(ID3D11Resource, dc8e63f3, d12b, 4952, b4, 7b, 5e, 45, 02, 6a, 86, 2d) : public ID3D11DeviceChild { + public: + virtual void STDMETHODCALLTYPE GetType( + /* [annotation] */ + _Out_ D3D11_RESOURCE_DIMENSION * pResourceDimension) PURE; + + virtual void STDMETHODCALLTYPE SetEvictionPriority( + /* [annotation] */ + _In_ UINT EvictionPriority) PURE; + + virtual UINT STDMETHODCALLTYPE GetEvictionPriority(void) PURE; + // xbox extra function + virtual void STDMETHODCALLTYPE GetDescriptor(D3D11X_DESCRIPTOR_RESOURCE* descriptor) PURE; + }; + + D3DINTERFACE(ID3D11Texture1D, f8fb5c27, c6b3, 4f75, a4, c8, 43, 9a, f2, ef, 56, 4c) : public ID3D11Resource { + public: + virtual void STDMETHODCALLTYPE GetDesc( + /* [annotation] */ + _Out_ D3D11_TEXTURE1D_DESC* pDesc) PURE; + }; + + D3DINTERFACE(ID3D11Texture2D, 6f15aaf2, d208, 4e89, 9a, b4, 48, 95, 35, d3, 4f, 9c) : public ID3D11Resource { + public: + virtual void STDMETHODCALLTYPE GetDesc( + /* [annotation] */ + _Out_ D3D11_TEXTURE2D_DESC * pDesc) PURE; + }; + + D3DINTERFACE(ID3D11Texture3D, 037e866e, f56d, 4357, a8, af, 9d, ab, be, 6e, 25, 0e) : public ID3D11Resource { + public: + virtual void STDMETHODCALLTYPE GetDesc( + /* [annotation] */ + _Out_ D3D11_TEXTURE3D_DESC* pDesc) PURE; + }; + + D3DINTERFACE(ID3D11Buffer, 48570b85, d1ee, 4fcd, a2, 50, eb, 35, 07, 22, b0, 37) : public ID3D11Resource { + public: + virtual void STDMETHODCALLTYPE GetDesc( + /* [annotation] */ + _Out_ D3D11_BUFFER_DESC* pDesc) PURE; + }; +} + +// @unixian: does this even need to be wrapped? seems like the only thing it does in the pre-rewrite code is handle GetDevice +namespace wd +{ + // this is only used for casting to other resources, as it's impossible to make a resource itself (has to be a texture or buffer) + class d3d11_resource : public wdi::ID3D11Resource + { + public: + void GetDevice(ID3D11Device** ppDevice) override + { + throw std::logic_error("Not implemented"); + } + + HRESULT GetPrivateData(const GUID& guid, UINT* pDataSize, void* pData) override + { + throw std::logic_error("Not implemented"); + } + + HRESULT SetPrivateData(const GUID& guid, UINT DataSize, const void* pData) override + { + throw std::logic_error("Not implemented"); + } + + HRESULT SetPrivateDataInterface(const GUID& guid, const IUnknown* pData) override + { + throw std::logic_error("Not implemented"); + } + + HRESULT SetPrivateDataInterfaceGraphics(const GUID& guid, const IGraphicsUnknown* pData) override + { + throw std::logic_error("Not implemented"); + } + + HRESULT SetName(LPCWSTR pName) override + { + throw std::logic_error("Not implemented"); + } + + void GetType(D3D11_RESOURCE_DIMENSION* pResourceDimension) override + { + throw std::logic_error("Not implemented"); + } + + void SetEvictionPriority(UINT EvictionPriority) override + { + throw std::logic_error("Not implemented"); + } + + UINT GetEvictionPriority() override + { + throw std::logic_error("Not implemented"); + } + + void GetDescriptor(wdi::D3D11X_DESCRIPTOR_RESOURCE* descriptor) override + { + throw std::logic_error("Not implemented"); + } + + ::ID3D11Resource* wrapped_interface; + }; + class texture_1d : public wdi::ID3D11Texture1D + { + public: + texture_1d(::ID3D11Texture1D* texture) : wrapped_interface(texture) { wrapped_interface->AddRef( ); } + + IGU_DEFINE_REF + + HRESULT QueryInterface(const IID& riid, void** ppvObject) override + { + if (riid == __uuidof(wdi::ID3D11Texture1D)) + { + *ppvObject = this; + AddRef( ); + return S_OK; + } + + TRACE_INTERFACE_NOT_HANDLED("texture_1d"); + *ppvObject = nullptr; + return E_NOINTERFACE; + } + void STDMETHODCALLTYPE GetDesc(D3D11_TEXTURE1D_DESC* pDesc) override + { + wrapped_interface->GetDesc(pDesc); + } + + void GetDevice(ID3D11Device** ppDevice) override + { + printf("WARN: texture_1d::GetDevice returns a PC device!!\n"); + wrapped_interface->GetDevice(ppDevice); + } + + HRESULT GetPrivateData(const GUID& guid, UINT* pDataSize, void* pData) override + { + return wrapped_interface->GetPrivateData(guid, pDataSize, pData); + } + + HRESULT SetPrivateData(const GUID& guid, UINT DataSize, const void* pData) override + { + return wrapped_interface->SetPrivateData(guid, DataSize, pData); + } + + HRESULT SetPrivateDataInterface(const GUID& guid, const IUnknown* pData) override + { + return wrapped_interface->SetPrivateDataInterface(guid, pData); + } + + HRESULT SetPrivateDataInterfaceGraphics(const GUID& guid, const IGraphicsUnknown* pData) override + { + TRACE_NOT_IMPLEMENTED("texture_1d"); + return E_NOTIMPL; + } + + HRESULT SetName(LPCWSTR pName) override + { + TRACE_NOT_IMPLEMENTED("texture_1d"); + return E_NOTIMPL; + } + + void GetType(D3D11_RESOURCE_DIMENSION* pResourceDimension) override + { + wrapped_interface->GetType(pResourceDimension); + } + + void SetEvictionPriority(UINT EvictionPriority) override + { + wrapped_interface->SetEvictionPriority(EvictionPriority); + } + + UINT GetEvictionPriority() override + { + return wrapped_interface->GetEvictionPriority( ); + } + + void GetDescriptor(wdi::D3D11X_DESCRIPTOR_RESOURCE* descriptor) override + { + TRACE_NOT_IMPLEMENTED("texture_1d"); + } + + ::ID3D11Texture1D* wrapped_interface; + }; + + class texture_2d : public wdi::ID3D11Texture2D + { + public: + texture_2d(::ID3D11Texture2D* texture) : wrapped_interface(texture) { wrapped_interface->AddRef( ); } + + IGU_DEFINE_REF + + HRESULT QueryInterface(const IID& riid, void** ppvObject) override + { + if (riid == __uuidof(wdi::ID3D11Texture2D)) + { + *ppvObject = this; + AddRef( ); + return S_OK; + } + + TRACE_INTERFACE_NOT_HANDLED("texture_2d"); + *ppvObject = nullptr; + return E_NOINTERFACE; + } + + void STDMETHODCALLTYPE GetDesc(D3D11_TEXTURE2D_DESC* pDesc) override + { + wrapped_interface->GetDesc(pDesc); + } + + void GetDevice(ID3D11Device** ppDevice) override + { + printf("WARN: texture_2d::GetDevice returns a PC device!!\n"); + wrapped_interface->GetDevice(ppDevice); + } + + HRESULT GetPrivateData(const GUID& guid, UINT* pDataSize, void* pData) override + { + return wrapped_interface->GetPrivateData(guid, pDataSize, pData); + } + + HRESULT SetPrivateData(const GUID& guid, UINT DataSize, const void* pData) override + { + return wrapped_interface->SetPrivateData(guid, DataSize, pData); + } + + HRESULT SetPrivateDataInterface(const GUID& guid, const IUnknown* pData) override + { + return wrapped_interface->SetPrivateDataInterface(guid, pData); + } + + HRESULT SetPrivateDataInterfaceGraphics(const GUID& guid, const IGraphicsUnknown* pData) override + { + TRACE_NOT_IMPLEMENTED("texture_2d"); + return E_NOTIMPL; + } + + HRESULT SetName(LPCWSTR pName) override + { + TRACE_NOT_IMPLEMENTED("texture_2d"); + return E_NOTIMPL; + } + + void GetType(D3D11_RESOURCE_DIMENSION* pResourceDimension) override + { + wrapped_interface->GetType(pResourceDimension); + } + + void SetEvictionPriority(UINT EvictionPriority) override + { + wrapped_interface->SetEvictionPriority(EvictionPriority); + } + + UINT GetEvictionPriority( ) override + { + return wrapped_interface->GetEvictionPriority( ); + } + + void GetDescriptor(wdi::D3D11X_DESCRIPTOR_RESOURCE* descriptor) override + { + TRACE_NOT_IMPLEMENTED("texture_2d"); + } + + ::ID3D11Texture2D* wrapped_interface; + }; + + class texture_3d : public wdi::ID3D11Texture3D + { + public: + texture_3d(::ID3D11Texture3D* texture) : wrapped_interface(texture) { wrapped_interface->AddRef( ); } + + IGU_DEFINE_REF + + HRESULT QueryInterface(const IID& riid, void** ppvObject) override + { + if (riid == __uuidof(wdi::ID3D11Texture3D)) + { + *ppvObject = this; + AddRef( ); + return S_OK; + } + + TRACE_INTERFACE_NOT_HANDLED("texture_3d"); + *ppvObject = nullptr; + return E_NOINTERFACE; + } + + void STDMETHODCALLTYPE GetDesc(D3D11_TEXTURE3D_DESC* pDesc) override + { + wrapped_interface->GetDesc(pDesc); + } + + void GetDevice(ID3D11Device** ppDevice) override + { + printf("WARN: texture_3d::GetDevice returns a PC device!!\n"); + wrapped_interface->GetDevice(ppDevice); + } + + HRESULT GetPrivateData(const GUID& guid, UINT* pDataSize, void* pData) override + { + return wrapped_interface->GetPrivateData(guid, pDataSize, pData); + } + + HRESULT SetPrivateData(const GUID& guid, UINT DataSize, const void* pData) override + { + return wrapped_interface->SetPrivateData(guid, DataSize, pData); + } + + HRESULT SetPrivateDataInterface(const GUID& guid, const IUnknown* pData) override + { + return wrapped_interface->SetPrivateDataInterface(guid, pData); + } + + HRESULT SetPrivateDataInterfaceGraphics(const GUID& guid, const IGraphicsUnknown* pData) override + { + TRACE_NOT_IMPLEMENTED("texture_3d"); + return E_NOTIMPL; + } + + HRESULT SetName(LPCWSTR pName) override + { + TRACE_NOT_IMPLEMENTED("texture_3d"); + return E_NOTIMPL; + } + + void GetType(D3D11_RESOURCE_DIMENSION* pResourceDimension) override + { + wrapped_interface->GetType(pResourceDimension); + } + + void SetEvictionPriority(UINT EvictionPriority) override + { + wrapped_interface->SetEvictionPriority(EvictionPriority); + } + + UINT GetEvictionPriority( ) override + { + return wrapped_interface->GetEvictionPriority( ); + } + + void GetDescriptor(wdi::D3D11X_DESCRIPTOR_RESOURCE* descriptor) override + { + TRACE_NOT_IMPLEMENTED("texture_3d"); + } + + ::ID3D11Texture3D* wrapped_interface; + }; + + class buffer : public wdi::ID3D11Buffer + { + public: + buffer(::ID3D11Buffer* buffer) : wrapped_interface(buffer) { wrapped_interface->AddRef( ); }\ + + IGU_DEFINE_REF + + HRESULT QueryInterface(const IID& riid, void** ppvObject) override + { + if (riid == __uuidof(wdi::ID3D11Buffer)) + { + *ppvObject = this; + AddRef( ); + return S_OK; + } + TRACE_INTERFACE_NOT_HANDLED("buffer"); + *ppvObject = nullptr; + return E_NOINTERFACE; + } + + void STDMETHODCALLTYPE GetDesc(D3D11_BUFFER_DESC* pDesc) override + { + wrapped_interface->GetDesc(pDesc); + } + + void GetDevice(ID3D11Device** ppDevice) override + { + printf("WARN: buffer::GetDevice returns a PC device!!\n"); + wrapped_interface->GetDevice(ppDevice); + } + + HRESULT GetPrivateData(const GUID& guid, UINT* pDataSize, void* pData) override + { + return wrapped_interface->GetPrivateData(guid, pDataSize, pData); + } + + HRESULT SetPrivateData(const GUID& guid, UINT DataSize, const void* pData) override + { + return wrapped_interface->SetPrivateData(guid, DataSize, pData); + } + + HRESULT SetPrivateDataInterface(const GUID& guid, const IUnknown* pData) override + { + return wrapped_interface->SetPrivateDataInterface(guid, pData); + } + + HRESULT SetPrivateDataInterfaceGraphics(const GUID& guid, const IGraphicsUnknown* pData) override + { + TRACE_NOT_IMPLEMENTED("buffer"); + return E_NOTIMPL; + } + + HRESULT SetName(LPCWSTR pName) override + { + TRACE_NOT_IMPLEMENTED("buffer"); + return E_NOTIMPL; + } + + void GetType(D3D11_RESOURCE_DIMENSION* pResourceDimension) override + { + wrapped_interface->GetType(pResourceDimension); + } + + void SetEvictionPriority(UINT EvictionPriority) override + { + wrapped_interface->SetEvictionPriority(EvictionPriority); + } + + UINT GetEvictionPriority( ) override + { + return wrapped_interface->GetEvictionPriority( ); + } + + void GetDescriptor(wdi::D3D11X_DESCRIPTOR_RESOURCE* descriptor) override + { + TRACE_NOT_IMPLEMENTED("buffer"); + } + + ::ID3D11Buffer* wrapped_interface; + }; +} \ No newline at end of file diff --git a/dlls/d3d11_x/view.hpp b/dlls/d3d11_x/view.hpp new file mode 100644 index 0000000..8bd7eb8 --- /dev/null +++ b/dlls/d3d11_x/view.hpp @@ -0,0 +1,377 @@ +#pragma once +#include +#include "device_child_x.h" +#include "resource.hpp" + +namespace wdi +{ + #define D3D11X_DESCRIPTOR_TEXTURE_VIEW_SIZE_IN_OWORDS 2 + #define D3D11X_DESCRIPTOR_TEXTURE_VIEW_SIZE_IN_QWORDS 4 + #define D3D11X_DESCRIPTOR_TEXTURE_VIEW_SIZE_IN_DWORDS 8 + #define D3D11X_DESCRIPTOR_TEXTURE_VIEW_SIZE_IN_BYTES 32 + + typedef struct D3D11X_DESCRIPTOR_TEXTURE_VIEW + { + union + { + __m128i Oword[ D3D11X_DESCRIPTOR_TEXTURE_VIEW_SIZE_IN_OWORDS ]; + UINT64 Qword[ D3D11X_DESCRIPTOR_TEXTURE_VIEW_SIZE_IN_QWORDS ]; + UINT32 Dword[ D3D11X_DESCRIPTOR_TEXTURE_VIEW_SIZE_IN_DWORDS ]; + }; + + } D3D11X_DESCRIPTOR_TEXTURE_VIEW; + + D3DINTERFACE(ID3D11View, 839d1216, bb2e, 412b, b7, f4, a9, db, eb, e0, 8e, d1) : public ID3D11DeviceChild + { + public: + ID3D11Resource* m_pResource; + unsigned int m_Type; + + virtual void STDMETHODCALLTYPE GetResource( + /* [annotation] */ + _Outptr_ ID3D11Resource** ppResource) PURE; + }; + + D3DINTERFACE(ID3D11RenderTargetView, dfdba067, 0b8d, 4865, 87, 5b, d7, b4, 51, 6c, c1, 64) : public ID3D11View + { + public: + virtual void STDMETHODCALLTYPE GetDesc( + /* [annotation] */ + _Out_ D3D11_RENDER_TARGET_VIEW_DESC* pDesc) PURE; + + }; + + D3DINTERFACE(ID3D11DepthStencilView, 9fdac92a, 1876, 48c3, af, ad, 25, b9, 4f, 84, a9, b6) : public ID3D11View + { + public: + virtual void STDMETHODCALLTYPE GetDesc( + /* [annotation] */ + _Out_ D3D11_DEPTH_STENCIL_VIEW_DESC* pDesc) PURE; + + }; + + D3DINTERFACE(ID3D11ShaderResourceView, b0e06fe0, 8192, 4e1a, b1, ca, 36, d7, 41, 47, 10, b2) : public ID3D11View + { + public: + virtual void STDMETHODCALLTYPE GetDesc( + /* [annotation] */ + _Out_ D3D11_SHADER_RESOURCE_VIEW_DESC* pDesc) PURE; + + }; + + D3DINTERFACE(ID3D11UnorderedAccessView, 28acf509, 7f5c, 48f6, 86, 11, f3, 16, 01, 0a, 63, 80) : public ID3D11View + { + public: + D3D11X_DESCRIPTOR_TEXTURE_VIEW m_Descriptor; + void* m_pAllocationStart; + + virtual void STDMETHODCALLTYPE GetDesc( + /* [annotation] */ + _Out_ D3D11_UNORDERED_ACCESS_VIEW_DESC* pDesc) PURE; + + }; +} + +namespace wd +{ + class render_target_view : public wdi::ID3D11RenderTargetView + { + public: + render_target_view(::ID3D11RenderTargetView* view) : wrapped_interface(view) + { + m_pResource = reinterpret_cast(wrapped_interface); + wrapped_interface->AddRef( ); + } + IGU_DEFINE_REF + + HRESULT QueryInterface(const IID& riid, void** ppvObject) override + { + if (riid == __uuidof(wdi::ID3D11RenderTargetView)) + { + *ppvObject = this; + AddRef( ); + return S_OK; + } + TRACE_INTERFACE_NOT_HANDLED("render_target_view"); + *ppvObject = nullptr; + return E_NOINTERFACE; + } + + void STDMETHODCALLTYPE GetDesc(D3D11_RENDER_TARGET_VIEW_DESC* pDesc) override + { + wrapped_interface->GetDesc(pDesc); + } + + void GetDevice(ID3D11Device** ppDevice) override + { + printf("WARN: render_target_view::GetDevice returns a PC device!!\n"); + wrapped_interface->GetDevice(ppDevice); + } + + HRESULT GetPrivateData(const GUID& guid, UINT* pDataSize, void* pData) override + { + return wrapped_interface->GetPrivateData(guid, pDataSize, pData); + } + + HRESULT SetPrivateData(const GUID& guid, UINT DataSize, const void* pData) override + { + return wrapped_interface->SetPrivateData(guid, DataSize, pData); + } + + HRESULT SetPrivateDataInterface(const GUID& guid, const IUnknown* pData) override + { + return wrapped_interface->SetPrivateDataInterface(guid, pData); + } + + HRESULT SetPrivateDataInterfaceGraphics(const GUID& guid, const IGraphicsUnknown* pData) override + { + TRACE_NOT_IMPLEMENTED("render_target_view"); + return E_NOTIMPL; + } + + HRESULT SetName(LPCWSTR pName) override + { + TRACE_NOT_IMPLEMENTED("render_target_view"); + return E_NOTIMPL; + } + + void GetResource(wdi::ID3D11Resource** ppResource) override + { + D3D11_RENDER_TARGET_VIEW_DESC desc; + wrapped_interface->GetDesc(&desc); + + // FIXME: this only targets 2D textures, but it doesn't matter since all texture* classes are the same + ::ID3D11Texture2D* texture2d = nullptr; + wrapped_interface->GetResource(reinterpret_cast<::ID3D11Resource**>(&texture2d)); + *reinterpret_cast(ppResource) = new texture_2d(texture2d); + } + + ::ID3D11RenderTargetView* wrapped_interface; + }; + + class depth_stencil_view : public wdi::ID3D11DepthStencilView + { + public: + depth_stencil_view(::ID3D11DepthStencilView* view) : wrapped_interface(view) + { + m_pResource = reinterpret_cast(wrapped_interface); + wrapped_interface->AddRef( ); + } + IGU_DEFINE_REF + + HRESULT QueryInterface(const IID& riid, void** ppvObject) override + { + if (riid == __uuidof(wdi::ID3D11DepthStencilView)) + { + *ppvObject = this; + AddRef( ); + return S_OK; + } + TRACE_INTERFACE_NOT_HANDLED("depth_stencil_view"); + *ppvObject = nullptr; + return E_NOINTERFACE; + } + + void STDMETHODCALLTYPE GetDesc(D3D11_DEPTH_STENCIL_VIEW_DESC* pDesc) override + { + wrapped_interface->GetDesc(pDesc); + } + + void GetDevice(ID3D11Device** ppDevice) override + { + printf("WARN: depth_stencil_view::GetDevice returns a PC device!!\n"); + wrapped_interface->GetDevice(ppDevice); + } + + HRESULT GetPrivateData(const GUID& guid, UINT* pDataSize, void* pData) override + { + return wrapped_interface->GetPrivateData(guid, pDataSize, pData); + } + + HRESULT SetPrivateData(const GUID& guid, UINT DataSize, const void* pData) override + { + return wrapped_interface->SetPrivateData(guid, DataSize, pData); + } + + HRESULT SetPrivateDataInterface(const GUID& guid, const IUnknown* pData) override + { + return wrapped_interface->SetPrivateDataInterface(guid, pData); + } + + HRESULT SetPrivateDataInterfaceGraphics(const GUID& guid, const IGraphicsUnknown* pData) override + { + TRACE_NOT_IMPLEMENTED("depth_stencil_view"); + return E_NOTIMPL; + } + + HRESULT SetName(LPCWSTR pName) override + { + TRACE_NOT_IMPLEMENTED("depth_stencil_view"); + return E_NOTIMPL; + } + + void GetResource(wdi::ID3D11Resource** ppResource) override + { + D3D11_DEPTH_STENCIL_VIEW_DESC desc; + wrapped_interface->GetDesc(&desc); + + // FIXME: this only targets 2D textures, but it doesn't matter since all texture* classes are the same + ::ID3D11Texture2D* texture2d = nullptr; + wrapped_interface->GetResource(reinterpret_cast<::ID3D11Resource**>(&texture2d)); + *reinterpret_cast(ppResource) = new texture_2d(texture2d); + } + + ::ID3D11DepthStencilView* wrapped_interface; + }; + + class shader_resource_view : public wdi::ID3D11ShaderResourceView + { + public: + shader_resource_view(::ID3D11ShaderResourceView* view) : wrapped_interface(view) + { + m_pResource = reinterpret_cast(wrapped_interface); + wrapped_interface->AddRef( ); + } + IGU_DEFINE_REF + + HRESULT QueryInterface(const IID& riid, void** ppvObject) override + { + if (riid == __uuidof(wdi::ID3D11ShaderResourceView)) + { + *ppvObject = this; + AddRef( ); + return S_OK; + } + TRACE_INTERFACE_NOT_HANDLED("shader_resource_view"); + *ppvObject = nullptr; + return E_NOINTERFACE; + } + + void STDMETHODCALLTYPE GetDesc(D3D11_SHADER_RESOURCE_VIEW_DESC* pDesc) override + { + wrapped_interface->GetDesc(pDesc); + } + + void GetDevice(ID3D11Device** ppDevice) override + { + printf("WARN: shader_resource_view::GetDevice returns a PC device!!\n"); + wrapped_interface->GetDevice(ppDevice); + } + + HRESULT GetPrivateData(const GUID& guid, UINT* pDataSize, void* pData) override + { + return wrapped_interface->GetPrivateData(guid, pDataSize, pData); + } + + HRESULT SetPrivateData(const GUID& guid, UINT DataSize, const void* pData) override + { + return wrapped_interface->SetPrivateData(guid, DataSize, pData); + } + + HRESULT SetPrivateDataInterface(const GUID& guid, const IUnknown* pData) override + { + return wrapped_interface->SetPrivateDataInterface(guid, pData); + } + + HRESULT SetPrivateDataInterfaceGraphics(const GUID& guid, const IGraphicsUnknown* pData) override + { + TRACE_NOT_IMPLEMENTED("shader_resource_view"); + return E_NOTIMPL; + } + + HRESULT SetName(LPCWSTR pName) override + { + TRACE_NOT_IMPLEMENTED("shader_resource_view"); + return E_NOTIMPL; + } + + void GetResource(wdi::ID3D11Resource** ppResource) override + { + D3D11_SHADER_RESOURCE_VIEW_DESC desc; + wrapped_interface->GetDesc(&desc); + + // FIXME: this only targets 2D textures, but it doesn't matter since all texture* classes are the same + ::ID3D11Texture2D* texture2d = nullptr; + wrapped_interface->GetResource(reinterpret_cast<::ID3D11Resource**>(&texture2d)); + *reinterpret_cast(ppResource) = new texture_2d(texture2d); + } + + ::ID3D11ShaderResourceView* wrapped_interface; + }; + + class unordered_access_view : public wdi::ID3D11UnorderedAccessView + { + public: + unordered_access_view(::ID3D11UnorderedAccessView* view) : wrapped_interface(view) + { + m_pResource = reinterpret_cast(wrapped_interface); + wrapped_interface->AddRef( ); + } + + IGU_DEFINE_REF + + HRESULT QueryInterface(const IID& riid, void** ppvObject) override + { + if (riid == __uuidof(wdi::ID3D11UnorderedAccessView)) + { + *ppvObject = this; + AddRef( ); + return S_OK; + } + TRACE_INTERFACE_NOT_HANDLED("shader_resource_view"); + *ppvObject = nullptr; + return E_NOINTERFACE; + } + + void STDMETHODCALLTYPE GetDesc(D3D11_UNORDERED_ACCESS_VIEW_DESC* pDesc) override + { + wrapped_interface->GetDesc(pDesc); + } + + void GetDevice(ID3D11Device** ppDevice) override + { + printf("WARN: depth_stencil_view::GetDevice returns a PC device!!\n"); + wrapped_interface->GetDevice(ppDevice); + } + + HRESULT GetPrivateData(const GUID& guid, UINT* pDataSize, void* pData) override + { + return wrapped_interface->GetPrivateData(guid, pDataSize, pData); + } + + HRESULT SetPrivateData(const GUID& guid, UINT DataSize, const void* pData) override + { + return wrapped_interface->SetPrivateData(guid, DataSize, pData); + } + + HRESULT SetPrivateDataInterface(const GUID& guid, const IUnknown* pData) override + { + return wrapped_interface->SetPrivateDataInterface(guid, pData); + } + + HRESULT SetPrivateDataInterfaceGraphics(const GUID& guid, const IGraphicsUnknown* pData) override + { + TRACE_NOT_IMPLEMENTED("shader_resource_view"); + return E_NOTIMPL; + } + + HRESULT SetName(LPCWSTR pName) override + { + TRACE_NOT_IMPLEMENTED("shader_resource_view"); + return E_NOTIMPL; + } + + void GetResource(wdi::ID3D11Resource** ppResource) override + { + D3D11_UNORDERED_ACCESS_VIEW_DESC desc; + wrapped_interface->GetDesc(&desc); + + // FIXME: this only targets 2D textures, but it doesn't matter since all texture* classes are the same + ::ID3D11Texture2D* texture2d = nullptr; + wrapped_interface->GetResource(reinterpret_cast<::ID3D11Resource**>(&texture2d)); + *reinterpret_cast(ppResource) = new texture_2d(texture2d); + } + + ::ID3D11UnorderedAccessView* wrapped_interface; + }; +} \ No newline at end of file diff --git a/dlls/etwplus/etwplus.vcxproj b/dlls/etwplus/etwplus.vcxproj index bee0180..139cbc4 100644 --- a/dlls/etwplus/etwplus.vcxproj +++ b/dlls/etwplus/etwplus.vcxproj @@ -69,6 +69,7 @@ Create pch.h stdcpp17 + true Windows @@ -87,6 +88,7 @@ true Use pch.h + true Windows diff --git a/dlls/kernelx/CoreApplicationWrapperX.cpp b/dlls/kernelx/CoreApplicationWrapperX.cpp index 04d395e..fb37d3d 100644 --- a/dlls/kernelx/CoreApplicationWrapperX.cpp +++ b/dlls/kernelx/CoreApplicationWrapperX.cpp @@ -116,19 +116,22 @@ HRESULT CoreApplicationWrapperX::QueryInterface(const IID& riid, void** ppvObjec AddRef(); return S_OK; } - else if (riid == __uuidof(ICoreApplicationX)) + + if (riid == __uuidof(ICoreApplicationX)) { *ppvObject = static_cast(this); AddRef(); return S_OK; } - else if (riid == __uuidof(ICoreApplicationResourceAvailabilityX)) // allow ICoreApplicationResourceAvailabilityX interface + + if (riid == __uuidof(ICoreApplicationResourceAvailabilityX)) // allow ICoreApplicationResourceAvailabilityX interface { *ppvObject = static_cast(this); AddRef(); return S_OK; } - else if (riid == __uuidof(ICoreApplicationGpuPolicy)) // allow ICoreApplicationResourceAvailabilityX interface + + if (riid == __uuidof(ICoreApplicationGpuPolicy)) // allow ICoreApplicationResourceAvailabilityX interface { *ppvObject = static_cast(this); AddRef(); diff --git a/dlls/kernelx/Exports.def b/dlls/kernelx/Exports.def index bbfc193..7728487 100644 --- a/dlls/kernelx/Exports.def +++ b/dlls/kernelx/Exports.def @@ -478,7 +478,7 @@ EXPORTS UnregisterTraceGuids = Kernel32.UnregisterTraceGuids @471 UnregisterWaitEx = Kernel32.UnregisterWaitEx @472 UpdateProcThreadAttribute = Kernel32.UpdateProcThreadAttribute @473 - VirtualAlloc = Kernel32.VirtualAlloc @474 + VirtualAlloc = VirtualAlloc_X @474 VirtualAllocEx = Kernel32.VirtualAllocEx @475 VirtualFree = Kernel32.VirtualFree @476 VirtualFreeEx = Kernel32.VirtualFreeEx @477 diff --git a/dlls/kernelx/dllmain.cpp b/dlls/kernelx/dllmain.cpp index daa9ad7..1246049 100644 --- a/dlls/kernelx/dllmain.cpp +++ b/dlls/kernelx/dllmain.cpp @@ -5,16 +5,12 @@ #include // note from unixian: i used this since using appxlauncher requires me attaching to the game after it launches -#define WINDURANGO_WAIT_FOR_DEBUGGER 0 +#define WINDURANGO_WAIT_FOR_DEBUGGER 1 //Rodrigo Todescatto: For debbuging Forza. #define RETURN_IF_FAILED(hr) if (FAILED(hr)) return hr #define FORZADEBUG -#define RETURN_HR(hr) return hr -#define RETURN_LAST_ERROR_IF(cond) if (cond) return HRESULT_FROM_WIN32(GetLastError()) - - std::vector loadedMods; inline void LoadMods() @@ -73,89 +69,6 @@ inline void UnLoadMods() FreeLibrary(mod); } } - - - - -inline HRESULT WINAPI GetActivationFactoryRedirect(PCWSTR str, REFIID riid, void** ppFactory) -{ - HRESULT hr; - HSTRING className; - HSTRING_HEADER classNameHeader; - - if (FAILED(hr = WindowsCreateStringReference(str, wcslen(str), &classNameHeader, &className))) - return hr; - - //printf("GetActivationFactoryRedirect: %S\n", str); - - hr = RoGetActivationFactory_Hook(className, riid, ppFactory); - WindowsDeleteString(className); - return hr; -} - -HRESULT XWineGetImport(_In_opt_ HMODULE Module, _In_ HMODULE ImportModule, _In_ LPCSTR Import, _Out_ PIMAGE_THUNK_DATA * pThunk) -{ - if (ImportModule == nullptr) - RETURN_HR(E_INVALIDARG); - - if (pThunk == nullptr) - RETURN_HR(E_POINTER); - - if (Module == nullptr) - Module = GetModuleHandleW(nullptr); - - auto dosHeader = (PIMAGE_DOS_HEADER)Module; - auto ntHeaders = (PIMAGE_NT_HEADERS)((PBYTE)Module + dosHeader->e_lfanew); - auto directory = &ntHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT]; - auto peImports = (PIMAGE_IMPORT_DESCRIPTOR)((PBYTE)Module + directory->VirtualAddress); - - for (size_t i = 0; peImports[i].Name; i++) - { - if (GetModuleHandleA((LPCSTR)((PBYTE)Module + peImports[i].Name)) != ImportModule) - continue; - - auto iatThunks = (PIMAGE_THUNK_DATA)((PBYTE)Module + peImports[i].FirstThunk); - auto intThunks = (PIMAGE_THUNK_DATA)((PBYTE)Module + peImports[i].OriginalFirstThunk); - - for (size_t j = 0; intThunks[j].u1.AddressOfData; j++) - { - if ((intThunks[j].u1.AddressOfData & IMAGE_ORDINAL_FLAG) != 0) - { - if (!IS_INTRESOURCE(Import)) - continue; - - if (((intThunks[j].u1.Ordinal & ~IMAGE_ORDINAL_FLAG) == (ULONG_PTR)Import)) - { - *pThunk = &iatThunks[j]; - return S_OK; - } - - continue; - } - - if (strcmp(((PIMAGE_IMPORT_BY_NAME)((PBYTE)Module + intThunks[j].u1.AddressOfData))->Name, Import)) - continue; - - *pThunk = &iatThunks[j]; - return S_OK; - } - } - - *pThunk = nullptr; - return (E_FAIL); -} - -HRESULT XWinePatchImport(_In_opt_ HMODULE Module, _In_ HMODULE ImportModule, _In_ PCSTR Import, _In_ PVOID Function) -{ - DWORD protect; - PIMAGE_THUNK_DATA pThunk; - RETURN_IF_FAILED(XWineGetImport(Module, ImportModule, Import, &pThunk)); - RETURN_LAST_ERROR_IF(!VirtualProtect(&pThunk->u1.Function, sizeof(ULONG_PTR), PAGE_READWRITE, &protect)); - pThunk->u1.Function = (ULONG_PTR)Function; - RETURN_LAST_ERROR_IF(!VirtualProtect(&pThunk->u1.Function, sizeof(ULONG_PTR), protect, &protect)); - return S_OK; -} - BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID reserved) { winrt::hstring GamePackage = winrt::Windows::ApplicationModel::Package::Current().Id().FamilyName(); @@ -227,18 +140,8 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID reserved) // games uses different vccorlib versions so just HardCoding vccorlib140 won't work // so we can just check if any of corlib modules are loaded and use that // (add more of them as we find in games) - std::array modules = { L"vccorlib140.dll", L"vccorlib110.dll", L"vccorlib120.dll" }; - HMODULE hModule = nullptr; - for (auto& module : modules) - { - hModule = GetModuleHandleW(module); - if (hModule != nullptr) - { - break; - } - } - XWinePatchImport(GetModuleHandleW(nullptr), hModule, "?GetActivationFactoryByPCWSTR@@YAJPEAXAEAVGuid@Platform@@PEAPEAX@Z", GetActivationFactoryRedirect); + XWinePatchImport(GetModuleHandleW(nullptr), GetRuntimeModule(), "?GetActivationFactoryByPCWSTR@@YAJPEAXAEAVGuid@Platform@@PEAPEAX@Z", GetActivationFactoryRedirect); DetourAttach(&reinterpret_cast(TrueOpenFile), OpenFile_Hook); DetourAttach(&reinterpret_cast(TrueCreateFileW), CreateFileW_Hook); @@ -247,6 +150,8 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID reserved) DetourAttach(&reinterpret_cast(TrueFindFirstFileW), FindFirstFileW_Hook); DetourAttach(&reinterpret_cast(TrueDeleteFileW), DeleteFileW_Hook); //DetourAttach(&reinterpret_cast(TrueLoadLibraryExW), LoadLibraryExW_Hook); + DetourAttach(&reinterpret_cast(TrueLoadLibraryW), LoadLibraryW_Hook); + DetourAttach(&reinterpret_cast(TrueLoadLibraryExA), LoadLibraryExA_Hook); DetourTransactionCommit(); diff --git a/dlls/kernelx/hooks.h b/dlls/kernelx/hooks.h index ca1865c..328816c 100644 --- a/dlls/kernelx/hooks.h +++ b/dlls/kernelx/hooks.h @@ -7,6 +7,9 @@ #include "CurrentAppWrapper.hpp" +#define RETURN_HR(hr) return hr +#define RETURN_LAST_ERROR_IF(cond) if (cond) return HRESULT_FROM_WIN32(GetLastError()) + /* This function is used to compare the class name of the classId with the classIdName. */ inline bool IsClassName(HSTRING classId, const char* classIdName) { @@ -17,6 +20,28 @@ inline bool IsClassName(HSTRING classId, const char* classIdName) return (classIdStringUTF8 == classIdName); } +HMODULE GetRuntimeModule() +{ + std::array modules = { L"vccorlib140.dll", L"vccorlib110.dll", L"vccorlib120.dll" }; + static HMODULE hModule = nullptr; + if (hModule != nullptr) + { + return hModule; + } + + for (auto& module : modules) + { + hModule = GetModuleHandleW(module); + if (hModule != nullptr) + { + break; + } + } + + return hModule; +} + +HRESULT WINAPI GetActivationFactoryRedirect(PCWSTR str, REFIID riid, void** ppFactory); /* Function pointers for the DllGetForCurrentThread */ typedef HRESULT(*DllGetForCurrentThreadFunc) (ICoreWindowStatic*, CoreWindow**); /* Function pointers for the DllGetForCurrentThread */ @@ -27,6 +52,7 @@ HRESULT(STDMETHODCALLTYPE* TrueGetForCurrentThread)(ICoreWindowStatic* staticWin typedef HRESULT(*DllGetActivationFactoryFunc) (HSTRING, IActivationFactory**); /* Function pointers for the DllGetActivationFactory */ DllGetActivationFactoryFunc pDllGetActivationFactory = nullptr; +DllGetActivationFactoryFunc pMediaDllGetActivationFactory = nullptr; /* Function pointers for the WinRT RoGetActivationFactory function. */ HRESULT(WINAPI* TrueRoGetActivationFactory)(HSTRING classId, REFIID iid, void** factory) = RoGetActivationFactory; @@ -53,6 +79,81 @@ HRESULT(STDMETHODCALLTYPE* TrueGetLicenseInformation)( ABI::Windows::ApplicationModel::Store::ILicenseInformation** value ) = nullptr; +HRESULT XWineGetImport(_In_opt_ HMODULE Module, _In_ HMODULE ImportModule, _In_ LPCSTR Import, _Out_ PIMAGE_THUNK_DATA* pThunk) +{ + if (ImportModule == nullptr) + RETURN_HR(E_INVALIDARG); + + if (pThunk == nullptr) + RETURN_HR(E_POINTER); + + if (Module == nullptr) + Module = GetModuleHandleW(nullptr); + + auto dosHeader = (PIMAGE_DOS_HEADER)Module; + auto ntHeaders = (PIMAGE_NT_HEADERS)((PBYTE)Module + dosHeader->e_lfanew); + auto directory = &ntHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT]; + + if (directory->VirtualAddress == 0) + RETURN_HR(E_FAIL); + + auto peImports = (PIMAGE_IMPORT_DESCRIPTOR)((PBYTE)Module + directory->VirtualAddress); + + for (size_t i = 0; peImports[i].Name; i++) + { + if (GetModuleHandleA((LPCSTR)((PBYTE)Module + peImports[i].Name)) != ImportModule) + continue; + + auto iatThunks = (PIMAGE_THUNK_DATA)((PBYTE)Module + peImports[i].FirstThunk); + auto intThunks = (PIMAGE_THUNK_DATA)((PBYTE)Module + peImports[i].OriginalFirstThunk); + + for (size_t j = 0; intThunks[j].u1.AddressOfData; j++) + { + if ((intThunks[j].u1.AddressOfData & IMAGE_ORDINAL_FLAG) != 0) + { + if (!IS_INTRESOURCE(Import)) + continue; + + if (((intThunks[j].u1.Ordinal & ~IMAGE_ORDINAL_FLAG) == (ULONG_PTR)Import)) + { + *pThunk = &iatThunks[j]; + return S_OK; + } + + continue; + } + + if (strcmp(((PIMAGE_IMPORT_BY_NAME)((PBYTE)Module + intThunks[j].u1.AddressOfData))->Name, Import)) + continue; + + *pThunk = &iatThunks[j]; + return S_OK; + } + } + + *pThunk = nullptr; + return (E_FAIL); +} + +HRESULT XWinePatchImport(_In_opt_ HMODULE Module, _In_ HMODULE ImportModule, _In_ PCSTR Import, _In_ PVOID Function) +{ + DWORD protect; + PIMAGE_THUNK_DATA pThunk; + RETURN_IF_FAILED(XWineGetImport(Module, ImportModule, Import, &pThunk)); + RETURN_LAST_ERROR_IF(!VirtualProtect(&pThunk->u1.Function, sizeof(ULONG_PTR), PAGE_READWRITE, &protect)); + pThunk->u1.Function = (ULONG_PTR)Function; + RETURN_LAST_ERROR_IF(!VirtualProtect(&pThunk->u1.Function, sizeof(ULONG_PTR), protect, &protect)); + return S_OK; +} + +HRESULT PatchNeededImports(_In_opt_ HMODULE Module, _In_ HMODULE ImportModule, _In_ PCSTR Import, _In_ PVOID Function) +{ + PIMAGE_THUNK_DATA pThunk; + RETURN_IF_FAILED(XWineGetImport(Module, ImportModule, Import, &pThunk)); + + return XWinePatchImport(Module, ImportModule, Import, Function); +} + HMODULE WINAPI LoadLibraryExW_X(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags) { printf("LoadLibraryExW_X: %S\n", lpLibFileName); @@ -85,8 +186,9 @@ HMODULE WINAPI LoadLibraryExW_X(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dw } } - - return LoadLibraryExW(lpLibFileName, hFile, dwFlags); + HMODULE mod = LoadLibraryExW(lpLibFileName, hFile, dwFlags); + PatchNeededImports(mod, GetRuntimeModule(), "?GetActivationFactoryByPCWSTR@@YAJPEAXAEAVGuid@Platform@@PEAPEAX@Z", GetActivationFactoryRedirect); + return mod; } @@ -146,6 +248,8 @@ HMODULE WINAPI LoadLibraryExA_Hook(LPCSTR lpLibFileName, _Reserved_ HANDLE hFile { printf("LoadLibraryExA_Hook failed: %d\n", GetLastError()); } + + PatchNeededImports(result, GetRuntimeModule(), "?GetActivationFactoryByPCWSTR@@YAJPEAXAEAVGuid@Platform@@PEAPEAX@Z", GetActivationFactoryRedirect); return result; } @@ -169,7 +273,9 @@ HMODULE WINAPI LoadLibraryW_Hook(LPCWSTR lpLibFileName) } //printf("LoadLibraryW_Hook: %ls\n", lpLibFileName); - return TrueLoadLibraryW(lpLibFileName); + HMODULE result = TrueLoadLibraryW(lpLibFileName); + PatchNeededImports(result, GetRuntimeModule(), "?GetActivationFactoryByPCWSTR@@YAJPEAXAEAVGuid@Platform@@PEAPEAX@Z", GetActivationFactoryRedirect); + return result; } HFILE WINAPI OpenFile_Hook(LPCSTR lpFileName, LPOFSTRUCT lpReOpenBuff, UINT uStyle) { @@ -276,69 +382,85 @@ inline HRESULT WINAPI RoGetActivationFactory_Hook(HSTRING classId, REFIID iid, v DetourTransactionCommit(); } - if (IsClassName(classId, "Windows.ApplicationModel.Core.CoreApplication")) - { - ComPtr realFactory; + if (IsClassName(classId, "Windows.ApplicationModel.Core.CoreApplication")) + { + ComPtr realFactory; - hr = TrueRoGetActivationFactory(HStringReference(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication).Get(), IID_PPV_ARGS(&realFactory)); + hr = TrueRoGetActivationFactory(HStringReference(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication).Get(), IID_PPV_ARGS(&realFactory)); - if (FAILED(hr)) - return hr; + if (FAILED(hr)) + return hr; - ComPtr wrappedFactory = Make(realFactory); + ComPtr wrappedFactory = Make(realFactory); - return wrappedFactory.CopyTo(iid, factory); + return wrappedFactory.CopyTo(iid, factory); + } + + if (IsClassName(classId, "Windows.UI.Core.CoreWindow")) + { + // + // for now we just hook GetForCurrentThread to get the CoreWindow but i'll change it later to + // wrap ICoreWindowStatic or as zombie said another thing that works is by hooking IFrameworkView::SetWindow + // but for now this *should* work just fine -AleBlbl + // + ComPtr coreWindowStatic; + hr = TrueRoGetActivationFactory(HStringReference(RuntimeClass_Windows_UI_Core_CoreWindow).Get(), IID_PPV_ARGS(&coreWindowStatic)); + if (FAILED(hr)) { + return hr; } - if (IsClassName(classId, "Windows.UI.Core.CoreWindow")) + if (!TrueGetForCurrentThread) { - // - // for now we just hook GetForCurrentThread to get the CoreWindow but i'll change it later to - // wrap ICoreWindowStatic or as zombie said another thing that works is by hooking IFrameworkView::SetWindow - // but for now this *should* work just fine -AleBlbl - // - ComPtr coreWindowStatic; - hr = TrueRoGetActivationFactory(HStringReference(RuntimeClass_Windows_UI_Core_CoreWindow).Get(), IID_PPV_ARGS(&coreWindowStatic)); - if (FAILED(hr)) { - return hr; - } + *reinterpret_cast(&TrueGetForCurrentThread) = (*reinterpret_cast(coreWindowStatic.Get()))[6]; - if (!TrueGetForCurrentThread) - { - *reinterpret_cast(&TrueGetForCurrentThread) = (*reinterpret_cast(coreWindowStatic.Get()))[6]; - - DetourTransactionBegin(); - DetourUpdateThread(GetCurrentThread()); - DetourAttach(&TrueGetForCurrentThread, GetForCurrentThread_Hook); - DetourTransactionCommit(); - } - - return coreWindowStatic.CopyTo(iid, factory); + DetourTransactionBegin(); + DetourUpdateThread(GetCurrentThread()); + DetourAttach(&TrueGetForCurrentThread, GetForCurrentThread_Hook); + DetourTransactionCommit(); } - // After WinDurango overrides try to load the rest + return coreWindowStatic.CopyTo(iid, factory); + } + + // After WinDurango overrides try to load the rest + + if (!pDllGetActivationFactory) + { + auto library = LoadPackagedLibrary(L"winrt_x.dll", 0); + + if (!library) library = LoadLibraryW(L"winrt_x.dll"); + + if (!library) return hr; + + pDllGetActivationFactory = reinterpret_cast + (GetProcAddress(library, "DllGetActivationFactory")); if (!pDllGetActivationFactory) - { - auto library = LoadPackagedLibrary(L"winrt_x.dll", 0); + return hr; + } - if (!library) library = LoadLibraryW(L"winrt_x.dll"); + // fallback + ComPtr fallbackFactory; + hr = pDllGetActivationFactory(classId, fallbackFactory.GetAddressOf()); - if (!library) return hr; - - pDllGetActivationFactory = reinterpret_cast - (GetProcAddress(library, "DllGetActivationFactory")); - - if (!pDllGetActivationFactory) - return hr; - } - - // fallback - ComPtr fallbackFactory; - hr = pDllGetActivationFactory(classId, fallbackFactory.GetAddressOf()); - - if (SUCCEEDED(hr)) - return fallbackFactory.CopyTo(iid, factory); + if (SUCCEEDED(hr)) + return fallbackFactory.CopyTo(iid, factory); return TrueRoGetActivationFactory(classId, iid, factory); } + +HRESULT WINAPI GetActivationFactoryRedirect(PCWSTR str, REFIID riid, void** ppFactory) +{ + HRESULT hr; + HSTRING className; + HSTRING_HEADER classNameHeader; + + if (FAILED(hr = WindowsCreateStringReference(str, wcslen(str), &classNameHeader, &className))) + return hr; + + //printf("GetActivationFactoryRedirect: %S\n", str); + + hr = RoGetActivationFactory_Hook(className, riid, ppFactory); + WindowsDeleteString(className); + return hr; +} diff --git a/dlls/kernelx/kernelx.cpp b/dlls/kernelx/kernelx.cpp index cc62f95..c791e5c 100644 --- a/dlls/kernelx/kernelx.cpp +++ b/dlls/kernelx/kernelx.cpp @@ -297,6 +297,10 @@ static decltype(&XMemFree_X) XMemFreeRoutine_X; void XMemSetAllocationHooks_X(decltype(&XMemAlloc_X) Alloc, decltype(&XMemFree_X) Free) { + if (XMemSetAllocationHooksLock_X.OwningThread == 0) { + InitializeCriticalSection(&XMemSetAllocationHooksLock_X); + } + EnterCriticalSection(&XMemSetAllocationHooksLock_X); if (Alloc) { @@ -311,219 +315,30 @@ void XMemSetAllocationHooks_X(decltype(&XMemAlloc_X) Alloc, decltype(&XMemFree_X LeaveCriticalSection(&XMemSetAllocationHooksLock_X); } -// TODO -// absolutely temporary implementation I just want to make it work -// sub_18001BCA0 -char* TblPtrs; -HANDLE hExtendedLocaleKey; -HANDLE hCustomLocaleKey; -HANDLE hLangGroupsKey; -HANDLE hAltSortsKey; -HANDLE hLocaleKey; -HANDLE hCodePageKey; -HANDLE gpACPHashN; -char* dword_18002B84C; -LPVOID P; // ?!?! ? -LPVOID P_0; // ¡!¡ ¡!?!?? -//sub_18001BB8C -int IsNlsProcessInitialized; +#define PROTECT_FLAGS_MASK (PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY | PAGE_NOACCESS | PAGE_READONLY | PAGE_READWRITE | PAGE_WRITECOPY | PAGE_GUARD | PAGE_NOCACHE) +#define ALLOCATION_FLAGS_MASK (MEM_COMMIT | MEM_RESERVE | MEM_RESET | MEM_LARGE_PAGES | MEM_PHYSICAL | MEM_TOP_DOWN | MEM_WRITE_WATCH) - -int sub_18001D528() +LPVOID VirtualAlloc_X( + LPVOID lpAddress, + SIZE_T dwSize, + DWORD flAllocationType, + DWORD flProtect +) { - //TODO - return 0; + flProtect &= PROTECT_FLAGS_MASK; + flAllocationType &= ALLOCATION_FLAGS_MASK; + + LPVOID ret = VirtualAlloc(lpAddress, dwSize, flAllocationType, flProtect); + + // backup plan in the case that VirtualAlloc fails despite the flags being masked away + if (ret == nullptr) + { + printf("VirtualAlloc failed with %i, using backup...\n", GetLastError()); + ret = VirtualAlloc(lpAddress, dwSize, MEM_COMMIT, flProtect); + } + + assert(ret != nullptr && "VirtualAlloc should not fail, check proper handling of xbox-one specific memory protection constants."); + + return ret; } - -INT16 sub_18001D768() -{ - //TODO - return 0; -} - -int sub_18001D96C(int v2, unsigned short* codePageData, unsigned int p, bool t, long l) -{ - //TODO - return 0; -} - -__int64 sub_18001BB8C() -{ - // I know it should look better if it was initalized at dllmain.cpp but then I can't fix some idiotic errors - HMODULE ntdll = LoadLibraryA("ntdll.dll"); - if (ntdll) { - NtAllocateVirtualMemory = - (NtAllocateVirtualMemory_t)GetProcAddress(ntdll, "NtAllocateVirtualMemory"); - NtFreeVirtualMemory = - (NtFreeVirtualMemory_t)GetProcAddress(ntdll, "NtFreeVirtualMemory"); - - FreeLibrary(ntdll); - } - /*unsigned int v0; // ebx - unsigned __int16* AnsiCodePageData; // rdx - int v2; // ecx - PVOID v3; // rbx - HMODULE v4; // rcx - - v0 = 0; - if (!dword_18002B84C) - { - - v0 = sub_18001D528(); - if (!v0) - { - v0 = sub_18001D768(); - if (!v0) - { - // not sure - AnsiCodePageData = (unsigned __int16*)NtCurrentTeb()->ProcessEnvironmentBlock->ProcessParameters; - v2 = AnsiCodePageData[1]; - dword_18002BF68 = v2; - v0 = sub_18001D96C(v2, AnsiCodePageData, (unsigned int)&P, 0, 0LL); - if (!v0) - { - RtlAcquireSRWLockExclusive(&unk_18002B838); - qword_18002B828 = sub_18001EB38(127LL); - if (qword_18002B828) - { - RtlReleaseSRWLockExclusive(&unk_18002B838); - qword_18002B990 = 0LL; - qword_18002B980 = 0LL; - word_18002BF64 = 1; - Event = 0LL; - dword_18002B84C = 1; - } - else - { - RtlReleaseSRWLockExclusive(&unk_18002B838); - v3 = gpACPHashN; - v4 = (HMODULE) * ((_QWORD*)gpACPHashN + 8); - if (v4) - FreeLibrary(v4); - RtlFreeHeap(NtCurrentPeb()->ProcessHeap, 0, v3); - gpACPHashN = 0LL; - return 87; - } - } - } - } - } - return v0;*/ - return 0; -} - - -// absolutely temporary implementation I just want to make it work -// decompilation from ghidra (it looks horrible lol) -NTSTATUS NlsProcessDestroy(HINSTANCE hInstance, DWORD forwardReason, LPVOID lpvReserved) -{ - char* v0; // rax - __int64 v1; // rdi - __int64 v2; // rsi - char* v3; // rbx - HMODULE v4; // rcx - char* v5; // rbp - char* v6; // rax - __int64 v7; // rdi - __int64 v8; // rsi - char* v9; // r8 - char* v10; // rbx - PVOID v11; // rbx - HMODULE v12; // rcx - NTSTATUS result; // al - - - v0 = (char*)TblPtrs; - if (TblPtrs) - { - v1 = 0LL; - v2 = 197LL; - do - { - v3 = *(char**)&v0[v1]; - if (v3) - { - do - { - v4 = (HMODULE)v3[8]; - v5 = (char*)v3[9]; - if (v4) - FreeLibrary(v4); - HeapFree(GetProcessHeap(), 0, v3); - v3 = v5; - } while (v5); - v0 = (char*)TblPtrs; - } - v1 += 8LL; - --v2; - } while (v2); - if (v0) - HeapFree(GetProcessHeap(), 0, TblPtrs); - TblPtrs = 0LL; - } - v6 = (char*)P; - v7 = 0LL; - v8 = 128LL; - do - { - v9 = *(char**)&v6[v7]; - if (v9) - { - do - { - v10 = (char*)v9[10]; - HeapFree(GetProcessHeap(), 0, v9); - v9 = v10; - } while (v10); - v6 = (char*)P; - } - v7 += 8LL; - --v8; - } while (v8); - if (v6) - HeapFree(GetProcessHeap(), 0, P); - P = 0LL; - if (P_0) - HeapFree(GetProcessHeap(), 0, P_0); - v11 = gpACPHashN; - P_0 = 0LL; - v12 = (HMODULE) * ((char*)gpACPHashN + 8); - if (v12) - FreeLibrary(v12); - result = HeapFree(GetProcessHeap(), 0, v11); - gpACPHashN = 0LL; - if (hCodePageKey) - { - result = NtClose(hCodePageKey); - hCodePageKey = 0LL; - } - if (hLocaleKey) - { - result = NtClose(hLocaleKey); - hLocaleKey = 0LL; - } - if (hAltSortsKey) - { - result = NtClose(hAltSortsKey); - hAltSortsKey = 0LL; - } - if (hLangGroupsKey) - { - result = NtClose(hLangGroupsKey); - hLangGroupsKey = 0LL; - } - if (hCustomLocaleKey) - { - result = NtClose(hCustomLocaleKey); - hCustomLocaleKey = 0LL; - } - if (hExtendedLocaleKey) - { - result = NtClose(hExtendedLocaleKey); - hExtendedLocaleKey = 0LL; - } - IsNlsProcessInitialized = 0; - return result; -} - diff --git a/dlls/kernelx/kernelx.vcxproj b/dlls/kernelx/kernelx.vcxproj index 98bef70..0f86b8b 100644 --- a/dlls/kernelx/kernelx.vcxproj +++ b/dlls/kernelx/kernelx.vcxproj @@ -63,6 +63,7 @@ Use pch.h stdcpp17 + true Windows @@ -82,6 +83,7 @@ true Use pch.h + true Windows diff --git a/dlls/kernelx/utils.h b/dlls/kernelx/utils.h index 434d7cb..25b1c6b 100644 --- a/dlls/kernelx/utils.h +++ b/dlls/kernelx/utils.h @@ -1,8 +1,9 @@ #pragma once - -#include +#define WIN32_LEAN_AND_MEAN +#include #include -#include +#include + #define FAILED(hr) (((HRESULT)(hr)) < 0) #define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0) diff --git a/dlls/mfplat/Exports.def b/dlls/mfplat/Exports.def deleted file mode 100644 index f4eae15..0000000 --- a/dlls/mfplat/Exports.def +++ /dev/null @@ -1,12 +0,0 @@ -LIBRARY mfplat -EXPORTS -MFCreateDxvaSampleRendererX = MFCreateDxvaSampleRendererX_X @34 -MFResetDXGIDeviceManagerX = MFResetDXGIDeviceManagerX_X @117 -MFCreateDXGIDeviceManager = MFCreateDXGIDeviceManager_X @32 -MFCreateAttributes = MFCreateAttributes_X @29 -MFCreateMediaType = MFCreateMediaType_X @45 -MFStartup = MFStartup_X @125 -MFShutdown = MFShutdown_X @126 -MFCreateNV12ToRGB32ConverterX = MFCreateNV12ToRGB32ConverterX_X @128 -MFCreateWaveFormatExFromMFMediaType = MFCreateWaveFormatExFromMFMediaType_X @129 -MFInitMediaTypeFromWaveFormatEx = MFInitMediaTypeFromWaveFormatEx_X @130 \ No newline at end of file diff --git a/dlls/mfplat/dllmain.cpp b/dlls/mfplat/dllmain.cpp index 821ff06..36e62ab 100644 --- a/dlls/mfplat/dllmain.cpp +++ b/dlls/mfplat/dllmain.cpp @@ -1,22 +1,460 @@ -#include "pch.h" -#include +#include +#include +// note from unixian: this proxy dll situation is temporary, but we need to use the actual functions from mfplat.dll while we're also named mfplat +#pragma region Proxy +struct mfplat_dll { + HMODULE dll; + FARPROC oCopyPropVariant; + FARPROC oCreatePropVariant; + FARPROC oCreatePropertyStore; + FARPROC oDestroyPropVariant; + FARPROC oGetAMSubtypeFromD3DFormat; + FARPROC oGetD3DFormatFromMFSubtype; + FARPROC oLFGetGlobalPool; + FARPROC oMFAddPeriodicCallback; + FARPROC oMFAllocateSerialWorkQueue; + FARPROC oMFAllocateWorkQueue; + FARPROC oMFAllocateWorkQueueEx; + FARPROC oMFAppendCollection; + FARPROC oMFAverageTimePerFrameToFrameRate; + FARPROC oMFBeginCreateFile; + FARPROC oMFBlockThread; + FARPROC oMFCalculateBitmapImageSize; + FARPROC oMFCalculateImageSize; + FARPROC oMFCancelCreateFile; + FARPROC oMFCancelWorkItem; + FARPROC oMFConvertColorInfoFromDXVA; + FARPROC oMFConvertColorInfoToDXVA; + FARPROC oMFConvertFromFP16Array; + FARPROC oMFConvertToFP16Array; + FARPROC oMFCopyImage; + FARPROC oMFCreate2DMediaBuffer; + FARPROC oMFCreateAMMediaTypeFromMFMediaType; + FARPROC oMFCreateAlignedMemoryBuffer; + FARPROC oMFCreateAsyncResult; + FARPROC oMFCreateAttributes; + FARPROC oMFCreateAudioMediaType; + FARPROC oMFCreateCollection; + FARPROC oMFCreateDXGIDeviceManager; + FARPROC oMFCreateDXGISurfaceBufferX; + FARPROC oMFCreateDxvaSampleRendererX; + FARPROC oMFCreateEventQueue; + FARPROC oMFCreateFile; + FARPROC oMFCreateFileFromHandle; + FARPROC oMFCreateLegacyMediaBufferOnMFMediaBuffer; + FARPROC oMFCreateMFByteStreamOnStream; + FARPROC oMFCreateMFVideoFormatFromMFMediaType; + FARPROC oMFCreateMediaBufferFromMediaType; + FARPROC oMFCreateMediaBufferWrapper; + FARPROC oMFCreateMediaEvent; + FARPROC oMFCreateMediaEventResult; + FARPROC oMFCreateMediaType; + FARPROC oMFCreateMediaTypeFromRepresentation; + FARPROC oMFCreateMemoryBuffer; + FARPROC oMFCreateMemoryStream; + FARPROC oMFCreateNV12ToRGB32ConverterX; + FARPROC oMFCreatePathFromURL; + FARPROC oMFCreatePresentationDescriptor; + FARPROC oMFCreateRGB32ToNV12ConverterX; + FARPROC oMFCreateSample; + FARPROC oMFCreateSourceResolver; + FARPROC oMFCreateSourceResolverInternal; + FARPROC oMFCreateStreamDescriptor; + FARPROC oMFCreateSystemTimeSource; + FARPROC oMFCreateTempFile; + FARPROC oMFCreateTrackedSample; + FARPROC oMFCreateURLFromPath; + FARPROC oMFCreateVideoMediaType; + FARPROC oMFCreateVideoMediaTypeFromBitMapInfoHeader; + FARPROC oMFCreateVideoMediaTypeFromBitMapInfoHeaderEx; + FARPROC oMFCreateVideoMediaTypeFromSubtype; + FARPROC oMFCreateVideoMediaTypeFromVideoInfoHeader; + FARPROC oMFCreateVideoMediaTypeFromVideoInfoHeader2; + FARPROC oMFCreateVideoSampleAllocatorEx; + FARPROC oMFCreateWaveFormatExFromMFMediaType; + FARPROC oMFDeserializeAttributesFromStream; + FARPROC oMFDeserializeEvent; + FARPROC oMFDeserializeMediaTypeFromStream; + FARPROC oMFDeserializePresentationDescriptor; + FARPROC oMFEndCreateFile; + FARPROC oMFFrameRateToAverageTimePerFrame; + FARPROC oMFGetAttributesAsBlob; + FARPROC oMFGetAttributesAsBlobSize; + FARPROC oMFGetConfigurationDWORD; + FARPROC oMFGetConfigurationPolicy; + FARPROC oMFGetConfigurationStore; + FARPROC oMFGetConfigurationString; + FARPROC oMFGetPlaneSize; + FARPROC oMFGetPlatform; + FARPROC oMFGetPrivateWorkqueues; + FARPROC oMFGetStrideForBitmapInfoHeader; + FARPROC oMFGetSupportedMimeTypes; + FARPROC oMFGetSupportedSchemes; + FARPROC oMFGetSystemTime; + FARPROC oMFGetTimerPeriodicity; + FARPROC oMFGetUncompressedVideoFormat; + FARPROC oMFGetWorkQueueMMCSSTaskId; + FARPROC oMFHeapAlloc; + FARPROC oMFHeapFree; + FARPROC oMFInitAMMediaTypeFromMFMediaType; + FARPROC oMFInitAttributesFromBlob; + FARPROC oMFInitMediaTypeFromAMMediaType; + FARPROC oMFInitMediaTypeFromMFVideoFormat; + FARPROC oMFInitMediaTypeFromVideoInfoHeader; + FARPROC oMFInitMediaTypeFromVideoInfoHeader2; + FARPROC oMFInitMediaTypeFromWaveFormatEx; + FARPROC oMFInitVideoFormat; + FARPROC oMFInitVideoFormat_RGB; + FARPROC oMFInvokeCallback; + FARPROC oMFJoinIoPort; + FARPROC oMFJoinWorkQueue; + FARPROC oMFLockDXGIDeviceManager; + FARPROC oMFLockPlatform; + FARPROC oMFLockSharedWorkQueue; + FARPROC oMFLockWorkQueue; + FARPROC oMFMapDX9FormatToDXGIFormat; + FARPROC oMFMapDXGIFormatToDX9Format; + FARPROC oMFPutWaitingWorkItem; + FARPROC oMFPutWorkItem; + FARPROC oMFPutWorkItem2; + FARPROC oMFPutWorkItemEx; + FARPROC oMFPutWorkItemEx2; + FARPROC oMFRemovePeriodicCallback; + FARPROC oMFResetDXGIDeviceManagerX; + FARPROC oMFScheduleWorkItem; + FARPROC oMFScheduleWorkItemEx; + FARPROC oMFSerializeAttributesToStream; + FARPROC oMFSerializeEvent; + FARPROC oMFSerializeMediaTypeToStream; + FARPROC oMFSerializePresentationDescriptor; + FARPROC oMFShutdown; + FARPROC oMFStartup; + FARPROC oMFTEnumEx; + FARPROC oMFTraceError; + FARPROC oMFTraceFuncEnter; + FARPROC oMFUnblockThread; + FARPROC oMFUnjoinWorkQueue; + FARPROC oMFUnlockDXGIDeviceManager; + FARPROC oMFUnlockPlatform; + FARPROC oMFUnlockWorkQueue; + FARPROC oMFUnwrapMediaType; + FARPROC oMFValidateMediaTypeSize; + FARPROC oMFWrapMediaType; + FARPROC oMFllMulDiv; + FARPROC oPropVariantFromStream; + FARPROC oPropVariantToStream; + FARPROC oValidateWaveFormat; +} mfplat; -BOOL APIENTRY DllMain(HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - break; +extern "C" { + FARPROC PA = 0; + int runASM(); - case DLL_PROCESS_DETACH: - break; + void fCopyPropVariant() { PA = mfplat.oCopyPropVariant; runASM(); } + void fCreatePropVariant() { PA = mfplat.oCreatePropVariant; runASM(); } + void fCreatePropertyStore() { PA = mfplat.oCreatePropertyStore; runASM(); } + void fDestroyPropVariant() { PA = mfplat.oDestroyPropVariant; runASM(); } + void fGetAMSubtypeFromD3DFormat() { PA = mfplat.oGetAMSubtypeFromD3DFormat; runASM(); } + void fGetD3DFormatFromMFSubtype() { PA = mfplat.oGetD3DFormatFromMFSubtype; runASM(); } + void fLFGetGlobalPool() { PA = mfplat.oLFGetGlobalPool; runASM(); } + void fMFAddPeriodicCallback() { PA = mfplat.oMFAddPeriodicCallback; runASM(); } + void fMFAllocateSerialWorkQueue() { PA = mfplat.oMFAllocateSerialWorkQueue; runASM(); } + void fMFAllocateWorkQueue() { PA = mfplat.oMFAllocateWorkQueue; runASM(); } + void fMFAllocateWorkQueueEx() { PA = mfplat.oMFAllocateWorkQueueEx; runASM(); } + void fMFAppendCollection() { PA = mfplat.oMFAppendCollection; runASM(); } + void fMFAverageTimePerFrameToFrameRate() { PA = mfplat.oMFAverageTimePerFrameToFrameRate; runASM(); } + void fMFBeginCreateFile() { PA = mfplat.oMFBeginCreateFile; runASM(); } + void fMFBlockThread() { PA = mfplat.oMFBlockThread; runASM(); } + void fMFCalculateBitmapImageSize() { PA = mfplat.oMFCalculateBitmapImageSize; runASM(); } + void fMFCalculateImageSize() { PA = mfplat.oMFCalculateImageSize; runASM(); } + void fMFCancelCreateFile() { PA = mfplat.oMFCancelCreateFile; runASM(); } + void fMFCancelWorkItem() { PA = mfplat.oMFCancelWorkItem; runASM(); } + void fMFConvertColorInfoFromDXVA() { PA = mfplat.oMFConvertColorInfoFromDXVA; runASM(); } + void fMFConvertColorInfoToDXVA() { PA = mfplat.oMFConvertColorInfoToDXVA; runASM(); } + void fMFConvertFromFP16Array() { PA = mfplat.oMFConvertFromFP16Array; runASM(); } + void fMFConvertToFP16Array() { PA = mfplat.oMFConvertToFP16Array; runASM(); } + void fMFCopyImage() { PA = mfplat.oMFCopyImage; runASM(); } + void fMFCreate2DMediaBuffer() { PA = mfplat.oMFCreate2DMediaBuffer; runASM(); } + void fMFCreateAMMediaTypeFromMFMediaType() { PA = mfplat.oMFCreateAMMediaTypeFromMFMediaType; runASM(); } + void fMFCreateAlignedMemoryBuffer() { PA = mfplat.oMFCreateAlignedMemoryBuffer; runASM(); } + void fMFCreateAsyncResult() { PA = mfplat.oMFCreateAsyncResult; runASM(); } + void fMFCreateAttributes() { PA = mfplat.oMFCreateAttributes; runASM(); } + void fMFCreateAudioMediaType() { PA = mfplat.oMFCreateAudioMediaType; runASM(); } + void fMFCreateCollection() { PA = mfplat.oMFCreateCollection; runASM(); } + void fMFCreateDXGIDeviceManager() { PA = mfplat.oMFCreateDXGIDeviceManager; runASM(); } + void fMFCreateDXGISurfaceBufferX() { PA = mfplat.oMFCreateDXGISurfaceBufferX; runASM(); } + void fMFCreateDxvaSampleRendererX() { PA = mfplat.oMFCreateDxvaSampleRendererX; runASM(); } + void fMFCreateEventQueue() { PA = mfplat.oMFCreateEventQueue; runASM(); } + void fMFCreateFile() { PA = mfplat.oMFCreateFile; runASM(); } + void fMFCreateFileFromHandle() { PA = mfplat.oMFCreateFileFromHandle; runASM(); } + void fMFCreateLegacyMediaBufferOnMFMediaBuffer() { PA = mfplat.oMFCreateLegacyMediaBufferOnMFMediaBuffer; runASM(); } + void fMFCreateMFByteStreamOnStream() { PA = mfplat.oMFCreateMFByteStreamOnStream; runASM(); } + void fMFCreateMFVideoFormatFromMFMediaType() { PA = mfplat.oMFCreateMFVideoFormatFromMFMediaType; runASM(); } + void fMFCreateMediaBufferFromMediaType() { PA = mfplat.oMFCreateMediaBufferFromMediaType; runASM(); } + void fMFCreateMediaBufferWrapper() { PA = mfplat.oMFCreateMediaBufferWrapper; runASM(); } + void fMFCreateMediaEvent() { PA = mfplat.oMFCreateMediaEvent; runASM(); } + void fMFCreateMediaEventResult() { PA = mfplat.oMFCreateMediaEventResult; runASM(); } + void fMFCreateMediaType() { PA = mfplat.oMFCreateMediaType; runASM(); } + void fMFCreateMediaTypeFromRepresentation() { PA = mfplat.oMFCreateMediaTypeFromRepresentation; runASM(); } + void fMFCreateMemoryBuffer() { PA = mfplat.oMFCreateMemoryBuffer; runASM(); } + void fMFCreateMemoryStream() { PA = mfplat.oMFCreateMemoryStream; runASM(); } + void fMFCreateNV12ToRGB32ConverterX() { PA = mfplat.oMFCreateNV12ToRGB32ConverterX; runASM(); } + void fMFCreatePathFromURL() { PA = mfplat.oMFCreatePathFromURL; runASM(); } + void fMFCreatePresentationDescriptor() { PA = mfplat.oMFCreatePresentationDescriptor; runASM(); } + void fMFCreateRGB32ToNV12ConverterX() { PA = mfplat.oMFCreateRGB32ToNV12ConverterX; runASM(); } + void fMFCreateSample() { PA = mfplat.oMFCreateSample; runASM(); } + void fMFCreateSourceResolver() { PA = mfplat.oMFCreateSourceResolver; runASM(); } + void fMFCreateSourceResolverInternal() { PA = mfplat.oMFCreateSourceResolverInternal; runASM(); } + void fMFCreateStreamDescriptor() { PA = mfplat.oMFCreateStreamDescriptor; runASM(); } + void fMFCreateSystemTimeSource() { PA = mfplat.oMFCreateSystemTimeSource; runASM(); } + void fMFCreateTempFile() { PA = mfplat.oMFCreateTempFile; runASM(); } + void fMFCreateTrackedSample() { PA = mfplat.oMFCreateTrackedSample; runASM(); } + void fMFCreateURLFromPath() { PA = mfplat.oMFCreateURLFromPath; runASM(); } + void fMFCreateVideoMediaType() { PA = mfplat.oMFCreateVideoMediaType; runASM(); } + void fMFCreateVideoMediaTypeFromBitMapInfoHeader() { PA = mfplat.oMFCreateVideoMediaTypeFromBitMapInfoHeader; runASM(); } + void fMFCreateVideoMediaTypeFromBitMapInfoHeaderEx() { PA = mfplat.oMFCreateVideoMediaTypeFromBitMapInfoHeaderEx; runASM(); } + void fMFCreateVideoMediaTypeFromSubtype() { PA = mfplat.oMFCreateVideoMediaTypeFromSubtype; runASM(); } + void fMFCreateVideoMediaTypeFromVideoInfoHeader() { PA = mfplat.oMFCreateVideoMediaTypeFromVideoInfoHeader; runASM(); } + void fMFCreateVideoMediaTypeFromVideoInfoHeader2() { PA = mfplat.oMFCreateVideoMediaTypeFromVideoInfoHeader2; runASM(); } + void fMFCreateVideoSampleAllocatorEx() { PA = mfplat.oMFCreateVideoSampleAllocatorEx; runASM(); } + void fMFCreateWaveFormatExFromMFMediaType() { PA = mfplat.oMFCreateWaveFormatExFromMFMediaType; runASM(); } + void fMFDeserializeAttributesFromStream() { PA = mfplat.oMFDeserializeAttributesFromStream; runASM(); } + void fMFDeserializeEvent() { PA = mfplat.oMFDeserializeEvent; runASM(); } + void fMFDeserializeMediaTypeFromStream() { PA = mfplat.oMFDeserializeMediaTypeFromStream; runASM(); } + void fMFDeserializePresentationDescriptor() { PA = mfplat.oMFDeserializePresentationDescriptor; runASM(); } + void fMFEndCreateFile() { PA = mfplat.oMFEndCreateFile; runASM(); } + void fMFFrameRateToAverageTimePerFrame() { PA = mfplat.oMFFrameRateToAverageTimePerFrame; runASM(); } + void fMFGetAttributesAsBlob() { PA = mfplat.oMFGetAttributesAsBlob; runASM(); } + void fMFGetAttributesAsBlobSize() { PA = mfplat.oMFGetAttributesAsBlobSize; runASM(); } + void fMFGetConfigurationDWORD() { PA = mfplat.oMFGetConfigurationDWORD; runASM(); } + void fMFGetConfigurationPolicy() { PA = mfplat.oMFGetConfigurationPolicy; runASM(); } + void fMFGetConfigurationStore() { PA = mfplat.oMFGetConfigurationStore; runASM(); } + void fMFGetConfigurationString() { PA = mfplat.oMFGetConfigurationString; runASM(); } + void fMFGetPlaneSize() { PA = mfplat.oMFGetPlaneSize; runASM(); } + void fMFGetPlatform() { PA = mfplat.oMFGetPlatform; runASM(); } + void fMFGetPrivateWorkqueues() { PA = mfplat.oMFGetPrivateWorkqueues; runASM(); } + void fMFGetStrideForBitmapInfoHeader() { PA = mfplat.oMFGetStrideForBitmapInfoHeader; runASM(); } + void fMFGetSupportedMimeTypes() { PA = mfplat.oMFGetSupportedMimeTypes; runASM(); } + void fMFGetSupportedSchemes() { PA = mfplat.oMFGetSupportedSchemes; runASM(); } + void fMFGetSystemTime() { PA = mfplat.oMFGetSystemTime; runASM(); } + void fMFGetTimerPeriodicity() { PA = mfplat.oMFGetTimerPeriodicity; runASM(); } + void fMFGetUncompressedVideoFormat() { PA = mfplat.oMFGetUncompressedVideoFormat; runASM(); } + void fMFGetWorkQueueMMCSSTaskId() { PA = mfplat.oMFGetWorkQueueMMCSSTaskId; runASM(); } + void fMFHeapAlloc() { PA = mfplat.oMFHeapAlloc; runASM(); } + void fMFHeapFree() { PA = mfplat.oMFHeapFree; runASM(); } + void fMFInitAMMediaTypeFromMFMediaType() { PA = mfplat.oMFInitAMMediaTypeFromMFMediaType; runASM(); } + void fMFInitAttributesFromBlob() { PA = mfplat.oMFInitAttributesFromBlob; runASM(); } + void fMFInitMediaTypeFromAMMediaType() { PA = mfplat.oMFInitMediaTypeFromAMMediaType; runASM(); } + void fMFInitMediaTypeFromMFVideoFormat() { PA = mfplat.oMFInitMediaTypeFromMFVideoFormat; runASM(); } + void fMFInitMediaTypeFromVideoInfoHeader() { PA = mfplat.oMFInitMediaTypeFromVideoInfoHeader; runASM(); } + void fMFInitMediaTypeFromVideoInfoHeader2() { PA = mfplat.oMFInitMediaTypeFromVideoInfoHeader2; runASM(); } + void fMFInitMediaTypeFromWaveFormatEx() { PA = mfplat.oMFInitMediaTypeFromWaveFormatEx; runASM(); } + void fMFInitVideoFormat() { PA = mfplat.oMFInitVideoFormat; runASM(); } + void fMFInitVideoFormat_RGB() { PA = mfplat.oMFInitVideoFormat_RGB; runASM(); } + void fMFInvokeCallback() { PA = mfplat.oMFInvokeCallback; runASM(); } + void fMFJoinIoPort() { PA = mfplat.oMFJoinIoPort; runASM(); } + void fMFJoinWorkQueue() { PA = mfplat.oMFJoinWorkQueue; runASM(); } + void fMFLockDXGIDeviceManager() { PA = mfplat.oMFLockDXGIDeviceManager; runASM(); } + void fMFLockPlatform() { PA = mfplat.oMFLockPlatform; runASM(); } + void fMFLockSharedWorkQueue() { PA = mfplat.oMFLockSharedWorkQueue; runASM(); } + void fMFLockWorkQueue() { PA = mfplat.oMFLockWorkQueue; runASM(); } + void fMFMapDX9FormatToDXGIFormat() { PA = mfplat.oMFMapDX9FormatToDXGIFormat; runASM(); } + void fMFMapDXGIFormatToDX9Format() { PA = mfplat.oMFMapDXGIFormatToDX9Format; runASM(); } + void fMFPutWaitingWorkItem() { PA = mfplat.oMFPutWaitingWorkItem; runASM(); } + void fMFPutWorkItem() { PA = mfplat.oMFPutWorkItem; runASM(); } + void fMFPutWorkItem2() { PA = mfplat.oMFPutWorkItem2; runASM(); } + void fMFPutWorkItemEx() { PA = mfplat.oMFPutWorkItemEx; runASM(); } + void fMFPutWorkItemEx2() { PA = mfplat.oMFPutWorkItemEx2; runASM(); } + void fMFRemovePeriodicCallback() { PA = mfplat.oMFRemovePeriodicCallback; runASM(); } + void fMFResetDXGIDeviceManagerX() { PA = mfplat.oMFResetDXGIDeviceManagerX; runASM(); } + void fMFScheduleWorkItem() { PA = mfplat.oMFScheduleWorkItem; runASM(); } + void fMFScheduleWorkItemEx() { PA = mfplat.oMFScheduleWorkItemEx; runASM(); } + void fMFSerializeAttributesToStream() { PA = mfplat.oMFSerializeAttributesToStream; runASM(); } + void fMFSerializeEvent() { PA = mfplat.oMFSerializeEvent; runASM(); } + void fMFSerializeMediaTypeToStream() { PA = mfplat.oMFSerializeMediaTypeToStream; runASM(); } + void fMFSerializePresentationDescriptor() { PA = mfplat.oMFSerializePresentationDescriptor; runASM(); } + void fMFShutdown() { PA = mfplat.oMFShutdown; runASM(); } - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - // Do nothing for thread-specific cases - break; - } - return TRUE; // Continue loading the DLL + HRESULT fMFStartup( ULONG Version, DWORD dwFlags ) + { + return reinterpret_cast(mfplat.oMFStartup)(MF_VERSION, dwFlags); + } + + void fMFTEnumEx() { PA = mfplat.oMFTEnumEx; runASM(); } + void fMFTraceError() { PA = mfplat.oMFTraceError; runASM(); } + void fMFTraceFuncEnter() { PA = mfplat.oMFTraceFuncEnter; runASM(); } + void fMFUnblockThread() { PA = mfplat.oMFUnblockThread; runASM(); } + void fMFUnjoinWorkQueue() { PA = mfplat.oMFUnjoinWorkQueue; runASM(); } + void fMFUnlockDXGIDeviceManager() { PA = mfplat.oMFUnlockDXGIDeviceManager; runASM(); } + void fMFUnlockPlatform() { PA = mfplat.oMFUnlockPlatform; runASM(); } + void fMFUnlockWorkQueue() { PA = mfplat.oMFUnlockWorkQueue; runASM(); } + void fMFUnwrapMediaType() { PA = mfplat.oMFUnwrapMediaType; runASM(); } + void fMFValidateMediaTypeSize() { PA = mfplat.oMFValidateMediaTypeSize; runASM(); } + void fMFWrapMediaType() { PA = mfplat.oMFWrapMediaType; runASM(); } + void fMFllMulDiv() { PA = mfplat.oMFllMulDiv; runASM(); } + void fPropVariantFromStream() { PA = mfplat.oPropVariantFromStream; runASM(); } + void fPropVariantToStream() { PA = mfplat.oPropVariantToStream; runASM(); } + void fValidateWaveFormat() { PA = mfplat.oValidateWaveFormat; runASM(); } +} + +void setupFunctions() { + mfplat.oCopyPropVariant = GetProcAddress(mfplat.dll, "CopyPropVariant"); + mfplat.oCreatePropVariant = GetProcAddress(mfplat.dll, "CreatePropVariant"); + mfplat.oCreatePropertyStore = GetProcAddress(mfplat.dll, "CreatePropertyStore"); + mfplat.oDestroyPropVariant = GetProcAddress(mfplat.dll, "DestroyPropVariant"); + mfplat.oGetAMSubtypeFromD3DFormat = GetProcAddress(mfplat.dll, "GetAMSubtypeFromD3DFormat"); + mfplat.oGetD3DFormatFromMFSubtype = GetProcAddress(mfplat.dll, "GetD3DFormatFromMFSubtype"); + mfplat.oLFGetGlobalPool = GetProcAddress(mfplat.dll, "LFGetGlobalPool"); + mfplat.oMFAddPeriodicCallback = GetProcAddress(mfplat.dll, "MFAddPeriodicCallback"); + mfplat.oMFAllocateSerialWorkQueue = GetProcAddress(mfplat.dll, "MFAllocateSerialWorkQueue"); + mfplat.oMFAllocateWorkQueue = GetProcAddress(mfplat.dll, "MFAllocateWorkQueue"); + mfplat.oMFAllocateWorkQueueEx = GetProcAddress(mfplat.dll, "MFAllocateWorkQueueEx"); + mfplat.oMFAppendCollection = GetProcAddress(mfplat.dll, "MFAppendCollection"); + mfplat.oMFAverageTimePerFrameToFrameRate = GetProcAddress(mfplat.dll, "MFAverageTimePerFrameToFrameRate"); + mfplat.oMFBeginCreateFile = GetProcAddress(mfplat.dll, "MFBeginCreateFile"); + mfplat.oMFBlockThread = GetProcAddress(mfplat.dll, "MFBlockThread"); + mfplat.oMFCalculateBitmapImageSize = GetProcAddress(mfplat.dll, "MFCalculateBitmapImageSize"); + mfplat.oMFCalculateImageSize = GetProcAddress(mfplat.dll, "MFCalculateImageSize"); + mfplat.oMFCancelCreateFile = GetProcAddress(mfplat.dll, "MFCancelCreateFile"); + mfplat.oMFCancelWorkItem = GetProcAddress(mfplat.dll, "MFCancelWorkItem"); + mfplat.oMFConvertColorInfoFromDXVA = GetProcAddress(mfplat.dll, "MFConvertColorInfoFromDXVA"); + mfplat.oMFConvertColorInfoToDXVA = GetProcAddress(mfplat.dll, "MFConvertColorInfoToDXVA"); + mfplat.oMFConvertFromFP16Array = GetProcAddress(mfplat.dll, "MFConvertFromFP16Array"); + mfplat.oMFConvertToFP16Array = GetProcAddress(mfplat.dll, "MFConvertToFP16Array"); + mfplat.oMFCopyImage = GetProcAddress(mfplat.dll, "MFCopyImage"); + mfplat.oMFCreate2DMediaBuffer = GetProcAddress(mfplat.dll, "MFCreate2DMediaBuffer"); + mfplat.oMFCreateAMMediaTypeFromMFMediaType = GetProcAddress(mfplat.dll, "MFCreateAMMediaTypeFromMFMediaType"); + mfplat.oMFCreateAlignedMemoryBuffer = GetProcAddress(mfplat.dll, "MFCreateAlignedMemoryBuffer"); + mfplat.oMFCreateAsyncResult = GetProcAddress(mfplat.dll, "MFCreateAsyncResult"); + mfplat.oMFCreateAttributes = GetProcAddress(mfplat.dll, "MFCreateAttributes"); + mfplat.oMFCreateAudioMediaType = GetProcAddress(mfplat.dll, "MFCreateAudioMediaType"); + mfplat.oMFCreateCollection = GetProcAddress(mfplat.dll, "MFCreateCollection"); + mfplat.oMFCreateDXGIDeviceManager = GetProcAddress(mfplat.dll, "MFCreateDXGIDeviceManager"); + mfplat.oMFCreateDXGISurfaceBufferX = GetProcAddress(mfplat.dll, "MFCreateDXGISurfaceBufferX"); + mfplat.oMFCreateDxvaSampleRendererX = GetProcAddress(mfplat.dll, "MFCreateDxvaSampleRendererX"); + mfplat.oMFCreateEventQueue = GetProcAddress(mfplat.dll, "MFCreateEventQueue"); + mfplat.oMFCreateFile = GetProcAddress(mfplat.dll, "MFCreateFile"); + mfplat.oMFCreateFileFromHandle = GetProcAddress(mfplat.dll, "MFCreateFileFromHandle"); + mfplat.oMFCreateLegacyMediaBufferOnMFMediaBuffer = GetProcAddress(mfplat.dll, "MFCreateLegacyMediaBufferOnMFMediaBuffer"); + mfplat.oMFCreateMFByteStreamOnStream = GetProcAddress(mfplat.dll, "MFCreateMFByteStreamOnStream"); + mfplat.oMFCreateMFVideoFormatFromMFMediaType = GetProcAddress(mfplat.dll, "MFCreateMFVideoFormatFromMFMediaType"); + mfplat.oMFCreateMediaBufferFromMediaType = GetProcAddress(mfplat.dll, "MFCreateMediaBufferFromMediaType"); + mfplat.oMFCreateMediaBufferWrapper = GetProcAddress(mfplat.dll, "MFCreateMediaBufferWrapper"); + mfplat.oMFCreateMediaEvent = GetProcAddress(mfplat.dll, "MFCreateMediaEvent"); + mfplat.oMFCreateMediaEventResult = GetProcAddress(mfplat.dll, "MFCreateMediaEventResult"); + mfplat.oMFCreateMediaType = GetProcAddress(mfplat.dll, "MFCreateMediaType"); + mfplat.oMFCreateMediaTypeFromRepresentation = GetProcAddress(mfplat.dll, "MFCreateMediaTypeFromRepresentation"); + mfplat.oMFCreateMemoryBuffer = GetProcAddress(mfplat.dll, "MFCreateMemoryBuffer"); + mfplat.oMFCreateMemoryStream = GetProcAddress(mfplat.dll, "MFCreateMemoryStream"); + mfplat.oMFCreateNV12ToRGB32ConverterX = GetProcAddress(mfplat.dll, "MFCreateNV12ToRGB32ConverterX"); + mfplat.oMFCreatePathFromURL = GetProcAddress(mfplat.dll, "MFCreatePathFromURL"); + mfplat.oMFCreatePresentationDescriptor = GetProcAddress(mfplat.dll, "MFCreatePresentationDescriptor"); + mfplat.oMFCreateRGB32ToNV12ConverterX = GetProcAddress(mfplat.dll, "MFCreateRGB32ToNV12ConverterX"); + mfplat.oMFCreateSample = GetProcAddress(mfplat.dll, "MFCreateSample"); + mfplat.oMFCreateSourceResolver = GetProcAddress(mfplat.dll, "MFCreateSourceResolver"); + mfplat.oMFCreateSourceResolverInternal = GetProcAddress(mfplat.dll, "MFCreateSourceResolverInternal"); + mfplat.oMFCreateStreamDescriptor = GetProcAddress(mfplat.dll, "MFCreateStreamDescriptor"); + mfplat.oMFCreateSystemTimeSource = GetProcAddress(mfplat.dll, "MFCreateSystemTimeSource"); + mfplat.oMFCreateTempFile = GetProcAddress(mfplat.dll, "MFCreateTempFile"); + mfplat.oMFCreateTrackedSample = GetProcAddress(mfplat.dll, "MFCreateTrackedSample"); + mfplat.oMFCreateURLFromPath = GetProcAddress(mfplat.dll, "MFCreateURLFromPath"); + mfplat.oMFCreateVideoMediaType = GetProcAddress(mfplat.dll, "MFCreateVideoMediaType"); + mfplat.oMFCreateVideoMediaTypeFromBitMapInfoHeader = GetProcAddress(mfplat.dll, "MFCreateVideoMediaTypeFromBitMapInfoHeader"); + mfplat.oMFCreateVideoMediaTypeFromBitMapInfoHeaderEx = GetProcAddress(mfplat.dll, "MFCreateVideoMediaTypeFromBitMapInfoHeaderEx"); + mfplat.oMFCreateVideoMediaTypeFromSubtype = GetProcAddress(mfplat.dll, "MFCreateVideoMediaTypeFromSubtype"); + mfplat.oMFCreateVideoMediaTypeFromVideoInfoHeader = GetProcAddress(mfplat.dll, "MFCreateVideoMediaTypeFromVideoInfoHeader"); + mfplat.oMFCreateVideoMediaTypeFromVideoInfoHeader2 = GetProcAddress(mfplat.dll, "MFCreateVideoMediaTypeFromVideoInfoHeader2"); + mfplat.oMFCreateVideoSampleAllocatorEx = GetProcAddress(mfplat.dll, "MFCreateVideoSampleAllocatorEx"); + mfplat.oMFCreateWaveFormatExFromMFMediaType = GetProcAddress(mfplat.dll, "MFCreateWaveFormatExFromMFMediaType"); + mfplat.oMFDeserializeAttributesFromStream = GetProcAddress(mfplat.dll, "MFDeserializeAttributesFromStream"); + mfplat.oMFDeserializeEvent = GetProcAddress(mfplat.dll, "MFDeserializeEvent"); + mfplat.oMFDeserializeMediaTypeFromStream = GetProcAddress(mfplat.dll, "MFDeserializeMediaTypeFromStream"); + mfplat.oMFDeserializePresentationDescriptor = GetProcAddress(mfplat.dll, "MFDeserializePresentationDescriptor"); + mfplat.oMFEndCreateFile = GetProcAddress(mfplat.dll, "MFEndCreateFile"); + mfplat.oMFFrameRateToAverageTimePerFrame = GetProcAddress(mfplat.dll, "MFFrameRateToAverageTimePerFrame"); + mfplat.oMFGetAttributesAsBlob = GetProcAddress(mfplat.dll, "MFGetAttributesAsBlob"); + mfplat.oMFGetAttributesAsBlobSize = GetProcAddress(mfplat.dll, "MFGetAttributesAsBlobSize"); + mfplat.oMFGetConfigurationDWORD = GetProcAddress(mfplat.dll, "MFGetConfigurationDWORD"); + mfplat.oMFGetConfigurationPolicy = GetProcAddress(mfplat.dll, "MFGetConfigurationPolicy"); + mfplat.oMFGetConfigurationStore = GetProcAddress(mfplat.dll, "MFGetConfigurationStore"); + mfplat.oMFGetConfigurationString = GetProcAddress(mfplat.dll, "MFGetConfigurationString"); + mfplat.oMFGetPlaneSize = GetProcAddress(mfplat.dll, "MFGetPlaneSize"); + mfplat.oMFGetPlatform = GetProcAddress(mfplat.dll, "MFGetPlatform"); + mfplat.oMFGetPrivateWorkqueues = GetProcAddress(mfplat.dll, "MFGetPrivateWorkqueues"); + mfplat.oMFGetStrideForBitmapInfoHeader = GetProcAddress(mfplat.dll, "MFGetStrideForBitmapInfoHeader"); + mfplat.oMFGetSupportedMimeTypes = GetProcAddress(mfplat.dll, "MFGetSupportedMimeTypes"); + mfplat.oMFGetSupportedSchemes = GetProcAddress(mfplat.dll, "MFGetSupportedSchemes"); + mfplat.oMFGetSystemTime = GetProcAddress(mfplat.dll, "MFGetSystemTime"); + mfplat.oMFGetTimerPeriodicity = GetProcAddress(mfplat.dll, "MFGetTimerPeriodicity"); + mfplat.oMFGetUncompressedVideoFormat = GetProcAddress(mfplat.dll, "MFGetUncompressedVideoFormat"); + mfplat.oMFGetWorkQueueMMCSSTaskId = GetProcAddress(mfplat.dll, "MFGetWorkQueueMMCSSTaskId"); + mfplat.oMFHeapAlloc = GetProcAddress(mfplat.dll, "MFHeapAlloc"); + mfplat.oMFHeapFree = GetProcAddress(mfplat.dll, "MFHeapFree"); + mfplat.oMFInitAMMediaTypeFromMFMediaType = GetProcAddress(mfplat.dll, "MFInitAMMediaTypeFromMFMediaType"); + mfplat.oMFInitAttributesFromBlob = GetProcAddress(mfplat.dll, "MFInitAttributesFromBlob"); + mfplat.oMFInitMediaTypeFromAMMediaType = GetProcAddress(mfplat.dll, "MFInitMediaTypeFromAMMediaType"); + mfplat.oMFInitMediaTypeFromMFVideoFormat = GetProcAddress(mfplat.dll, "MFInitMediaTypeFromMFVideoFormat"); + mfplat.oMFInitMediaTypeFromVideoInfoHeader = GetProcAddress(mfplat.dll, "MFInitMediaTypeFromVideoInfoHeader"); + mfplat.oMFInitMediaTypeFromVideoInfoHeader2 = GetProcAddress(mfplat.dll, "MFInitMediaTypeFromVideoInfoHeader2"); + mfplat.oMFInitMediaTypeFromWaveFormatEx = GetProcAddress(mfplat.dll, "MFInitMediaTypeFromWaveFormatEx"); + mfplat.oMFInitVideoFormat = GetProcAddress(mfplat.dll, "MFInitVideoFormat"); + mfplat.oMFInitVideoFormat_RGB = GetProcAddress(mfplat.dll, "MFInitVideoFormat_RGB"); + mfplat.oMFInvokeCallback = GetProcAddress(mfplat.dll, "MFInvokeCallback"); + mfplat.oMFJoinIoPort = GetProcAddress(mfplat.dll, "MFJoinIoPort"); + mfplat.oMFJoinWorkQueue = GetProcAddress(mfplat.dll, "MFJoinWorkQueue"); + mfplat.oMFLockDXGIDeviceManager = GetProcAddress(mfplat.dll, "MFLockDXGIDeviceManager"); + mfplat.oMFLockPlatform = GetProcAddress(mfplat.dll, "MFLockPlatform"); + mfplat.oMFLockSharedWorkQueue = GetProcAddress(mfplat.dll, "MFLockSharedWorkQueue"); + mfplat.oMFLockWorkQueue = GetProcAddress(mfplat.dll, "MFLockWorkQueue"); + mfplat.oMFMapDX9FormatToDXGIFormat = GetProcAddress(mfplat.dll, "MFMapDX9FormatToDXGIFormat"); + mfplat.oMFMapDXGIFormatToDX9Format = GetProcAddress(mfplat.dll, "MFMapDXGIFormatToDX9Format"); + mfplat.oMFPutWaitingWorkItem = GetProcAddress(mfplat.dll, "MFPutWaitingWorkItem"); + mfplat.oMFPutWorkItem = GetProcAddress(mfplat.dll, "MFPutWorkItem"); + mfplat.oMFPutWorkItem2 = GetProcAddress(mfplat.dll, "MFPutWorkItem2"); + mfplat.oMFPutWorkItemEx = GetProcAddress(mfplat.dll, "MFPutWorkItemEx"); + mfplat.oMFPutWorkItemEx2 = GetProcAddress(mfplat.dll, "MFPutWorkItemEx2"); + mfplat.oMFRemovePeriodicCallback = GetProcAddress(mfplat.dll, "MFRemovePeriodicCallback"); + mfplat.oMFResetDXGIDeviceManagerX = GetProcAddress(mfplat.dll, "MFResetDXGIDeviceManagerX"); + mfplat.oMFScheduleWorkItem = GetProcAddress(mfplat.dll, "MFScheduleWorkItem"); + mfplat.oMFScheduleWorkItemEx = GetProcAddress(mfplat.dll, "MFScheduleWorkItemEx"); + mfplat.oMFSerializeAttributesToStream = GetProcAddress(mfplat.dll, "MFSerializeAttributesToStream"); + mfplat.oMFSerializeEvent = GetProcAddress(mfplat.dll, "MFSerializeEvent"); + mfplat.oMFSerializeMediaTypeToStream = GetProcAddress(mfplat.dll, "MFSerializeMediaTypeToStream"); + mfplat.oMFSerializePresentationDescriptor = GetProcAddress(mfplat.dll, "MFSerializePresentationDescriptor"); + mfplat.oMFShutdown = GetProcAddress(mfplat.dll, "MFShutdown"); + mfplat.oMFStartup = GetProcAddress(mfplat.dll, "MFStartup"); + mfplat.oMFTEnumEx = GetProcAddress(mfplat.dll, "MFTEnumEx"); + mfplat.oMFTraceError = GetProcAddress(mfplat.dll, "MFTraceError"); + mfplat.oMFTraceFuncEnter = GetProcAddress(mfplat.dll, "MFTraceFuncEnter"); + mfplat.oMFUnblockThread = GetProcAddress(mfplat.dll, "MFUnblockThread"); + mfplat.oMFUnjoinWorkQueue = GetProcAddress(mfplat.dll, "MFUnjoinWorkQueue"); + mfplat.oMFUnlockDXGIDeviceManager = GetProcAddress(mfplat.dll, "MFUnlockDXGIDeviceManager"); + mfplat.oMFUnlockPlatform = GetProcAddress(mfplat.dll, "MFUnlockPlatform"); + mfplat.oMFUnlockWorkQueue = GetProcAddress(mfplat.dll, "MFUnlockWorkQueue"); + mfplat.oMFUnwrapMediaType = GetProcAddress(mfplat.dll, "MFUnwrapMediaType"); + mfplat.oMFValidateMediaTypeSize = GetProcAddress(mfplat.dll, "MFValidateMediaTypeSize"); + mfplat.oMFWrapMediaType = GetProcAddress(mfplat.dll, "MFWrapMediaType"); + mfplat.oMFllMulDiv = GetProcAddress(mfplat.dll, "MFllMulDiv"); + mfplat.oPropVariantFromStream = GetProcAddress(mfplat.dll, "PropVariantFromStream"); + mfplat.oPropVariantToStream = GetProcAddress(mfplat.dll, "PropVariantToStream"); + mfplat.oValidateWaveFormat = GetProcAddress(mfplat.dll, "ValidateWaveFormat"); +} +#pragma endregion + +BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { + switch (ul_reason_for_call) { + case DLL_PROCESS_ATTACH: + char path[MAX_PATH]; + GetWindowsDirectoryA(path, sizeof(path)); + + strcat_s(path, "\\System32\\mfplat.dll"); + mfplat.dll = LoadLibraryA(path); + setupFunctions(); + + break; + case DLL_PROCESS_DETACH: + FreeLibrary(mfplat.dll); + break; + } + return 1; } diff --git a/dlls/mfplat/framework.h b/dlls/mfplat/framework.h deleted file mode 100644 index 54b83e9..0000000 --- a/dlls/mfplat/framework.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files -#include diff --git a/dlls/mfplat/mfplat.asm b/dlls/mfplat/mfplat.asm new file mode 100644 index 0000000..e6b6bd3 --- /dev/null +++ b/dlls/mfplat/mfplat.asm @@ -0,0 +1,7 @@ +.data +extern PA : qword +.code +runASM proc +jmp qword ptr [PA] +runASM endp +end diff --git a/dlls/mfplat/mfplat.cpp b/dlls/mfplat/mfplat.cpp deleted file mode 100644 index 41761f6..0000000 --- a/dlls/mfplat/mfplat.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "pch.h" - -#include - -HRESULT MFCreateDxvaSampleRendererX_X(void* pDevice, void* pAttribute, void** pObject) -{ - return E_NOTIMPL; -} - -HRESULT MFCreateDXGIDeviceManager_X(UINT* resetToken, void** ppDeviceManager) -{ - return E_NOTIMPL; -} - -HRESULT MFResetDXGIDeviceManagerX_X( - void* pDeviceManager, - void* pUnkDevice, - UINT resetToken -) -{ - return E_NOTIMPL; -} - -HRESULT MFCreateAttributes_X( - void** ppMFAttributes, - UINT32 cInitialSize -) -{ - return E_NOTIMPL; -} - -HRESULT MFCreateMediaType_X( - void** ppMFType -) -{ - return E_NOTIMPL; -} - -HRESULT MFStartup_X( - ULONG Version, - DWORD dwFlags -) -{ - return E_NOTIMPL; -} - -HRESULT MFShutdown_X( ) -{ - return E_NOTIMPL; -} - -HRESULT __fastcall MFCreateNV12ToRGB32ConverterX_X(void*, void*, void*) -{ - return E_NOTIMPL; -} - -HRESULT(MFCreateWaveFormatExFromMFMediaType_X)(void* pMFType, void** ppWF, UINT32* pcbSize, UINT32 Flags) { - return E_NOTIMPL; -} - -HRESULT MFInitMediaTypeFromWaveFormatEx_X( - void* pMFType, - const WAVEFORMATEX* pWaveFormat, - UINT32 cbBufSize -) -{ - return E_NOTIMPL; -} \ No newline at end of file diff --git a/dlls/mfplat/mfplat.def b/dlls/mfplat/mfplat.def new file mode 100644 index 0000000..e821a3e --- /dev/null +++ b/dlls/mfplat/mfplat.def @@ -0,0 +1,142 @@ +LIBRARY mfplat +EXPORTS + CopyPropVariant=fCopyPropVariant @1 + CreatePropVariant=fCreatePropVariant @2 + CreatePropertyStore=fCreatePropertyStore @3 + DestroyPropVariant=fDestroyPropVariant @4 + GetAMSubtypeFromD3DFormat=fGetAMSubtypeFromD3DFormat @5 + GetD3DFormatFromMFSubtype=fGetD3DFormatFromMFSubtype @6 + LFGetGlobalPool=fLFGetGlobalPool @7 + MFAddPeriodicCallback=fMFAddPeriodicCallback @8 + MFAllocateSerialWorkQueue=fMFAllocateSerialWorkQueue @9 + MFAllocateWorkQueue=fMFAllocateWorkQueue @10 + MFAllocateWorkQueueEx=fMFAllocateWorkQueueEx @11 + MFAppendCollection=fMFAppendCollection @12 + MFAverageTimePerFrameToFrameRate=fMFAverageTimePerFrameToFrameRate @13 + MFBeginCreateFile=fMFBeginCreateFile @14 + MFBlockThread=fMFBlockThread @15 + MFCalculateBitmapImageSize=fMFCalculateBitmapImageSize @16 + MFCalculateImageSize=fMFCalculateImageSize @17 + MFCancelCreateFile=fMFCancelCreateFile @18 + MFCancelWorkItem=fMFCancelWorkItem @19 + MFConvertColorInfoFromDXVA=fMFConvertColorInfoFromDXVA @20 + MFConvertColorInfoToDXVA=fMFConvertColorInfoToDXVA @21 + MFConvertFromFP16Array=fMFConvertFromFP16Array @22 + MFConvertToFP16Array=fMFConvertToFP16Array @23 + MFCopyImage=fMFCopyImage @24 + MFCreate2DMediaBuffer=fMFCreate2DMediaBuffer @25 + MFCreateAMMediaTypeFromMFMediaType=fMFCreateAMMediaTypeFromMFMediaType @26 + MFCreateAlignedMemoryBuffer=fMFCreateAlignedMemoryBuffer @27 + MFCreateAsyncResult=fMFCreateAsyncResult @28 + MFCreateAttributes=fMFCreateAttributes @29 + MFCreateAudioMediaType=fMFCreateAudioMediaType @30 + MFCreateCollection=fMFCreateCollection @31 + MFCreateDXGIDeviceManager=fMFCreateDXGIDeviceManager @32 + MFCreateDXGISurfaceBufferX=fMFCreateDXGISurfaceBufferX @33 + MFCreateDxvaSampleRendererX=fMFCreateDxvaSampleRendererX @34 + MFCreateEventQueue=fMFCreateEventQueue @35 + MFCreateFile=fMFCreateFile @36 + MFCreateFileFromHandle=fMFCreateFileFromHandle @37 + MFCreateLegacyMediaBufferOnMFMediaBuffer=fMFCreateLegacyMediaBufferOnMFMediaBuffer @38 + MFCreateMFByteStreamOnStream=fMFCreateMFByteStreamOnStream @39 + MFCreateMFVideoFormatFromMFMediaType=fMFCreateMFVideoFormatFromMFMediaType @40 + MFCreateMediaBufferFromMediaType=fMFCreateMediaBufferFromMediaType @41 + MFCreateMediaBufferWrapper=fMFCreateMediaBufferWrapper @42 + MFCreateMediaEvent=fMFCreateMediaEvent @43 + MFCreateMediaEventResult=fMFCreateMediaEventResult @44 + MFCreateMediaType=fMFCreateMediaType @45 + MFCreateMediaTypeFromRepresentation=fMFCreateMediaTypeFromRepresentation @46 + MFCreateMemoryBuffer=fMFCreateMemoryBuffer @47 + MFCreateMemoryStream=fMFCreateMemoryStream @48 + MFCreateNV12ToRGB32ConverterX=fMFCreateNV12ToRGB32ConverterX @49 + MFCreatePathFromURL=fMFCreatePathFromURL @50 + MFCreatePresentationDescriptor=fMFCreatePresentationDescriptor @51 + MFCreateRGB32ToNV12ConverterX=fMFCreateRGB32ToNV12ConverterX @52 + MFCreateSample=fMFCreateSample @53 + MFCreateSourceResolver=fMFCreateSourceResolver @54 + MFCreateSourceResolverInternal=fMFCreateSourceResolverInternal @55 + MFCreateStreamDescriptor=fMFCreateStreamDescriptor @56 + MFCreateSystemTimeSource=fMFCreateSystemTimeSource @57 + MFCreateTempFile=fMFCreateTempFile @58 + MFCreateTrackedSample=fMFCreateTrackedSample @59 + MFCreateURLFromPath=fMFCreateURLFromPath @60 + MFCreateVideoMediaType=fMFCreateVideoMediaType @61 + MFCreateVideoMediaTypeFromBitMapInfoHeader=fMFCreateVideoMediaTypeFromBitMapInfoHeader @62 + MFCreateVideoMediaTypeFromBitMapInfoHeaderEx=fMFCreateVideoMediaTypeFromBitMapInfoHeaderEx @63 + MFCreateVideoMediaTypeFromSubtype=fMFCreateVideoMediaTypeFromSubtype @64 + MFCreateVideoMediaTypeFromVideoInfoHeader=fMFCreateVideoMediaTypeFromVideoInfoHeader @65 + MFCreateVideoMediaTypeFromVideoInfoHeader2=fMFCreateVideoMediaTypeFromVideoInfoHeader2 @66 + MFCreateVideoSampleAllocatorEx=fMFCreateVideoSampleAllocatorEx @67 + MFCreateWaveFormatExFromMFMediaType=fMFCreateWaveFormatExFromMFMediaType @68 + MFDeserializeAttributesFromStream=fMFDeserializeAttributesFromStream @69 + MFDeserializeEvent=fMFDeserializeEvent @70 + MFDeserializeMediaTypeFromStream=fMFDeserializeMediaTypeFromStream @71 + MFDeserializePresentationDescriptor=fMFDeserializePresentationDescriptor @72 + MFEndCreateFile=fMFEndCreateFile @73 + MFFrameRateToAverageTimePerFrame=fMFFrameRateToAverageTimePerFrame @74 + MFGetAttributesAsBlob=fMFGetAttributesAsBlob @75 + MFGetAttributesAsBlobSize=fMFGetAttributesAsBlobSize @76 + MFGetConfigurationDWORD=fMFGetConfigurationDWORD @77 + MFGetConfigurationPolicy=fMFGetConfigurationPolicy @78 + MFGetConfigurationStore=fMFGetConfigurationStore @79 + MFGetConfigurationString=fMFGetConfigurationString @80 + MFGetPlaneSize=fMFGetPlaneSize @81 + MFGetPlatform=fMFGetPlatform @82 + MFGetPrivateWorkqueues=fMFGetPrivateWorkqueues @83 + MFGetStrideForBitmapInfoHeader=fMFGetStrideForBitmapInfoHeader @84 + MFGetSupportedMimeTypes=fMFGetSupportedMimeTypes @85 + MFGetSupportedSchemes=fMFGetSupportedSchemes @86 + MFGetSystemTime=fMFGetSystemTime @87 + MFGetTimerPeriodicity=fMFGetTimerPeriodicity @88 + MFGetUncompressedVideoFormat=fMFGetUncompressedVideoFormat @89 + MFGetWorkQueueMMCSSTaskId=fMFGetWorkQueueMMCSSTaskId @90 + MFHeapAlloc=fMFHeapAlloc @91 + MFHeapFree=fMFHeapFree @92 + MFInitAMMediaTypeFromMFMediaType=fMFInitAMMediaTypeFromMFMediaType @93 + MFInitAttributesFromBlob=fMFInitAttributesFromBlob @94 + MFInitMediaTypeFromAMMediaType=fMFInitMediaTypeFromAMMediaType @95 + MFInitMediaTypeFromMFVideoFormat=fMFInitMediaTypeFromMFVideoFormat @96 + MFInitMediaTypeFromVideoInfoHeader=fMFInitMediaTypeFromVideoInfoHeader @97 + MFInitMediaTypeFromVideoInfoHeader2=fMFInitMediaTypeFromVideoInfoHeader2 @98 + MFInitMediaTypeFromWaveFormatEx=fMFInitMediaTypeFromWaveFormatEx @99 + MFInitVideoFormat=fMFInitVideoFormat @100 + MFInitVideoFormat_RGB=fMFInitVideoFormat_RGB @101 + MFInvokeCallback=fMFInvokeCallback @102 + MFJoinIoPort=fMFJoinIoPort @103 + MFJoinWorkQueue=fMFJoinWorkQueue @104 + MFLockDXGIDeviceManager=fMFLockDXGIDeviceManager @105 + MFLockPlatform=fMFLockPlatform @106 + MFLockSharedWorkQueue=fMFLockSharedWorkQueue @107 + MFLockWorkQueue=fMFLockWorkQueue @108 + MFMapDX9FormatToDXGIFormat=fMFMapDX9FormatToDXGIFormat @109 + MFMapDXGIFormatToDX9Format=fMFMapDXGIFormatToDX9Format @110 + MFPutWaitingWorkItem=fMFPutWaitingWorkItem @111 + MFPutWorkItem=fMFPutWorkItem @112 + MFPutWorkItem2=fMFPutWorkItem2 @113 + MFPutWorkItemEx=fMFPutWorkItemEx @114 + MFPutWorkItemEx2=fMFPutWorkItemEx2 @115 + MFRemovePeriodicCallback=fMFRemovePeriodicCallback @116 + MFResetDXGIDeviceManagerX=fMFResetDXGIDeviceManagerX @117 + MFScheduleWorkItem=fMFScheduleWorkItem @118 + MFScheduleWorkItemEx=fMFScheduleWorkItemEx @119 + MFSerializeAttributesToStream=fMFSerializeAttributesToStream @120 + MFSerializeEvent=fMFSerializeEvent @121 + MFSerializeMediaTypeToStream=fMFSerializeMediaTypeToStream @122 + MFSerializePresentationDescriptor=fMFSerializePresentationDescriptor @123 + MFShutdown=fMFShutdown @124 + MFStartup=fMFStartup @125 + MFTEnumEx=fMFTEnumEx @126 + MFTraceError=fMFTraceError @127 + MFTraceFuncEnter=fMFTraceFuncEnter @128 + MFUnblockThread=fMFUnblockThread @129 + MFUnjoinWorkQueue=fMFUnjoinWorkQueue @130 + MFUnlockDXGIDeviceManager=fMFUnlockDXGIDeviceManager @131 + MFUnlockPlatform=fMFUnlockPlatform @132 + MFUnlockWorkQueue=fMFUnlockWorkQueue @133 + MFUnwrapMediaType=fMFUnwrapMediaType @134 + MFValidateMediaTypeSize=fMFValidateMediaTypeSize @135 + MFWrapMediaType=fMFWrapMediaType @136 + MFllMulDiv=fMFllMulDiv @137 + PropVariantFromStream=fPropVariantFromStream @138 + PropVariantToStream=fPropVariantToStream @139 + ValidateWaveFormat=fValidateWaveFormat @140 diff --git a/dlls/mfplat/mfplat.vcxproj b/dlls/mfplat/mfplat.vcxproj index 284b829..9da0ea5 100644 --- a/dlls/mfplat/mfplat.vcxproj +++ b/dlls/mfplat/mfplat.vcxproj @@ -16,6 +16,7 @@ {a67d1cec-9f56-4d53-97c2-88badeddb22d} mfplat 10.0 + mfplat @@ -33,6 +34,7 @@ + @@ -57,15 +59,17 @@ true _DEBUG;MFPLAT_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - Use + NotUsing pch.h stdcpp17 + true Windows true false - Exports.def + mfplat.def + $(CoreLibraryDependencies);%(AdditionalDependencies);mfplat.lib @@ -76,8 +80,9 @@ true NDEBUG;MFPLAT_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - Use + NotUsing pch.h + true Windows @@ -85,25 +90,21 @@ true true false - Exports.def + mfplat.def + $(CoreLibraryDependencies);%(AdditionalDependencies);mfplat.lib - - - - - + + Document + + - - - Create - Create - + \ No newline at end of file diff --git a/dlls/mfplat/mfplat.vcxproj.filters b/dlls/mfplat/mfplat.vcxproj.filters index 8b79237..e1fe3cd 100644 --- a/dlls/mfplat/mfplat.vcxproj.filters +++ b/dlls/mfplat/mfplat.vcxproj.filters @@ -1,15 +1,12 @@  - - - - - - - + + + + \ No newline at end of file diff --git a/dlls/mfplat/pch.cpp b/dlls/mfplat/pch.cpp deleted file mode 100644 index 64b7eef..0000000 --- a/dlls/mfplat/pch.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// pch.cpp: source file corresponding to the pre-compiled header - -#include "pch.h" - -// When you are using pre-compiled headers, this source file is necessary for compilation to succeed. diff --git a/dlls/mfplat/pch.h b/dlls/mfplat/pch.h deleted file mode 100644 index 885d5d6..0000000 --- a/dlls/mfplat/pch.h +++ /dev/null @@ -1,13 +0,0 @@ -// pch.h: This is a precompiled header file. -// Files listed below are compiled only once, improving build performance for future builds. -// This also affects IntelliSense performance, including code completion and many code browsing features. -// However, files listed here are ALL re-compiled if any one of them is updated between builds. -// Do not add files here that you will be updating frequently as this negates the performance advantage. - -#ifndef PCH_H -#define PCH_H - -// add headers that you want to pre-compile here -#include "framework.h" - -#endif //PCH_H diff --git a/dlls/winrt_x/Implementation/Microsoft.Xbox.Services.RealTimeActivity.RealTimeActivityService.cpp b/dlls/winrt_x/Implementation/Microsoft.Xbox.Services.RealTimeActivity.RealTimeActivityService.cpp index a71d5ef..763cf3e 100644 --- a/dlls/winrt_x/Implementation/Microsoft.Xbox.Services.RealTimeActivity.RealTimeActivityService.cpp +++ b/dlls/winrt_x/Implementation/Microsoft.Xbox.Services.RealTimeActivity.RealTimeActivityService.cpp @@ -29,7 +29,7 @@ namespace winrt::Microsoft::Xbox::Services::RealTimeActivity::implementation } void RealTimeActivityService::Deactivate() { - throw hresult_not_implemented(); + printf("[RealTimeActivityService] Deactivate (function is stubbed)\n"); } winrt::event_token RealTimeActivityService::RealTimeActivityConnectionStateChange(winrt::Windows::Foundation::EventHandler const& __param0) { diff --git a/dlls/winrt_x/Implementation/Microsoft.Xbox.Services.XboxLiveContext.cpp b/dlls/winrt_x/Implementation/Microsoft.Xbox.Services.XboxLiveContext.cpp index 9f6653b..93f46d8 100644 --- a/dlls/winrt_x/Implementation/Microsoft.Xbox.Services.XboxLiveContext.cpp +++ b/dlls/winrt_x/Implementation/Microsoft.Xbox.Services.XboxLiveContext.cpp @@ -4,6 +4,7 @@ #include "Microsoft.Xbox.Services.Presence.PresenceService.h" #include "Microsoft.Xbox.Services.XboxLiveContext.g.cpp" #include "Microsoft.Xbox.Services.Multiplayer.MultiplayerService.h" +#include "Microsoft.Xbox.Services.RealTimeActivity.RealTimeActivityService.h" #include "Microsoft.Xbox.Services.Social.SocialService.h" #include "Microsoft.Xbox.Services.UserStatistics.UserStatisticsService.h" @@ -83,8 +84,7 @@ namespace winrt::Microsoft::Xbox::Services::implementation } winrt::Microsoft::Xbox::Services::RealTimeActivity::RealTimeActivityService XboxLiveContext::RealTimeActivityService() { - printf("!!!!! Microsoft.Xbox.Services.XboxLiveContext [RealTimeActivityService] NOT IMPLEMENTED !!!!\n"); - throw hresult_not_implemented(); + return winrt::make( ); } winrt::Microsoft::Xbox::Services::Presence::PresenceService XboxLiveContext::PresenceService() { diff --git a/dlls/winrt_x/Implementation/Windows.Xbox.ApplicationModel.Store.Product.cpp b/dlls/winrt_x/Implementation/Windows.Xbox.ApplicationModel.Store.Product.cpp index c855298..0e0710e 100644 --- a/dlls/winrt_x/Implementation/Windows.Xbox.ApplicationModel.Store.Product.cpp +++ b/dlls/winrt_x/Implementation/Windows.Xbox.ApplicationModel.Store.Product.cpp @@ -47,13 +47,11 @@ namespace winrt::Windows::Xbox::ApplicationModel::Store::implementation winrt::Windows::Foundation::IAsyncOperation Product::CheckPrivilegeAsync(winrt::Windows::Xbox::System::IUser user, uint32_t privilegeId, bool attemptResolution, hstring friendlyDisplay) { auto args = winrt::make( ); - m_productPurchasedEvent(args); co_return PrivilegeCheckResult::NoIssue; } winrt::Windows::Foundation::IAsyncOperation Product::CheckPrivilegesAsync(winrt::Windows::Xbox::System::IUser user, winrt::Windows::Foundation::Collections::IVectorView privilegeIds, bool attemptResolution, hstring friendlyDisplay) { auto args = winrt::make( ); - m_productPurchasedEvent(args); co_return PrivilegeCheckResult::NoIssue; } winrt::event_token Product::ProductPurchased(winrt::Windows::Xbox::ApplicationModel::Store::ProductPurchasedEventHandler const& handler) diff --git a/dlls/winrt_x/Implementation/Windows.Xbox.Input.Controller.cpp b/dlls/winrt_x/Implementation/Windows.Xbox.Input.Controller.cpp index c04dc51..8af74ce 100644 --- a/dlls/winrt_x/Implementation/Windows.Xbox.Input.Controller.cpp +++ b/dlls/winrt_x/Implementation/Windows.Xbox.Input.Controller.cpp @@ -60,12 +60,11 @@ namespace winrt::Windows::Xbox::Input::implementation winrt::event_token Controller::ControllerOrderChanged(winrt::Windows::Foundation::EventHandler const& handler) { printf("[ControllerOrderChanged] STUBBED\n"); - throw hresult_not_implemented( ); + return {}; } void Controller::ControllerOrderChanged(winrt::event_token const& token) noexcept { - printf("[ControllerOrderChanged] STUBBED\n"); - throw hresult_not_implemented( ); + printf("[ControllerOrderChangedInternal] STUBBED\n"); } winrt::Windows::Xbox::Input::IController Controller::GetControllerById(uint64_t controllerId) { diff --git a/dlls/winrt_x/Implementation/Windows.Xbox.Management.Deployment.PackageTransferManager.cpp b/dlls/winrt_x/Implementation/Windows.Xbox.Management.Deployment.PackageTransferManager.cpp index 7266f53..d1362c8 100644 --- a/dlls/winrt_x/Implementation/Windows.Xbox.Management.Deployment.PackageTransferManager.cpp +++ b/dlls/winrt_x/Implementation/Windows.Xbox.Management.Deployment.PackageTransferManager.cpp @@ -37,7 +37,13 @@ namespace winrt::Windows::Xbox::Management::Deployment::implementation } winrt::Windows::Xbox::Management::Deployment::PackageTransferManager PackageTransferManager::Current() { - throw hresult_not_implemented(); + if (static_manager == Deployment::PackageTransferManager{ nullptr }) + { + static_manager = make( ); + } + + printf("PackageTransferManager::Current()\n"); + return static_manager; } winrt::Windows::Xbox::Management::Deployment::PackageTransferManager PackageTransferManager::Create(winrt::Windows::ApplicationModel::Package const& package) { @@ -49,7 +55,8 @@ namespace winrt::Windows::Xbox::Management::Deployment::implementation } bool PackageTransferManager::IsChunkInstalled(uint32_t chunkId) { - throw hresult_not_implemented(); + printf("PackageTransferManager::IsChunkInstalled() STUBBED\n"); + return true; } bool PackageTransferManager::AreChunksInstalled(winrt::Windows::Foundation::Collections::IIterable const& chunkIds) { diff --git a/dlls/winrt_x/Implementation/Windows.Xbox.Management.Deployment.PackageTransferManager.h b/dlls/winrt_x/Implementation/Windows.Xbox.Management.Deployment.PackageTransferManager.h index 6134388..99a02ab 100644 --- a/dlls/winrt_x/Implementation/Windows.Xbox.Management.Deployment.PackageTransferManager.h +++ b/dlls/winrt_x/Implementation/Windows.Xbox.Management.Deployment.PackageTransferManager.h @@ -42,6 +42,8 @@ namespace winrt::Windows::Xbox::Management::Deployment::implementation winrt::Windows::Xbox::Management::Deployment::InstallationState GetInstallationState(winrt::Windows::Xbox::Management::Deployment::ChunkSpecifiers const& specifiers); winrt::Windows::Foundation::IAsyncOperation AddChunkSpecifiersAsync(winrt::Windows::Xbox::Management::Deployment::ChunkSpecifiers additionalSpecifiers); winrt::Windows::Foundation::IAsyncAction RemoveChunkSpecifiersAsync(winrt::Windows::Xbox::Management::Deployment::ChunkSpecifiers removeSpecifiers); + + inline static Deployment::PackageTransferManager static_manager = { nullptr }; }; } namespace winrt::Windows::Xbox::Management::Deployment::factory_implementation diff --git a/dlls/xg_x/xg_x.vcxproj b/dlls/xg_x/xg_x.vcxproj index f81442a..ae1815a 100644 --- a/dlls/xg_x/xg_x.vcxproj +++ b/dlls/xg_x/xg_x.vcxproj @@ -58,6 +58,7 @@ Use pch.h stdcpp17 + true Windows @@ -76,6 +77,7 @@ true Use pch.h + true Windows diff --git a/symlink.ps1 b/symlink.ps1 index 709c4e4..c0f13cc 100644 --- a/symlink.ps1 +++ b/symlink.ps1 @@ -15,7 +15,7 @@ make-link("d3d11_x.dll") make-link("etwplus.dll") make-link("kernelx.dll") make-link("mfplat.dll") -#make-link("MMDevAPI.dll") +make-link("MMDevAPI.dll") make-link("XboxIntegratedMultiplayer.dll") make-link("xg_x.dll") make-link("XFrontPanelDisplay.dll") diff --git a/thirdparty/Detours b/thirdparty/Detours index 4b8c659..09e0356 160000 --- a/thirdparty/Detours +++ b/thirdparty/Detours @@ -1 +1 @@ -Subproject commit 4b8c659f549b0ab21cf649377c7a84eb708f5e68 +Subproject commit 09e035677dfd566280b65f36b9c017b6ed51537a