From: José Fonseca Date: Sat, 10 Nov 2012 09:14:13 +0000 (+0000) Subject: Merge branch 'd2d' X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=cbe34810938b91291bc46a5de5535057b869f750;hp=4647f208f5a2b87391281e0f1202f66c23943bd9;p=apitrace Merge branch 'd2d' --- diff --git a/dispatch/dxvaint.h b/dispatch/dxvaint.h index f275d55..ad11304 100644 --- a/dispatch/dxvaint.h +++ b/dispatch/dxvaint.h @@ -27,6 +27,23 @@ #include +#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_PVP_SETKEY DXVA2_PVP_SETKEY; /* XXX */ typedef struct _DXVA2_DECODEBUFFERDESC { diff --git a/gui/graphing/frameaxiswidget.h b/gui/graphing/frameaxiswidget.h index db091d9..59fdc16 100644 --- a/gui/graphing/frameaxiswidget.h +++ b/gui/graphing/frameaxiswidget.h @@ -5,6 +5,8 @@ class FrameDataProvider { public: + virtual ~FrameDataProvider() {} + /* Number of frames */ virtual unsigned size() const = 0; diff --git a/helpers/d3d10size.hpp b/helpers/d3d10size.hpp index dbcab6a..92d4544 100644 --- a/helpers/d3d10size.hpp +++ b/helpers/d3d10size.hpp @@ -41,189 +41,8 @@ #include +#include "dxgisize.hpp" -static size_t -_calcDataSize(DXGI_FORMAT Format, UINT Width, UINT Height, UINT RowPitch, UINT Depth = 1, UINT DepthPitch = 0) { - if (Width == 0 || Height == 0 || Depth == 0) { - return 0; - } - - size_t BlockSize = 0; - UINT BlockWidth = 1; - UINT BlockHeight = 1; - switch (Format) { - case DXGI_FORMAT_UNKNOWN: - return 0; - case DXGI_FORMAT_R32G32B32A32_TYPELESS: - case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R32G32B32A32_UINT: - case DXGI_FORMAT_R32G32B32A32_SINT: - BlockSize = 128; - break; - case DXGI_FORMAT_R32G32B32_TYPELESS: - case DXGI_FORMAT_R32G32B32_FLOAT: - case DXGI_FORMAT_R32G32B32_UINT: - case DXGI_FORMAT_R32G32B32_SINT: - BlockSize = 96; - break; - case DXGI_FORMAT_R16G16B16A16_TYPELESS: - case DXGI_FORMAT_R16G16B16A16_FLOAT: - case DXGI_FORMAT_R16G16B16A16_UNORM: - case DXGI_FORMAT_R16G16B16A16_UINT: - case DXGI_FORMAT_R16G16B16A16_SNORM: - case DXGI_FORMAT_R16G16B16A16_SINT: - case DXGI_FORMAT_R32G32_TYPELESS: - case DXGI_FORMAT_R32G32_FLOAT: - case DXGI_FORMAT_R32G32_UINT: - case DXGI_FORMAT_R32G32_SINT: - case DXGI_FORMAT_R32G8X24_TYPELESS: - case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: - case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: - case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: - BlockSize = 64; - break; - case DXGI_FORMAT_R10G10B10A2_TYPELESS: - case DXGI_FORMAT_R10G10B10A2_UNORM: - case DXGI_FORMAT_R10G10B10A2_UINT: - case DXGI_FORMAT_R11G11B10_FLOAT: - case DXGI_FORMAT_R8G8B8A8_TYPELESS: - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_R8G8B8A8_UINT: - case DXGI_FORMAT_R8G8B8A8_SNORM: - case DXGI_FORMAT_R8G8B8A8_SINT: - case DXGI_FORMAT_R16G16_TYPELESS: - case DXGI_FORMAT_R16G16_FLOAT: - case DXGI_FORMAT_R16G16_UNORM: - case DXGI_FORMAT_R16G16_UINT: - case DXGI_FORMAT_R16G16_SNORM: - case DXGI_FORMAT_R16G16_SINT: - case DXGI_FORMAT_R32_TYPELESS: - case DXGI_FORMAT_D32_FLOAT: - case DXGI_FORMAT_R32_FLOAT: - case DXGI_FORMAT_R32_UINT: - case DXGI_FORMAT_R32_SINT: - case DXGI_FORMAT_R24G8_TYPELESS: - case DXGI_FORMAT_D24_UNORM_S8_UINT: - case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: - case DXGI_FORMAT_X24_TYPELESS_G8_UINT: - case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: - case DXGI_FORMAT_B8G8R8A8_TYPELESS: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8X8_TYPELESS: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - BlockSize = 32; - break; - case DXGI_FORMAT_R8G8_TYPELESS: - case DXGI_FORMAT_R8G8_UNORM: - case DXGI_FORMAT_R8G8_UINT: - case DXGI_FORMAT_R8G8_SNORM: - case DXGI_FORMAT_R8G8_SINT: - case DXGI_FORMAT_R16_TYPELESS: - case DXGI_FORMAT_R16_FLOAT: - case DXGI_FORMAT_D16_UNORM: - case DXGI_FORMAT_R16_UNORM: - case DXGI_FORMAT_R16_UINT: - case DXGI_FORMAT_R16_SNORM: - case DXGI_FORMAT_R16_SINT: - case DXGI_FORMAT_B5G6R5_UNORM: - case DXGI_FORMAT_B5G5R5A1_UNORM: - BlockSize = 16; - break; - case DXGI_FORMAT_R8_TYPELESS: - case DXGI_FORMAT_R8_UNORM: - case DXGI_FORMAT_R8_UINT: - case DXGI_FORMAT_R8_SNORM: - case DXGI_FORMAT_R8_SINT: - case DXGI_FORMAT_A8_UNORM: - BlockSize = 8; - break; - case DXGI_FORMAT_R1_UNORM: - BlockSize = 1; - break; - case DXGI_FORMAT_R8G8_B8G8_UNORM: - case DXGI_FORMAT_G8R8_G8B8_UNORM: - BlockSize = 32; - BlockWidth = 2; - break; - case DXGI_FORMAT_BC1_TYPELESS: - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: - BlockSize = 64; - BlockWidth = 4; - BlockHeight = 4; - break; - case DXGI_FORMAT_BC2_TYPELESS: - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_TYPELESS: - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - BlockSize = 128; - BlockWidth = 4; - BlockHeight = 4; - break; - default: - os::log("apitrace: warning: %s: unknown format 0x%04X\n", __FUNCTION__, Format); - return 0; - } - - Width = (Width + BlockWidth - 1) / BlockWidth; - Height = (Height + BlockHeight - 1) / BlockHeight; - - size_t size = (Width * BlockSize + 7)/ 8; - - if (Height > 1) { - size += (Height - 1) * RowPitch; - } - - if (Depth > 1) { - size += (Depth - 1) * DepthPitch; - } - - return size; -} - -static size_t -_calcMipDataSize(UINT MipLevel, DXGI_FORMAT Format, UINT Width, UINT Height, UINT RowPitch, UINT Depth = 1, UINT DepthPitch = 0) { - if (Width == 0 || Height == 0 || Depth == 0) { - return 0; - } - - Width = std::max(Width >> MipLevel, UINT(1)); - Height = std::max(Height >> MipLevel, UINT(1)); - Depth = std::max(Depth >> MipLevel, UINT(1)); - - return _calcDataSize(Format, Width, Height, RowPitch, Depth, DepthPitch); -} - - -inline UINT -_getNumMipLevels(UINT Width, UINT Height = 1, UINT Depth = 1) { - UINT MipLevels = 0; - do { - ++MipLevels; - Width >>= 1; - Height >>= 1; - Depth >>= 1; - } while (Width || Height || Depth); - return MipLevels; -} inline UINT _getNumMipLevels(const D3D10_BUFFER_DESC *pDesc) { @@ -357,27 +176,6 @@ _getMapInfo(ID3D10Texture3D *pResource, UINT Subresource, D3D10_MAP MapType, UIN } -static inline void -_getMapInfo(IDXGISurface *pResource, DXGI_MAPPED_RECT * pLockedRect, UINT MapFlags, - void * & pMappedData, size_t & MappedSize) { - pMappedData = 0; - MappedSize = 0; - - if (!(MapFlags & DXGI_MAP_WRITE)) { - return; - } - - DXGI_SURFACE_DESC Desc; - HRESULT hr = pResource->GetDesc(&Desc); - if (FAILED(hr)) { - return; - } - - pMappedData = pLockedRect->pBits; - MappedSize = _calcDataSize(Desc.Format, Desc.Width, Desc.Height, pLockedRect->Pitch); -} - - static inline size_t _calcSubresourceSize(ID3D10Resource *pDstResource, UINT DstSubresource, const D3D10_BOX *pDstBox, UINT SrcRowPitch, UINT SrcDepthPitch) { if (pDstBox && diff --git a/helpers/d3d11size.hpp b/helpers/d3d11size.hpp new file mode 100644 index 0000000..f746d80 --- /dev/null +++ b/helpers/d3d11size.hpp @@ -0,0 +1,191 @@ +/************************************************************************** + * + * Copyright 2012 Jose Fonseca + * 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, sub license, + * 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 (including the next + * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * AUTHORS, + * AND/OR THEIR SUPPLIERS 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. + * + **************************************************************************/ + + +/* + * Auxiliary functions to compute the size of array/blob arguments. + */ + +#ifndef _D3D11SIZE_HPP_ +#define _D3D11SIZE_HPP_ + + +/* We purposedly don't include any D3D header, so that this header can be used + * with all D3D versions. */ + +#include + +#include + +#include "dxgisize.hpp" + + +inline UINT +_getNumMipLevels(const D3D11_BUFFER_DESC *pDesc) { + return 1; +} + +inline UINT +_getNumMipLevels(const D3D11_TEXTURE1D_DESC *pDesc) { + return pDesc->MipLevels != 0 ? pDesc->MipLevels : _getNumMipLevels(pDesc->Width); +} + +inline UINT +_getNumMipLevels(const D3D11_TEXTURE2D_DESC *pDesc) { + return pDesc->MipLevels != 0 ? pDesc->MipLevels : _getNumMipLevels(pDesc->Width, pDesc->Height); +} + +inline UINT +_getNumMipLevels(const D3D11_TEXTURE3D_DESC *pDesc) { + return pDesc->MipLevels != 0 ? pDesc->MipLevels : _getNumMipLevels(pDesc->Width, pDesc->Height, pDesc->Depth); +} + +inline UINT +_getNumSubResources(const D3D11_BUFFER_DESC *pDesc) { + return 1; +} + +inline UINT +_getNumSubResources(const D3D11_TEXTURE1D_DESC *pDesc) { + return _getNumMipLevels(pDesc) * pDesc->ArraySize; +} + +inline UINT +_getNumSubResources(const D3D11_TEXTURE2D_DESC *pDesc) { + return _getNumMipLevels(pDesc) * pDesc->ArraySize; +} + +inline UINT +_getNumSubResources(const D3D11_TEXTURE3D_DESC *pDesc) { + return _getNumMipLevels(pDesc); +} + +static inline size_t +_calcSubresourceSize(const D3D11_BUFFER_DESC *pDesc, UINT Subresource, UINT RowPitch = 0, UINT SlicePitch = 0) { + return pDesc->ByteWidth; +} + +static inline size_t +_calcSubresourceSize(const D3D11_TEXTURE1D_DESC *pDesc, UINT Subresource, UINT RowPitch = 0, UINT SlicePitch = 0) { + UINT MipLevel = Subresource % _getNumMipLevels(pDesc); + return _calcMipDataSize(MipLevel, pDesc->Format, pDesc->Width, 1, RowPitch, 1, SlicePitch); +} + +static inline size_t +_calcSubresourceSize(const D3D11_TEXTURE2D_DESC *pDesc, UINT Subresource, UINT RowPitch, UINT SlicePitch = 0) { + UINT MipLevel = Subresource % _getNumMipLevels(pDesc); + return _calcMipDataSize(MipLevel, pDesc->Format, pDesc->Width, pDesc->Height, RowPitch, 1, SlicePitch); +} + +static inline size_t +_calcSubresourceSize(const D3D11_TEXTURE3D_DESC *pDesc, UINT Subresource, UINT RowPitch, UINT SlicePitch) { + UINT MipLevel = Subresource; + return _calcMipDataSize(MipLevel, pDesc->Format, pDesc->Width, pDesc->Height, RowPitch, pDesc->Depth, SlicePitch); +} + +static inline size_t +_calcSubresourceSize(ID3D11Resource *pDstResource, UINT DstSubresource, const D3D11_BOX *pDstBox, UINT SrcRowPitch, UINT SrcDepthPitch) { + if (pDstBox && + (pDstBox->left >= pDstBox->right || + pDstBox->top >= pDstBox->bottom || + pDstBox->front >= pDstBox->back)) { + return 0; + } + + D3D11_RESOURCE_DIMENSION Type = D3D11_RESOURCE_DIMENSION_UNKNOWN; + pDstResource->GetType(&Type); + + DXGI_FORMAT Format; + UINT Width; + UINT Height = 1; + UINT Depth = 1; + UINT MipLevel = 0; + + switch (Type) { + case D3D11_RESOURCE_DIMENSION_BUFFER: + if (pDstBox) { + return pDstBox->right - pDstBox->left; + } else { + D3D11_BUFFER_DESC Desc; + static_cast(pDstResource)->GetDesc(&Desc); + return Desc.ByteWidth; + } + case D3D11_RESOURCE_DIMENSION_TEXTURE1D: + { + D3D11_TEXTURE1D_DESC Desc; + static_cast(pDstResource)->GetDesc(&Desc); + Format = Desc.Format; + Width = Desc.Width; + MipLevel = DstSubresource % Desc.MipLevels; + } + break; + case D3D11_RESOURCE_DIMENSION_TEXTURE2D: + { + D3D11_TEXTURE2D_DESC Desc; + static_cast(pDstResource)->GetDesc(&Desc); + Format = Desc.Format; + Width = Desc.Width; + Height = Desc.Height; + MipLevel = DstSubresource % Desc.MipLevels; + } + break; + case D3D11_RESOURCE_DIMENSION_TEXTURE3D: + { + D3D11_TEXTURE3D_DESC Desc; + static_cast(pDstResource)->GetDesc(&Desc); + Format = Desc.Format; + Width = Desc.Width; + Height = Desc.Height; + Depth = Desc.Depth; + } + break; + case D3D11_RESOURCE_DIMENSION_UNKNOWN: + default: + assert(0); + return 0; + } + + return _calcMipDataSize(MipLevel, Format, Width, Height, SrcRowPitch, Depth, SrcDepthPitch); +} + + +static inline void +_getMapInfo(ID3D11DeviceContext* pContext, ID3D11Resource * pResource, UINT Subresource, D3D11_MAP MapType, UINT MapFlags, D3D11_MAPPED_SUBRESOURCE * pMappedResource, + void * & pMappedData, size_t & MappedSize) { + pMappedData = 0; + MappedSize = 0; + + if (MapType == D3D11_MAP_READ) { + return; + } + + pMappedData = pMappedResource->pData; + MappedSize = _calcSubresourceSize(pResource, Subresource, NULL, pMappedResource->RowPitch, pMappedResource->DepthPitch); +} + + +#endif /* _D3D11SIZE_HPP_ */ diff --git a/helpers/dxgisize.hpp b/helpers/dxgisize.hpp new file mode 100644 index 0000000..a2749ff --- /dev/null +++ b/helpers/dxgisize.hpp @@ -0,0 +1,252 @@ +/************************************************************************** + * + * Copyright 2012 Jose Fonseca + * 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, sub license, + * 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 (including the next + * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * AUTHORS, + * AND/OR THEIR SUPPLIERS 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. + * + **************************************************************************/ + + +/* + * Auxiliary functions to compute the size of array/blob arguments. + */ + +#ifndef _DXGISIZE_HPP_ +#define _DXGISIZE_HPP_ + + +/* We purposedly don't include any D3D header, so that this header can be used + * with all D3D versions. */ + +#include + +#include + +#include "os.hpp" + + +static size_t +_calcDataSize(DXGI_FORMAT Format, UINT Width, UINT Height, UINT RowPitch, UINT Depth = 1, UINT DepthPitch = 0) { + if (Width == 0 || Height == 0 || Depth == 0) { + return 0; + } + + size_t BlockSize = 0; + UINT BlockWidth = 1; + UINT BlockHeight = 1; + switch (Format) { + case DXGI_FORMAT_UNKNOWN: + return 0; + case DXGI_FORMAT_R32G32B32A32_TYPELESS: + case DXGI_FORMAT_R32G32B32A32_FLOAT: + case DXGI_FORMAT_R32G32B32A32_UINT: + case DXGI_FORMAT_R32G32B32A32_SINT: + BlockSize = 128; + break; + case DXGI_FORMAT_R32G32B32_TYPELESS: + case DXGI_FORMAT_R32G32B32_FLOAT: + case DXGI_FORMAT_R32G32B32_UINT: + case DXGI_FORMAT_R32G32B32_SINT: + BlockSize = 96; + break; + case DXGI_FORMAT_R16G16B16A16_TYPELESS: + case DXGI_FORMAT_R16G16B16A16_FLOAT: + case DXGI_FORMAT_R16G16B16A16_UNORM: + case DXGI_FORMAT_R16G16B16A16_UINT: + case DXGI_FORMAT_R16G16B16A16_SNORM: + case DXGI_FORMAT_R16G16B16A16_SINT: + case DXGI_FORMAT_R32G32_TYPELESS: + case DXGI_FORMAT_R32G32_FLOAT: + case DXGI_FORMAT_R32G32_UINT: + case DXGI_FORMAT_R32G32_SINT: + case DXGI_FORMAT_R32G8X24_TYPELESS: + case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: + case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: + case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: + BlockSize = 64; + break; + case DXGI_FORMAT_R10G10B10A2_TYPELESS: + case DXGI_FORMAT_R10G10B10A2_UNORM: + case DXGI_FORMAT_R10G10B10A2_UINT: + case DXGI_FORMAT_R11G11B10_FLOAT: + case DXGI_FORMAT_R8G8B8A8_TYPELESS: + case DXGI_FORMAT_R8G8B8A8_UNORM: + case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: + case DXGI_FORMAT_R8G8B8A8_UINT: + case DXGI_FORMAT_R8G8B8A8_SNORM: + case DXGI_FORMAT_R8G8B8A8_SINT: + case DXGI_FORMAT_R16G16_TYPELESS: + case DXGI_FORMAT_R16G16_FLOAT: + case DXGI_FORMAT_R16G16_UNORM: + case DXGI_FORMAT_R16G16_UINT: + case DXGI_FORMAT_R16G16_SNORM: + case DXGI_FORMAT_R16G16_SINT: + case DXGI_FORMAT_R32_TYPELESS: + case DXGI_FORMAT_D32_FLOAT: + case DXGI_FORMAT_R32_FLOAT: + case DXGI_FORMAT_R32_UINT: + case DXGI_FORMAT_R32_SINT: + case DXGI_FORMAT_R24G8_TYPELESS: + case DXGI_FORMAT_D24_UNORM_S8_UINT: + case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: + case DXGI_FORMAT_X24_TYPELESS_G8_UINT: + case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: + case DXGI_FORMAT_B8G8R8A8_UNORM: + case DXGI_FORMAT_B8G8R8X8_UNORM: + case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: + case DXGI_FORMAT_B8G8R8A8_TYPELESS: + case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: + case DXGI_FORMAT_B8G8R8X8_TYPELESS: + case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: + BlockSize = 32; + break; + case DXGI_FORMAT_R8G8_TYPELESS: + case DXGI_FORMAT_R8G8_UNORM: + case DXGI_FORMAT_R8G8_UINT: + case DXGI_FORMAT_R8G8_SNORM: + case DXGI_FORMAT_R8G8_SINT: + case DXGI_FORMAT_R16_TYPELESS: + case DXGI_FORMAT_R16_FLOAT: + case DXGI_FORMAT_D16_UNORM: + case DXGI_FORMAT_R16_UNORM: + case DXGI_FORMAT_R16_UINT: + case DXGI_FORMAT_R16_SNORM: + case DXGI_FORMAT_R16_SINT: + case DXGI_FORMAT_B5G6R5_UNORM: + case DXGI_FORMAT_B5G5R5A1_UNORM: + BlockSize = 16; + break; + case DXGI_FORMAT_R8_TYPELESS: + case DXGI_FORMAT_R8_UNORM: + case DXGI_FORMAT_R8_UINT: + case DXGI_FORMAT_R8_SNORM: + case DXGI_FORMAT_R8_SINT: + case DXGI_FORMAT_A8_UNORM: + BlockSize = 8; + break; + case DXGI_FORMAT_R1_UNORM: + BlockSize = 1; + break; + case DXGI_FORMAT_R8G8_B8G8_UNORM: + case DXGI_FORMAT_G8R8_G8B8_UNORM: + BlockSize = 32; + BlockWidth = 2; + break; + case DXGI_FORMAT_BC1_TYPELESS: + case DXGI_FORMAT_BC1_UNORM: + case DXGI_FORMAT_BC1_UNORM_SRGB: + case DXGI_FORMAT_BC4_TYPELESS: + case DXGI_FORMAT_BC4_UNORM: + case DXGI_FORMAT_BC4_SNORM: + BlockSize = 64; + BlockWidth = 4; + BlockHeight = 4; + break; + case DXGI_FORMAT_BC2_TYPELESS: + case DXGI_FORMAT_BC2_UNORM: + case DXGI_FORMAT_BC2_UNORM_SRGB: + case DXGI_FORMAT_BC3_TYPELESS: + case DXGI_FORMAT_BC3_UNORM: + case DXGI_FORMAT_BC3_UNORM_SRGB: + case DXGI_FORMAT_BC5_TYPELESS: + case DXGI_FORMAT_BC5_UNORM: + case DXGI_FORMAT_BC5_SNORM: + case DXGI_FORMAT_BC6H_TYPELESS: + case DXGI_FORMAT_BC6H_UF16: + case DXGI_FORMAT_BC6H_SF16: + case DXGI_FORMAT_BC7_TYPELESS: + case DXGI_FORMAT_BC7_UNORM: + case DXGI_FORMAT_BC7_UNORM_SRGB: + BlockSize = 128; + BlockWidth = 4; + BlockHeight = 4; + break; + default: + os::log("apitrace: warning: %s: unknown format 0x%04X\n", __FUNCTION__, Format); + return 0; + } + + Width = (Width + BlockWidth - 1) / BlockWidth; + Height = (Height + BlockHeight - 1) / BlockHeight; + + size_t size = (Width * BlockSize + 7)/ 8; + + if (Height > 1) { + size += (Height - 1) * RowPitch; + } + + if (Depth > 1) { + size += (Depth - 1) * DepthPitch; + } + + return size; +} + +static size_t +_calcMipDataSize(UINT MipLevel, DXGI_FORMAT Format, UINT Width, UINT Height, UINT RowPitch, UINT Depth = 1, UINT DepthPitch = 0) { + if (Width == 0 || Height == 0 || Depth == 0) { + return 0; + } + + Width = std::max(Width >> MipLevel, UINT(1)); + Height = std::max(Height >> MipLevel, UINT(1)); + Depth = std::max(Depth >> MipLevel, UINT(1)); + + return _calcDataSize(Format, Width, Height, RowPitch, Depth, DepthPitch); +} + + +inline UINT +_getNumMipLevels(UINT Width, UINT Height = 1, UINT Depth = 1) { + UINT MipLevels = 0; + do { + ++MipLevels; + Width >>= 1; + Height >>= 1; + Depth >>= 1; + } while (Width || Height || Depth); + return MipLevels; +} + + +static inline void +_getMapInfo(IDXGISurface *pResource, DXGI_MAPPED_RECT * pLockedRect, UINT MapFlags, + void * & pMappedData, size_t & MappedSize) { + pMappedData = 0; + MappedSize = 0; + + if (!(MapFlags & DXGI_MAP_WRITE)) { + return; + } + + DXGI_SURFACE_DESC Desc; + HRESULT hr = pResource->GetDesc(&Desc); + if (FAILED(hr)) { + return; + } + + pMappedData = pLockedRect->pBits; + MappedSize = _calcDataSize(Desc.Format, Desc.Width, Desc.Height, pLockedRect->Pitch); +} + + +#endif /* _DXGISIZE_HPP_ */ diff --git a/retrace/CMakeLists.txt b/retrace/CMakeLists.txt index 63fbed6..1f260e4 100644 --- a/retrace/CMakeLists.txt +++ b/retrace/CMakeLists.txt @@ -131,9 +131,9 @@ endif () if (WIN32 AND DirectX_D3DX9_INCLUDE_DIR) add_custom_command ( OUTPUT d3dretrace_d3d9.cpp - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3dretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_d3d9.cpp + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9retrace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_d3d9.cpp DEPENDS - d3dretrace.py + d3d9retrace.py dllretrace.py retrace.py ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py @@ -149,13 +149,122 @@ if (WIN32 AND DirectX_D3DX9_INCLUDE_DIR) d3dretrace_main.cpp d3dretrace_d3d9.cpp d3dretrace_ws.cpp - d3dstate.cpp - d3dstate_images.cpp + d3d9state.cpp + d3d9state_images.cpp ) target_link_libraries (d3dretrace retrace_common ) - - install (TARGETS d3dretrace RUNTIME DESTINATION bin) + + install (TARGETS d3dretrace RUNTIME DESTINATION bin) +endif () + +if (WIN32 AND DirectX_D3D10_INCLUDE_DIR) + add_custom_command ( + OUTPUT d3dretrace_d3d10.cpp + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d10retrace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_d3d10.cpp + DEPENDS + d3d10retrace.py + d3dcommonretrace.py + dllretrace.py + retrace.py + ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py + ${CMAKE_SOURCE_DIR}/specs/d3d10.py + ${CMAKE_SOURCE_DIR}/specs/d3d10misc.py + ${CMAKE_SOURCE_DIR}/specs/d3d10sdklayers.py + ${CMAKE_SOURCE_DIR}/specs/d3d10shader.py + ${CMAKE_SOURCE_DIR}/specs/d3d10effect.py + ${CMAKE_SOURCE_DIR}/specs/d3dcommon.py + ${CMAKE_SOURCE_DIR}/specs/dxgi.py + ${CMAKE_SOURCE_DIR}/specs/dxgitype.py + ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py + ${CMAKE_SOURCE_DIR}/specs/winapi.py + ${CMAKE_SOURCE_DIR}/specs/stdapi.py + ) + + include_directories (SYSTEM ${DirectX_D3D10_INCLUDE_DIR}) + add_executable (d3d10retrace + d3dretrace_main.cpp + d3dretrace_d3d10.cpp + d3dretrace_ws.cpp + d3d9state.cpp + d3d9state_images.cpp + ) + target_link_libraries (d3d10retrace + retrace_common + ) + + install (TARGETS d3d10retrace RUNTIME DESTINATION bin) endif () +if (WIN32 AND DirectX_D3D10_1_INCLUDE_DIR) + add_custom_command ( + OUTPUT d3dretrace_d3d10_1.cpp + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d10_1retrace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_d3d10_1.cpp + DEPENDS + d3d10retrace.py + d3dcommonretrace.py + dllretrace.py + retrace.py + ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py + ${CMAKE_SOURCE_DIR}/specs/d3d10_1.py + ${CMAKE_SOURCE_DIR}/specs/d3d10.py + ${CMAKE_SOURCE_DIR}/specs/d3d10sdklayers.py + ${CMAKE_SOURCE_DIR}/specs/d3dcommon.py + ${CMAKE_SOURCE_DIR}/specs/dxgi.py + ${CMAKE_SOURCE_DIR}/specs/dxgitype.py + ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py + ${CMAKE_SOURCE_DIR}/specs/winapi.py + ${CMAKE_SOURCE_DIR}/specs/stdapi.py + ) + + include_directories (SYSTEM ${DirectX_D3D10_1_INCLUDE_DIR}) + add_executable (d3d10_1retrace + d3dretrace_main.cpp + d3dretrace_d3d10_1.cpp + d3dretrace_ws.cpp + d3d9state.cpp + d3d9state_images.cpp + ) + target_link_libraries (d3d10_1retrace + retrace_common + ) + + install (TARGETS d3d10_1retrace RUNTIME DESTINATION bin) +endif () + +if (WIN32 AND DirectX_D3D11_INCLUDE_DIR) + add_custom_command ( + OUTPUT d3dretrace_d3d11.cpp + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d11retrace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_d3d11.cpp + DEPENDS + d3d11retrace.py + d3dcommonretrace.py + dllretrace.py + retrace.py + ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py + ${CMAKE_SOURCE_DIR}/specs/d3d11_1.py + ${CMAKE_SOURCE_DIR}/specs/d3d11.py + ${CMAKE_SOURCE_DIR}/specs/d3d11sdklayers.py + ${CMAKE_SOURCE_DIR}/specs/d3dcommon.py + ${CMAKE_SOURCE_DIR}/specs/dxgi.py + ${CMAKE_SOURCE_DIR}/specs/dxgitype.py + ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py + ${CMAKE_SOURCE_DIR}/specs/winapi.py + ${CMAKE_SOURCE_DIR}/specs/stdapi.py + ) + + include_directories (SYSTEM ${DirectX_D3D11_INCLUDE_DIR}) + add_executable (d3d11retrace + d3dretrace_main.cpp + d3dretrace_d3d11.cpp + d3dretrace_ws.cpp + d3d9state.cpp + d3d9state_images.cpp + ) + target_link_libraries (d3d11retrace + retrace_common + ) + + install (TARGETS d3d11retrace RUNTIME DESTINATION bin) +endif () diff --git a/retrace/d3d10_1retrace.py b/retrace/d3d10_1retrace.py new file mode 100644 index 0000000..bb45b82 --- /dev/null +++ b/retrace/d3d10_1retrace.py @@ -0,0 +1,48 @@ +########################################################################## +# +# Copyright 2011 Jose Fonseca +# 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. +# +##########################################################################/ + + +"""D3D10 retracer generator.""" + + +from d3dcommonretrace import D3DRetracer +import specs.stdapi as stdapi +from specs.d3d10_1 import d3d10_1 + + +if __name__ == '__main__': + print r''' +#include + +#include + +#include "d3d10_1imports.hpp" +#include "d3d10size.hpp" +#include "d3dretrace.hpp" + +''' + + retracer = D3DRetracer() + retracer.retraceApi(d3d10_1) diff --git a/retrace/d3d10retrace.py b/retrace/d3d10retrace.py new file mode 100644 index 0000000..877b1e4 --- /dev/null +++ b/retrace/d3d10retrace.py @@ -0,0 +1,48 @@ +########################################################################## +# +# Copyright 2011 Jose Fonseca +# 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. +# +##########################################################################/ + + +"""D3D10 retracer generator.""" + + +from d3dcommonretrace import D3DRetracer +import specs.stdapi as stdapi +from specs.d3d10 import d3d10 + + +if __name__ == '__main__': + print r''' +#include + +#include + +#include "d3d10imports.hpp" +#include "d3d10size.hpp" +#include "d3dretrace.hpp" + +''' + + retracer = D3DRetracer() + retracer.retraceApi(d3d10) diff --git a/retrace/d3d11retrace.py b/retrace/d3d11retrace.py new file mode 100644 index 0000000..8831024 --- /dev/null +++ b/retrace/d3d11retrace.py @@ -0,0 +1,48 @@ +########################################################################## +# +# Copyright 2011 Jose Fonseca +# 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. +# +##########################################################################/ + + +"""D3D10 retracer generator.""" + + +from d3dcommonretrace import D3DRetracer +import specs.stdapi as stdapi +from specs.d3d11 import d3d11 + + +if __name__ == '__main__': + print r''' +#include + +#include + +#include "d3d11imports.hpp" +#include "d3d11size.hpp" +#include "d3dretrace.hpp" + +''' + + retracer = D3DRetracer() + retracer.retraceApi(d3d11) diff --git a/retrace/d3d9retrace.py b/retrace/d3d9retrace.py new file mode 100644 index 0000000..7030f86 --- /dev/null +++ b/retrace/d3d9retrace.py @@ -0,0 +1,127 @@ +########################################################################## +# +# Copyright 2011 Jose Fonseca +# 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. +# +##########################################################################/ + + +"""D3D retracer generator.""" + + +from dllretrace import DllRetracer as Retracer +import specs.stdapi as stdapi +from specs.d3d9 import * + + +class D3DRetracer(Retracer): + + def retraceApi(self, api): + print '// Swizzling mapping for lock addresses' + print 'static std::map _locks;' + print + + self.table_name = 'd3dretrace::d3d_callbacks' + + Retracer.retraceApi(self, api) + + def invokeFunction(self, function): + if function.name in ('Direct3DCreate9', 'Direct3DCreate9Ex'): + print 'if (retrace::debug && !g_szD3D9DllName) {' + print ' /* ' + print ' * XXX: D3D9D only works for simple things, it often introduces errors' + print ' * on complex traces, or traces which use unofficial D3D9 features.' + print ' */' + print ' if (0) {' + print ' g_szD3D9DllName = "d3d9d.dll";' + print ' }' + print '}' + + Retracer.invokeFunction(self, function) + + def invokeInterfaceMethod(self, interface, method): + # keep track of the last used device for state dumping + if interface.name in ('IDirect3DDevice9', 'IDirect3DDevice9Ex'): + print r' d3dretrace::pLastDirect3DDevice9 = _this;' + + # create windows as neccessary + if method.name in ('CreateDevice', 'CreateDeviceEx', 'CreateAdditionalSwapChain'): + print r' HWND hWnd = d3dretrace::createWindow(pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);' + print r' pPresentationParameters->hDeviceWindow = hWnd;' + if 'hFocusWindow' in method.argNames(): + print r' hFocusWindow = hWnd;' + + if method.name in ('Reset', 'ResetEx'): + print r' if (pPresentationParameters->Windowed) {' + print r' d3dretrace::resizeWindow(pPresentationParameters->hDeviceWindow, pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);' + print r' }' + + # notify frame has been completed + if method.name == 'Present': + print r' retrace::frameComplete(call);' + print r' hDestWindowOverride = NULL;' + + if 'pSharedHandle' in method.argNames(): + print r' if (pSharedHandle) {' + print r' retrace::warning(call) << "shared surfaces unsupported\n";' + print r' pSharedHandle = NULL;' + print r' }' + + Retracer.invokeInterfaceMethod(self, interface, method) + + # process events after presents + if method.name == 'Present': + print r' d3dretrace::processEvents();' + + # check errors + if str(method.type) == 'HRESULT': + print r' if (FAILED(_result)) {' + print r' retrace::warning(call) << "failed\n";' + print r' }' + + if method.name in ('Lock', 'LockRect', 'LockBox'): + print ' VOID *_pbData = NULL;' + print ' size_t _LockedSize = 0;' + print ' _getLockInfo(_this, %s, _pbData, _LockedSize);' % ', '.join(method.argNames()[:-1]) + print ' _locks[_this] = _pbData;' + + if method.name in ('Unlock', 'UnlockRect', 'UnlockBox'): + print ' VOID *_pbData = 0;' + print ' _pbData = _locks[_this];' + print ' if (_pbData) {' + print ' retrace::delRegionByPointer(_pbData);' + print ' }' + + +if __name__ == '__main__': + print r''' +#include + +#include + +#include "d3d9imports.hpp" +#include "d3d9size.hpp" +#include "d3dretrace.hpp" + +''' + + retracer = D3DRetracer() + retracer.retraceApi(d3d9) diff --git a/retrace/d3d9state.cpp b/retrace/d3d9state.cpp new file mode 100644 index 0000000..73746e7 --- /dev/null +++ b/retrace/d3d9state.cpp @@ -0,0 +1,165 @@ +/************************************************************************** + * + * Copyright 2011 Jose Fonseca + * 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 + +#include + +#include "d3d9imports.hpp" +#include "json.hpp" + + +namespace d3dstate { + + +typedef HRESULT +(WINAPI *PD3DXDISASSEMBLESHADER)( + CONST DWORD *pShader, + BOOL EnableColorCode, + LPCSTR pComments, + LPD3DXBUFFER *ppDisassembly +); + + +HRESULT +disassembleShader(const DWORD *tokens, LPD3DXBUFFER *ppDisassembly) +{ + static BOOL firsttime = TRUE; + + /* + * TODO: Consider using d3dcompile_xx.dll per + * http://msdn.microsoft.com/en-us/library/windows/desktop/ee663275.aspx + */ + + static HMODULE hD3DXModule = NULL; + static PD3DXDISASSEMBLESHADER pfnD3DXDisassembleShader = NULL; + + if (firsttime) { + if (!hD3DXModule) { + unsigned release; + int version; + for (release = 0; release <= 1; ++release) { + /* Version 41 corresponds to Mar 2009 version of DirectX Runtime / SDK */ + for (version = 41; version >= 0; --version) { + char filename[256]; + _snprintf(filename, sizeof(filename), + "d3dx9%s%s%u.dll", release ? "" : "d", version ? "_" : "", version); + hD3DXModule = LoadLibraryA(filename); + if (hD3DXModule) + goto found; + } + } +found: + ; + } + + if (hD3DXModule) { + if (!pfnD3DXDisassembleShader) { + pfnD3DXDisassembleShader = (PD3DXDISASSEMBLESHADER)GetProcAddress(hD3DXModule, "D3DXDisassembleShader"); + } + } + + firsttime = FALSE; + } + + if (!pfnD3DXDisassembleShader) { + return E_FAIL; + } + + return pfnD3DXDisassembleShader(tokens, FALSE, NULL, ppDisassembly); +} + + +template< class T > +inline void +dumpShader(JSONWriter &json, const char *name, T *pShader) { + if (!pShader) { + return; + } + + HRESULT hr; + + UINT SizeOfData = 0; + + hr = pShader->GetFunction(NULL, &SizeOfData); + if (SUCCEEDED(hr)) { + void *pData; + pData = malloc(SizeOfData); + if (pData) { + hr = pShader->GetFunction(pData, &SizeOfData); + if (SUCCEEDED(hr)) { + LPD3DXBUFFER pDisassembly; + + hr = disassembleShader((const DWORD *)pData, &pDisassembly); + if (SUCCEEDED(hr)) { + json.beginMember(name); + json.writeString((const char *)pDisassembly->GetBufferPointer() /*, pDisassembly->GetBufferSize() */); + json.endMember(); + pDisassembly->Release(); + } + + } + free(pData); + } + } +} + +static void +dumpShaders(JSONWriter &json, IDirect3DDevice9 *pDevice) +{ + json.beginMember("shaders"); + + HRESULT hr; + json.beginObject(); + + IDirect3DVertexShader9 *pVertexShader = NULL; + hr = pDevice->GetVertexShader(&pVertexShader); + if (SUCCEEDED(hr)) { + dumpShader(json, "vertex", pVertexShader); + } + + IDirect3DPixelShader9 *pPixelShader = NULL; + hr = pDevice->GetPixelShader(&pPixelShader); + if (SUCCEEDED(hr)) { + dumpShader(json, "pixel", pPixelShader); + } + + json.endObject(); + json.endMember(); // shaders +} + +void +dumpDevice(std::ostream &os, IDirect3DDevice9 *pDevice) +{ + JSONWriter json(os); + + dumpShaders(json, pDevice); + + /* TODO */ +} + + +} /* namespace d3dstate */ diff --git a/retrace/d3d9state.hpp b/retrace/d3d9state.hpp new file mode 100644 index 0000000..053e7df --- /dev/null +++ b/retrace/d3d9state.hpp @@ -0,0 +1,55 @@ +/************************************************************************** + * + * Copyright 2011 Jose Fonseca + * 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. + * + **************************************************************************/ + +#ifndef _D3D9STATE_HPP_ +#define _D3D9STATE_HPP_ + + +#include + + +struct IDirect3DDevice9; + + +namespace image { + class Image; +} + + +namespace d3dstate { + + +image::Image * +getRenderTargetImage(IDirect3DDevice9 *pDevice); + + +void +dumpDevice(std::ostream &os, IDirect3DDevice9 *pDevice); + + +} /* namespace d3dstate */ + + +#endif /* _D3DSTATE_HPP_ */ diff --git a/retrace/d3d9state_images.cpp b/retrace/d3d9state_images.cpp new file mode 100644 index 0000000..855dede --- /dev/null +++ b/retrace/d3d9state_images.cpp @@ -0,0 +1,100 @@ +/************************************************************************** + * + * Copyright 2011 Jose Fonseca + * 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 + +#include "image.hpp" +#include "d3d9imports.hpp" + + +namespace d3dstate { + + +image::Image * +getRenderTargetImage(IDirect3DDevice9 *pDevice) { + image::Image *image = NULL; + IDirect3DSurface9 *pRenderTarget = NULL; + D3DSURFACE_DESC Desc; + IDirect3DSurface9 *pStagingSurface = NULL; + D3DLOCKED_RECT LockedRect; + const unsigned char *src; + unsigned char *dst; + HRESULT hr; + + hr = pDevice->GetRenderTarget(0, &pRenderTarget); + if (FAILED(hr)) { + goto no_rendertarget; + } + assert(pRenderTarget); + + hr = pRenderTarget->GetDesc(&Desc); + assert(SUCCEEDED(hr)); + assert(Desc.Format == D3DFMT_X8R8G8B8 || Desc.Format == D3DFMT_A8R8G8B8); + + hr = pDevice->CreateOffscreenPlainSurface(Desc.Width, Desc.Height, Desc.Format, D3DPOOL_SYSTEMMEM, &pStagingSurface, NULL); + if (FAILED(hr)) { + goto no_staging; + } + + hr = pDevice->GetRenderTargetData(pRenderTarget, pStagingSurface); + if (FAILED(hr)) { + goto no_rendertargetdata; + } + + hr = pStagingSurface->LockRect(&LockedRect, NULL, D3DLOCK_READONLY); + if (FAILED(hr)) { + goto no_rendertargetdata; + } + + image = new image::Image(Desc.Width, Desc.Height, 3, true); + if (!image) { + goto no_image; + } + + dst = image->start(); + src = (const unsigned char *)LockedRect.pBits; + for (unsigned y = 0; y < Desc.Height; ++y) { + for (unsigned x = 0; x < Desc.Width; ++x) { + dst[3*x + 0] = src[4*x + 2]; + dst[3*x + 1] = src[4*x + 1]; + dst[3*x + 2] = src[4*x + 0]; + } + src += LockedRect.Pitch; + dst += image->stride(); + } + +no_image: + pStagingSurface->UnlockRect(); +no_rendertargetdata: + pStagingSurface->Release(); +no_staging: + pRenderTarget->Release(); +no_rendertarget: + return image; +} + + +} /* namespace d3dstate */ diff --git a/retrace/d3dcommonretrace.py b/retrace/d3dcommonretrace.py new file mode 100644 index 0000000..ea09eb0 --- /dev/null +++ b/retrace/d3dcommonretrace.py @@ -0,0 +1,94 @@ +########################################################################## +# +# Copyright 2011 Jose Fonseca +# 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. +# +##########################################################################/ + + +"""D3D retracer generator.""" + + +from dllretrace import DllRetracer as Retracer +import specs.stdapi as stdapi + + +class D3DRetracer(Retracer): + + def retraceApi(self, api): + print '// Swizzling mapping for lock addresses' + print 'static std::map _maps;' + print + + self.table_name = 'd3dretrace::d3d_callbacks' + + Retracer.retraceApi(self, api) + + def invokeFunction(self, function): + # create windows as neccessary + if function.name in ('D3D10CreateDeviceAndSwapChain', 'D3D10CreateDeviceAndSwapChain1', 'D3D11CreateDeviceAndSwapChain'): + print r' pSwapChainDesc->OutputWindow = d3dretrace::createWindow(512, 512);' + + Retracer.invokeFunction(self, function) + + def invokeInterfaceMethod(self, interface, method): + # keep track of the last used device for state dumping + #if interface.name in ('IDirect3DDevice9', 'IDirect3DDevice9Ex'): + # print r' d3dretrace::pLastDirect3DDevice9 = _this;' + + # create windows as neccessary + if method.name == 'CreateSwapChain': + print r' pDesc->OutputWindow = d3dretrace::createWindow(512, 512);' + + # notify frame has been completed + if method.name == 'Present': + print r' retrace::frameComplete(call);' + + if 'pSharedResource' in method.argNames(): + print r' if (pSharedResource) {' + print r' retrace::warning(call) << "shared surfaces unsupported\n";' + print r' pSharedResource = NULL;' + print r' }' + + Retracer.invokeInterfaceMethod(self, interface, method) + + # process events after presents + if method.name == 'Present': + print r' d3dretrace::processEvents();' + + # check errors + if str(method.type) == 'HRESULT': + print r' if (FAILED(_result)) {' + print r' retrace::warning(call) << "failed\n";' + print r' }' + + if method.name == 'Map': + print ' VOID *_pbData = NULL;' + print ' size_t _MappedSize = 0;' + print ' _getMapInfo(_this, %s, _pbData, _MappedSize);' % ', '.join(method.argNames()) + print ' _maps[_this] = _pbData;' + + if method.name == 'Unmap': + print ' VOID *_pbData = 0;' + print ' _pbData = _maps[_this];' + print ' if (_pbData) {' + print ' retrace::delRegionByPointer(_pbData);' + print ' }' diff --git a/retrace/d3dretrace.hpp b/retrace/d3dretrace.hpp index b552c0b..dc174a8 100644 --- a/retrace/d3dretrace.hpp +++ b/retrace/d3dretrace.hpp @@ -35,16 +35,13 @@ struct IDirect3DDevice9; -extern const char *g_szD3D9DllName; - - namespace d3dretrace { extern IDirect3DDevice9 *pLastDirect3DDevice9; -extern const retrace::Entry d3d9_callbacks[]; +extern const retrace::Entry d3d_callbacks[]; HWND diff --git a/retrace/d3dretrace.py b/retrace/d3dretrace.py deleted file mode 100644 index 14b92ab..0000000 --- a/retrace/d3dretrace.py +++ /dev/null @@ -1,113 +0,0 @@ -########################################################################## -# -# Copyright 2011 Jose Fonseca -# 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. -# -##########################################################################/ - - -"""D3D retracer generator.""" - - -from dllretrace import DllRetracer as Retracer -import specs.stdapi as stdapi -from specs.d3d9 import * - - -class D3DRetracer(Retracer): - - def retraceApi(self, api): - print '// Swizzling mapping for lock addresses' - print 'static std::map _locks;' - print - - self.table_name = 'd3dretrace::%s_callbacks' % api.name.lower() - - Retracer.retraceApi(self, api) - - def invokeInterfaceMethod(self, interface, method): - # keep track of the last used device for state dumping - if interface.name in ('IDirect3DDevice9', 'IDirect3DDevice9Ex'): - print r' d3dretrace::pLastDirect3DDevice9 = _this;' - - # create windows as neccessary - if method.name in ('CreateDevice', 'CreateDeviceEx', 'CreateAdditionalSwapChain'): - print r' HWND hWnd = d3dretrace::createWindow(pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);' - print r' pPresentationParameters->hDeviceWindow = hWnd;' - if 'hFocusWindow' in method.argNames(): - print r' hFocusWindow = hWnd;' - - if method.name in ('Reset', 'ResetEx'): - print r' if (pPresentationParameters->Windowed) {' - print r' d3dretrace::resizeWindow(pPresentationParameters->hDeviceWindow, pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);' - print r' }' - - # notify frame has been completed - if method.name == 'Present': - print r' retrace::frameComplete(call);' - print r' hDestWindowOverride = NULL;' - - if 'pSharedHandle' in method.argNames(): - print r' if (pSharedHandle) {' - print r' retrace::warning(call) << "shared surfaces unsupported\n";' - print r' pSharedHandle = NULL;' - print r' }' - - Retracer.invokeInterfaceMethod(self, interface, method) - - # process events after presents - if method.name == 'Present': - print r' d3dretrace::processEvents();' - - # check errors - if str(method.type) == 'HRESULT': - print r' if (FAILED(_result)) {' - print r' retrace::warning(call) << "failed\n";' - print r' }' - - if method.name in ('Lock', 'LockRect', 'LockBox'): - print ' VOID *_pbData = NULL;' - print ' size_t _LockedSize = 0;' - print ' _getLockInfo(_this, %s, _pbData, _LockedSize);' % ', '.join(method.argNames()[:-1]) - print ' _locks[_this] = _pbData;' - - if method.name in ('Unlock', 'UnlockRect', 'UnlockBox'): - print ' VOID *_pbData = 0;' - print ' _pbData = _locks[_this];' - print ' if (_pbData) {' - print ' retrace::delRegionByPointer(_pbData);' - print ' }' - - -if __name__ == '__main__': - print r''' -#include - -#include - -#include "d3d9imports.hpp" -#include "d3d9size.hpp" -#include "d3dretrace.hpp" - -''' - - retracer = D3DRetracer() - retracer.retraceApi(d3d9) diff --git a/retrace/d3dretrace_main.cpp b/retrace/d3dretrace_main.cpp index 9878fe3..a19511a 100644 --- a/retrace/d3dretrace_main.cpp +++ b/retrace/d3dretrace_main.cpp @@ -28,7 +28,7 @@ #include "os_string.hpp" -#include "d3dstate.hpp" +#include "d3d9state.hpp" #include "retrace.hpp" #include "d3dretrace.hpp" @@ -39,22 +39,13 @@ d3dretrace::pLastDirect3DDevice9 = NULL; void retrace::setUp(void) { - if (retrace::debug) { - /* - * XXX: D3D9D only works for simple things, it often introduces errors - * on complex traces, or traces which use unofficial D3D9 features. - */ - if (0) { - g_szD3D9DllName = "d3d9d.dll"; - } - } } void retrace::addCallbacks(retrace::Retracer &retracer) { - retracer.addCallbacks(d3dretrace::d3d9_callbacks); + retracer.addCallbacks(d3dretrace::d3d_callbacks); } diff --git a/retrace/d3dstate.cpp b/retrace/d3dstate.cpp deleted file mode 100644 index 73746e7..0000000 --- a/retrace/d3dstate.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/************************************************************************** - * - * Copyright 2011 Jose Fonseca - * 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 - -#include - -#include "d3d9imports.hpp" -#include "json.hpp" - - -namespace d3dstate { - - -typedef HRESULT -(WINAPI *PD3DXDISASSEMBLESHADER)( - CONST DWORD *pShader, - BOOL EnableColorCode, - LPCSTR pComments, - LPD3DXBUFFER *ppDisassembly -); - - -HRESULT -disassembleShader(const DWORD *tokens, LPD3DXBUFFER *ppDisassembly) -{ - static BOOL firsttime = TRUE; - - /* - * TODO: Consider using d3dcompile_xx.dll per - * http://msdn.microsoft.com/en-us/library/windows/desktop/ee663275.aspx - */ - - static HMODULE hD3DXModule = NULL; - static PD3DXDISASSEMBLESHADER pfnD3DXDisassembleShader = NULL; - - if (firsttime) { - if (!hD3DXModule) { - unsigned release; - int version; - for (release = 0; release <= 1; ++release) { - /* Version 41 corresponds to Mar 2009 version of DirectX Runtime / SDK */ - for (version = 41; version >= 0; --version) { - char filename[256]; - _snprintf(filename, sizeof(filename), - "d3dx9%s%s%u.dll", release ? "" : "d", version ? "_" : "", version); - hD3DXModule = LoadLibraryA(filename); - if (hD3DXModule) - goto found; - } - } -found: - ; - } - - if (hD3DXModule) { - if (!pfnD3DXDisassembleShader) { - pfnD3DXDisassembleShader = (PD3DXDISASSEMBLESHADER)GetProcAddress(hD3DXModule, "D3DXDisassembleShader"); - } - } - - firsttime = FALSE; - } - - if (!pfnD3DXDisassembleShader) { - return E_FAIL; - } - - return pfnD3DXDisassembleShader(tokens, FALSE, NULL, ppDisassembly); -} - - -template< class T > -inline void -dumpShader(JSONWriter &json, const char *name, T *pShader) { - if (!pShader) { - return; - } - - HRESULT hr; - - UINT SizeOfData = 0; - - hr = pShader->GetFunction(NULL, &SizeOfData); - if (SUCCEEDED(hr)) { - void *pData; - pData = malloc(SizeOfData); - if (pData) { - hr = pShader->GetFunction(pData, &SizeOfData); - if (SUCCEEDED(hr)) { - LPD3DXBUFFER pDisassembly; - - hr = disassembleShader((const DWORD *)pData, &pDisassembly); - if (SUCCEEDED(hr)) { - json.beginMember(name); - json.writeString((const char *)pDisassembly->GetBufferPointer() /*, pDisassembly->GetBufferSize() */); - json.endMember(); - pDisassembly->Release(); - } - - } - free(pData); - } - } -} - -static void -dumpShaders(JSONWriter &json, IDirect3DDevice9 *pDevice) -{ - json.beginMember("shaders"); - - HRESULT hr; - json.beginObject(); - - IDirect3DVertexShader9 *pVertexShader = NULL; - hr = pDevice->GetVertexShader(&pVertexShader); - if (SUCCEEDED(hr)) { - dumpShader(json, "vertex", pVertexShader); - } - - IDirect3DPixelShader9 *pPixelShader = NULL; - hr = pDevice->GetPixelShader(&pPixelShader); - if (SUCCEEDED(hr)) { - dumpShader(json, "pixel", pPixelShader); - } - - json.endObject(); - json.endMember(); // shaders -} - -void -dumpDevice(std::ostream &os, IDirect3DDevice9 *pDevice) -{ - JSONWriter json(os); - - dumpShaders(json, pDevice); - - /* TODO */ -} - - -} /* namespace d3dstate */ diff --git a/retrace/d3dstate.hpp b/retrace/d3dstate.hpp deleted file mode 100644 index 33322a1..0000000 --- a/retrace/d3dstate.hpp +++ /dev/null @@ -1,55 +0,0 @@ -/************************************************************************** - * - * Copyright 2011 Jose Fonseca - * 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. - * - **************************************************************************/ - -#ifndef _D3DSTATE_HPP_ -#define _D3DSTATE_HPP_ - - -#include - - -struct IDirect3DDevice9; - - -namespace image { - class Image; -} - - -namespace d3dstate { - - -image::Image * -getRenderTargetImage(IDirect3DDevice9 *pDevice); - - -void -dumpDevice(std::ostream &os, IDirect3DDevice9 *pDevice); - - -} /* namespace d3dstate */ - - -#endif /* _D3DSTATE_HPP_ */ diff --git a/retrace/d3dstate_images.cpp b/retrace/d3dstate_images.cpp deleted file mode 100644 index 855dede..0000000 --- a/retrace/d3dstate_images.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/************************************************************************** - * - * Copyright 2011 Jose Fonseca - * 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 - -#include "image.hpp" -#include "d3d9imports.hpp" - - -namespace d3dstate { - - -image::Image * -getRenderTargetImage(IDirect3DDevice9 *pDevice) { - image::Image *image = NULL; - IDirect3DSurface9 *pRenderTarget = NULL; - D3DSURFACE_DESC Desc; - IDirect3DSurface9 *pStagingSurface = NULL; - D3DLOCKED_RECT LockedRect; - const unsigned char *src; - unsigned char *dst; - HRESULT hr; - - hr = pDevice->GetRenderTarget(0, &pRenderTarget); - if (FAILED(hr)) { - goto no_rendertarget; - } - assert(pRenderTarget); - - hr = pRenderTarget->GetDesc(&Desc); - assert(SUCCEEDED(hr)); - assert(Desc.Format == D3DFMT_X8R8G8B8 || Desc.Format == D3DFMT_A8R8G8B8); - - hr = pDevice->CreateOffscreenPlainSurface(Desc.Width, Desc.Height, Desc.Format, D3DPOOL_SYSTEMMEM, &pStagingSurface, NULL); - if (FAILED(hr)) { - goto no_staging; - } - - hr = pDevice->GetRenderTargetData(pRenderTarget, pStagingSurface); - if (FAILED(hr)) { - goto no_rendertargetdata; - } - - hr = pStagingSurface->LockRect(&LockedRect, NULL, D3DLOCK_READONLY); - if (FAILED(hr)) { - goto no_rendertargetdata; - } - - image = new image::Image(Desc.Width, Desc.Height, 3, true); - if (!image) { - goto no_image; - } - - dst = image->start(); - src = (const unsigned char *)LockedRect.pBits; - for (unsigned y = 0; y < Desc.Height; ++y) { - for (unsigned x = 0; x < Desc.Width; ++x) { - dst[3*x + 0] = src[4*x + 2]; - dst[3*x + 1] = src[4*x + 1]; - dst[3*x + 2] = src[4*x + 0]; - } - src += LockedRect.Pitch; - dst += image->stride(); - } - -no_image: - pStagingSurface->UnlockRect(); -no_rendertargetdata: - pStagingSurface->Release(); -no_staging: - pRenderTarget->Release(); -no_rendertarget: - return image; -} - - -} /* namespace d3dstate */ diff --git a/retrace/dllretrace.py b/retrace/dllretrace.py index 318741c..4fd481c 100644 --- a/retrace/dllretrace.py +++ b/retrace/dllretrace.py @@ -50,7 +50,6 @@ class DllDispatcher(Dispatcher): print r' if (!g_h%sModule) {' % tag print r' os::log("error: failed to load %s.dll\n");' % api.name print r' exit(1);' - print r' return NULL;' print r' }' print r' }' print r' return GetProcAddress(g_h%sModule, lpProcName);' % tag diff --git a/retrace/retrace.py b/retrace/retrace.py index f9b800c..2dd8e2f 100644 --- a/retrace/retrace.py +++ b/retrace/retrace.py @@ -34,7 +34,6 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) import specs.stdapi as stdapi -import specs.glapi as glapi class UnsupportedType(Exception): @@ -151,7 +150,7 @@ class ValueDeserializer(stdapi.Visitor): print ' %s = static_cast<%s>((%s).toPointer());' % (lvalue, pointer, rvalue) def visitObjPointer(self, pointer, lvalue, rvalue): - print ' %s = static_cast<%s>(retrace::toObjPointer(%s));' % (lvalue, pointer, rvalue) + print ' %s = static_cast<%s>(retrace::toObjPointer(call, %s));' % (lvalue, pointer, rvalue) def visitLinearPointer(self, pointer, lvalue, rvalue): print ' %s = static_cast<%s>(retrace::toPointer(%s));' % (lvalue, pointer, rvalue) @@ -357,9 +356,8 @@ class Retracer: def deserializeThisPointer(self, interface): print r' %s *_this;' % (interface.name,) - print r' _this = static_cast<%s *>(retrace::toObjPointer(call.arg(0)));' % (interface.name,) + print r' _this = static_cast<%s *>(retrace::toObjPointer(call, call.arg(0)));' % (interface.name,) print r' if (!_this) {' - print r' retrace::warning(call) << "NULL this pointer\n";' print r' return;' print r' }' diff --git a/retrace/retrace_swizzle.cpp b/retrace/retrace_swizzle.cpp index a7e777d..fe0df21 100644 --- a/retrace/retrace_swizzle.cpp +++ b/retrace/retrace_swizzle.cpp @@ -271,9 +271,18 @@ delObj(trace::Value &value) { } void * -toObjPointer(trace::Value &value) { +toObjPointer(trace::Call &call, trace::Value &value) { unsigned long long address = value.toUIntPtr(); - void *obj = address ? _obj_map[address] : NULL; + + void *obj; + if (address) { + obj = _obj_map[address]; + if (!obj) { + warning(call) << "unknown object 0x" << std::hex << address << std::dec << " call\n"; + } + } else { + obj = NULL; + } if (retrace::verbosity >= 2) { std::cout << std::hex << "obj 0x" << address << " <- 0x" << size_t(obj) << std::dec << "\n"; diff --git a/retrace/retrace_swizzle.hpp b/retrace/retrace_swizzle.hpp index 66c2962..bab6d56 100644 --- a/retrace/retrace_swizzle.hpp +++ b/retrace/retrace_swizzle.hpp @@ -94,7 +94,7 @@ void delObj(trace::Value &value); void * -toObjPointer(trace::Value &value); +toObjPointer(trace::Call &call, trace::Value &value); } /* namespace retrace */ diff --git a/specs/d3d10.py b/specs/d3d10.py index 7b0f182..9a25327 100644 --- a/specs/d3d10.py +++ b/specs/d3d10.py @@ -603,12 +603,12 @@ D3D10_VIEWPORT = Struct("D3D10_VIEWPORT", [ ]) D3D10_MAPPED_TEXTURE2D = Struct("D3D10_MAPPED_TEXTURE2D", [ - (OpaquePointer(Void), "pData"), + (LinearPointer(Void, "_MappedSize"), "pData"), (UINT, "RowPitch"), ]) D3D10_MAPPED_TEXTURE3D = Struct("D3D10_MAPPED_TEXTURE3D", [ - (OpaquePointer(Void), "pData"), + (LinearPointer(Void, "_MappedSize"), "pData"), (UINT, "RowPitch"), (UINT, "DepthPitch"), ]) @@ -722,13 +722,13 @@ ID3D10Resource.methods += [ ] ID3D10Buffer.methods += [ - Method(HRESULT, "Map", [(D3D10_MAP, "MapType"), (D3D10_MAP_FLAG, "MapFlags"), Out(Pointer(OpaquePointer(Void)), "ppData")]), + Method(HRESULT, "Map", [(D3D10_MAP, "MapType"), (D3D10_MAP_FLAG, "MapFlags"), Out(Pointer(LinearPointer(Void, "_MappedSize")), "ppData")]), Method(Void, "Unmap", []), Method(Void, "GetDesc", [Out(Pointer(D3D10_BUFFER_DESC), "pDesc")], sideeffects=False), ] ID3D10Texture1D.methods += [ - Method(HRESULT, "Map", [(UINT, "Subresource"), (D3D10_MAP, "MapType"), (D3D10_MAP_FLAG, "MapFlags"), Out(Pointer(OpaquePointer(Void)), "ppData")]), + Method(HRESULT, "Map", [(UINT, "Subresource"), (D3D10_MAP, "MapType"), (D3D10_MAP_FLAG, "MapFlags"), Out(Pointer(LinearPointer(Void, "_MappedSize")), "ppData")]), Method(Void, "Unmap", [(UINT, "Subresource")]), Method(Void, "GetDesc", [Out(Pointer(D3D10_TEXTURE1D_DESC), "pDesc")], sideeffects=False), ] diff --git a/specs/d3d10effect.py b/specs/d3d10effect.py index 57746aa..d88cdcd 100644 --- a/specs/d3d10effect.py +++ b/specs/d3d10effect.py @@ -136,7 +136,7 @@ D3D10_EFFECT_TYPE_DESC = Struct("D3D10_EFFECT_TYPE_DESC", [ ID3D10EffectType.methods += [ StdMethod(BOOL, "IsValid", []), - StdMethod(HRESULT, "GetDesc", [(Pointer(D3D10_EFFECT_TYPE_DESC), "pDesc")]), + StdMethod(HRESULT, "GetDesc", [Out(Pointer(D3D10_EFFECT_TYPE_DESC), "pDesc")]), StdMethod(ObjPointer(ID3D10EffectType), "GetMemberTypeByIndex", [(UINT, "Index")]), StdMethod(ObjPointer(ID3D10EffectType), "GetMemberTypeByName", [(LPCSTR, "Name")]), StdMethod(ObjPointer(ID3D10EffectType), "GetMemberTypeBySemantic", [(LPCSTR, "Semantic")]), @@ -177,8 +177,8 @@ ID3D10EffectVariable.methods += [ StdMethod(ObjPointer(ID3D10EffectDepthStencilVariable), "AsDepthStencil", []), StdMethod(ObjPointer(ID3D10EffectRasterizerVariable), "AsRasterizer", []), StdMethod(ObjPointer(ID3D10EffectSamplerVariable), "AsSampler", []), - StdMethod(HRESULT, "SetRawValue", [(OpaquePointer(Void), "pData"), (UINT, "Offset"), (UINT, "ByteCount")]), - StdMethod(HRESULT, "GetRawValue", [Out(OpaquePointer(Void), "pData"), (UINT, "Offset"), (UINT, "ByteCount")]), + StdMethod(HRESULT, "SetRawValue", [(Blob(Void, "ByteCount"), "pData"), (UINT, "Offset"), (UINT, "ByteCount")]), + StdMethod(HRESULT, "GetRawValue", [Out(OpaqueBlob(Void, "ByteCount"), "pData"), (UINT, "Offset"), (UINT, "ByteCount")], sideeffects=False), ] ID3D10EffectScalarVariable.methods += [ @@ -200,26 +200,26 @@ ID3D10EffectVectorVariable.methods += [ StdMethod(HRESULT, "SetBoolVector", [(Pointer(BOOL), "pData")]), StdMethod(HRESULT, "SetIntVector", [(Pointer(Int), "pData")]), StdMethod(HRESULT, "SetFloatVector", [(Pointer(Float), "pData")]), - StdMethod(HRESULT, "GetBoolVector", [(Pointer(BOOL), "pData")]), - StdMethod(HRESULT, "GetIntVector", [(Pointer(Int), "pData")]), - StdMethod(HRESULT, "GetFloatVector", [(Pointer(Float), "pData")]), + StdMethod(HRESULT, "GetBoolVector", [Out(Pointer(BOOL), "pData")]), + StdMethod(HRESULT, "GetIntVector", [Out(Pointer(Int), "pData")]), + StdMethod(HRESULT, "GetFloatVector", [Out(Pointer(Float), "pData")]), StdMethod(HRESULT, "SetBoolVectorArray", [(Pointer(BOOL), "pData"), (UINT, "Offset"), (UINT, "Count")]), StdMethod(HRESULT, "SetIntVectorArray", [(Pointer(Int), "pData"), (UINT, "Offset"), (UINT, "Count")]), StdMethod(HRESULT, "SetFloatVectorArray", [(Pointer(Float), "pData"), (UINT, "Offset"), (UINT, "Count")]), - StdMethod(HRESULT, "GetBoolVectorArray", [(Pointer(BOOL), "pData"), (UINT, "Offset"), (UINT, "Count")]), - StdMethod(HRESULT, "GetIntVectorArray", [(Pointer(Int), "pData"), (UINT, "Offset"), (UINT, "Count")]), - StdMethod(HRESULT, "GetFloatVectorArray", [(Pointer(Float), "pData"), (UINT, "Offset"), (UINT, "Count")]), + StdMethod(HRESULT, "GetBoolVectorArray", [Out(Pointer(BOOL), "pData"), (UINT, "Offset"), (UINT, "Count")]), + StdMethod(HRESULT, "GetIntVectorArray", [Out(Pointer(Int), "pData"), (UINT, "Offset"), (UINT, "Count")]), + StdMethod(HRESULT, "GetFloatVectorArray", [Out(Pointer(Float), "pData"), (UINT, "Offset"), (UINT, "Count")]), ] ID3D10EffectMatrixVariable.methods += [ StdMethod(HRESULT, "SetMatrix", [(Pointer(Float), "pData")]), - StdMethod(HRESULT, "GetMatrix", [(Pointer(Float), "pData")]), + StdMethod(HRESULT, "GetMatrix", [Out(Pointer(Float), "pData")]), StdMethod(HRESULT, "SetMatrixArray", [(Pointer(Float), "pData"), (UINT, "Offset"), (UINT, "Count")]), - StdMethod(HRESULT, "GetMatrixArray", [(Pointer(Float), "pData"), (UINT, "Offset"), (UINT, "Count")]), + StdMethod(HRESULT, "GetMatrixArray", [Out(Pointer(Float), "pData"), (UINT, "Offset"), (UINT, "Count")]), StdMethod(HRESULT, "SetMatrixTranspose", [(Pointer(Float), "pData")]), - StdMethod(HRESULT, "GetMatrixTranspose", [(Pointer(Float), "pData")]), + StdMethod(HRESULT, "GetMatrixTranspose", [Out(Pointer(Float), "pData")]), StdMethod(HRESULT, "SetMatrixTransposeArray", [(Pointer(Float), "pData"), (UINT, "Offset"), (UINT, "Count")]), - StdMethod(HRESULT, "GetMatrixTransposeArray", [(Pointer(Float), "pData"), (UINT, "Offset"), (UINT, "Count")]), + StdMethod(HRESULT, "GetMatrixTransposeArray", [Out(Pointer(Float), "pData"), (UINT, "Offset"), (UINT, "Count")]), ] ID3D10EffectStringVariable.methods += [ @@ -275,8 +275,8 @@ ID3D10EffectShaderVariable.methods += [ ] ID3D10EffectBlendVariable.methods += [ - StdMethod(HRESULT, "GetBlendState", [(UINT, "Index"), (Pointer(ObjPointer(ID3D10BlendState)), "ppBlendState")]), - StdMethod(HRESULT, "GetBackingStore", [(UINT, "Index"), (Pointer(D3D10_BLEND_DESC), "pBlendDesc")]), + StdMethod(HRESULT, "GetBlendState", [(UINT, "Index"), Out(Pointer(ObjPointer(ID3D10BlendState)), "ppBlendState")]), + StdMethod(HRESULT, "GetBackingStore", [(UINT, "Index"), Out(Pointer(D3D10_BLEND_DESC), "pBlendDesc")]), ] ID3D10EffectDepthStencilVariable.methods += [ @@ -311,10 +311,10 @@ D3D10_PASS_SHADER_DESC = Struct("D3D10_PASS_SHADER_DESC", [ ID3D10EffectPass.methods += [ StdMethod(BOOL, "IsValid", []), - StdMethod(HRESULT, "GetDesc", [(Pointer(D3D10_PASS_DESC), "pDesc")]), - StdMethod(HRESULT, "GetVertexShaderDesc", [(Pointer(D3D10_PASS_SHADER_DESC), "pDesc")]), - StdMethod(HRESULT, "GetGeometryShaderDesc", [(Pointer(D3D10_PASS_SHADER_DESC), "pDesc")]), - StdMethod(HRESULT, "GetPixelShaderDesc", [(Pointer(D3D10_PASS_SHADER_DESC), "pDesc")]), + StdMethod(HRESULT, "GetDesc", [Out(Pointer(D3D10_PASS_DESC), "pDesc")]), + StdMethod(HRESULT, "GetVertexShaderDesc", [Out(Pointer(D3D10_PASS_SHADER_DESC), "pDesc")]), + StdMethod(HRESULT, "GetGeometryShaderDesc", [Out(Pointer(D3D10_PASS_SHADER_DESC), "pDesc")]), + StdMethod(HRESULT, "GetPixelShaderDesc", [Out(Pointer(D3D10_PASS_SHADER_DESC), "pDesc")]), StdMethod(ObjPointer(ID3D10EffectVariable), "GetAnnotationByIndex", [(UINT, "Index")]), StdMethod(ObjPointer(ID3D10EffectVariable), "GetAnnotationByName", [(LPCSTR, "Name")]), StdMethod(HRESULT, "Apply", [(UINT, "Flags")]), @@ -329,7 +329,7 @@ D3D10_TECHNIQUE_DESC = Struct("D3D10_TECHNIQUE_DESC", [ ID3D10EffectTechnique.methods += [ StdMethod(BOOL, "IsValid", []), - StdMethod(HRESULT, "GetDesc", [(Pointer(D3D10_TECHNIQUE_DESC), "pDesc")]), + StdMethod(HRESULT, "GetDesc", [Out(Pointer(D3D10_TECHNIQUE_DESC), "pDesc")]), StdMethod(ObjPointer(ID3D10EffectVariable), "GetAnnotationByIndex", [(UINT, "Index")]), StdMethod(ObjPointer(ID3D10EffectVariable), "GetAnnotationByName", [(LPCSTR, "Name")]), StdMethod(ObjPointer(ID3D10EffectPass), "GetPassByIndex", [(UINT, "Index")]), @@ -377,8 +377,8 @@ d3d10.addFunctions([ StdFunction(HRESULT, "D3D10StateBlockMaskDisableAll", [Out(Pointer(D3D10_STATE_BLOCK_MASK), "pMask")]), StdFunction(BOOL, "D3D10StateBlockMaskGetSetting", [(Pointer(D3D10_STATE_BLOCK_MASK), "pMask"), (D3D10_DEVICE_STATE_TYPES, "StateType"), (UINT, "Entry")]), StdFunction(HRESULT, "D3D10CreateStateBlock", [(ObjPointer(ID3D10Device), "pDevice"), (Pointer(D3D10_STATE_BLOCK_MASK), "pStateBlockMask"), Out(Pointer(ObjPointer(ID3D10StateBlock)), "ppStateBlock")]), - StdFunction(HRESULT, "D3D10CompileEffectFromMemory", [(OpaquePointer(Void), "pData"), (SIZE_T, "DataLength"), (LPCSTR, "pSrcFileName"), (Pointer(Const(D3D10_SHADER_MACRO)), "pDefines"), (LPD3D10INCLUDE, "pInclude"), (UINT, "HLSLFlags"), (UINT, "FXFlags"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppCompiledEffect"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppErrors")]), - StdFunction(HRESULT, "D3D10CreateEffectFromMemory", [(OpaquePointer(Void), "pData"), (SIZE_T, "DataLength"), (UINT, "FXFlags"), (ObjPointer(ID3D10Device), "pDevice"), (ObjPointer(ID3D10EffectPool), "pEffectPool"), Out(Pointer(ObjPointer(ID3D10Effect)), "ppEffect")]), - StdFunction(HRESULT, "D3D10CreateEffectPoolFromMemory", [(OpaquePointer(Void), "pData"), (SIZE_T, "DataLength"), (UINT, "FXFlags"), (ObjPointer(ID3D10Device), "pDevice"), Out(Pointer(ObjPointer(ID3D10EffectPool)), "ppEffectPool")]), + StdFunction(HRESULT, "D3D10CompileEffectFromMemory", [(Blob(Void, "DataLength"), "pData"), (SIZE_T, "DataLength"), (LPCSTR, "pSrcFileName"), (Pointer(Const(D3D10_SHADER_MACRO)), "pDefines"), (LPD3D10INCLUDE, "pInclude"), (UINT, "HLSLFlags"), (UINT, "FXFlags"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppCompiledEffect"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppErrors")]), + StdFunction(HRESULT, "D3D10CreateEffectFromMemory", [(Blob(Void, "DataLength"), "pData"), (SIZE_T, "DataLength"), (UINT, "FXFlags"), (ObjPointer(ID3D10Device), "pDevice"), (ObjPointer(ID3D10EffectPool), "pEffectPool"), Out(Pointer(ObjPointer(ID3D10Effect)), "ppEffect")]), + StdFunction(HRESULT, "D3D10CreateEffectPoolFromMemory", [(Blob(Void, "DataLength"), "pData"), (SIZE_T, "DataLength"), (UINT, "FXFlags"), (ObjPointer(ID3D10Device), "pDevice"), Out(Pointer(ObjPointer(ID3D10EffectPool)), "ppEffectPool")]), StdFunction(HRESULT, "D3D10DisassembleEffect", [(ObjPointer(ID3D10Effect), "pEffect"), (BOOL, "EnableColorCode"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppDisassembly")]), ]) diff --git a/specs/d3d10misc.py b/specs/d3d10misc.py index 6564cc2..2a3c55e 100644 --- a/specs/d3d10misc.py +++ b/specs/d3d10misc.py @@ -44,8 +44,8 @@ d3d10.addFunctions([ StdFunction(HRESULT, "D3D10CreateBlob", [(SIZE_T, "NumBytes"), Out(Pointer(LPD3D10BLOB), "ppBuffer")]), # Undocumented - StdFunction(DWORD, "D3D10GetVersion", []), - StdFunction(DWORD, "D3D10RegisterLayers", []), + StdFunction(DWORD, "D3D10GetVersion", [], internal=True), + StdFunction(DWORD, "D3D10RegisterLayers", [], internal=True), ]) d3d10.addInterfaces([ diff --git a/specs/d3d10shader.py b/specs/d3d10shader.py index 43ea865..08de330 100644 --- a/specs/d3d10shader.py +++ b/specs/d3d10shader.py @@ -130,7 +130,7 @@ D3D10_SIGNATURE_PARAMETER_DESC = Struct("D3D10_SIGNATURE_PARAMETER_DESC", [ ID3D10ShaderReflectionType = Interface("ID3D10ShaderReflectionType") ID3D10ShaderReflectionType.methods += [ - StdMethod(HRESULT, "GetDesc", [(Pointer(D3D10_SHADER_TYPE_DESC), "pDesc")]), + StdMethod(HRESULT, "GetDesc", [Out(Pointer(D3D10_SHADER_TYPE_DESC), "pDesc")]), StdMethod(ObjPointer(ID3D10ShaderReflectionType), "GetMemberTypeByIndex", [(UINT, "Index")]), StdMethod(ObjPointer(ID3D10ShaderReflectionType), "GetMemberTypeByName", [(LPCSTR, "Name")]), StdMethod(LPCSTR, "GetMemberTypeName", [(UINT, "Index")]), @@ -162,14 +162,14 @@ ID3D10ShaderReflection.methods += [ d3d10.addFunctions([ StdFunction(HRESULT, "D3D10CompileShader", [(LPCSTR, "pSrcData"), (SIZE_T, "SrcDataSize"), (LPCSTR, "pFileName"), (Pointer(Const(D3D10_SHADER_MACRO)), "pDefines"), (LPD3D10INCLUDE, "pInclude"), (LPCSTR, "pFunctionName"), (LPCSTR, "pProfile"), (UINT, "Flags"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppShader"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppErrorMsgs")]), - StdFunction(HRESULT, "D3D10DisassembleShader", [(OpaquePointer(Const(Void)), "pShader"), (SIZE_T, "BytecodeLength"), (BOOL, "EnableColorCode"), (LPCSTR, "pComments"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppDisassembly")]), + StdFunction(HRESULT, "D3D10DisassembleShader", [(Blob(Const(Void), "BytecodeLength"), "pShader"), (SIZE_T, "BytecodeLength"), (BOOL, "EnableColorCode"), (LPCSTR, "pComments"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppDisassembly")]), StdFunction(LPCSTR, "D3D10GetPixelShaderProfile", [(ObjPointer(ID3D10Device), "pDevice")]), StdFunction(LPCSTR, "D3D10GetVertexShaderProfile", [(ObjPointer(ID3D10Device), "pDevice")]), StdFunction(LPCSTR, "D3D10GetGeometryShaderProfile", [(ObjPointer(ID3D10Device), "pDevice")]), - StdFunction(HRESULT, "D3D10ReflectShader", [(OpaquePointer(Const(Void)), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10ShaderReflection)), "ppReflector")]), + StdFunction(HRESULT, "D3D10ReflectShader", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10ShaderReflection)), "ppReflector")]), StdFunction(HRESULT, "D3D10PreprocessShader", [(LPCSTR, "pSrcData"), (SIZE_T, "SrcDataSize"), (LPCSTR, "pFileName"), (Pointer(Const(D3D10_SHADER_MACRO)), "pDefines"), (LPD3D10INCLUDE, "pInclude"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppShaderText"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppErrorMsgs")]), - StdFunction(HRESULT, "D3D10GetInputSignatureBlob", [(OpaquePointer(Const(Void)), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppSignatureBlob")]), - StdFunction(HRESULT, "D3D10GetOutputSignatureBlob", [(OpaquePointer(Const(Void)), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppSignatureBlob")]), - StdFunction(HRESULT, "D3D10GetInputAndOutputSignatureBlob", [(OpaquePointer(Const(Void)), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppSignatureBlob")]), - StdFunction(HRESULT, "D3D10GetShaderDebugInfo", [(OpaquePointer(Const(Void)), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppDebugInfo")]), + StdFunction(HRESULT, "D3D10GetInputSignatureBlob", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppSignatureBlob")]), + StdFunction(HRESULT, "D3D10GetOutputSignatureBlob", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppSignatureBlob")]), + StdFunction(HRESULT, "D3D10GetInputAndOutputSignatureBlob", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppSignatureBlob")]), + StdFunction(HRESULT, "D3D10GetShaderDebugInfo", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppDebugInfo")]), ]) diff --git a/specs/d3d11.py b/specs/d3d11.py index 8a681bd..d299a23 100644 --- a/specs/d3d11.py +++ b/specs/d3d11.py @@ -327,9 +327,9 @@ D3D11_BOX = Struct("D3D11_BOX", [ ID3D11DeviceChild.methods += [ StdMethod(Void, "GetDevice", [Out(Pointer(ObjPointer(ID3D11Device)), "ppDevice")]), - StdMethod(HRESULT, "GetPrivateData", [(REFGUID, "guid"), Out(Pointer(UINT), "pDataSize"), Out(OpaquePointer(Void), "pData")]), - StdMethod(HRESULT, "SetPrivateData", [(REFGUID, "guid"), (UINT, "DataSize"), (OpaqueBlob(Const(Void), "DataSize"), "pData")]), - StdMethod(HRESULT, "SetPrivateDataInterface", [(REFGUID, "guid"), (OpaquePointer(Const(IUnknown)), "pData")]), + StdMethod(HRESULT, "GetPrivateData", [(REFGUID, "guid"), Out(Pointer(UINT), "pDataSize"), Out(OpaquePointer(Void), "pData")], sideeffects=False), + StdMethod(HRESULT, "SetPrivateData", [(REFGUID, "guid"), (UINT, "DataSize"), (OpaqueBlob(Const(Void), "DataSize"), "pData")], sideeffects=False), + StdMethod(HRESULT, "SetPrivateDataInterface", [(REFGUID, "guid"), (OpaquePointer(Const(IUnknown)), "pData")], sideeffects=False), ] D3D11_COMPARISON_FUNC = Enum("D3D11_COMPARISON_FUNC", [ @@ -456,7 +456,7 @@ ID3D11RasterizerState.methods += [ ] D3D11_SUBRESOURCE_DATA = Struct("D3D11_SUBRESOURCE_DATA", [ - (OpaquePointer(Const(Void)), "pSysMem"), + (Blob(Const(Void), "_calcSubresourceSize(pDesc, {i}, {self}.SysMemPitch, {self}.SysMemSlicePitch)"), "pSysMem"), (UINT, "SysMemPitch"), (UINT, "SysMemSlicePitch"), ]) @@ -893,7 +893,7 @@ D3D11_FORMAT_SUPPORT2 = Enum("D3D11_FORMAT_SUPPORT2", [ ]) ID3D11Asynchronous.methods += [ - StdMethod(UINT, "GetDataSize", []), + StdMethod(UINT, "GetDataSize", [], sideeffects=False), ] D3D11_ASYNC_GETDATA_FLAG = Flags(UINT, [ @@ -1006,9 +1006,9 @@ D3D11_CLASS_INSTANCE_DESC = Struct("D3D11_CLASS_INSTANCE_DESC", [ ID3D11ClassInstance.methods += [ StdMethod(Void, "GetClassLinkage", [Out(Pointer(ObjPointer(ID3D11ClassLinkage)), "ppLinkage")]), - StdMethod(Void, "GetDesc", [Out(Pointer(D3D11_CLASS_INSTANCE_DESC), "pDesc")]), - StdMethod(Void, "GetInstanceName", [Out(LPSTR, "pInstanceName"), Out(Pointer(SIZE_T), "pBufferLength")]), - StdMethod(Void, "GetTypeName", [Out(LPSTR, "pTypeName"), Out(Pointer(SIZE_T), "pBufferLength")]), + StdMethod(Void, "GetDesc", [Out(Pointer(D3D11_CLASS_INSTANCE_DESC), "pDesc")], sideeffects=False), + StdMethod(Void, "GetInstanceName", [Out(LPSTR, "pInstanceName"), Out(Pointer(SIZE_T), "pBufferLength")], sideeffects=False), + StdMethod(Void, "GetTypeName", [Out(LPSTR, "pTypeName"), Out(Pointer(SIZE_T), "pBufferLength")], sideeffects=False), ] ID3D11ClassLinkage.methods += [ @@ -1074,7 +1074,7 @@ ID3D11DeviceContext.methods += [ StdMethod(Void, "VSSetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), (Array(Const(ObjPointer(ID3D11SamplerState)), "NumSamplers"), "ppSamplers")]), StdMethod(Void, "Begin", [(ObjPointer(ID3D11Asynchronous), "pAsync")]), StdMethod(Void, "End", [(ObjPointer(ID3D11Asynchronous), "pAsync")]), - StdMethod(HRESULT, "GetData", [(ObjPointer(ID3D11Asynchronous), "pAsync"), Out(OpaqueBlob(Void, "DataSize"), "pData"), (UINT, "DataSize"), (D3D11_ASYNC_GETDATA_FLAG, "GetDataFlags")]), + StdMethod(HRESULT, "GetData", [(ObjPointer(ID3D11Asynchronous), "pAsync"), Out(OpaqueBlob(Void, "DataSize"), "pData"), (UINT, "DataSize"), (D3D11_ASYNC_GETDATA_FLAG, "GetDataFlags")], sideeffects=False), StdMethod(Void, "SetPredication", [(ObjPointer(ID3D11Predicate), "pPredicate"), (BOOL, "PredicateValue")]), StdMethod(Void, "GSSetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), (Array(Const(ObjPointer(ID3D11ShaderResourceView)), "NumViews"), "ppShaderResourceViews")]), StdMethod(Void, "GSSetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), (Array(Const(ObjPointer(ID3D11SamplerState)), "NumSamplers"), "ppSamplers")]), @@ -1093,7 +1093,7 @@ ID3D11DeviceContext.methods += [ StdMethod(Void, "RSSetScissorRects", [(UINT, "NumRects"), (Array(Const(D3D11_RECT), "NumRects"), "pRects")]), StdMethod(Void, "CopySubresourceRegion", [(ObjPointer(ID3D11Resource), "pDstResource"), (UINT, "DstSubresource"), (UINT, "DstX"), (UINT, "DstY"), (UINT, "DstZ"), (ObjPointer(ID3D11Resource), "pSrcResource"), (UINT, "SrcSubresource"), (Pointer(Const(D3D11_BOX)), "pSrcBox")]), StdMethod(Void, "CopyResource", [(ObjPointer(ID3D11Resource), "pDstResource"), (ObjPointer(ID3D11Resource), "pSrcResource")]), - StdMethod(Void, "UpdateSubresource", [(ObjPointer(ID3D11Resource), "pDstResource"), (UINT, "DstSubresource"), (Pointer(Const(D3D11_BOX)), "pDstBox"), (OpaquePointer(Const(Void)), "pSrcData"), (UINT, "SrcRowPitch"), (UINT, "SrcDepthPitch")]), + StdMethod(Void, "UpdateSubresource", [(ObjPointer(ID3D11Resource), "pDstResource"), (UINT, "DstSubresource"), (Pointer(Const(D3D11_BOX)), "pDstBox"), (Blob(Const(Void), "_calcSubresourceSize(pDstResource, DstSubresource, pDstBox, SrcRowPitch, SrcDepthPitch)"), "pSrcData"), (UINT, "SrcRowPitch"), (UINT, "SrcDepthPitch")]), StdMethod(Void, "CopyStructureCount", [(ObjPointer(ID3D11Buffer), "pDstBuffer"), (UINT, "DstAlignedByteOffset"), (ObjPointer(ID3D11UnorderedAccessView), "pSrcView")]), StdMethod(Void, "ClearRenderTargetView", [(ObjPointer(ID3D11RenderTargetView), "pRenderTargetView"), (Array(Const(FLOAT), 4), "ColorRGBA")]), StdMethod(Void, "ClearUnorderedAccessViewUint", [(ObjPointer(ID3D11UnorderedAccessView), "pUnorderedAccessView"), (Array(Const(UINT), 4), "Values")]), @@ -1171,10 +1171,10 @@ D3D11_CREATE_DEVICE_FLAG = Flags(UINT, [ ]) ID3D11Device.methods += [ - StdMethod(HRESULT, "CreateBuffer", [(Pointer(Const(D3D11_BUFFER_DESC)), "pDesc"), (Pointer(Const(D3D11_SUBRESOURCE_DATA)), "pInitialData"), Out(Pointer(ObjPointer(ID3D11Buffer)), "ppBuffer")]), - StdMethod(HRESULT, "CreateTexture1D", [(Pointer(Const(D3D11_TEXTURE1D_DESC)), "pDesc"), (Pointer(Const(D3D11_SUBRESOURCE_DATA)), "pInitialData"), Out(Pointer(ObjPointer(ID3D11Texture1D)), "ppTexture1D")]), - StdMethod(HRESULT, "CreateTexture2D", [(Pointer(Const(D3D11_TEXTURE2D_DESC)), "pDesc"), (Pointer(Const(D3D11_SUBRESOURCE_DATA)), "pInitialData"), Out(Pointer(ObjPointer(ID3D11Texture2D)), "ppTexture2D")]), - StdMethod(HRESULT, "CreateTexture3D", [(Pointer(Const(D3D11_TEXTURE3D_DESC)), "pDesc"), (Pointer(Const(D3D11_SUBRESOURCE_DATA)), "pInitialData"), Out(Pointer(ObjPointer(ID3D11Texture3D)), "ppTexture3D")]), + StdMethod(HRESULT, "CreateBuffer", [(Pointer(Const(D3D11_BUFFER_DESC)), "pDesc"), (Array(Const(D3D11_SUBRESOURCE_DATA), "1"), "pInitialData"), Out(Pointer(ObjPointer(ID3D11Buffer)), "ppBuffer")]), + StdMethod(HRESULT, "CreateTexture1D", [(Pointer(Const(D3D11_TEXTURE1D_DESC)), "pDesc"), (Array(Const(D3D11_SUBRESOURCE_DATA), "_getNumSubResources(pDesc)"), "pInitialData"), Out(Pointer(ObjPointer(ID3D11Texture1D)), "ppTexture1D")]), + StdMethod(HRESULT, "CreateTexture2D", [(Pointer(Const(D3D11_TEXTURE2D_DESC)), "pDesc"), (Array(Const(D3D11_SUBRESOURCE_DATA), "_getNumSubResources(pDesc)"), "pInitialData"), Out(Pointer(ObjPointer(ID3D11Texture2D)), "ppTexture2D")]), + StdMethod(HRESULT, "CreateTexture3D", [(Pointer(Const(D3D11_TEXTURE3D_DESC)), "pDesc"), (Array(Const(D3D11_SUBRESOURCE_DATA), "_getNumSubResources(pDesc)"), "pInitialData"), Out(Pointer(ObjPointer(ID3D11Texture3D)), "ppTexture3D")]), StdMethod(HRESULT, "CreateShaderResourceView", [(ObjPointer(ID3D11Resource), "pResource"), (Pointer(Const(D3D11_SHADER_RESOURCE_VIEW_DESC)), "pDesc"), Out(Pointer(ObjPointer(ID3D11ShaderResourceView)), "ppSRView")]), StdMethod(HRESULT, "CreateUnorderedAccessView", [(ObjPointer(ID3D11Resource), "pResource"), (Pointer(Const(D3D11_UNORDERED_ACCESS_VIEW_DESC)), "pDesc"), Out(Pointer(ObjPointer(ID3D11UnorderedAccessView)), "ppUAView")]), StdMethod(HRESULT, "CreateRenderTargetView", [(ObjPointer(ID3D11Resource), "pResource"), (Pointer(Const(D3D11_RENDER_TARGET_VIEW_DESC)), "pDesc"), Out(Pointer(ObjPointer(ID3D11RenderTargetView)), "ppRTView")]), @@ -1200,11 +1200,11 @@ ID3D11Device.methods += [ StdMethod(HRESULT, "CheckFormatSupport", [(DXGI_FORMAT, "Format"), Out(Pointer(D3D11_FORMAT_SUPPORT), "pFormatSupport")]), StdMethod(HRESULT, "CheckMultisampleQualityLevels", [(DXGI_FORMAT, "Format"), (UINT, "SampleCount"), Out(Pointer(UINT), "pNumQualityLevels")]), StdMethod(Void, "CheckCounterInfo", [Out(Pointer(D3D11_COUNTER_INFO), "pCounterInfo")]), - StdMethod(HRESULT, "CheckCounter", [(Pointer(Const(D3D11_COUNTER_DESC)), "pDesc"), Out(Pointer(D3D11_COUNTER_TYPE), "pType"), Out(Pointer(UINT), "pActiveCounters"), Out(LPSTR, "szName"), Out(Pointer(UINT), "pNameLength"), Out(LPSTR, "szUnits"), Out(Pointer(UINT), "pUnitsLength"), Out(LPSTR, "szDescription"), Out(Pointer(UINT), "pDescriptionLength")]), - StdMethod(HRESULT, "CheckFeatureSupport", [(D3D11_FEATURE, "Feature"), Out(D3D11_FEATURE_DATA, "pFeatureSupportData"), (UINT, "FeatureSupportDataSize")]), - StdMethod(HRESULT, "GetPrivateData", [(REFGUID, "guid"), Out(Pointer(UINT), "pDataSize"), Out(OpaquePointer(Void), "pData")]), - StdMethod(HRESULT, "SetPrivateData", [(REFGUID, "guid"), (UINT, "DataSize"), (OpaqueBlob(Const(Void), "DataSize"), "pData")]), - StdMethod(HRESULT, "SetPrivateDataInterface", [(REFGUID, "guid"), (OpaquePointer(Const(IUnknown)), "pData")]), + StdMethod(HRESULT, "CheckCounter", [(Pointer(Const(D3D11_COUNTER_DESC)), "pDesc"), Out(Pointer(D3D11_COUNTER_TYPE), "pType"), Out(Pointer(UINT), "pActiveCounters"), Out(LPSTR, "szName"), Out(Pointer(UINT), "pNameLength"), Out(LPSTR, "szUnits"), Out(Pointer(UINT), "pUnitsLength"), Out(LPSTR, "szDescription"), Out(Pointer(UINT), "pDescriptionLength")], sideeffects=False), + StdMethod(HRESULT, "CheckFeatureSupport", [(D3D11_FEATURE, "Feature"), Out(D3D11_FEATURE_DATA, "pFeatureSupportData"), (UINT, "FeatureSupportDataSize")], sideeffects=False), + StdMethod(HRESULT, "GetPrivateData", [(REFGUID, "guid"), Out(Pointer(UINT), "pDataSize"), Out(OpaquePointer(Void), "pData")], sideeffects=False), + StdMethod(HRESULT, "SetPrivateData", [(REFGUID, "guid"), (UINT, "DataSize"), (OpaqueBlob(Const(Void), "DataSize"), "pData")], sideeffects=False), + StdMethod(HRESULT, "SetPrivateDataInterface", [(REFGUID, "guid"), (OpaquePointer(Const(IUnknown)), "pData")], sideeffects=False), StdMethod(D3D_FEATURE_LEVEL, "GetFeatureLevel", []), StdMethod(D3D11_CREATE_DEVICE_FLAG, "GetCreationFlags", []), StdMethod(HRESULT, "GetDeviceRemovedReason", []), diff --git a/specs/d3d11sdklayers.py b/specs/d3d11sdklayers.py index 13d85be..0e246fd 100644 --- a/specs/d3d11sdklayers.py +++ b/specs/d3d11sdklayers.py @@ -851,40 +851,40 @@ D3D11_INFO_QUEUE_FILTER = Struct("D3D11_INFO_QUEUE_FILTER", [ ID3D11InfoQueue = Interface("ID3D11InfoQueue", IUnknown) ID3D11InfoQueue.methods += [ - StdMethod(HRESULT, "SetMessageCountLimit", [(UINT64, "MessageCountLimit")]), - StdMethod(Void, "ClearStoredMessages", []), - StdMethod(HRESULT, "GetMessage", [(UINT64, "MessageIndex"), Out(Pointer(D3D11_MESSAGE), "pMessage"), Out(Pointer(SIZE_T), "pMessageByteLength")]), - StdMethod(UINT64, "GetNumMessagesAllowedByStorageFilter", []), - StdMethod(UINT64, "GetNumMessagesDeniedByStorageFilter", []), - StdMethod(UINT64, "GetNumStoredMessages", []), - StdMethod(UINT64, "GetNumStoredMessagesAllowedByRetrievalFilter", []), - StdMethod(UINT64, "GetNumMessagesDiscardedByMessageCountLimit", []), - StdMethod(UINT64, "GetMessageCountLimit", []), - StdMethod(HRESULT, "AddStorageFilterEntries", [(Pointer(D3D11_INFO_QUEUE_FILTER), "pFilter")]), - StdMethod(HRESULT, "GetStorageFilter", [Out(Pointer(D3D11_INFO_QUEUE_FILTER), "pFilter"), Out(Pointer(SIZE_T), "pFilterByteLength")]), - StdMethod(Void, "ClearStorageFilter", []), - StdMethod(HRESULT, "PushEmptyStorageFilter", []), - StdMethod(HRESULT, "PushCopyOfStorageFilter", []), - StdMethod(HRESULT, "PushStorageFilter", [(Pointer(D3D11_INFO_QUEUE_FILTER), "pFilter")]), - StdMethod(Void, "PopStorageFilter", []), - StdMethod(UINT, "GetStorageFilterStackSize", []), - StdMethod(HRESULT, "AddRetrievalFilterEntries", [(Pointer(D3D11_INFO_QUEUE_FILTER), "pFilter")]), - StdMethod(HRESULT, "GetRetrievalFilter", [Out(Pointer(D3D11_INFO_QUEUE_FILTER), "pFilter"), Out(Pointer(SIZE_T), "pFilterByteLength")]), - StdMethod(Void, "ClearRetrievalFilter", []), - StdMethod(HRESULT, "PushEmptyRetrievalFilter", []), - StdMethod(HRESULT, "PushCopyOfRetrievalFilter", []), - StdMethod(HRESULT, "PushRetrievalFilter", [(Pointer(D3D11_INFO_QUEUE_FILTER), "pFilter")]), - StdMethod(Void, "PopRetrievalFilter", []), - StdMethod(UINT, "GetRetrievalFilterStackSize", []), - StdMethod(HRESULT, "AddMessage", [(D3D11_MESSAGE_CATEGORY, "Category"), (D3D11_MESSAGE_SEVERITY, "Severity"), (D3D11_MESSAGE_ID, "ID"), (LPCSTR, "pDescription")]), - StdMethod(HRESULT, "AddApplicationMessage", [(D3D11_MESSAGE_SEVERITY, "Severity"), (LPCSTR, "pDescription")]), - StdMethod(HRESULT, "SetBreakOnCategory", [(D3D11_MESSAGE_CATEGORY, "Category"), (BOOL, "bEnable")]), - StdMethod(HRESULT, "SetBreakOnSeverity", [(D3D11_MESSAGE_SEVERITY, "Severity"), (BOOL, "bEnable")]), - StdMethod(HRESULT, "SetBreakOnID", [(D3D11_MESSAGE_ID, "ID"), (BOOL, "bEnable")]), - StdMethod(BOOL, "GetBreakOnCategory", [(D3D11_MESSAGE_CATEGORY, "Category")]), - StdMethod(BOOL, "GetBreakOnSeverity", [(D3D11_MESSAGE_SEVERITY, "Severity")]), - StdMethod(BOOL, "GetBreakOnID", [(D3D11_MESSAGE_ID, "ID")]), - StdMethod(Void, "SetMuteDebugOutput", [(BOOL, "bMute")]), - StdMethod(BOOL, "GetMuteDebugOutput", []), + StdMethod(HRESULT, "SetMessageCountLimit", [(UINT64, "MessageCountLimit")], sideeffects=False), + StdMethod(Void, "ClearStoredMessages", [], sideeffects=False), + StdMethod(HRESULT, "GetMessage", [(UINT64, "MessageIndex"), Out(Pointer(D3D11_MESSAGE), "pMessage"), Out(Pointer(SIZE_T), "pMessageByteLength")], sideeffects=False), + StdMethod(UINT64, "GetNumMessagesAllowedByStorageFilter", [], sideeffects=False), + StdMethod(UINT64, "GetNumMessagesDeniedByStorageFilter", [], sideeffects=False), + StdMethod(UINT64, "GetNumStoredMessages", [], sideeffects=False), + StdMethod(UINT64, "GetNumStoredMessagesAllowedByRetrievalFilter", [], sideeffects=False), + StdMethod(UINT64, "GetNumMessagesDiscardedByMessageCountLimit", [], sideeffects=False), + StdMethod(UINT64, "GetMessageCountLimit", [], sideeffects=False), + StdMethod(HRESULT, "AddStorageFilterEntries", [(Pointer(D3D11_INFO_QUEUE_FILTER), "pFilter")], sideeffects=False), + StdMethod(HRESULT, "GetStorageFilter", [Out(Pointer(D3D11_INFO_QUEUE_FILTER), "pFilter"), Out(Pointer(SIZE_T), "pFilterByteLength")], sideeffects=False), + StdMethod(Void, "ClearStorageFilter", [], sideeffects=False), + StdMethod(HRESULT, "PushEmptyStorageFilter", [], sideeffects=False), + StdMethod(HRESULT, "PushCopyOfStorageFilter", [], sideeffects=False), + StdMethod(HRESULT, "PushStorageFilter", [(Pointer(D3D11_INFO_QUEUE_FILTER), "pFilter")], sideeffects=False), + StdMethod(Void, "PopStorageFilter", [], sideeffects=False), + StdMethod(UINT, "GetStorageFilterStackSize", [], sideeffects=False), + StdMethod(HRESULT, "AddRetrievalFilterEntries", [(Pointer(D3D11_INFO_QUEUE_FILTER), "pFilter")], sideeffects=False), + StdMethod(HRESULT, "GetRetrievalFilter", [Out(Pointer(D3D11_INFO_QUEUE_FILTER), "pFilter"), Out(Pointer(SIZE_T), "pFilterByteLength")], sideeffects=False), + StdMethod(Void, "ClearRetrievalFilter", [], sideeffects=False), + StdMethod(HRESULT, "PushEmptyRetrievalFilter", [], sideeffects=False), + StdMethod(HRESULT, "PushCopyOfRetrievalFilter", [], sideeffects=False), + StdMethod(HRESULT, "PushRetrievalFilter", [(Pointer(D3D11_INFO_QUEUE_FILTER), "pFilter")], sideeffects=False), + StdMethod(Void, "PopRetrievalFilter", [], sideeffects=False), + StdMethod(UINT, "GetRetrievalFilterStackSize", [], sideeffects=False), + StdMethod(HRESULT, "AddMessage", [(D3D11_MESSAGE_CATEGORY, "Category"), (D3D11_MESSAGE_SEVERITY, "Severity"), (D3D11_MESSAGE_ID, "ID"), (LPCSTR, "pDescription")], sideeffects=False), + StdMethod(HRESULT, "AddApplicationMessage", [(D3D11_MESSAGE_SEVERITY, "Severity"), (LPCSTR, "pDescription")], sideeffects=False), + StdMethod(HRESULT, "SetBreakOnCategory", [(D3D11_MESSAGE_CATEGORY, "Category"), (BOOL, "bEnable")], sideeffects=False), + StdMethod(HRESULT, "SetBreakOnSeverity", [(D3D11_MESSAGE_SEVERITY, "Severity"), (BOOL, "bEnable")], sideeffects=False), + StdMethod(HRESULT, "SetBreakOnID", [(D3D11_MESSAGE_ID, "ID"), (BOOL, "bEnable")], sideeffects=False), + StdMethod(BOOL, "GetBreakOnCategory", [(D3D11_MESSAGE_CATEGORY, "Category")], sideeffects=False), + StdMethod(BOOL, "GetBreakOnSeverity", [(D3D11_MESSAGE_SEVERITY, "Severity")], sideeffects=False), + StdMethod(BOOL, "GetBreakOnID", [(D3D11_MESSAGE_ID, "ID")], sideeffects=False), + StdMethod(Void, "SetMuteDebugOutput", [(BOOL, "bMute")], sideeffects=False), + StdMethod(BOOL, "GetMuteDebugOutput", [], sideeffects=False), ] diff --git a/specs/d3d11shader.py b/specs/d3d11shader.py index 1fe357b..cb944f3 100644 --- a/specs/d3d11shader.py +++ b/specs/d3d11shader.py @@ -158,7 +158,7 @@ ID3D11ShaderReflectionVariable.methods += [ ] ID3D11ShaderReflectionConstantBuffer.methods += [ - StdMethod(HRESULT, "GetDesc", [(Pointer(D3D11_SHADER_BUFFER_DESC), "pDesc")]), + StdMethod(HRESULT, "GetDesc", [Out(Pointer(D3D11_SHADER_BUFFER_DESC), "pDesc")]), StdMethod(ObjPointer(ID3D11ShaderReflectionVariable), "GetVariableByIndex", [(UINT, "Index")]), StdMethod(ObjPointer(ID3D11ShaderReflectionVariable), "GetVariableByName", [(LPCSTR, "Name")]), ] diff --git a/thirdparty/snappy/CMakeLists.txt b/thirdparty/snappy/CMakeLists.txt index 87873d9..9bbecdb 100644 --- a/thirdparty/snappy/CMakeLists.txt +++ b/thirdparty/snappy/CMakeLists.txt @@ -1,4 +1,7 @@ -add_definitions (-DHAVE_CONFIG_H) +add_definitions ( + -DNDEBUG + -DHAVE_CONFIG_H +) # Adjust warnings if (CMAKE_COMPILER_IS_GNUCXX) diff --git a/wrappers/CMakeLists.txt b/wrappers/CMakeLists.txt index 01cbdea..9cb4504 100644 --- a/wrappers/CMakeLists.txt +++ b/wrappers/CMakeLists.txt @@ -143,7 +143,11 @@ if (WIN32) ${CMAKE_SOURCE_DIR}/specs/winapi.py ${CMAKE_SOURCE_DIR}/specs/stdapi.py ) - add_library (d3d10trace MODULE d3d10.def d3d10trace.cpp d3d10shader.cpp) + add_library (d3d10trace MODULE + d3d10.def + d3d10trace.cpp + d3dcommonshader.cpp + ) target_link_libraries (d3d10trace common_trace common @@ -179,7 +183,11 @@ if (WIN32) ${CMAKE_SOURCE_DIR}/specs/winapi.py ${CMAKE_SOURCE_DIR}/specs/stdapi.py ) - add_library (d3d10_1trace MODULE d3d10_1.def d3d10_1trace.cpp d3d10shader.cpp) + add_library (d3d10_1trace MODULE + d3d10_1.def + d3d10_1trace.cpp + d3dcommonshader.cpp + ) target_link_libraries (d3d10_1trace common_trace common @@ -207,6 +215,7 @@ if (WIN32) COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d11trace.py ${HAVE_D3D11_1} > ${CMAKE_CURRENT_BINARY_DIR}/d3d11trace.cpp DEPENDS d3d11trace.py + d3dcommontrace.py dlltrace.py trace.py ${CMAKE_SOURCE_DIR}/specs/d3d11_1.py @@ -219,7 +228,11 @@ if (WIN32) ${CMAKE_SOURCE_DIR}/specs/winapi.py ${CMAKE_SOURCE_DIR}/specs/stdapi.py ) - add_library (d3d11trace MODULE d3d11.def d3d11trace.cpp) + add_library (d3d11trace MODULE + d3d11.def + d3d11trace.cpp + d3dcommonshader.cpp + ) target_link_libraries (d3d11trace common_trace common diff --git a/wrappers/d3d10_1trace.py b/wrappers/d3d10_1trace.py index d2f72a7..6fa3efc 100644 --- a/wrappers/d3d10_1trace.py +++ b/wrappers/d3d10_1trace.py @@ -35,7 +35,7 @@ if __name__ == '__main__': print '#include "os.hpp"' print print '#include "d3d10_1imports.hpp"' - print '#include "d3d10shader.hpp"' + print '#include "d3dcommonshader.hpp"' print '#include "d3d10size.hpp"' print tracer = D3DCommonTracer('d3d10_1.dll') diff --git a/wrappers/d3d10shader.cpp b/wrappers/d3d10shader.cpp deleted file mode 100644 index 3670f2f..0000000 --- a/wrappers/d3d10shader.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/************************************************************************** - * - * Copyright 2011 Jose Fonseca - * Copyright 2008-2009 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 - -#include "d3d10shader.hpp" - - -struct ID3D10Blob : public IUnknown { -public: - virtual LPVOID STDMETHODCALLTYPE GetBufferPointer( void) = 0; - virtual SIZE_T STDMETHODCALLTYPE GetBufferSize( void) = 0; -}; - -typedef ID3D10Blob ID3DBlob; -typedef ID3DBlob* LPD3DBLOB; - -#define D3D_DISASM_ENABLE_COLOR_CODE 0x00000001 -#define D3D_DISASM_ENABLE_DEFAULT_VALUE_PRINTS 0x00000002 -#define D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING 0x00000004 -#define D3D_DISASM_ENABLE_INSTRUCTION_CYCLE 0x00000008 -#define D3D_DISASM_DISABLE_DEBUG_INFO 0x00000010 -#define D3D_DISASM_ENABLE_INSTRUCTION_OFFSET 0x00000020 -#define D3D_DISASM_INSTRUCTION_ONLY 0x00000040 - -typedef HRESULT -(WINAPI *PFND3DDISASSEMBLE)( - LPCVOID pSrcData, - SIZE_T SrcDataSize, - UINT Flags, - LPCSTR szComments, - ID3DBlob **ppDisassembly -); - - -static HMODULE hD3DCompilerModule = NULL; -static PFND3DDISASSEMBLE pfnD3DDisassemble = NULL; - - -void DumpShader(trace::Writer &writer, const void *pShaderBytecode, SIZE_T BytecodeLength) -{ - static BOOL firsttime = TRUE; - - if (firsttime) { - if (!hD3DCompilerModule) { - int version; - for (version = 44; version >= 33; --version) { - char filename[256]; - _snprintf(filename, sizeof(filename), "d3dcompiler_%u.dll", version); - hD3DCompilerModule = LoadLibraryA(filename); - if (hD3DCompilerModule) { - break; - } - } - } - - if (hD3DCompilerModule) { - if (!pfnD3DDisassemble) { - pfnD3DDisassemble = (PFND3DDISASSEMBLE)GetProcAddress(hD3DCompilerModule, "D3DDisassemble"); - } - } - - firsttime = FALSE; - } - - /* - * TODO: Fallback to D3D10DisassembleShader, which should be always present. - */ - - LPD3DBLOB pDisassembly = NULL; - HRESULT hr = E_FAIL; - - if (pfnD3DDisassemble) { - hr = pfnD3DDisassemble(pShaderBytecode, BytecodeLength, 0, NULL, &pDisassembly); - } - - if (SUCCEEDED(hr)) { - writer.beginRepr(); - writer.writeString((const char *)pDisassembly->GetBufferPointer(), pDisassembly->GetBufferSize()); - } - - writer.writeBlob(pShaderBytecode, BytecodeLength); - - if (pDisassembly) { - pDisassembly->Release(); - } - - if (SUCCEEDED(hr)) { - writer.endRepr(); - } -} diff --git a/wrappers/d3d10shader.hpp b/wrappers/d3d10shader.hpp deleted file mode 100644 index b447b48..0000000 --- a/wrappers/d3d10shader.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/************************************************************************** - * - * Copyright 2011 Jose Fonseca - * Copyright 2008-2009 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. - * - **************************************************************************/ - -#ifndef _D3D10SHADER_HPP_ -#define _D3D10SHADER_HPP_ - - -#include - -#include "trace_writer.hpp" - -void DumpShader(trace::Writer &writer, const void *pShaderBytecode, SIZE_T BytecodeLength); - - -#endif /* _D3D10SHADER_HPP_ */ diff --git a/wrappers/d3d10trace.py b/wrappers/d3d10trace.py index adb5dae..42f6058 100644 --- a/wrappers/d3d10trace.py +++ b/wrappers/d3d10trace.py @@ -35,7 +35,7 @@ if __name__ == '__main__': print '#include "os.hpp"' print print '#include "d3d10imports.hpp"' - print '#include "d3d10shader.hpp"' + print '#include "d3dcommonshader.hpp"' print '#include "d3d10size.hpp"' print tracer = D3DCommonTracer('d3d10.dll') diff --git a/wrappers/d3d11trace.py b/wrappers/d3d11trace.py index 80e855f..c504f5e 100644 --- a/wrappers/d3d11trace.py +++ b/wrappers/d3d11trace.py @@ -26,7 +26,7 @@ import sys -from dlltrace import DllTracer +from d3dcommontrace import D3DCommonTracer from specs.d3d11 import d3d11 @@ -44,5 +44,8 @@ if __name__ == '__main__': print '#include ' print - tracer = DllTracer('d3d11.dll') + print '#include "d3dcommonshader.hpp"' + print '#include "d3d11size.hpp"' + print + tracer = D3DCommonTracer('d3d11.dll') tracer.traceApi(d3d11) diff --git a/wrappers/d3dcommonshader.cpp b/wrappers/d3dcommonshader.cpp new file mode 100644 index 0000000..2ae804b --- /dev/null +++ b/wrappers/d3dcommonshader.cpp @@ -0,0 +1,133 @@ +/************************************************************************** + * + * Copyright 2011 Jose Fonseca + * Copyright 2008-2009 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 + +#include "d3dcommonshader.hpp" + + +struct ID3D10Blob : public IUnknown { +public: + virtual LPVOID STDMETHODCALLTYPE GetBufferPointer( void) = 0; + virtual SIZE_T STDMETHODCALLTYPE GetBufferSize( void) = 0; +}; + +typedef ID3D10Blob ID3DBlob; +typedef ID3DBlob* LPD3DBLOB; + +#define D3D_DISASM_ENABLE_COLOR_CODE 0x00000001 +#define D3D_DISASM_ENABLE_DEFAULT_VALUE_PRINTS 0x00000002 +#define D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING 0x00000004 +#define D3D_DISASM_ENABLE_INSTRUCTION_CYCLE 0x00000008 +#define D3D_DISASM_DISABLE_DEBUG_INFO 0x00000010 +#define D3D_DISASM_ENABLE_INSTRUCTION_OFFSET 0x00000020 +#define D3D_DISASM_INSTRUCTION_ONLY 0x00000040 + +typedef HRESULT +(WINAPI *PFND3DDISASSEMBLE)( + LPCVOID pSrcData, + SIZE_T SrcDataSize, + UINT Flags, + LPCSTR szComments, + ID3DBlob **ppDisassembly +); + +static PFND3DDISASSEMBLE pfnD3DDisassemble = NULL; + +typedef HRESULT +(WINAPI *PFND3D10DISASSEMBLESHADER)( + const void *pShader, + SIZE_T BytecodeLength, + BOOL EnableColorCode, + LPCSTR pComments, + ID3D10Blob **ppDisassembly +); + +static PFND3D10DISASSEMBLESHADER pfnD3D10DisassembleShader = NULL; + +void DumpShader(trace::Writer &writer, const void *pShaderBytecode, SIZE_T BytecodeLength) +{ + static bool firsttime = true; + + if (firsttime) { + char szFilename[MAX_PATH]; + HMODULE hModule = NULL; + + int version; + for (version = 44; version >= 33; --version) { + _snprintf(szFilename, sizeof(szFilename), "d3dcompiler_%i.dll", version); + hModule = LoadLibraryA(szFilename); + if (hModule) { + pfnD3DDisassemble = (PFND3DDISASSEMBLE) + GetProcAddress(hModule, "D3DDisassemble"); + if (pfnD3DDisassemble) { + break; + } + } + } + + if (!pfnD3DDisassemble) { + /* + * Fallback to D3D10DisassembleShader, which should be always present. + */ + if (GetSystemDirectoryA(szFilename, MAX_PATH)) { + strcat(szFilename, "\\d3d10.dll"); + hModule = LoadLibraryA(szFilename); + if (hModule) { + pfnD3D10DisassembleShader = (PFND3D10DISASSEMBLESHADER) + GetProcAddress(hModule, "D3D10DisassembleShader"); + } + } + } + + firsttime = false; + } + + LPD3DBLOB pDisassembly = NULL; + HRESULT hr = E_FAIL; + + if (pfnD3DDisassemble) { + hr = pfnD3DDisassemble(pShaderBytecode, BytecodeLength, 0, NULL, &pDisassembly); + } else if (pfnD3D10DisassembleShader) { + hr = pfnD3D10DisassembleShader(pShaderBytecode, BytecodeLength, 0, NULL, &pDisassembly); + } + + if (SUCCEEDED(hr)) { + writer.beginRepr(); + writer.writeString((const char *)pDisassembly->GetBufferPointer(), pDisassembly->GetBufferSize()); + } + + writer.writeBlob(pShaderBytecode, BytecodeLength); + + if (pDisassembly) { + pDisassembly->Release(); + } + + if (SUCCEEDED(hr)) { + writer.endRepr(); + } +} diff --git a/wrappers/d3dcommonshader.hpp b/wrappers/d3dcommonshader.hpp new file mode 100644 index 0000000..6d8500b --- /dev/null +++ b/wrappers/d3dcommonshader.hpp @@ -0,0 +1,38 @@ +/************************************************************************** + * + * Copyright 2011 Jose Fonseca + * Copyright 2008-2009 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. + * + **************************************************************************/ + +#ifndef _D3DCOMMONSHADER_HPP_ +#define _D3DCOMMONSHADER_HPP_ + + +#include + +#include "trace_writer.hpp" + +void DumpShader(trace::Writer &writer, const void *pShaderBytecode, SIZE_T BytecodeLength); + + +#endif /* _D3DCOMMONSHADER_HPP_ */ diff --git a/wrappers/gltrace.py b/wrappers/gltrace.py index 96da4e8..feb96e4 100644 --- a/wrappers/gltrace.py +++ b/wrappers/gltrace.py @@ -355,7 +355,7 @@ class GlTracer(Tracer): print 'void _shadow_glGetBufferSubData(GLenum target, GLintptr offset,' print ' GLsizeiptr size, GLvoid *data)' print '{' - print ' struct gltrace::Context *ctx = gltrace::getContext();' + print ' gltrace::Context *ctx = gltrace::getContext();' print ' if (!ctx->needsShadowBuffers() || target != GL_ELEMENT_ARRAY_BUFFER) {' print ' _glGetBufferSubData(target, offset, size, data);' print ' return;' diff --git a/wrappers/trace.py b/wrappers/trace.py index 4563f45..cbdc0c0 100644 --- a/wrappers/trace.py +++ b/wrappers/trace.py @@ -513,10 +513,12 @@ class Tracer: self.invokeFunction(function) if not function.internal: print ' trace::localWriter.beginLeave(_call);' + print ' if (%s) {' % self.wasFunctionSuccessful(function) for arg in function.args: if arg.output: self.serializeArg(function, arg) self.wrapArg(function, arg) + print ' }' if function.type is not stdapi.Void: self.serializeRet(function, "_result") print ' trace::localWriter.endLeave();' @@ -531,6 +533,13 @@ class Tracer: dispatch = prefix + function.name + suffix print ' %s%s(%s);' % (result, dispatch, ', '.join([str(arg.name) for arg in function.args])) + def wasFunctionSuccessful(self, function): + if function.type is stdapi.Void: + return 'true' + if str(function.type) == 'HRESULT': + return 'SUCCEEDED(_result)' + return 'false' + def serializeArg(self, function, arg): print ' trace::localWriter.beginArg(%u);' % (arg.index,) self.serializeArgValue(function, arg) @@ -670,10 +679,13 @@ class Tracer: self.invokeMethod(interface, base, method) print ' trace::localWriter.beginLeave(_call);' + + print ' if (%s) {' % self.wasFunctionSuccessful(method) for arg in method.args: if arg.output: self.serializeArg(method, arg) self.wrapArg(method, arg) + print ' }' if method.type is not stdapi.Void: self.serializeRet(method, '_result')