]> git.cworth.org Git - apitrace/commitdiff
Merge branch 'union-type'
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Tue, 20 Nov 2012 17:04:39 +0000 (17:04 +0000)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Tue, 20 Nov 2012 17:04:39 +0000 (17:04 +0000)
18 files changed:
common/trace_parser_flags.cpp
dispatch/d3d10_1imports.hpp
dispatch/d3d10imports.hpp
dispatch/d3d11imports.hpp
dispatch/dxgiint.h [new file with mode: 0644]
retrace/CMakeLists.txt
retrace/d3d10state.cpp [new file with mode: 0644]
retrace/d3d10state_images.cpp [new file with mode: 0644]
retrace/d3d11state.cpp
retrace/d3dcommonretrace.py
retrace/d3dstate.hpp
specs/d3d10.py
specs/dxgi.py
specs/scripts/cdecl.py
wrappers/d3d10.def
wrappers/d3d10_1.def
wrappers/d3d10_1trace.py
wrappers/d3d10trace.py

index 2589b4342f6667175a5f67b6b8950af6375b5c18..1ff2b0b76677b68c5c035a62b88d1d005daf3405 100644 (file)
@@ -82,6 +82,7 @@ callFlagTable[] = {
     { "ID3D11DeviceContext::OMSetRenderTargets",       CALL_FLAG_SWAP_RENDERTARGET },
     { "ID3D11DeviceContext::OMSetRenderTargetsAndUnorderedAccessViews", CALL_FLAG_SWAP_RENDERTARGET },
     { "IDXGISwapChain::Present",                       CALL_FLAG_END_FRAME },
+    { "IDXGISwapChainDWM::Present",                    CALL_FLAG_END_FRAME },
     { "IDirect3D9::CheckDeviceFormat",                 CALL_FLAG_NO_SIDE_EFFECTS | CALL_FLAG_VERBOSE },
     { "IDirect3D9::EnumAdapterModes",                  CALL_FLAG_NO_SIDE_EFFECTS | CALL_FLAG_VERBOSE },
     { "IDirect3D9::GetAdapterModeCount",               CALL_FLAG_NO_SIDE_EFFECTS | CALL_FLAG_VERBOSE },
index 254323e7850cf73612705a0d46e543e34a59e18a..2b97cf3c152ac11f06ccb172e4de6efceb7bd1f8 100644 (file)
@@ -24,7 +24,7 @@
  **************************************************************************/
 
 /*
- * Central place for all D3D10 includes, and respective OS dependent headers.
+ * Central place for all D3D10.1 includes, and respective OS dependent headers.
  */
 
 #ifndef _D3D10_1IMPORTS_HPP_
 
 #include "d3derr.hpp"
 
+#include "dxgiint.h"
+
+#define D3D10_CREATE_DEVICE_PREVENT_ALTERING_LAYER_SETTINGS_FROM_REGISTRY 0x0080
+#define D3D10_CREATE_DEVICE_STRICT_VALIDATION                             0x0200
+#define D3D10_CREATE_DEVICE_DEBUGGABLE                                    0x0400
 
 #endif /* _D3D10_1IMPORTS_HPP_ */
index d21aec8c1133e2e9257b17b165259a81c42804d4..04d4119d00bd654bd3cbebf682b66c3ef81409ac 100644 (file)
 
 #include "d3derr.hpp"
 
+#include "dxgiint.h"
+
+#define D3D10_CREATE_DEVICE_PREVENT_ALTERING_LAYER_SETTINGS_FROM_REGISTRY 0x0080
+#define D3D10_CREATE_DEVICE_STRICT_VALIDATION                             0x0200
+#define D3D10_CREATE_DEVICE_DEBUGGABLE                                    0x0400
 
 #endif /* _D3D10IMPORTS_HPP_ */
index eabcaf13957e0af40e0ca7dbdaedd4251a9ce0f6..b667bf85611719a3679809977f06d772ab4cd81a 100644 (file)
@@ -39,5 +39,7 @@
 
 #include "d3derr.hpp"
 
+#include "dxgiint.h"
+
 
 #endif /* _D3D11IMPORTS_HPP_ */
diff --git a/dispatch/dxgiint.h b/dispatch/dxgiint.h
new file mode 100644 (file)
index 0000000..f985ed1
--- /dev/null
@@ -0,0 +1,62 @@
+/**************************************************************************
+ *
+ * Copyright 2012 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#ifndef _DXGIINT_H_
+#define _DXGIINT_H_
+
+#include <windows.h>
+
+#include "compat.h"
+
+#include <dxgi.h>
+
+
+static const GUID IID_IDXGIFactoryDWM = {0x713F394E,0x92CA,0x47E7,{0xAB,0x81,0x11,0x59,0xC2,0x79,0x1E,0x54}};
+static const GUID IID_IDXGISwapChainDWM = {0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; // XXX
+
+struct IDXGIFactoryDWM;
+struct IDXGISwapChainDWM;
+
+struct IDXGIFactoryDWM: public IUnknown
+{
+    virtual HRESULT STDMETHODCALLTYPE CreateSwapChain(IUnknown *pDevice, DXGI_SWAP_CHAIN_DESC *pDesc, IDXGIOutput *pOutput, IDXGISwapChainDWM **ppSwapChain) = 0;
+};
+
+struct IDXGISwapChainDWM: public IDXGIDeviceSubObject 
+{ 
+    virtual HRESULT STDMETHODCALLTYPE Present (UINT SyncInterval, UINT Flags) = 0; 
+    virtual HRESULT STDMETHODCALLTYPE GetBuffer (UINT Buffer, REFIID riid, void **ppSurface) = 0; 
+    virtual HRESULT STDMETHODCALLTYPE GetDesc (DXGI_SWAP_CHAIN_DESC *pDesc) = 0; 
+    virtual HRESULT STDMETHODCALLTYPE ResizeBuffers (UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags) = 0; 
+    virtual HRESULT STDMETHODCALLTYPE ResizeTarget (const DXGI_MODE_DESC *pNewTargetParameters) = 0; 
+    virtual HRESULT STDMETHODCALLTYPE GetContainingOutput (IDXGIOutput **ppOutput) = 0; 
+    virtual HRESULT STDMETHODCALLTYPE GetFrameStatistics (DXGI_FRAME_STATISTICS *pStats) = 0; 
+    virtual HRESULT STDMETHODCALLTYPE GetLastPresentCount (UINT *pLastPresentCount) = 0; 
+    virtual HRESULT STDMETHODCALLTYPE SetFullscreenState (BOOL Fullscreen, IDXGIOutput *pTarget) = 0; 
+    virtual HRESULT STDMETHODCALLTYPE GetFullscreenState (BOOL *pFullscreen, IDXGIOutput **ppTarget) = 0; 
+}; 
+
+#endif /* _DXGIINT_H_ */
index c582338c00cd9534365879e44cb3bf7dd5248f06..383417d5a1b2d419f6f85cce4175bc30e8c047ea 100644 (file)
@@ -153,6 +153,10 @@ if (WIN32 AND DirectX_D3DX9_INCLUDE_DIR)
             include_directories (SYSTEM ${DirectX_D3D10_1_INCLUDE_DIR})
             set (D3D10_MODULES ${D3D10_MODULES} d3d10_1)
         endif ()
+        set (D3DSTATE_SOURCES ${D3DSTATE_SOURCES}
+            d3d10state.cpp
+            d3d10state_images.cpp
+        )
     endif ()
 
     if (DirectX_D3D11_INCLUDE_DIR)
@@ -162,7 +166,7 @@ if (WIN32 AND DirectX_D3DX9_INCLUDE_DIR)
             include_directories (SYSTEM ${DirectX_D3D11_1_INCLUDE_DIR})
             set (D3D10_MODULES ${D3D10_MODULES} d3d11_1)
         endif ()
-        set (D3D11STATE_SOURCES
+        set (D3DSTATE_SOURCES ${D3DSTATE_SOURCES}
             d3d11state.cpp
             d3d11state_images.cpp
         )
@@ -200,7 +204,7 @@ if (WIN32 AND DirectX_D3DX9_INCLUDE_DIR)
         d3dretrace_ws.cpp
         d3d9state.cpp
         d3d9state_images.cpp
-        ${D3D11STATE_SOURCES}
+        ${D3DSTATE_SOURCES}
     )
     target_link_libraries (d3dretrace
         retrace_common
diff --git a/retrace/d3d10state.cpp b/retrace/d3d10state.cpp
new file mode 100644 (file)
index 0000000..fd0eb5b
--- /dev/null
@@ -0,0 +1,47 @@
+/**************************************************************************
+ *
+ * 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 <stdio.h>
+
+#include <iostream>
+
+#include "d3d11imports.hpp"
+#include "json.hpp"
+
+
+namespace d3dstate {
+
+
+void
+dumpDevice(std::ostream &os, ID3D10Device *pDevice)
+{
+    JSONWriter json(os);
+
+    /* TODO */
+}
+
+
+} /* namespace d3dstate */
diff --git a/retrace/d3d10state_images.cpp b/retrace/d3d10state_images.cpp
new file mode 100644 (file)
index 0000000..781f937
--- /dev/null
@@ -0,0 +1,311 @@
+/**************************************************************************
+ *
+ * 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 <assert.h>
+
+#include <iostream>
+#include <algorithm>
+
+#include "image.hpp"
+#include "d3d10imports.hpp"
+
+
+namespace d3dstate {
+
+static HRESULT
+stageResource(ID3D10Device *pDevice,
+              ID3D10Resource *pResource,
+              ID3D10Resource **ppStagingResource,
+              UINT *pWidth, UINT *pHeight, UINT *pDepth) {
+    D3D10_USAGE Usage = D3D10_USAGE_STAGING;
+    UINT BindFlags = 0;
+    UINT CPUAccessFlags = D3D10_CPU_ACCESS_READ;
+    UINT MiscFlags = 0;
+    union {
+         ID3D10Resource *pStagingResource;
+         ID3D10Buffer *pStagingBuffer;
+         ID3D10Texture1D *pStagingTexture1D;
+         ID3D10Texture2D *pStagingTexture2D;
+         ID3D10Texture3D *pStagingTexture3D;
+    };
+    HRESULT hr;
+
+    D3D10_RESOURCE_DIMENSION Type = D3D10_RESOURCE_DIMENSION_UNKNOWN;
+    pResource->GetType(&Type);
+    switch (Type) {
+    case D3D10_RESOURCE_DIMENSION_BUFFER:
+        {
+            D3D10_BUFFER_DESC Desc;
+            static_cast<ID3D10Buffer *>(pResource)->GetDesc(&Desc);
+            Desc.Usage = Usage;
+            Desc.BindFlags = BindFlags;
+            Desc.CPUAccessFlags = CPUAccessFlags;
+            Desc.MiscFlags = MiscFlags;
+
+            *pWidth = Desc.ByteWidth;
+            *pHeight = 1;
+            *pDepth = 1;
+
+            hr = pDevice->CreateBuffer(&Desc, NULL, &pStagingBuffer);
+        }
+        break;
+    case D3D10_RESOURCE_DIMENSION_TEXTURE1D:
+        {
+            D3D10_TEXTURE1D_DESC Desc;
+            static_cast<ID3D10Texture1D *>(pResource)->GetDesc(&Desc);
+            Desc.Usage = Usage;
+            Desc.BindFlags = BindFlags;
+            Desc.CPUAccessFlags = CPUAccessFlags;
+            Desc.MiscFlags = MiscFlags;
+
+            *pWidth = Desc.Width;
+            *pHeight = 1;
+            *pDepth = 1;
+
+            hr = pDevice->CreateTexture1D(&Desc, NULL, &pStagingTexture1D);
+        }
+        break;
+    case D3D10_RESOURCE_DIMENSION_TEXTURE2D:
+        {
+            D3D10_TEXTURE2D_DESC Desc;
+            static_cast<ID3D10Texture2D *>(pResource)->GetDesc(&Desc);
+            Desc.Usage = Usage;
+            Desc.BindFlags = BindFlags;
+            Desc.CPUAccessFlags = CPUAccessFlags;
+            Desc.MiscFlags &= ~D3D10_RESOURCE_MISC_TEXTURECUBE;
+
+            *pWidth = Desc.Width;
+            *pHeight = Desc.Height;
+            *pDepth = 1;
+
+            hr = pDevice->CreateTexture2D(&Desc, NULL, &pStagingTexture2D);
+        }
+        break;
+    case D3D10_RESOURCE_DIMENSION_TEXTURE3D:
+        {
+            D3D10_TEXTURE3D_DESC Desc;
+            static_cast<ID3D10Texture3D *>(pResource)->GetDesc(&Desc);
+            Desc.Usage = Usage;
+            Desc.BindFlags = BindFlags;
+            Desc.CPUAccessFlags = CPUAccessFlags;
+            Desc.MiscFlags = MiscFlags;
+
+            *pWidth = Desc.Width;
+            *pHeight = Desc.Height;
+            *pDepth = Desc.Depth;
+
+            hr = pDevice->CreateTexture3D(&Desc, NULL, &pStagingTexture3D);
+        }
+        break;
+    default:
+        assert(0);
+        hr = E_NOTIMPL;
+        break;
+    }
+
+    if (SUCCEEDED(hr)) {
+        *ppStagingResource = pStagingResource;
+        pDevice->CopyResource(pStagingResource, pResource);
+    }
+    
+    return hr;
+}
+
+static HRESULT
+mapResource(ID3D10Resource *pResource,
+            UINT Subresource, D3D10_MAP MapType, UINT MapFlags,
+            D3D10_MAPPED_TEXTURE3D *pMappedSubresource) {
+    D3D10_RESOURCE_DIMENSION Type = D3D10_RESOURCE_DIMENSION_UNKNOWN;
+    pResource->GetType(&Type);
+    switch (Type) {
+    case D3D10_RESOURCE_DIMENSION_BUFFER:
+        assert(Subresource == 0);
+        return static_cast<ID3D10Buffer *>(pResource)->Map(MapType, MapFlags, &pMappedSubresource->pData);
+    case D3D10_RESOURCE_DIMENSION_TEXTURE1D:
+        return static_cast<ID3D10Texture1D *>(pResource)->Map(Subresource, MapType, MapFlags, &pMappedSubresource->pData);
+    case D3D10_RESOURCE_DIMENSION_TEXTURE2D:
+        return static_cast<ID3D10Texture2D *>(pResource)->Map(Subresource, MapType, MapFlags, reinterpret_cast<D3D10_MAPPED_TEXTURE2D *>(pMappedSubresource));
+    case D3D10_RESOURCE_DIMENSION_TEXTURE3D:
+        return static_cast<ID3D10Texture3D *>(pResource)->Map(Subresource, MapType, MapFlags, pMappedSubresource);
+    default:
+        assert(0);
+        return E_NOTIMPL;
+    }
+}
+
+static void
+unmapResource(ID3D10Resource *pResource, UINT Subresource) {
+    D3D10_RESOURCE_DIMENSION Type = D3D10_RESOURCE_DIMENSION_UNKNOWN;
+    pResource->GetType(&Type);
+    switch (Type) {
+    case D3D10_RESOURCE_DIMENSION_BUFFER:
+        assert(Subresource == 0);
+        static_cast<ID3D10Buffer *>(pResource)->Unmap();
+        break;
+    case D3D10_RESOURCE_DIMENSION_TEXTURE1D:
+        static_cast<ID3D10Texture1D *>(pResource)->Unmap(Subresource);
+        break;
+    case D3D10_RESOURCE_DIMENSION_TEXTURE2D:
+        static_cast<ID3D10Texture2D *>(pResource)->Unmap(Subresource);
+        break;
+    case D3D10_RESOURCE_DIMENSION_TEXTURE3D:
+        static_cast<ID3D10Texture3D *>(pResource)->Unmap(Subresource);
+        break;
+    default:
+        assert(0);
+    }
+}
+
+image::Image *
+getRenderTargetImage(ID3D10Device *pDevice) {
+    image::Image *image = NULL;
+    ID3D10RenderTargetView *pRenderTargetView = NULL;
+    D3D10_RENDER_TARGET_VIEW_DESC Desc;
+    ID3D10Resource *pResource = NULL;
+    ID3D10Resource *pStagingResource = NULL;
+    UINT Width, Height, Depth;
+    UINT MipSlice;
+    UINT Subresource;
+    D3D10_MAPPED_TEXTURE3D MappedSubresource;
+    HRESULT hr;
+    const unsigned char *src;
+    unsigned char *dst;
+
+    pDevice->OMGetRenderTargets(1, &pRenderTargetView, NULL);
+    if (!pRenderTargetView) {
+        goto no_rendertarget;
+    }
+
+    pRenderTargetView->GetResource(&pResource);
+    assert(pResource);
+
+    pRenderTargetView->GetDesc(&Desc);
+    if (Desc.Format != DXGI_FORMAT_R8G8B8A8_UNORM &&
+        Desc.Format != DXGI_FORMAT_R32G32B32A32_FLOAT &&
+        Desc.Format != DXGI_FORMAT_B8G8R8A8_UNORM) {
+        std::cerr << "warning: unsupported DXGI format " << Desc.Format << "\n";
+        goto no_staging;
+    }
+
+    hr = stageResource(pDevice, pResource, &pStagingResource, &Width, &Height, &Depth);
+    if (FAILED(hr)) {
+        goto no_staging;
+    }
+
+    // TODO: Take the slice in consideration
+    switch (Desc.ViewDimension) {
+    case D3D10_RTV_DIMENSION_BUFFER:
+        MipSlice = 0;
+        break;
+    case D3D10_RTV_DIMENSION_TEXTURE1D:
+        MipSlice = Desc.Texture1D.MipSlice;
+        break;
+    case D3D10_RTV_DIMENSION_TEXTURE1DARRAY:
+        MipSlice = Desc.Texture1DArray.MipSlice;
+        break;
+    case D3D10_RTV_DIMENSION_TEXTURE2D:
+        MipSlice = Desc.Texture2D.MipSlice;
+        MipSlice = 0;
+        break;
+    case D3D10_RTV_DIMENSION_TEXTURE2DARRAY:
+        MipSlice = Desc.Texture2DArray.MipSlice;
+        break;
+    case D3D10_RTV_DIMENSION_TEXTURE2DMS:
+        MipSlice = 0;
+        break;
+    case D3D10_RTV_DIMENSION_TEXTURE2DMSARRAY:
+        MipSlice = 0;
+        break;
+    case D3D10_RTV_DIMENSION_TEXTURE3D:
+        MipSlice = Desc.Texture3D.MipSlice;
+        break;
+    case D3D10_SRV_DIMENSION_UNKNOWN:
+    default:
+        assert(0);
+        goto no_map;
+    }
+    Subresource = MipSlice;
+
+    Width  = std::max(Width  >> MipSlice, 1U);
+    Height = std::max(Height >> MipSlice, 1U);
+    Depth  = std::max(Depth  >> MipSlice, 1U);
+
+    hr = mapResource(pStagingResource, Subresource, D3D10_MAP_READ, 0, &MappedSubresource);
+    if (FAILED(hr)) {
+        goto no_map;
+    }
+
+    image = new image::Image(Width, Height, 4, true);
+    if (!image) {
+        goto no_image;
+    }
+
+    dst = image->start();
+    src = (const unsigned char *)MappedSubresource.pData;
+    for (unsigned y = 0; y < Height; ++y) {
+        if (Desc.Format == DXGI_FORMAT_R8G8B8A8_UNORM) {
+            memcpy(dst, src, Width * 4);
+        } else if (Desc.Format == DXGI_FORMAT_R32G32B32A32_FLOAT) {
+            float scale = 1.0f/255.0f;
+            for (unsigned x = 0; x < Width; ++x) {
+                dst[4*x + 0] = ((float *)src)[4*x + 0] * scale;
+                dst[4*x + 1] = ((float *)src)[4*x + 1] * scale;
+                dst[4*x + 2] = ((float *)src)[4*x + 2] * scale;
+                dst[4*x + 3] = ((float *)src)[4*x + 3] * scale;
+            }
+        } else if (Desc.Format == DXGI_FORMAT_B8G8R8A8_UNORM) {
+            for (unsigned x = 0; x < Width; ++x) {
+                dst[4*x + 0] = src[4*x + 2];
+                dst[4*x + 1] = src[4*x + 1];
+                dst[4*x + 2] = src[4*x + 0];
+                dst[4*x + 3] = src[4*x + 3];
+            }
+        } else {
+            assert(0);
+        }
+        src += MappedSubresource.RowPitch;
+        dst += image->stride();
+    }
+
+no_image:
+    unmapResource(pStagingResource, Subresource);
+no_map:
+    if (pStagingResource) {
+        pStagingResource->Release();
+    }
+no_staging:
+    if (pResource) {
+        pResource->Release();
+    }
+    if (pRenderTargetView) {
+        pRenderTargetView->Release();
+    }
+no_rendertarget:
+    return image;
+}
+
+
+} /* namespace d3dstate */
index 602f05fa88b574b9a0985994453b107830fb1629..05885f4cd2cde494760cd8e8627aaacd15f82371 100644 (file)
@@ -36,7 +36,7 @@ namespace d3dstate {
 
 
 void
-dumpDevice(std::ostream &os, ID3D11DeviceContext *pDevice)
+dumpDevice(std::ostream &os, ID3D11DeviceContext *pDeviceContext)
 {
     JSONWriter json(os);
 
index 4496b2c2376ebfc9cc76f58313bfe0997ed09e01..7a64d81a1348105d49e328412879e456f98f3223 100644 (file)
@@ -81,6 +81,11 @@ class D3DRetracer(Retracer):
 
     def invokeInterfaceMethod(self, interface, method):
         # keep track of the last used device for state dumping
+        if interface.name in ('ID3D10Device', 'ID3D10Device1'):
+            if method.name == 'Release':
+                print r'    d3d10Dumper.unbindDevice(_this);'
+            else:
+                print r'    d3d10Dumper.bindDevice(_this);'
         if interface.name in ('ID3D11DeviceContext',):
             if method.name == 'Release':
                 print r'    d3d11Dumper.unbindDevice(_this);'
@@ -137,8 +142,10 @@ def main():
     moduleNames = sys.argv[1:]
 
     api = API()
+    
     if moduleNames:
         api.addModule(dxgi)
+    
     if 'd3d10' in moduleNames:
         if 'd3d10_1' in moduleNames:
             print r'#include "d3d10_1imports.hpp"'
@@ -149,6 +156,10 @@ def main():
             print r'#include "d3d10imports.hpp"'
         print r'#include "d3d10size.hpp"'
         api.addModule(d3d10)
+        print
+        print '''static d3dretrace::D3DDumper<ID3D10Device> d3d10Dumper;'''
+        print
+
     if 'd3d11' in moduleNames:
         print r'#include "d3d11imports.hpp"'
         if 'd3d11_1' in moduleNames:
index 941d82ddc2785da0b5aa4c06cff8cc33df62a5c0..c21c3618c75214f656946500db99170e2a141481 100644 (file)
@@ -31,6 +31,7 @@
 
 
 struct IDirect3DDevice9;
+struct ID3D10Device;
 struct ID3D11DeviceContext;
 
 
@@ -49,6 +50,13 @@ void
 dumpDevice(std::ostream &os, IDirect3DDevice9 *pDevice);
 
 
+image::Image *
+getRenderTargetImage(ID3D10Device *pDevice);
+
+void
+dumpDevice(std::ostream &os, ID3D10Device *pDevice);
+
+
 image::Image *
 getRenderTargetImage(ID3D11DeviceContext *pDeviceContext);
 
index 2c1c44c9197710048e9405da8d68c3797c62c56d..167e4911407e92f3a1f49a22ddd52b5487b9e811 100644 (file)
@@ -212,6 +212,7 @@ D3D10_FORMAT_SUPPORT = Flags(UINT, [
     "D3D10_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET",
     "D3D10_FORMAT_SUPPORT_MULTISAMPLE_LOAD",
     "D3D10_FORMAT_SUPPORT_SHADER_GATHER",
+    "D3D10_FORMAT_SUPPORT_BACK_BUFFER_CAST",
 ])
 
 D3D10_COUNTER = Enum("D3D10_COUNTER", [
@@ -683,6 +684,10 @@ D3D10_CREATE_DEVICE_FLAG = Flags(UINT, [
     "D3D10_CREATE_DEVICE_ALLOW_NULL_FROM_MAP",
     "D3D10_CREATE_DEVICE_BGRA_SUPPORT",
     "D3D10_CREATE_DEVICE_STRICT_VALIDATION",
+    "D3D10_CREATE_DEVICE_BGRA_SUPPORT",
+    "D3D10_CREATE_DEVICE_PREVENT_ALTERING_LAYER_SETTINGS_FROM_REGISTRY",
+    "D3D10_CREATE_DEVICE_STRICT_VALIDATION",
+    "D3D10_CREATE_DEVICE_DEBUGGABLE",
 ])
 
 D3D10_RAISE_FLAG = Flags(UINT, [
index eef7c65d6d66ab9700d8c686fbb42da4b0481f7f..ca05368a82cfb00f95168e3c40bb7f0e1401f05e 100644 (file)
@@ -215,7 +215,7 @@ IDXGISwapChain.methods += [
     StdMethod(HRESULT, "SetFullscreenState", [(BOOL, "Fullscreen"), (ObjPointer(IDXGIOutput), "pTarget")]),
     StdMethod(HRESULT, "GetFullscreenState", [Out(Pointer(BOOL), "pFullscreen"), Out(Pointer(ObjPointer(IDXGIOutput)), "ppTarget")]),
     StdMethod(HRESULT, "GetDesc", [Out(Pointer(DXGI_SWAP_CHAIN_DESC), "pDesc")], sideeffects=False),
-    StdMethod(HRESULT, "ResizeBuffers", [(UINT, "BufferCount"), (UINT, "Width"), (UINT, "Height"), (DXGI_FORMAT, "NewFormat"), (UINT, "SwapChainFlags")]),
+    StdMethod(HRESULT, "ResizeBuffers", [(UINT, "BufferCount"), (UINT, "Width"), (UINT, "Height"), (DXGI_FORMAT, "NewFormat"), (DXGI_SWAP_CHAIN_FLAG, "SwapChainFlags")]),
     StdMethod(HRESULT, "ResizeTarget", [(Pointer(Const(DXGI_MODE_DESC)), "pNewTargetParameters")]),
     StdMethod(HRESULT, "GetContainingOutput", [Out(Pointer(ObjPointer(IDXGIOutput)), "ppOutput")]),
     StdMethod(HRESULT, "GetFrameStatistics", [Out(Pointer(DXGI_FRAME_STATISTICS), "pStats")], sideeffects=False),
@@ -282,9 +282,32 @@ IDXGIDevice1.methods += [
     StdMethod(HRESULT, "GetMaximumFrameLatency", [Out(Pointer(UINT), "pMaxLatency")], sideeffects=False),
 ]
 
+
+IDXGIFactoryDWM = Interface("IDXGIFactoryDWM", IUnknown)
+IDXGISwapChainDWM = Interface("IDXGISwapChainDWM", IDXGIDeviceSubObject)
+
+IDXGIFactoryDWM.methods += [
+    StdMethod(HRESULT, "CreateSwapChain", [(ObjPointer(IUnknown), "pDevice"), (Pointer(DXGI_SWAP_CHAIN_DESC), "pDesc"), (ObjPointer(IDXGIOutput), "pOutput"), Out(Pointer(ObjPointer(IDXGISwapChainDWM)), "ppSwapChain")]),
+]
+
+IDXGISwapChainDWM.methods += [
+    StdMethod(HRESULT, "Present", [(UINT, "SyncInterval"), (DXGI_PRESENT, "Flags")]),
+    StdMethod(HRESULT, "GetBuffer", [(UINT, "Buffer"), (REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppSurface")]),
+    StdMethod(HRESULT, "GetDesc", [Out(Pointer(DXGI_SWAP_CHAIN_DESC), "pDesc")], sideeffects=False),
+    StdMethod(HRESULT, "ResizeBuffers", [(UINT, "BufferCount"), (UINT, "Width"), (UINT, "Height"), (DXGI_FORMAT, "NewFormat"), (DXGI_SWAP_CHAIN_FLAG, "SwapChainFlags")]),
+    StdMethod(HRESULT, "ResizeTarget", [(Pointer(Const(DXGI_MODE_DESC)), "pNewTargetParameters")]),
+    StdMethod(HRESULT, "GetContainingOutput", [Out(Pointer(ObjPointer(IDXGIOutput)), "ppOutput")]),
+    StdMethod(HRESULT, "GetFrameStatistics", [(Pointer(DXGI_FRAME_STATISTICS), "pStats")], sideeffects=False),
+    StdMethod(HRESULT, "GetLastPresentCount", [(Pointer(UINT), "pLastPresentCount")], sideeffects=False),
+    StdMethod(HRESULT, "SetFullscreenState", [(BOOL, "Fullscreen"), (ObjPointer(IDXGIOutput), "pTarget")]),
+    StdMethod(HRESULT, "GetFullscreenState", [Out(Pointer(BOOL), "pFullscreen"), Out(Pointer(ObjPointer(IDXGIOutput)), "ppTarget")]),
+]
+
+
 dxgi = Module('dxgi')
 dxgi.addInterfaces([
-    IDXGIFactory1
+    IDXGIFactory1,
+    IDXGIFactoryDWM,
 ])
 dxgi.addFunctions([
     StdFunction(HRESULT, "CreateDXGIFactory", [(REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppFactory")]),
index 7c1568aed544a4a56452f6c3e0cd475a9eb4512c..7deb2955d51778d1c4559a54e9f0e227cf379b69 100755 (executable)
@@ -234,7 +234,7 @@ class DeclParser:
                 self.consume()
                 self.consume(':')
             else:
-                self.parse_prototype('StdMethod')
+                self.parse_prototype('Method')
                 self.consume(';')
         self.consume('}')
 
@@ -247,7 +247,7 @@ class DeclParser:
 
         ret = self.parse_type()
 
-        if self.match('__stdcall', 'WINAPI'):
+        if self.match('__stdcall', 'WINAPI', 'STDMETHODCALLTYPE'):
             self.consume()
             creator = 'Std' + creator
 
index 4cf0f7d716d8a2b2e9ccc1db42cb93a6da359352..95dc4ef6c650cf29b7a01cecc8f839cc07f25d30 100644 (file)
@@ -29,3 +29,6 @@ EXPORTS
     D3D10StateBlockMaskGetSetting
     D3D10StateBlockMaskIntersect
     D3D10StateBlockMaskUnion
+
+    CreateDXGIFactory
+    CreateDXGIFactory1
index 36dd5947f20c6ee38ade6133f23404a0727c6689..730cb0ebe39ac675341d01895cba230df7ba95ff 100644 (file)
@@ -1,6 +1,9 @@
 LIBRARY "d3d10_1"
 
 EXPORTS
-        D3D10CreateDevice1
-        D3D10CreateDeviceAndSwapChain1
-        D3D10CreateBlob
+    D3D10CreateDevice1
+    D3D10CreateDeviceAndSwapChain1
+    D3D10CreateBlob
+
+    CreateDXGIFactory
+    CreateDXGIFactory1
index 94bd743cd6fa567fb44b21882497812a8edb55ec..08aa23937c969509deb6bf741063b41b072a8911 100644 (file)
@@ -26,6 +26,7 @@
 
 from d3dcommontrace import D3DCommonTracer
 from specs.stdapi import API
+from specs.dxgi import dxgi
 from specs.d3d10_1 import d3d10_1
 
 
@@ -41,6 +42,7 @@ if __name__ == '__main__':
     print
 
     api = API()
+    api.addModule(dxgi)
     api.addModule(d3d10_1)
     tracer = D3DCommonTracer()
     tracer.traceApi(api)
index 7a9f3ff0af92e9e270c1e20aa3ba9c0fdac42e54..1de13927c5bf7fe9562f749029da3848af520fea 100644 (file)
@@ -26,6 +26,7 @@
 
 from d3dcommontrace import D3DCommonTracer
 from specs.stdapi import API
+from specs.dxgi import dxgi
 from specs.d3d10misc import d3d10
 
 
@@ -41,6 +42,7 @@ if __name__ == '__main__':
     print
 
     api = API()
+    api.addModule(dxgi)
     api.addModule(d3d10)
     tracer = D3DCommonTracer()
     tracer.traceApi(api)