From: José Fonseca Date: Wed, 18 Apr 2012 22:36:50 +0000 (+0100) Subject: Trace IDirect3DDevice9::Draw*PrimitiveUP blobs X-Git-Url: https://git.cworth.org/git?p=apitrace;a=commitdiff_plain;h=e32a797c854b8f7b281fc9e5a4b6e3cafda58f25 Trace IDirect3DDevice9::Draw*PrimitiveUP blobs --- diff --git a/helpers/d3dsize.hpp b/helpers/d3dsize.hpp new file mode 100644 index 0000000..7909501 --- /dev/null +++ b/helpers/d3dsize.hpp @@ -0,0 +1,90 @@ +/************************************************************************** + * + * 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 _D3D_SIZE_HPP_ +#define _D3D_SIZE_HPP_ + + +/* We purposedly don't include any D3D header, so that this header can be used + * with all D3D versions. */ + +#include "os.hpp" + + +static inline size_t +_vertexCount(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount) +{ + switch (PrimitiveType) { + case D3DPT_POINTLIST: + return PrimitiveCount; + case D3DPT_LINELIST: + return PrimitiveCount*2; + case D3DPT_LINESTRIP: + return PrimitiveCount + 1; + case D3DPT_TRIANGLELIST: + return PrimitiveCount * 3; + case D3DPT_TRIANGLESTRIP: + return PrimitiveCount + 2; + case D3DPT_TRIANGLEFAN: + return PrimitiveCount + 1; + default: + os::log("apitrace: warning: %s: unknown D3DPRIMITIVETYPE %u\n", __FUNCTION__, PrimitiveType); + return 0; + } +} + + +static inline size_t +_vertexDataSize(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, UINT VertexStride) { + return _vertexCount(PrimitiveType, PrimitiveCount) * VertexStride; +} + + +static inline size_t +_indexDataSize(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, D3DFORMAT IndexDataFormat) { + UINT IndexStride; + switch (IndexDataFormat) { + case D3DFMT_INDEX16: + IndexStride = 2; + break; + case D3DFMT_INDEX32: + IndexStride = 4; + break; + default: + os::log("apitrace: warning: %s: unexpected index D3DFORMAT %u\n", __FUNCTION__, IndexDataFormat); + return 0; + } + return _vertexCount(PrimitiveType, PrimitiveCount) * IndexStride; +} + + +#endif /* _D3D_SIZE_HPP_ */ diff --git a/specs/d3d9.py b/specs/d3d9.py index 050517b..293be90 100644 --- a/specs/d3d9.py +++ b/specs/d3d9.py @@ -250,8 +250,8 @@ IDirect3DDevice9.methods += [ Method(Float, "GetNPatchMode", [], sideeffects=False), Method(HRESULT, "DrawPrimitive", [(D3DPRIMITIVETYPE, "PrimitiveType"), (UINT, "StartVertex"), (UINT, "PrimitiveCount")]), Method(HRESULT, "DrawIndexedPrimitive", [(D3DPRIMITIVETYPE, "PrimitiveType"), (INT, "BaseVertexIndex"), (UINT, "MinVertexIndex"), (UINT, "NumVertices"), (UINT, "startIndex"), (UINT, "primCount")]), - Method(HRESULT, "DrawPrimitiveUP", [(D3DPRIMITIVETYPE, "PrimitiveType"), (UINT, "PrimitiveCount"), (OpaquePointer(Const(Void)), "pVertexStreamZeroData"), (UINT, "VertexStreamZeroStride")]), - Method(HRESULT, "DrawIndexedPrimitiveUP", [(D3DPRIMITIVETYPE, "PrimitiveType"), (UINT, "MinVertexIndex"), (UINT, "NumVertices"), (UINT, "PrimitiveCount"), (OpaquePointer(Const(Void)), "pIndexData"), (D3DFORMAT, "IndexDataFormat"), (OpaquePointer(Const(Void)), "pVertexStreamZeroData"), (UINT, "VertexStreamZeroStride")]), + Method(HRESULT, "DrawPrimitiveUP", [(D3DPRIMITIVETYPE, "PrimitiveType"), (UINT, "PrimitiveCount"), (Blob(Const(Void), "_vertexDataSize(PrimitiveType, PrimitiveCount, VertexStreamZeroStride)"), "pVertexStreamZeroData"), (UINT, "VertexStreamZeroStride")]), + Method(HRESULT, "DrawIndexedPrimitiveUP", [(D3DPRIMITIVETYPE, "PrimitiveType"), (UINT, "MinVertexIndex"), (UINT, "NumVertices"), (UINT, "PrimitiveCount"), (Blob(Const(Void), "_indexDataSize(PrimitiveType, PrimitiveCount, IndexDataFormat)"), "pIndexData"), (D3DFORMAT, "IndexDataFormat"), (Blob(Const(Void), "NumVertices*VertexStreamZeroStride"), "pVertexStreamZeroData"), (UINT, "VertexStreamZeroStride")]), Method(HRESULT, "ProcessVertices", [(UINT, "SrcStartIndex"), (UINT, "DestIndex"), (UINT, "VertexCount"), (PDIRECT3DVERTEXBUFFER9, "pDestBuffer"), (PDIRECT3DVERTEXDECLARATION9, "pVertexDecl"), (D3DPV, "Flags")]), Method(HRESULT, "CreateVertexDeclaration", [(Array(Const(D3DVERTEXELEMENT9), "_declCount(pVertexElements)"), "pVertexElements"), Out(Pointer(PDIRECT3DVERTEXDECLARATION9), "ppDecl")]), Method(HRESULT, "SetVertexDeclaration", [(PDIRECT3DVERTEXDECLARATION9, "pDecl")]), @@ -306,8 +306,8 @@ IDirect3DSwapChain9.methods += [ IDirect3DResource9.methods += [ Method(HRESULT, "GetDevice", [Out(Pointer(PDIRECT3DDEVICE9), "ppDevice")], sideeffects=False), - Method(HRESULT, "SetPrivateData", [(REFGUID, "refguid"), (OpaquePointer(Const(Void)), "pData"), (DWORD, "SizeOfData"), (D3DSPD, "Flags")], sideeffects=False), - Method(HRESULT, "GetPrivateData", [(REFGUID, "refguid"), Out(OpaquePointer(Void), "pData"), Out(Pointer(DWORD), "pSizeOfData")], sideeffects=False), + Method(HRESULT, "SetPrivateData", [(REFGUID, "refguid"), (OpaqueBlob(Const(Void), "SizeOfData"), "pData"), (DWORD, "SizeOfData"), (D3DSPD, "Flags")], sideeffects=False), + Method(HRESULT, "GetPrivateData", [(REFGUID, "refguid"), Out(OpaqueBlob(Void, "*pSizeOfData"), "pData"), Out(Pointer(DWORD), "pSizeOfData")], sideeffects=False), Method(HRESULT, "FreePrivateData", [(REFGUID, "refguid")], sideeffects=False), Method(D3D9_RESOURCE_PRIORITY, "SetPriority", [(D3D9_RESOURCE_PRIORITY, "PriorityNew")]), Method(D3D9_RESOURCE_PRIORITY, "GetPriority", [], sideeffects=False), @@ -322,12 +322,12 @@ IDirect3DVertexDeclaration9.methods += [ IDirect3DVertexShader9.methods += [ Method(HRESULT, "GetDevice", [Out(Pointer(PDIRECT3DDEVICE9), "ppDevice")], sideeffects=False), - Method(HRESULT, "GetFunction", [Out(OpaquePointer(Void), "pData"), Out(Pointer(UINT), "pSizeOfData")], sideeffects=False), + Method(HRESULT, "GetFunction", [Out(OpaqueBlob(Void, "*pSizeOfData"), "pData"), Out(Pointer(UINT), "pSizeOfData")], sideeffects=False), ] IDirect3DPixelShader9.methods += [ Method(HRESULT, "GetDevice", [Out(Pointer(PDIRECT3DDEVICE9), "ppDevice")], sideeffects=False), - Method(HRESULT, "GetFunction", [Out(OpaquePointer(Void), "pData"), Out(Pointer(UINT), "pSizeOfData")], sideeffects=False), + Method(HRESULT, "GetFunction", [Out(OpaqueBlob(Void, "*pSizeOfData"), "pData"), Out(Pointer(UINT), "pSizeOfData")], sideeffects=False), ] IDirect3DBaseTexture9.methods += [ @@ -386,8 +386,8 @@ IDirect3DSurface9.methods += [ IDirect3DVolume9.methods += [ Method(HRESULT, "GetDevice", [Out(Pointer(PDIRECT3DDEVICE9), "ppDevice")], sideeffects=False), - Method(HRESULT, "SetPrivateData", [(REFGUID, "refguid"), (OpaquePointer(Const(Void)), "pData"), (DWORD, "SizeOfData"), (D3DSPD, "Flags")], sideeffects=False), - Method(HRESULT, "GetPrivateData", [(REFGUID, "refguid"), Out(OpaquePointer(Void), "pData"), Out(Pointer(DWORD), "pSizeOfData")], sideeffects=False), + Method(HRESULT, "SetPrivateData", [(REFGUID, "refguid"), (OpaqueBlob(Const(Void), "SizeOfData"), "pData"), (DWORD, "SizeOfData"), (D3DSPD, "Flags")], sideeffects=False), + Method(HRESULT, "GetPrivateData", [(REFGUID, "refguid"), Out(OpaqueBlob(Void, "*pSizeOfData"), "pData"), Out(Pointer(DWORD), "pSizeOfData")], sideeffects=False), Method(HRESULT, "FreePrivateData", [(REFGUID, "refguid")], sideeffects=False), Method(HRESULT, "GetContainer", [(REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppContainer")], sideeffects=False), Method(HRESULT, "GetDesc", [Out(Pointer(D3DVOLUME_DESC), "pDesc")], sideeffects=False), diff --git a/wrappers/d3d9trace.py b/wrappers/d3d9trace.py index 9fb290d..4823089 100644 --- a/wrappers/d3d9trace.py +++ b/wrappers/d3d9trace.py @@ -87,6 +87,7 @@ if __name__ == '__main__': print '#include "os.hpp"' print print '#include "d3d9imports.hpp"' + print '#include "d3dsize.hpp"' print '#include "d3dshader.hpp"' print print '''