diff options
author | Jose Fonseca <jfonseca@vmware.com> | 2015-07-16 12:56:54 +0100 |
---|---|---|
committer | Jose Fonseca <jfonseca@vmware.com> | 2015-07-16 13:02:11 +0100 |
commit | f2a1305448efefacb2ec7e654d797bb9fbe7202e (patch) | |
tree | 61d46c09422ad9185f7073504895cab48fc5820f | |
parent | e39d56edca49495aa401ffd22a35da4a10a1fd38 (diff) |
d3dtrace: Trace the actual DXVA2 API calls.
As opposed to internal interfaces.
-rw-r--r-- | dispatch/dxva2imports.hpp | 49 | ||||
-rw-r--r-- | dispatch/dxvaint.h | 179 | ||||
-rw-r--r-- | inject/injectee.cpp | 3 | ||||
-rw-r--r-- | retrace/CMakeLists.txt | 2 | ||||
-rw-r--r-- | retrace/d3d9retrace.py | 5 | ||||
-rw-r--r-- | specs/dxva2.py | 458 | ||||
-rw-r--r-- | wrappers/CMakeLists.txt | 2 | ||||
-rw-r--r-- | wrappers/d3d9.def | 2 | ||||
-rw-r--r-- | wrappers/d3d9trace.py | 6 |
9 files changed, 520 insertions, 186 deletions
diff --git a/dispatch/dxva2imports.hpp b/dispatch/dxva2imports.hpp new file mode 100644 index 00000000..9d2e02be --- /dev/null +++ b/dispatch/dxva2imports.hpp @@ -0,0 +1,49 @@ +/************************************************************************** + * + * Copyright 2012 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + **************************************************************************/ + + +#pragma once + +#include "d3d9imports.hpp" + +#include <dxva2api.h> + + +#ifndef DXVA2_E_NOT_INITIALIZED +#define DXVA2_E_NOT_INITIALIZED ((HRESULT)0x80041000L) +#endif + +#ifndef DXVA2_E_NEW_VIDEO_DEVICE +#define DXVA2_E_NEW_VIDEO_DEVICE ((HRESULT)0x80041001L) +#endif + +#ifndef DXVA2_E_VIDEO_DEVICE_LOCKED +#define DXVA2_E_VIDEO_DEVICE_LOCKED ((HRESULT)0x80041002L) +#endif + +#ifndef DXVA2_E_NOT_AVAILABLE +#define DXVA2_E_NOT_AVAILABLE ((HRESULT)0x80041003L) +#endif + diff --git a/dispatch/dxvaint.h b/dispatch/dxvaint.h deleted file mode 100644 index 0f90730b..00000000 --- a/dispatch/dxvaint.h +++ /dev/null @@ -1,179 +0,0 @@ -/************************************************************************** - * - * Copyright 2012 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - **************************************************************************/ - - -#include <dxva2api.h> - - -#ifndef DXVA2_E_NOT_INITIALIZED -#define DXVA2_E_NOT_INITIALIZED ((HRESULT)0x80041000L) -#endif - -#ifndef DXVA2_E_NEW_VIDEO_DEVICE -#define DXVA2_E_NEW_VIDEO_DEVICE ((HRESULT)0x80041001L) -#endif - -#ifndef DXVA2_E_VIDEO_DEVICE_LOCKED -#define DXVA2_E_VIDEO_DEVICE_LOCKED ((HRESULT)0x80041002L) -#endif - -#ifndef DXVA2_E_NOT_AVAILABLE -#define DXVA2_E_NOT_AVAILABLE ((HRESULT)0x80041003L) -#endif - - -typedef struct _DXVA2_DECODEBUFFERDESC { - IDirect3DSurface9 *pRenderTarget; - DWORD CompressedBufferType; - DWORD BufferIndex; - DWORD DataOffset; - DWORD DataSize; - DWORD FirstMBaddress; - DWORD NumMBsInBuffer; - DWORD Width; - DWORD Height; - DWORD Stride; - DWORD ReservedBits; - PVOID pCipherCounter; -} DXVA2_DECODEBUFFERDESC; - -typedef struct _DXVA2_DECODEEXECUTE { - UINT NumCompBuffers; - DXVA2_DECODEBUFFERDESC *pCompressedBuffers; -} DXVA2_DECODEEXECUTE; - -typedef struct _DXVA2_VIDEOSAMPLE { - REFERENCE_TIME Start; - REFERENCE_TIME End; - DXVA2_ExtendedFormat SampleFormat; - DWORD SampleFlags; - IDirect3DSurface9* SrcSurface; - RECT SrcRect; - RECT DstRect; - DXVA2_AYUVSample8 Pal[16]; - DXVA2_Fixed32 PlanarAlpha; -} DXVA2_VIDEOSAMPLE; - -/** - * See also: - * - D3DDDIARG_VIDEOPROCESSBLT - * - DXVA2_VideoProcessBltParams - */ -typedef struct _DXVA2_VIDEOPROCESSBLT { - REFERENCE_TIME TargetFrame; - RECT TargetRect; - SIZE ConstrictionSize; - DWORD StreamingFlags; - DXVA2_AYUVSample16 BackgroundColor; - DXVA2_ExtendedFormat DestFormat; - DWORD DestFlags; - DXVA2_ProcAmpValues ProcAmpValues; - DXVA2_Fixed32 Alpha; - DXVA2_FilterValues NoiseFilterLuma; - DXVA2_FilterValues NoiseFilterChroma; - DXVA2_FilterValues DetailFilterLuma; - DXVA2_FilterValues DetailFilterChroma; - DXVA2_VIDEOSAMPLE *pSrcSurfaces; - UINT NumSrcSurfaces; -} DXVA2_VIDEOPROCESSBLT; - -typedef struct _DXVA2_DECODEBUFFERINFO DXVA2_DECODEBUFFERINFO; /* XXX */ - -typedef struct _DXVA2_EXTENSIONEXECUTE DXVA2_EXTENSIONEXECUTE; /* XXX */ - - -static const GUID IID_IDirect3DDecodeDevice9 = {0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; /* XXX */ -static const GUID IID_IDirect3DVideoProcessDevice9 = {0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} /* XXX */; -static const GUID IID_IDirect3DDXVAExtensionDevice9 = {0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; /* XXX */ -static const GUID IID_IDirect3DDxva2Container9 = {0x126D0349,0x4787,0x4AA6,{0x8E,0x1B,0x40,0xC1,0x77,0xC6,0x0A,0x01}}; - - -typedef struct DECLSPEC_ALIGN(16) _DXVA2_PVP_KEY128 -{ - BYTE Data[16]; -} DXVA2_PVP_KEY128; - -typedef struct _DXVA2_PVP_SETKEY -{ - DXVA2_PVP_KEY128 ContentKey; -} DXVA2_PVP_SETKEY; - -class IDirect3DDecodeDevice9 : public IUnknown -{ -public: - virtual HRESULT STDMETHODCALLTYPE DecodeBeginFrame(DXVA2_PVP_SETKEY *pPVPSetKey) = 0; - virtual HRESULT STDMETHODCALLTYPE DecodeEndFrame(HANDLE *pHandleComplete) = 0; - virtual HRESULT STDMETHODCALLTYPE DecodeSetRenderTarget(IDirect3DSurface9 *pRenderTarget) = 0; - virtual HRESULT STDMETHODCALLTYPE DecodeExecute(DXVA2_DECODEEXECUTE /* const */ *pExecuteParams) = 0; -}; - - -class IDirect3DVideoProcessDevice9 : public IUnknown -{ -public: - virtual HRESULT STDMETHODCALLTYPE VideoProcessBeginFrame(void) = 0; - virtual HRESULT STDMETHODCALLTYPE VideoProcessEndFrame(HANDLE *pHandleComplete) = 0; - virtual HRESULT STDMETHODCALLTYPE VideoProcessSetRenderTarget(IDirect3DSurface9 *pRenderTarget) = 0; - virtual HRESULT STDMETHODCALLTYPE VideoProcessBlt(DXVA2_VIDEOPROCESSBLT /* const */ *pData) = 0; -}; - - -class IDirect3DDXVAExtensionDevice9 : public IUnknown -{ -public: - virtual HRESULT STDMETHODCALLTYPE ExtensionExecute(DXVA2_EXTENSIONEXECUTE *pData) = 0; -}; - - -class IDirect3DDxva2Container9 : public IUnknown -{ -public: - virtual HRESULT STDMETHODCALLTYPE CreateSurface(UINT Width, UINT Height, UINT BackBuffers, D3DFORMAT Format, D3DPOOL Pool, DWORD Usage, DWORD DxvaType, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle) = 0; - virtual HRESULT STDMETHODCALLTYPE VidToSysBlt(IDirect3DSurface9 *pSourceSurface, RECT *pSourceRect, IDirect3DSurface9 *pDestSurface, RECT *pDestRect) = 0; - virtual HRESULT STDMETHODCALLTYPE GetDecodeGuidCount(UINT *pCount) = 0; - virtual HRESULT STDMETHODCALLTYPE GetDecodeGuids(UINT Count, GUID *pGuids) = 0; - virtual HRESULT STDMETHODCALLTYPE GetDecodeRenderTargetFormatCount(REFGUID Guid, UINT *pCount) = 0; - virtual HRESULT STDMETHODCALLTYPE GetDecodeRenderTargets(REFGUID Guid, UINT Count, D3DFORMAT *pFormats) = 0; - virtual HRESULT STDMETHODCALLTYPE GetDecodeCompressedBufferCount(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, UINT *pCount) = 0; - virtual HRESULT STDMETHODCALLTYPE GetDecodeCompressedBuffers(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, UINT Count, DXVA2_DECODEBUFFERINFO *pBufferInfo) = 0; - virtual HRESULT STDMETHODCALLTYPE GetDecodeConfigurationCount(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, UINT *pCount) = 0; - virtual HRESULT STDMETHODCALLTYPE GetDecodeConfigurations(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, UINT Count, DXVA2_ConfigPictureDecode *pConfigs) = 0; - virtual HRESULT STDMETHODCALLTYPE CreateDecodeDevice(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, DXVA2_ConfigPictureDecode const *pConfig, IDirect3DSurface9 * *ppDecoderRenderTargets, UINT NumSurfaces, IDirect3DDecodeDevice9 ** ppDecode) = 0; - virtual HRESULT STDMETHODCALLTYPE GetVideoProcessorDeviceGuidCount(const DXVA2_VideoDesc *pVideoDesc, UINT *pCount) = 0; - virtual HRESULT STDMETHODCALLTYPE GetVideoProcessorDeviceGuids(const DXVA2_VideoDesc *pVideoDesc, UINT Count, GUID *pGuids) = 0; - virtual HRESULT STDMETHODCALLTYPE GetVideoProcessorCaps(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, D3DFORMAT Format, DXVA2_VideoProcessorCaps *pCaps) = 0; - virtual HRESULT STDMETHODCALLTYPE GetProcAmpRange(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, D3DFORMAT Format, UINT ProcAmpCap, DXVA2_ValueRange *pRange) = 0; - virtual HRESULT STDMETHODCALLTYPE GetFilterPropertyRange(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, D3DFORMAT Format, UINT FilterSetting, DXVA2_ValueRange *pRange) = 0; - virtual HRESULT STDMETHODCALLTYPE GetVideoProcessorRenderTargetCount(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, UINT *pCount) = 0; - virtual HRESULT STDMETHODCALLTYPE GetVideoProcessorRenderTargets(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, UINT Count, D3DFORMAT *pFormats) = 0; - virtual HRESULT STDMETHODCALLTYPE GetVideoProcessorSubStreamFormatCount(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, D3DFORMAT Format, UINT *pCount) = 0; - virtual HRESULT STDMETHODCALLTYPE GetVideoProcessorSubStreamFormats(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, D3DFORMAT Format, UINT Count, D3DFORMAT *pFormats) = 0; - virtual HRESULT STDMETHODCALLTYPE CreateVideoProcessDevice(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, D3DFORMAT Format, UINT, IDirect3DVideoProcessDevice9 * * ppVideoProcessDevice) = 0; - virtual HRESULT STDMETHODCALLTYPE GetExtensionGuidCount(DWORD Extension, UINT *pCount) = 0; - virtual HRESULT STDMETHODCALLTYPE GetExtensionGuids(DWORD Extension, UINT Count, GUID *pGuids) = 0; - virtual HRESULT STDMETHODCALLTYPE GetExtensionCaps(REFGUID Guid, UINT, void *, UINT, void *, UINT) = 0; - virtual HRESULT STDMETHODCALLTYPE CreateExtensionDevice(REFGUID Guid, void *, UINT, IDirect3DDXVAExtensionDevice9 ** ppExtension) = 0; -}; - diff --git a/inject/injectee.cpp b/inject/injectee.cpp index bba2b353..c0f417e7 100644 --- a/inject/injectee.cpp +++ b/inject/injectee.cpp @@ -1079,6 +1079,9 @@ DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) registerModuleHooks("d3d10_1.dll", g_hHookModule); registerModuleHooks("d3d11.dll", g_hHookModule); registerModuleHooks("d3d9.dll", g_hHookModule); // for D3DPERF_* + } else if (stricmp(szNewDllBaseName, "d3d9.dll") == 0) { + registerModuleHooks("d3d9.dll", g_hHookModule); + registerModuleHooks("dxva2.dll", g_hHookModule); } else if (stricmp(szNewDllBaseName, "d2d1trace.dll") == 0) { registerModuleHooks("d2d1.dll", g_hHookModule); registerModuleHooks("dwrite.dll", g_hHookModule); diff --git a/retrace/CMakeLists.txt b/retrace/CMakeLists.txt index a113b963..31d5d698 100644 --- a/retrace/CMakeLists.txt +++ b/retrace/CMakeLists.txt @@ -287,7 +287,7 @@ if (WIN32) ${CMAKE_SOURCE_DIR}/specs/d3d9.py ${CMAKE_SOURCE_DIR}/specs/d3d9types.py ${CMAKE_SOURCE_DIR}/specs/d3d9caps.py - ${CMAKE_SOURCE_DIR}/specs/d3d9dxva2.py + ${CMAKE_SOURCE_DIR}/specs/dxva2.py ${CMAKE_SOURCE_DIR}/specs/winapi.py ${CMAKE_SOURCE_DIR}/specs/stdapi.py ) diff --git a/retrace/d3d9retrace.py b/retrace/d3d9retrace.py index 3f2754af..7313acc9 100644 --- a/retrace/d3d9retrace.py +++ b/retrace/d3d9retrace.py @@ -248,12 +248,13 @@ def main(): if support: if moduleName == 'd3d9': from specs.d3d9 import d3d9, d3dperf - import specs.d3d9dxva2 + from specs.dxva2 import dxva2 print r'#include "d3d9imports.hpp"' print r'#include "d3d9size.hpp"' - print r'#include "dxvaint.h"' + print r'#include "dxva2imports.hpp"' d3d9.mergeModule(d3dperf) api.addModule(d3d9) + api.addModule(dxva2) print print '''static d3dretrace::D3DDumper<IDirect3DDevice9> d3d9Dumper;''' print '''static d3dretrace::D3DDumper<IDirect3DSwapChain9> d3d9scDumper;''' diff --git a/specs/dxva2.py b/specs/dxva2.py new file mode 100644 index 00000000..330eb22c --- /dev/null +++ b/specs/dxva2.py @@ -0,0 +1,458 @@ +########################################################################## +# +# Copyright 2012-2015 VMware, Inc. +# All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# +##########################################################################/ + + +from d3d9 import * + + +HRESULT = MAKE_HRESULT(errors = [ + "DXVA2_E_NOT_INITIALIZED", + "DXVA2_E_NEW_VIDEO_DEVICE", + "DXVA2_E_VIDEO_DEVICE_LOCKED", + "DXVA2_E_NOT_AVAILABLE", +]) + +DXVA2_SampleFormat = FakeEnum(UINT, [ + "DXVA2_SampleUnknown", + "DXVA2_SampleProgressiveFrame", + "DXVA2_SampleFieldInterleavedEvenFirst", + "DXVA2_SampleFieldInterleavedOddFirst", + "DXVA2_SampleFieldSingleEven", + "DXVA2_SampleFieldSingleOdd", + "DXVA2_SampleSubStream", +]) + +DXVA2_VideoChromaSubSampling = FakeEnum(UINT, [ + "DXVA2_VideoChromaSubsampling_Unknown", + "DXVA2_VideoChromaSubsampling_ProgressiveChroma", + "DXVA2_VideoChromaSubsampling_Horizontally_Cosited", + "DXVA2_VideoChromaSubsampling_Vertically_Cosited", + "DXVA2_VideoChromaSubsampling_Vertically_AlignedChromaPlanes", + "DXVA2_VideoChromaSubsampling_MPEG2", + "DXVA2_VideoChromaSubsampling_MPEG1", + "DXVA2_VideoChromaSubsampling_DV_PAL", + "DXVA2_VideoChromaSubsampling_Cosited", +]) + +DXVA2_NominalRange = FakeEnum(UINT, [ + "DXVA2_NominalRange_Unknown", + "DXVA2_NominalRange_Normal", + "DXVA2_NominalRange_Wide", + "DXVA2_NominalRange_0_255", + "DXVA2_NominalRange_16_235", + "DXVA2_NominalRange_48_208", +]) + +DXVA2_VideoTransferMatrix = FakeEnum(UINT, [ + "DXVA2_VideoTransferMatrix_Unknown", + "DXVA2_VideoTransferMatrix_BT709", + "DXVA2_VideoTransferMatrix_BT601", + "DXVA2_VideoTransferMatrix_SMPTE240M", +]) + +DXVA2_VideoLighting = FakeEnum(UINT, [ + "DXVA2_VideoLighting_Unknown", + "DXVA2_VideoLighting_bright", + "DXVA2_VideoLighting_office", + "DXVA2_VideoLighting_dim", + "DXVA2_VideoLighting_dark", +]) + +DXVA2_VideoPrimaries = FakeEnum(UINT, [ + "DXVA2_VideoPrimaries_Unknown", + "DXVA2_VideoPrimaries_reserved", + "DXVA2_VideoPrimaries_BT709", + "DXVA2_VideoPrimaries_BT470_2_SysM", + "DXVA2_VideoPrimaries_BT470_2_SysBG", + "DXVA2_VideoPrimaries_SMPTE170M", + "DXVA2_VideoPrimaries_SMPTE240M", + "DXVA2_VideoPrimaries_EBU3213", + "DXVA2_VideoPrimaries_SMPTE_C", +]) + +DXVA2_VideoTransferFunction = FakeEnum(UINT, [ + "DXVA2_VideoTransFunc_Unknown", + "DXVA2_VideoTransFunc_10", + "DXVA2_VideoTransFunc_18", + "DXVA2_VideoTransFunc_20", + "DXVA2_VideoTransFunc_22", + "DXVA2_VideoTransFunc_709", + "DXVA2_VideoTransFunc_240M", + "DXVA2_VideoTransFunc_sRGB", + "DXVA2_VideoTransFunc_28", +]) + +DXVA2_ExtendedFormat = Struct("DXVA2_ExtendedFormat", [ + (DXVA2_SampleFormat, "SampleFormat"), + (DXVA2_VideoChromaSubSampling, "VideoChromaSubsampling"), + (DXVA2_NominalRange, "NominalRange"), + (DXVA2_VideoTransferMatrix, "VideoTransferMatrix"), + (DXVA2_VideoLighting, "VideoLighting"), + (DXVA2_VideoPrimaries, "VideoPrimaries"), + (DXVA2_VideoTransferFunction, "VideoTransferFunction"), +]) + +DXVA2_Frequency = Struct("DXVA2_Frequency", [ + (UINT, "Numerator"), + (UINT, "Denominator"), +]) + +DXVA2_VideoDesc = Struct("DXVA2_VideoDesc", [ + (UINT, "SampleWidth"), + (UINT, "SampleHeight"), + (DXVA2_ExtendedFormat, "SampleFormat"), + (D3DFORMAT, "Format"), + (DXVA2_Frequency, "InputSampleFreq"), + (DXVA2_Frequency, "OutputFrameFreq"), + (UINT, "UABProtectionLevel"), + (UINT, "Reserved"), +]) + +DXVA2_DeinterlaceTech = Flags(UINT, [ + "DXVA2_DeinterlaceTech_Unknown", + "DXVA2_DeinterlaceTech_BOBLineReplicate", + "DXVA2_DeinterlaceTech_BOBVerticalStretch", + "DXVA2_DeinterlaceTech_BOBVerticalStretch4Tap", + "DXVA2_DeinterlaceTech_MedianFiltering", + "DXVA2_DeinterlaceTech_EdgeFiltering", + "DXVA2_DeinterlaceTech_FieldAdaptive", + "DXVA2_DeinterlaceTech_PixelAdaptive", + "DXVA2_DeinterlaceTech_MotionVectorSteered", + "DXVA2_DeinterlaceTech_InverseTelecine", +]) + +DXVA2_Filter = Enum("DXVA2_Filter", [ + "DXVA2_NoiseFilterLumaLevel", + "DXVA2_NoiseFilterLumaThreshold", + "DXVA2_NoiseFilterLumaRadius", + "DXVA2_NoiseFilterChromaLevel", + "DXVA2_NoiseFilterChromaThreshold", + "DXVA2_NoiseFilterChromaRadius", + "DXVA2_DetailFilterLumaLevel", + "DXVA2_DetailFilterLumaThreshold", + "DXVA2_DetailFilterLumaRadius", + "DXVA2_DetailFilterChromaLevel", + "DXVA2_DetailFilterChromaThreshold", + "DXVA2_DetailFilterChromaRadius", +]) + +DXVA2_NoiseFilterTech = Flags(UINT, [ + "DXVA2_NoiseFilterTech_Unsupported", + "DXVA2_NoiseFilterTech_Unknown", + "DXVA2_NoiseFilterTech_Median", + "DXVA2_NoiseFilterTech_Temporal", + "DXVA2_NoiseFilterTech_BlockNoise", + "DXVA2_NoiseFilterTech_MosquitoNoise", +]) + +DXVA2_DetailFilterTech = Flags(UINT, [ + "DXVA2_DetailFilterTech_Unsupported", + "DXVA2_DetailFilterTech_Unknown", + "DXVA2_DetailFilterTech_Edge", + "DXVA2_DetailFilterTech_Sharpening", +]) + +DXVA2_ProcAmp = Flags(UINT, [ + "DXVA2_ProcAmp_None", + "DXVA2_ProcAmp_Brightness", + "DXVA2_ProcAmp_Contrast", + "DXVA2_ProcAmp_Hue", + "DXVA2_ProcAmp_Saturation", +]) + +DXVA2_VideoProcess = Flags(UINT, [ + "DXVA2_VideoProcess_None", + "DXVA2_VideoProcess_YUV2RGB", + "DXVA2_VideoProcess_StretchX", + "DXVA2_VideoProcess_StretchY", + "DXVA2_VideoProcess_AlphaBlend", + "DXVA2_VideoProcess_SubRects", + "DXVA2_VideoProcess_SubStreams", + "DXVA2_VideoProcess_SubStreamsExtended", + "DXVA2_VideoProcess_YUV2RGBExtended", + "DXVA2_VideoProcess_AlphaBlendExtended", + "DXVA2_VideoProcess_Constriction", + "DXVA2_VideoProcess_NoiseFilter", + "DXVA2_VideoProcess_DetailFilter", + "DXVA2_VideoProcess_PlanarAlpha", + "DXVA2_VideoProcess_LinearScaling", + "DXVA2_VideoProcess_GammaCompensated", + "DXVA2_VideoProcess_MaintainsOriginalFieldData", +]) + +DXVA2_VPDev = Flags(UINT, [ + "DXVA2_VPDev_HardwareDevice", + "DXVA2_VPDev_EmulatedDXVA1", + "DXVA2_VPDev_SoftwareDevice", +]) + +DXVA2_SampleData = Flags(UINT, [ + "DXVA2_SampleData_RFF", + "DXVA2_SampleData_TFF", + "DXVA2_SampleData_RFF_TFF_Present", +]) + +DXVA2_DestData = Flags(UINT, [ + "DXVA2_DestData_RFF", + "DXVA2_DestData_TFF", + "DXVA2_DestData_RFF_TFF_Present", +]) + +DXVA2_VideoProcessorCaps = Struct("DXVA2_VideoProcessorCaps", [ + (DXVA2_VPDev, "DeviceCaps"), + (D3DPOOL, "InputPool"), + (UINT, "NumForwardRefSamples"), + (UINT, "NumBackwardRefSamples"), + (UINT, "Reserved"), + (DXVA2_DeinterlaceTech, "DeinterlaceTechnology"), + (DXVA2_ProcAmp, "ProcAmpControlCaps"), + (DXVA2_VideoProcess, "VideoProcessorOperations"), + (DXVA2_NoiseFilterTech, "NoiseFilterTechnology"), + (DXVA2_DetailFilterTech, "DetailFilterTechnology"), +]) + +DXVA2_Fixed32 = Struct("DXVA2_Fixed32", [ + (USHORT, "Fraction"), + (SHORT, "Value"), +]) + +DXVA2_AYUVSample8 = Struct("DXVA2_AYUVSample8", [ + (UCHAR, "Cr"), + (UCHAR, "Cb"), + (UCHAR, "Y"), + (UCHAR, "Alpha"), +]) + +DXVA2_AYUVSample16 = Struct("DXVA2_AYUVSample16", [ + (USHORT, "Cr"), + (USHORT, "Cb"), + (USHORT, "Y"), + (USHORT, "Alpha"), +]) + +REFERENCE_TIME = Alias("REFERENCE_TIME", LONGLONG) +DXVA2_VideoSample = Struct("DXVA2_VideoSample", [ + (REFERENCE_TIME, "Start"), + (REFERENCE_TIME, "End"), + (DXVA2_ExtendedFormat, "SampleFormat"), + (ObjPointer(IDirect3DSurface9), "SrcSurface"), + (RECT, "SrcRect"), + (RECT, "DstRect"), + (Array(DXVA2_AYUVSample8, 16), "Pal"), + (DXVA2_Fixed32, "PlanarAlpha"), + (DWORD, "SampleData"), +]) + +DXVA2_ValueRange = Struct("DXVA2_ValueRange", [ + (DXVA2_Fixed32, "MinValue"), + (DXVA2_Fixed32, "MaxValue"), + (DXVA2_Fixed32, "DefaultValue"), + (DXVA2_Fixed32, "StepSize"), +]) + +DXVA2_ProcAmpValues = Struct("DXVA2_ProcAmpValues", [ + (DXVA2_Fixed32, "Brightness"), + (DXVA2_Fixed32, "Contrast"), + (DXVA2_Fixed32, "Hue"), + (DXVA2_Fixed32, "Saturation"), +]) + +DXVA2_FilterValues = Struct("DXVA2_FilterValues", [ + (DXVA2_Fixed32, "Level"), + (DXVA2_Fixed32, "Threshold"), + (DXVA2_Fixed32, "Radius"), +]) + +DXVA2_VideoProcessBltParams = Struct("DXVA2_VideoProcessBltParams", [ + (REFERENCE_TIME, "TargetFrame"), + (RECT, "TargetRect"), + (SIZE, "ConstrictionSize"), + (UINT, "StreamingFlags"), + (DXVA2_AYUVSample16, "BackgroundColor"), + (DXVA2_ExtendedFormat, "DestFormat"), + (DXVA2_ProcAmpValues, "ProcAmpValues"), + (DXVA2_Fixed32, "Alpha"), + (DXVA2_FilterValues, "NoiseFilterLuma"), + (DXVA2_FilterValues, "NoiseFilterChroma"), + (DXVA2_FilterValues, "DetailFilterLuma"), + (DXVA2_FilterValues, "DetailFilterChroma"), + (DWORD, "DestData"), +]) + +DXVA2_BufferType = FakeEnum(UINT, [ + "DXVA2_PictureParametersBufferType", + "DXVA2_MacroBlockControlBufferType", + "DXVA2_ResidualDifferenceBufferType", + "DXVA2_DeblockingControlBufferType", + "DXVA2_InverseQuantizationMatrixBufferType", + "DXVA2_SliceControlBufferType", + "DXVA2_BitStreamDateBufferType", + "DXVA2_MotionVectorBuffer", + "DXVA2_FilmGrainBuffer", +]) + +DXVA2_Type = FakeEnum(DWORD, [ + "DXVA2_VideoDecoderRenderTarget", + "DXVA2_VideoProcessorRenderTarget", + "DXVA2_VideoSoftwareRenderTarget", +]) + +DXVA2_ConfigPictureDecode = Struct("DXVA2_ConfigPictureDecode", [ + (GUID, "guidConfigBitstreamEncryption"), + (GUID, "guidConfigMBcontrolEncryption"), + (GUID, "guidConfigResidDiffEncryption"), + (UINT, "ConfigBitstreamRaw"), + (UINT, "ConfigMBcontrolRasterOrder"), + (UINT, "ConfigResidDiffHost"), + (UINT, "ConfigSpatialResid8"), + (UINT, "ConfigResid8Subtraction"), + (UINT, "ConfigSpatialHost8or9Clipping"), + (UINT, "ConfigSpatialResidInterleaved"), + (UINT, "ConfigIntraResidUnsigned"), + (UINT, "ConfigResidDiffAccelerator"), + (UINT, "ConfigHostInverseScan"), + (UINT, "ConfigSpecificIDCT"), + (UINT, "Config4GroupedCoefs"), + (USHORT, "ConfigMinRenderTargetBuffCount"), + (USHORT, "ConfigDecoderSpecific"), +]) + +DXVA2_DecodeBufferDesc = Struct("DXVA2_DecodeBufferDesc", [ + (DXVA2_BufferType, "CompressedBufferType"), + (UINT, "BufferIndex"), + (UINT, "DataOffset"), + (UINT, "DataSize"), + (UINT, "FirstMBaddress"), + (UINT, "NumMBsInBuffer"), + (UINT, "Width"), + (UINT, "Height"), + (UINT, "Stride"), + (UINT, "ReservedBits"), + (PVOID, "pvPVPState"), +]) + +DXVA2_AES_CTR_IV = Struct("DXVA2_AES_CTR_IV", [ + (UINT64, "IV"), + (UINT64, "Count"), +]) + +DXVA2_DecodeExtensionData = Struct("DXVA2_DecodeExtensionData", [ + (UINT, "Function"), + (PVOID, "pPrivateInputData"), + (UINT, "PrivateInputDataSize"), + (PVOID, "pPrivateOutputData"), + (UINT, "PrivateOutputDataSize"), +]) + +DXVA2_DecodeExecuteParams = Struct("DXVA2_DecodeExecuteParams", [ + (UINT, "NumCompBuffers"), + (Array(DXVA2_DecodeBufferDesc, "{self}.NumCompBuffers"), "pCompressedBuffers"), + (Pointer(DXVA2_DecodeExtensionData), "pExtensionData"), +]) + +RESET_TOKEN = Handle("resetToken", UINT) + +IDirect3DDeviceManager9 = Interface("IDirect3DDeviceManager9", IUnknown) +IDirectXVideoAccelerationService = Interface("IDirectXVideoAccelerationService", IUnknown) +IDirectXVideoDecoderService = Interface("IDirectXVideoDecoderService", IDirectXVideoAccelerationService) +IDirectXVideoProcessorService = Interface("IDirectXVideoProcessorService", IDirectXVideoAccelerationService) +IDirectXVideoDecoder = Interface("IDirectXVideoDecoder", IUnknown) +IDirectXVideoProcessor = Interface("IDirectXVideoProcessor", IUnknown) + +IDirect3DDeviceManager9.methods += [ + StdMethod(HRESULT, "ResetDevice", [(ObjPointer(IDirect3DDevice9), "pDevice"), (RESET_TOKEN, "resetToken")]), + StdMethod(HRESULT, "OpenDeviceHandle", [Out(Pointer(HANDLE), "phDevice")]), + StdMethod(HRESULT, "CloseDeviceHandle", [(HANDLE, "hDevice")]), + StdMethod(HRESULT, "TestDevice", [(HANDLE, "hDevice")]), + StdMethod(HRESULT, "LockDevice", [(HANDLE, "hDevice"), Out(Pointer(ObjPointer(IDirect3DDevice9)), "ppDevice"), (BOOL, "fBlock")]), + StdMethod(HRESULT, "UnlockDevice", [(HANDLE, "hDevice"), (BOOL, "fSaveState")]), + StdMethod(HRESULT, "GetVideoService", [(HANDLE, "hDevice"), (REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppService")]), +] + +IDirectXVideoAccelerationService.methods += [ + StdMethod(HRESULT, "CreateSurface", [(UINT, "Width"), (UINT, "Height"), (UINT, "BackBuffers"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), (D3DUSAGE, "Usage"), (DXVA2_Type, "DxvaType"), Out(Pointer(ObjPointer(IDirect3DSurface9)), "ppSurface"), Out(Pointer(HANDLE), "pSharedHandle")]), +] + +IDirectXVideoDecoderService.methods += [ + StdMethod(HRESULT, "GetDecoderDeviceGuids", [Out(Pointer(UINT), "pCount"), Out(Pointer(Array(GUID, "pCount ? *pCount : 0")), "pGuids")], sideeffects=False), + StdMethod(HRESULT, "GetDecoderRenderTargets", [(REFGUID, "Guid"), Out(Pointer(UINT), "pCount"), Out(Pointer(Array(D3DFORMAT, "pCount ? *pCount : 0")), "pFormats")], sideeffects=False), + StdMethod(HRESULT, "GetDecoderConfigurations", [(REFGUID, "Guid"), (Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), (OpaquePointer(Void), "pReserved"), Out(Pointer(UINT), "pCount"), Out(Pointer(Array(DXVA2_ConfigPictureDecode, "pCount ? *pCount : 0")), "ppConfigs")], sideeffects=False), + StdMethod(HRESULT, "CreateVideoDecoder", [(REFGUID, "Guid"), (Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), (Pointer(Const(DXVA2_ConfigPictureDecode)), "pConfig"), Out(Array(ObjPointer(IDirect3DSurface9), "NumRenderTargets"), "ppDecoderRenderTargets"), (UINT, "NumRenderTargets"), Out(Pointer(ObjPointer(IDirectXVideoDecoder)), "ppDecode")]), +] + +IDirectXVideoProcessorService.methods += [ + StdMethod(HRESULT, "RegisterVideoProcessorSoftwareDevice", [(OpaquePointer(Void), "pCallbacks")], sideeffects=False), + StdMethod(HRESULT, "GetVideoProcessorDeviceGuids", [(Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), Out(Pointer(UINT), "pCount"), Out(Pointer(Array(GUID, "pCount ? *pCount : 0")), "pGuids")], sideeffects=False), + StdMethod(HRESULT, "GetVideoProcessorRenderTargets", [(REFGUID, "VideoProcDeviceGuid"), (Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), Out(Pointer(UINT), "pCount"), Out(Pointer(Array(D3DFORMAT, "pCount ? *pCount : 0")), "pFormats")], sideeffects=False), + StdMethod(HRESULT, "GetVideoProcessorSubStreamFormats", [(REFGUID, "VideoProcDeviceGuid"), (Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), (D3DFORMAT, "RenderTargetFormat"), Out(Pointer(UINT), "pCount"), Out(Pointer(Array(D3DFORMAT, "pCount ? *pCount : 0")), "pFormats")], sideeffects=False), + StdMethod(HRESULT, "GetVideoProcessorCaps", [(REFGUID, "VideoProcDeviceGuid"), (Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), (D3DFORMAT, "RenderTargetFormat"), Out(Pointer(DXVA2_VideoProcessorCaps), "pCaps")], sideeffects=False), + StdMethod(HRESULT, "GetProcAmpRange", [(REFGUID, "VideoProcDeviceGuid"), (Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), (D3DFORMAT, "RenderTargetFormat"), (UINT, "ProcAmpCap"), Out(Pointer(DXVA2_ValueRange), "pRange")], sideeffects=False), + StdMethod(HRESULT, "GetFilterPropertyRange", [(REFGUID, "VideoProcDeviceGuid"), (Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), (D3DFORMAT, "RenderTargetFormat"), (UINT, "FilterSetting"), Out(Pointer(DXVA2_ValueRange), "pRange")], sideeffects=False), + StdMethod(HRESULT, "CreateVideoProcessor", [(REFGUID, "VideoProcDeviceGuid"), (Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), (D3DFORMAT, "RenderTargetFormat"), (UINT, "MaxNumSubStreams"), Out(Pointer(ObjPointer(IDirectXVideoProcessor)), "ppVidProcess")]), +] + +IDirectXVideoDecoder.methods += [ + StdMethod(HRESULT, "GetVideoDecoderService", [Out(Pointer(ObjPointer(IDirectXVideoDecoderService)), "ppService")]), + StdMethod(HRESULT, "GetCreationParameters", [Out(Pointer(GUID), "pDeviceGuid"), Out(Pointer(DXVA2_VideoDesc), "pVideoDesc"), Out(Pointer(DXVA2_ConfigPictureDecode), "pConfig"), Out(Pointer(Pointer(ObjPointer(IDirect3DSurface9))), "pDecoderRenderTargets"), Out(Pointer(UINT), "pNumSurfaces")]), + StdMethod(HRESULT, "GetBuffer", [(DXVA2_BufferType, "BufferType"), Out(Pointer(OpaqueBlob(Void, "*pBufferSize")), "ppBuffer"), Out(Pointer(UINT), "pBufferSize")]), + StdMethod(HRESULT, "ReleaseBuffer", [(UINT, "BufferType")]), + StdMethod(HRESULT, "BeginFrame", [(ObjPointer(IDirect3DSurface9), "pRenderTarget"), (OpaquePointer(Void), "pvPVPData")]), + StdMethod(HRESULT, "EndFrame", [Out(Pointer(HANDLE), "pHandleComplete")]), + StdMethod(HRESULT, "Execute", [(Pointer(Const(DXVA2_DecodeExecuteParams)), "pExecuteParams")]), +] + +IDirectXVideoProcessor.methods += [ + StdMethod(HRESULT, "GetVideoProcessorService", [Out(Pointer(ObjPointer(IDirectXVideoProcessorService)), "ppService")]), + StdMethod(HRESULT, "GetCreationParameters", [Out(Pointer(GUID), "pDeviceGuid"), Out(Pointer(DXVA2_VideoDesc), "pVideoDesc"), Out(Pointer(D3DFORMAT), "pRenderTargetFormat"), Out(Pointer(UINT), "pMaxNumSubStreams")], sideeffects=False), + StdMethod(HRESULT, "GetVideoProcessorCaps", [Out(Pointer(DXVA2_VideoProcessorCaps), "pCaps")], sideeffects=False), + StdMethod(HRESULT, "GetProcAmpRange", [(UINT, "ProcAmpCap"), Out(Pointer(DXVA2_ValueRange), "pRange")], sideeffects=False), + StdMethod(HRESULT, "GetFilterPropertyRange", [(UINT, "FilterSetting"), Out(Pointer(DXVA2_ValueRange), "pRange")], sideeffects=False), + StdMethod(HRESULT, "VideoProcessBlt", [(ObjPointer(IDirect3DSurface9), "pRenderTarget"), (Pointer(Const(DXVA2_VideoProcessBltParams)), "pBltParams"), (Array(Const(DXVA2_VideoSample), "NumSamples"), "pSamples"), (UINT, "NumSamples"), Out(Pointer(HANDLE), "pHandleComplete")]), +] + +DXVA2_SurfaceType = Enum("DXVA2_SurfaceType", [ + "DXVA2_SurfaceType_DecoderRenderTarget", + "DXVA2_SurfaceType_ProcessorRenderTarget", + "DXVA2_SurfaceType_D3DRenderTargetTexture", +]) + +IDirectXVideoMemoryConfiguration = Interface("IDirectXVideoMemoryConfiguration", IUnknown) +IDirectXVideoMemoryConfiguration.methods += [ + StdMethod(HRESULT, "GetAvailableSurfaceTypeByIndex", [(DWORD, "dwTypeIndex"), Out(Pointer(DXVA2_SurfaceType), "pdwType")], sideeffects=False), + StdMethod(HRESULT, "SetSurfaceType", [(DXVA2_SurfaceType, "dwType")]), +] + +dxva2 = Module("dxva2") +dxva2.addInterfaces([ + IDirectXVideoAccelerationService, + IDirectXVideoDecoderService, + IDirectXVideoProcessorService, + IDirectXVideoMemoryConfiguration, +]) + +dxva2.addFunctions([ + StdFunction(HRESULT, "DXVA2CreateDirect3DDeviceManager9", [Out(Pointer(RESET_TOKEN), "pResetToken"), Out(Pointer(ObjPointer(IDirect3DDeviceManager9)), "ppDeviceManager")]), + StdFunction(HRESULT, "DXVA2CreateVideoService", [(ObjPointer(IDirect3DDevice9), "pDD"), (REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppService")]), +]) diff --git a/wrappers/CMakeLists.txt b/wrappers/CMakeLists.txt index fd081c53..3a6f8b75 100644 --- a/wrappers/CMakeLists.txt +++ b/wrappers/CMakeLists.txt @@ -150,7 +150,7 @@ if (WIN32) ${CMAKE_SOURCE_DIR}/specs/d3d9.py ${CMAKE_SOURCE_DIR}/specs/d3d9types.py ${CMAKE_SOURCE_DIR}/specs/d3d9caps.py - ${CMAKE_SOURCE_DIR}/specs/d3d9dxva2.py + ${CMAKE_SOURCE_DIR}/specs/dxva2.py ${CMAKE_SOURCE_DIR}/specs/winapi.py ${CMAKE_SOURCE_DIR}/specs/stdapi.py ) diff --git a/wrappers/d3d9.def b/wrappers/d3d9.def index f52c0c49..8bb86905 100644 --- a/wrappers/d3d9.def +++ b/wrappers/d3d9.def @@ -10,3 +10,5 @@ EXPORTS D3DPERF_QueryRepeatFrame D3DPERF_SetOptions D3DPERF_GetStatus + DXVA2CreateDirect3DDeviceManager9 + DXVA2CreateVideoService diff --git a/wrappers/d3d9trace.py b/wrappers/d3d9trace.py index 45c950d6..0850ba3e 100644 --- a/wrappers/d3d9trace.py +++ b/wrappers/d3d9trace.py @@ -27,8 +27,7 @@ from dlltrace import DllTracer from specs.stdapi import API, Pointer, ObjPointer from specs.d3d9 import d3d9, D3DSHADER9, IDirect3DSwapChain9Ex, d3dperf - -import specs.d3d9dxva2 +from specs.dxva2 import dxva2 class D3D9Tracer(DllTracer): @@ -114,12 +113,13 @@ if __name__ == '__main__': print '#include "d3d9imports.hpp"' print '#include "d3d9size.hpp"' print '#include "d3d9shader.hpp"' - print '#include "dxvaint.h"' + print '#include "dxva2imports.hpp"' print d3d9.mergeModule(d3dperf) api = API() api.addModule(d3d9) + api.addModule(dxva2) tracer = D3D9Tracer() tracer.traceApi(api) |