//----------------------------------------------------------------------------- /// Wrapped_ID3D12Pageable::SetPrivateData //----------------------------------------------------------------------------- HRESULT STDMETHODCALLTYPE Wrapped_ID3D12Pageable::SetPrivateData(REFGUID guid, UINT DataSize, const void* pData) { #if SERIALIZE_DX12_ENTRY_POINTS ScopeLock lock(&s_mutex); #endif HRESULT result = {}; DX12Interceptor* interceptor = GetDX12LayerManager()->GetInterceptor(); if (interceptor && interceptor->ShouldCollectTrace()) { ParameterEntry parameters[] = { { PARAMETER_GUID, &guid }, { PARAMETER_UNSIGNED_INT, &DataSize }, { PARAMETER_POINTER, pData }, }; int numParameters = (sizeof(parameters) / sizeof(parameters[0])); DX12APIEntry* pNewEntry = interceptor->PreCall(this, FuncId_ID3D12Object_SetPrivateData, numParameters, parameters); result = mRealPageable->SetPrivateData(guid, DataSize, pData); interceptor->PostCall(pNewEntry, result); } else { result = mRealPageable->SetPrivateData(guid, DataSize, pData); } return result; }
//----------------------------------------------------------------------------- /// Wrapped_ID3D12QueryHeap::Release //----------------------------------------------------------------------------- ULONG STDMETHODCALLTYPE Wrapped_ID3D12QueryHeap::Release() { #if SERIALIZE_DX12_ENTRY_POINTS ScopeLock lock(&s_mutex); #endif ULONG result = {}; DX12Interceptor* interceptor = GetDX12LayerManager()->GetInterceptor(); if (interceptor->ShouldCollectTrace()) { DX12APIEntry* pNewEntry = interceptor->PreCall(this, FuncId_IUnknown_Release, 0, nullptr); result = mRealQueryHeap->Release(); interceptor->PostCall(pNewEntry, result); } else { result = mRealQueryHeap->Release(); } if (result == 0) { DX12WrappedObjectDatabase* objectDatabase = (DX12WrappedObjectDatabase*)DX12ObjectDatabaseProcessor::Instance()->GetObjectDatabase(); IDX12InstanceBase* objectMetadata = objectDatabase->GetMetadataObject(this); if (objectMetadata != nullptr) { objectMetadata->FlagAsDestroyed(); } } return result; }
//----------------------------------------------------------------------------- /// Wrapped_ID3D12CommandQueue::CopyTileMappings //----------------------------------------------------------------------------- void STDMETHODCALLTYPE Wrapped_ID3D12CommandQueue::CopyTileMappings(ID3D12Resource* pDstResource, const D3D12_TILED_RESOURCE_COORDINATE* pDstRegionStartCoordinate, ID3D12Resource* pSrcResource, const D3D12_TILED_RESOURCE_COORDINATE* pSrcRegionStartCoordinate, const D3D12_TILE_REGION_SIZE* pRegionSize, D3D12_TILE_MAPPING_FLAGS Flags) { #if SERIALIZE_DX12_ENTRY_POINTS ScopeLock lock(&s_mutex); #endif ID3D12Resource* pDstResourceUnwrapped; DX12CoreDeepCopy::UnwrapInterface(pDstResource, &(pDstResourceUnwrapped)); ID3D12Resource* pSrcResourceUnwrapped; DX12CoreDeepCopy::UnwrapInterface(pSrcResource, &(pSrcResourceUnwrapped)); DX12Interceptor* interceptor = GetDX12LayerManager()->GetInterceptor(); if (interceptor && interceptor->ShouldCollectTrace()) { ParameterEntry parameters[] = { { PARAMETER_POINTER_SPECIAL, pDstResource }, { PARAMETER_POINTER, pDstRegionStartCoordinate }, { PARAMETER_POINTER_SPECIAL, pSrcResource }, { PARAMETER_POINTER, pSrcRegionStartCoordinate }, { PARAMETER_POINTER, pRegionSize }, { PARAMETER_UNSIGNED_INT, &Flags }, }; int numParameters = (sizeof(parameters) / sizeof(parameters[0])); DX12APIEntry* pNewEntry = interceptor->PreCall(this, FuncId_ID3D12CommandQueue_CopyTileMappings, numParameters, parameters); mRealCommandQueue->CopyTileMappings(pDstResourceUnwrapped, pDstRegionStartCoordinate, pSrcResourceUnwrapped, pSrcRegionStartCoordinate, pRegionSize, Flags); interceptor->PostCall(pNewEntry); } else { mRealCommandQueue->CopyTileMappings(pDstResourceUnwrapped, pDstRegionStartCoordinate, pSrcResourceUnwrapped, pSrcRegionStartCoordinate, pRegionSize, Flags); } }
//----------------------------------------------------------------------------- /// Wrapped_ID3D12QueryHeap::SetName //----------------------------------------------------------------------------- HRESULT STDMETHODCALLTYPE Wrapped_ID3D12QueryHeap::SetName(LPCWSTR Name) { #if SERIALIZE_DX12_ENTRY_POINTS ScopeLock lock(&s_mutex); #endif HRESULT result = {}; DX12Interceptor* interceptor = GetDX12LayerManager()->GetInterceptor(); if (interceptor->ShouldCollectTrace()) { ParameterEntry parameters[] = { { PARAMETER_WIDE_STRING, Name }, }; int numParameters = (sizeof(parameters) / sizeof(parameters[0])); DX12APIEntry* pNewEntry = interceptor->PreCall(this, FuncId_ID3D12Object_SetName, numParameters, parameters); result = mRealQueryHeap->SetName(Name); interceptor->PostCall(pNewEntry, result); } else { result = mRealQueryHeap->SetName(Name); } return result; }
//----------------------------------------------------------------------------- /// Wrapped_ID3D12CommandQueue::Wait //----------------------------------------------------------------------------- HRESULT STDMETHODCALLTYPE Wrapped_ID3D12CommandQueue::Wait(ID3D12Fence* pFence, UINT64 Value) { #if SERIALIZE_DX12_ENTRY_POINTS ScopeLock lock(&s_mutex); #endif HRESULT result = {}; ID3D12Fence* pFenceUnwrapped; DX12CoreDeepCopy::UnwrapInterface(pFence, &(pFenceUnwrapped)); DX12Interceptor* interceptor = GetDX12LayerManager()->GetInterceptor(); if (interceptor && interceptor->ShouldCollectTrace()) { ParameterEntry parameters[] = { { PARAMETER_POINTER_SPECIAL, pFence }, { PARAMETER_UINT64, &Value }, }; int numParameters = (sizeof(parameters) / sizeof(parameters[0])); DX12APIEntry* pNewEntry = interceptor->PreCall(this, FuncId_ID3D12CommandQueue_Wait, numParameters, parameters); result = mRealCommandQueue->Wait(pFenceUnwrapped, Value); interceptor->PostCall(pNewEntry, result); } else { result = mRealCommandQueue->Wait(pFenceUnwrapped, Value); } return result; }
//----------------------------------------------------------------------------- /// Wrapped_ID3D12QueryHeap::SetPrivateDataInterface //----------------------------------------------------------------------------- HRESULT STDMETHODCALLTYPE Wrapped_ID3D12QueryHeap::SetPrivateDataInterface(REFGUID guid, const IUnknown* pData) { #if SERIALIZE_DX12_ENTRY_POINTS ScopeLock lock(&s_mutex); #endif HRESULT result = {}; DX12Interceptor* interceptor = GetDX12LayerManager()->GetInterceptor(); if (interceptor->ShouldCollectTrace()) { ParameterEntry parameters[] = { { PARAMETER_GUID, &guid }, { PARAMETER_POINTER_SPECIAL, pData }, }; int numParameters = (sizeof(parameters) / sizeof(parameters[0])); DX12APIEntry* pNewEntry = interceptor->PreCall(this, FuncId_ID3D12Object_SetPrivateDataInterface, numParameters, parameters); result = mRealQueryHeap->SetPrivateDataInterface(guid, pData); interceptor->PostCall(pNewEntry, result); } else { result = mRealQueryHeap->SetPrivateDataInterface(guid, pData); } return result; }
//----------------------------------------------------------------------------- /// Wrapped_ID3D12CommandQueue::GetClockCalibration //----------------------------------------------------------------------------- HRESULT STDMETHODCALLTYPE Wrapped_ID3D12CommandQueue::GetClockCalibration(UINT64* pGpuTimestamp, UINT64* pCpuTimestamp) { #if SERIALIZE_DX12_ENTRY_POINTS ScopeLock lock(&s_mutex); #endif HRESULT result = {}; DX12Interceptor* interceptor = GetDX12LayerManager()->GetInterceptor(); if (interceptor && interceptor->ShouldCollectTrace()) { ParameterEntry parameters[] = { { PARAMETER_POINTER, pGpuTimestamp }, { PARAMETER_POINTER, pCpuTimestamp }, }; int numParameters = (sizeof(parameters) / sizeof(parameters[0])); DX12APIEntry* pNewEntry = interceptor->PreCall(this, FuncId_ID3D12CommandQueue_GetClockCalibration, numParameters, parameters); result = mRealCommandQueue->GetClockCalibration(pGpuTimestamp, pCpuTimestamp); interceptor->PostCall(pNewEntry, result); } else { result = mRealCommandQueue->GetClockCalibration(pGpuTimestamp, pCpuTimestamp); } return result; }
//----------------------------------------------------------------------------- /// Wrapped_ID3D12CommandQueue::UpdateTileMappings //----------------------------------------------------------------------------- void STDMETHODCALLTYPE Wrapped_ID3D12CommandQueue::UpdateTileMappings(ID3D12Resource* pResource, UINT NumResourceRegions, const D3D12_TILED_RESOURCE_COORDINATE* pResourceRegionStartCoordinates, const D3D12_TILE_REGION_SIZE* pResourceRegionSizes, ID3D12Heap* pHeap, UINT NumRanges, const D3D12_TILE_RANGE_FLAGS* pRangeFlags, const UINT* pHeapRangeStartOffsets, const UINT* pRangeTileCounts, D3D12_TILE_MAPPING_FLAGS Flags) { #if SERIALIZE_DX12_ENTRY_POINTS ScopeLock lock(&s_mutex); #endif ID3D12Resource* pResourceUnwrapped; DX12CoreDeepCopy::UnwrapInterface(pResource, &(pResourceUnwrapped)); ID3D12Heap* pHeapUnwrapped; DX12CoreDeepCopy::UnwrapInterface(pHeap, &(pHeapUnwrapped)); DX12Interceptor* interceptor = GetDX12LayerManager()->GetInterceptor(); if (interceptor && interceptor->ShouldCollectTrace()) { // print variables with nullptr pointer check UINT heapRangeStartOffsets = 0; if (pHeapRangeStartOffsets != nullptr) { heapRangeStartOffsets = *pHeapRangeStartOffsets; } UINT rangeTileCounts = 0; if (pRangeTileCounts != nullptr) { rangeTileCounts = *pRangeTileCounts; } ParameterEntry parameters[] = { { PARAMETER_POINTER_SPECIAL, pResource }, { PARAMETER_UNSIGNED_INT, &NumResourceRegions }, { PARAMETER_POINTER, pResourceRegionStartCoordinates }, { PARAMETER_POINTER, pResourceRegionSizes }, { PARAMETER_POINTER_SPECIAL, pHeap }, { PARAMETER_UNSIGNED_INT, &NumRanges }, { PARAMETER_POINTER, pRangeFlags }, { PARAMETER_UNSIGNED_INT, &heapRangeStartOffsets }, { PARAMETER_UNSIGNED_INT, &rangeTileCounts }, { PARAMETER_UNSIGNED_INT, &Flags }, }; int numParameters = (sizeof(parameters) / sizeof(parameters[0])); DX12APIEntry* pNewEntry = interceptor->PreCall(this, FuncId_ID3D12CommandQueue_UpdateTileMappings, numParameters, parameters); mRealCommandQueue->UpdateTileMappings(pResourceUnwrapped, NumResourceRegions, pResourceRegionStartCoordinates, pResourceRegionSizes, pHeapUnwrapped, NumRanges, pRangeFlags, pHeapRangeStartOffsets, pRangeTileCounts, Flags); interceptor->PostCall(pNewEntry); } else { mRealCommandQueue->UpdateTileMappings(pResourceUnwrapped, NumResourceRegions, pResourceRegionStartCoordinates, pResourceRegionSizes, pHeapUnwrapped, NumRanges, pRangeFlags, pHeapRangeStartOffsets, pRangeTileCounts, Flags); } }
//----------------------------------------------------------------------------- /// Wrapped_ID3D12QueryHeap::QueryInterface //----------------------------------------------------------------------------- HRESULT STDMETHODCALLTYPE Wrapped_ID3D12QueryHeap::QueryInterface(REFIID riid, void** ppvObject) { #if SERIALIZE_DX12_ENTRY_POINTS ScopeLock lock(&s_mutex); #endif HRESULT result = {}; if (riid == IID_IWrappedObject) { *ppvObject = mRealQueryHeap; result = S_OK; } else { DX12Interceptor* interceptor = GetDX12LayerManager()->GetInterceptor(); if (interceptor->ShouldCollectTrace()) { ParameterEntry parameters[] = { { PARAMETER_REFIID, &riid }, { PARAMETER_POINTER, ppvObject }, }; int numParameters = (sizeof(parameters) / sizeof(parameters[0])); DX12APIEntry* pNewEntry = interceptor->PreCall(this, FuncId_IUnknown_QueryInterface, numParameters, parameters); result = mRealQueryHeap->QueryInterface(riid, ppvObject); interceptor->PostCall(pNewEntry, result); } else { result = mRealQueryHeap->QueryInterface(riid, ppvObject); } if (result == S_OK) { if (riid == __uuidof(ID3D12QueryHeap)) { WrapD3D12QueryHeap(nullptr, (ID3D12QueryHeap**)ppvObject); } } } return result; }
//----------------------------------------------------------------------------- /// Wrapped_ID3D12CommandQueue::ExecuteCommandLists //----------------------------------------------------------------------------- void STDMETHODCALLTYPE Wrapped_ID3D12CommandQueue::ExecuteCommandLists(UINT NumCommandLists, ID3D12CommandList* const* ppCommandLists) { #if SERIALIZE_DX12_ENTRY_POINTS ScopeLock lock(&s_mutex); #endif ID3D12CommandList** ppCommandListsCopy = nullptr; if (NumCommandLists > 0) { ppCommandListsCopy = new ID3D12CommandList*[NumCommandLists]; for (UINT index = 0; index < NumCommandLists; index++) { DX12CoreDeepCopy::UnwrapInterface(ppCommandLists[index], &(ppCommandListsCopy[index])); } } DX12Interceptor* interceptor = GetDX12LayerManager()->GetInterceptor(); if (interceptor && interceptor->ShouldCollectTrace()) { int numParameters = NumCommandLists + 1; ParameterEntry* parameters = new ParameterEntry[numParameters]; parameters[0].mType = PARAMETER_UNSIGNED_INT; parameters[0].mData = &NumCommandLists; for (UINT loop = 0; loop < NumCommandLists; loop++) { parameters[loop + 1].mType = PARAMETER_POINTER; parameters[loop + 1].mData = ppCommandLists[loop]; } DX12APIEntry* pNewEntry = interceptor->PreCall(this, FuncId_ID3D12CommandQueue_ExecuteCommandLists, numParameters, parameters); mRealCommandQueue->ExecuteCommandLists(NumCommandLists, ppCommandListsCopy); interceptor->PostCall(pNewEntry); delete[] parameters; } else { mRealCommandQueue->ExecuteCommandLists(NumCommandLists, ppCommandListsCopy); } SAFE_DELETE_ARRAY(ppCommandListsCopy); }
//----------------------------------------------------------------------------- /// Wrapped_ID3D12CommandQueue::EndEvent //----------------------------------------------------------------------------- void STDMETHODCALLTYPE Wrapped_ID3D12CommandQueue::EndEvent() { #if SERIALIZE_DX12_ENTRY_POINTS ScopeLock lock(&s_mutex); #endif DX12Interceptor* interceptor = GetDX12LayerManager()->GetInterceptor(); if (interceptor && interceptor->ShouldCollectTrace()) { DX12APIEntry* pNewEntry = interceptor->PreCall(this, FuncId_ID3D12CommandQueue_EndEvent, 0); mRealCommandQueue->EndEvent(); interceptor->PostCall(pNewEntry); } else { mRealCommandQueue->EndEvent(); } }
//----------------------------------------------------------------------------- /// Wrapped_ID3D12DescriptorHeap::GetGPUDescriptorHandleForHeapStart //----------------------------------------------------------------------------- D3D12_GPU_DESCRIPTOR_HANDLE STDMETHODCALLTYPE Wrapped_ID3D12DescriptorHeap::GetGPUDescriptorHandleForHeapStart() { #if SERIALIZE_DX12_ENTRY_POINTS ScopeLock lock(&s_mutex); #endif D3D12_GPU_DESCRIPTOR_HANDLE result = {}; DX12Interceptor* interceptor = GetDX12LayerManager()->GetInterceptor(); if (interceptor && interceptor->ShouldCollectTrace()) { DX12APIEntry* pNewEntry = interceptor->PreCall(this, FuncId_ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart, 0, nullptr); result = mRealDescriptorHeap->GetGPUDescriptorHandleForHeapStart(); interceptor->PostCall(pNewEntry, static_cast<INT64>(result.ptr), RETURN_VALUE_HEX); } else { result = mRealDescriptorHeap->GetGPUDescriptorHandleForHeapStart(); } return result; }
//----------------------------------------------------------------------------- /// Wrapped_ID3D12CommandAllocator::Reset //----------------------------------------------------------------------------- HRESULT STDMETHODCALLTYPE Wrapped_ID3D12CommandAllocator::Reset() { #if SERIALIZE_DX12_ENTRY_POINTS ScopeLock lock(&s_mutex); #endif HRESULT result = {}; DX12Interceptor* interceptor = GetDX12LayerManager()->GetInterceptor(); if (interceptor->ShouldCollectTrace()) { DX12APIEntry* pNewEntry = interceptor->PreCall(this, FuncId_ID3D12CommandAllocator_Reset, 0, nullptr); result = mRealCommandAllocator->Reset(); interceptor->PostCall(pNewEntry, result); } else { result = mRealCommandAllocator->Reset(); } return result; }
//----------------------------------------------------------------------------- /// Wrapped_ID3D12QueryHeap::AddRef //----------------------------------------------------------------------------- ULONG STDMETHODCALLTYPE Wrapped_ID3D12QueryHeap::AddRef() { #if SERIALIZE_DX12_ENTRY_POINTS ScopeLock lock(&s_mutex); #endif ULONG result = {}; DX12Interceptor* interceptor = GetDX12LayerManager()->GetInterceptor(); if (interceptor->ShouldCollectTrace()) { DX12APIEntry* pNewEntry = interceptor->PreCall(this, FuncId_IUnknown_AddRef, 0, nullptr); result = mRealQueryHeap->AddRef(); interceptor->PostCall(pNewEntry, result); } else { result = mRealQueryHeap->AddRef(); } return result; }
//----------------------------------------------------------------------------- /// Wrapped_ID3D12CommandList::GetType //----------------------------------------------------------------------------- D3D12_COMMAND_LIST_TYPE STDMETHODCALLTYPE Wrapped_ID3D12CommandList::GetType() { #if SERIALIZE_DX12_ENTRY_POINTS ScopeLock lock(&s_mutex); #endif D3D12_COMMAND_LIST_TYPE result = {}; DX12Interceptor* interceptor = GetDX12LayerManager()->GetInterceptor(); if (interceptor && interceptor->ShouldCollectTrace()) { DX12APIEntry* pNewEntry = interceptor->PreCall(this, FuncId_ID3D12CommandList_GetType, 0, nullptr); result = mRealCommandList->GetType(); interceptor->PostCall(pNewEntry, result); } else { result = mRealCommandList->GetType(); } return result; }
//----------------------------------------------------------------------------- /// Wrapped_ID3D12CommandQueue::BeginEvent //----------------------------------------------------------------------------- void STDMETHODCALLTYPE Wrapped_ID3D12CommandQueue::BeginEvent(UINT Metadata, const void* pData, UINT Size) { #if SERIALIZE_DX12_ENTRY_POINTS ScopeLock lock(&s_mutex); #endif DX12Interceptor* interceptor = GetDX12LayerManager()->GetInterceptor(); if (interceptor && interceptor->ShouldCollectTrace()) { ParameterEntry parameters[] = { { PARAMETER_UNSIGNED_INT, &Metadata }, { PARAMETER_STRING, pData }, { PARAMETER_UNSIGNED_INT, &Size }, }; int numParameters = (sizeof(parameters) / sizeof(parameters[0])); if (Metadata == DirectX::Detail::PIX_EVENT_UNICODE_VERSION) { parameters[1].mType = PARAMETER_WIDE_STRING; } else if (Metadata != DirectX::Detail::PIX_EVENT_ANSI_VERSION) { numParameters = 0; } DX12APIEntry* pNewEntry = interceptor->PreCall(this, FuncId_ID3D12CommandQueue_BeginEvent, numParameters, parameters); mRealCommandQueue->BeginEvent(Metadata, pData, Size); interceptor->PostCall(pNewEntry); } else { mRealCommandQueue->BeginEvent(Metadata, pData, Size); } }
//----------------------------------------------------------------------------- /// Wrapped_ID3D12QueryHeap::GetDevice //----------------------------------------------------------------------------- HRESULT STDMETHODCALLTYPE Wrapped_ID3D12QueryHeap::GetDevice(REFIID riid, void** ppvDevice) { #if SERIALIZE_DX12_ENTRY_POINTS ScopeLock lock(&s_mutex); #endif HRESULT result = {}; DX12Interceptor* interceptor = GetDX12LayerManager()->GetInterceptor(); if (interceptor->ShouldCollectTrace()) { ParameterEntry parameters[] = { { PARAMETER_REFIID, &riid }, { PARAMETER_POINTER, ppvDevice }, }; int numParameters = (sizeof(parameters) / sizeof(parameters[0])); DX12APIEntry* pNewEntry = interceptor->PreCall(this, FuncId_ID3D12DeviceChild_GetDevice, numParameters, parameters); result = mRealQueryHeap->GetDevice(riid, ppvDevice); interceptor->PostCall(pNewEntry, result); } else { result = mRealQueryHeap->GetDevice(riid, ppvDevice); } if (ppvDevice != nullptr && *ppvDevice != nullptr) { DX12WrappedObjectDatabase* objectDatabase = (DX12WrappedObjectDatabase*)DX12ObjectDatabaseProcessor::Instance()->GetObjectDatabase(); objectDatabase->WrappedObject((IUnknown**)ppvDevice); } return result; }
//----------------------------------------------------------------------------- /// Wrapped_ID3D12CommandQueue::GetDesc //----------------------------------------------------------------------------- D3D12_COMMAND_QUEUE_DESC STDMETHODCALLTYPE Wrapped_ID3D12CommandQueue::GetDesc() { #if SERIALIZE_DX12_ENTRY_POINTS ScopeLock lock(&s_mutex); #endif D3D12_COMMAND_QUEUE_DESC result = {}; DX12Interceptor* interceptor = GetDX12LayerManager()->GetInterceptor(); if (interceptor && interceptor->ShouldCollectTrace()) { DX12APIEntry* pNewEntry = interceptor->PreCall(this, FuncId_ID3D12CommandQueue_GetDesc, 0); result = mRealCommandQueue->GetDesc(); // TODO: get return value interceptor->PostCall(pNewEntry); } else { result = mRealCommandQueue->GetDesc(); } return result; }