]> git.cworth.org Git - apitrace/commitdiff
Rename d3dshader.* -> d3d9shader.*
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Sun, 13 May 2012 10:41:08 +0000 (11:41 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Sun, 13 May 2012 10:41:08 +0000 (11:41 +0100)
common/json.hpp [deleted file]
retrace/json.hpp [new file with mode: 0644]
wrappers/CMakeLists.txt
wrappers/d3d8trace.py
wrappers/d3d9shader.cpp [new file with mode: 0644]
wrappers/d3d9shader.hpp [new file with mode: 0644]
wrappers/d3d9trace.py
wrappers/d3dshader.cpp [deleted file]
wrappers/d3dshader.hpp [deleted file]

diff --git a/common/json.hpp b/common/json.hpp
deleted file mode 100644 (file)
index 14ff501..0000000
+++ /dev/null
@@ -1,361 +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.
- *
- **************************************************************************/
-
-/*
- * Trace writing functions.
- */
-
-#ifndef _JSON_HPP_
-#define _JSON_HPP_
-
-#include <assert.h>
-#include <stddef.h>
-#include <wchar.h>
-
-#include <iomanip>
-#include <ostream>
-#include <string>
-
-
-class JSONWriter
-{
-private:
-    std::ostream &os;
-
-    int level;
-    bool value;
-    char space;
-
-    void newline(void) {
-        os << "\n";
-        for (int i = 0; i < level; ++i) 
-            os << "  ";
-    }
-
-    void separator(void) {
-        if (value) {
-            os << ",";
-            switch (space) {
-            case '\0':
-                break;
-            case '\n':
-                newline();
-                break;
-            default:
-                os << space;
-                break;
-            }
-        } else {
-            if (space == '\n') {
-                newline();
-            }
-        }
-    }
-
-    void escapeAsciiString(const char *str) {
-        os << "\"";
-
-        const unsigned char *src = (const unsigned char *)str;
-        unsigned char c;
-        while ((c = *src++)) {
-            if ((c == '\"') ||
-                (c == '\\')) {
-                // escape character
-                os << '\\' << (unsigned char)c;
-            } else if ((c >= 0x20 && c <= 0x7e) ||
-                        c == '\t' ||
-                        c == '\r' ||
-                        c == '\n') {
-                // pass-through character
-                os << (unsigned char)c;
-            } else {
-                assert(0);
-                os << "?";
-            }
-        }
-
-        os << "\"";
-    }
-
-    void escapeUnicodeString(const char *str) {
-        os << "\"";
-
-        const char *locale = setlocale(LC_CTYPE, "");
-        const char *src = str;
-        mbstate_t state;
-
-        memset(&state, 0, sizeof state);
-
-        do {
-            // Convert characters one at a time in order to recover from
-            // conversion errors
-            wchar_t c;
-            size_t written = mbsrtowcs(&c, &src, 1, &state);
-            if (written == 0) {
-                // completed
-                break;
-            } if (written == (size_t)-1) {
-                // conversion error -- skip 
-                os << "?";
-                do {
-                    ++src;
-                } while (*src & 0x80);
-            } else if ((c == '\"') ||
-                       (c == '\\')) {
-                // escape character
-                os << '\\' << (unsigned char)c;
-            } else if ((c >= 0x20 && c <= 0x7e) ||
-                        c == '\t' ||
-                        c == '\r' ||
-                        c == '\n') {
-                // pass-through character
-                os << (unsigned char)c;
-            } else {
-                // unicode
-                os << "\\u" << std::setfill('0') << std::hex << std::setw(4) << (unsigned)c;
-                os << std::dec;
-            }
-        } while (src);
-
-        setlocale(LC_CTYPE, locale);
-
-        os << "\"";
-    }
-
-    void encodeBase64String(const unsigned char *bytes, size_t size) {
-        const char *table64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-        unsigned char c0, c1, c2, c3;
-        char buf[4];
-        unsigned written;
-
-        os << "\"";
-
-        written = 0;
-        while (size >= 3) {
-            c0 = bytes[0] >> 2;
-            c1 = ((bytes[0] & 0x03) << 4) | ((bytes[1] & 0xf0) >> 4);
-            c2 = ((bytes[1] & 0x0f) << 2) | ((bytes[2] & 0xc0) >> 6);
-            c3 = bytes[2] & 0x3f;
-
-            buf[0] = table64[c0];
-            buf[1] = table64[c1];
-            buf[2] = table64[c2];
-            buf[3] = table64[c3];
-
-            os.write(buf, 4);
-
-            bytes += 3;
-            size -= 3;
-            ++written;
-
-            if (written >= 76/4 && size) {
-                os << "\n";
-                written = 0;
-            }
-        }
-
-        if (size > 0) {
-            c0 = bytes[0] >> 2;
-            c1 = ((bytes[0] & 0x03) << 4);
-            buf[2] = '=';
-            buf[3] = '=';
-            
-            if (size > 1) {
-                c1 |= ((bytes[1] & 0xf0) >> 4);
-                c2 = ((bytes[1] & 0x0f) << 2);
-                if (size > 2) {
-                    c2 |= ((bytes[2] & 0xc0) >> 6);
-                    c3 = bytes[2] & 0x3f;
-                    buf[3] = table64[c3];
-                }
-                buf[2] = table64[c2];
-            }
-            buf[1] = table64[c1];
-            buf[0] = table64[c0];
-
-            os.write(buf, 4);
-        }
-
-        os << "\"";
-    }
-
-public:
-    JSONWriter(std::ostream &_os) : 
-        os(_os), 
-        level(0),
-        value(false),
-        space(0)
-    {
-        beginObject();
-    }
-
-    ~JSONWriter() {
-        endObject();
-        newline();
-    }
-
-    inline void beginObject() {
-        separator();
-        os << "{";
-        ++level;
-        value = false;
-    }
-
-    inline void endObject() {
-        --level;
-        if (value)
-            newline();
-        os << "}";
-        value = true;
-        space = '\n';
-    }
-
-    inline void beginMember(const char * name) {
-        space = 0;
-        separator();
-        newline();
-        escapeAsciiString(name);
-        os << ": ";
-        value = false;
-    }
-
-    inline void beginMember(const std::string &name) {
-        beginMember(name.c_str());
-    }
-
-    inline void endMember(void) {
-        assert(value);
-        value = true;
-        space = 0;
-    }
-
-    inline void beginArray() {
-        separator();
-        os << "[";
-        ++level;
-        value = false;
-        space = 0;
-    }
-
-    inline void endArray(void) {
-        --level;
-        if (space == '\n') {
-            newline();
-        }
-        os << "]";
-        value = true;
-        space = '\n';
-    }
-
-    inline void writeString(const char *s) {
-        if (!s) {
-            writeNull();
-            return;
-        }
-
-        separator();
-        escapeUnicodeString(s);
-        value = true;
-        space = ' ';
-    }
-
-    inline void writeString(const std::string &s) {
-        writeString(s.c_str());
-    }
-
-    inline void writeBase64(const void *bytes, size_t size) {
-        separator();
-        encodeBase64String((const unsigned char *)bytes, size);
-        value = true;
-        space = ' ';
-    }
-
-    inline void writeNull(void) {
-        separator();
-        os << "null";
-        value = true;
-        space = ' ';
-    }
-
-    inline void writeBool(bool b) {
-        separator();
-        os << (b ? "true" : "false");
-        value = true;
-        space = ' ';
-    }
-
-
-    /**
-     * Special case for char to prevent it to be written as a literal
-     * character.
-     */
-    inline void writeNumber(char n) {
-        separator();
-        os << std::dec << static_cast<int>(n);
-        value = true;
-        space = ' ';
-    }
-
-    inline void writeNumber(unsigned char n) {
-        separator();
-        os << std::dec << static_cast<unsigned>(n);
-        value = true;
-        space = ' ';
-    }
-
-    template<class T>
-    inline void writeNumber(T n) {
-        if (n != n) {
-            // NaN
-            writeNull();
-        } else {
-            separator();
-            os << std::dec << std::setprecision(9) << n;
-            value = true;
-            space = ' ';
-        }
-    }
-    
-    inline void writeStringMember(const char *name, const char *s) {
-        beginMember(name);
-        writeString(s);
-        endMember();
-    }
-
-    inline void writeBoolMember(const char *name, bool b) {
-        beginMember(name);
-        writeBool(b);
-        endMember();
-    }
-
-    template<class T>
-    inline void writeNumberMember(const char *name, T n) {
-        beginMember(name);
-        writeNumber(n);
-        endMember();
-    }
-};
-
-#endif /* _JSON_HPP_ */
diff --git a/retrace/json.hpp b/retrace/json.hpp
new file mode 100644 (file)
index 0000000..14ff501
--- /dev/null
@@ -0,0 +1,361 @@
+/**************************************************************************
+ *
+ * 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.
+ *
+ **************************************************************************/
+
+/*
+ * Trace writing functions.
+ */
+
+#ifndef _JSON_HPP_
+#define _JSON_HPP_
+
+#include <assert.h>
+#include <stddef.h>
+#include <wchar.h>
+
+#include <iomanip>
+#include <ostream>
+#include <string>
+
+
+class JSONWriter
+{
+private:
+    std::ostream &os;
+
+    int level;
+    bool value;
+    char space;
+
+    void newline(void) {
+        os << "\n";
+        for (int i = 0; i < level; ++i) 
+            os << "  ";
+    }
+
+    void separator(void) {
+        if (value) {
+            os << ",";
+            switch (space) {
+            case '\0':
+                break;
+            case '\n':
+                newline();
+                break;
+            default:
+                os << space;
+                break;
+            }
+        } else {
+            if (space == '\n') {
+                newline();
+            }
+        }
+    }
+
+    void escapeAsciiString(const char *str) {
+        os << "\"";
+
+        const unsigned char *src = (const unsigned char *)str;
+        unsigned char c;
+        while ((c = *src++)) {
+            if ((c == '\"') ||
+                (c == '\\')) {
+                // escape character
+                os << '\\' << (unsigned char)c;
+            } else if ((c >= 0x20 && c <= 0x7e) ||
+                        c == '\t' ||
+                        c == '\r' ||
+                        c == '\n') {
+                // pass-through character
+                os << (unsigned char)c;
+            } else {
+                assert(0);
+                os << "?";
+            }
+        }
+
+        os << "\"";
+    }
+
+    void escapeUnicodeString(const char *str) {
+        os << "\"";
+
+        const char *locale = setlocale(LC_CTYPE, "");
+        const char *src = str;
+        mbstate_t state;
+
+        memset(&state, 0, sizeof state);
+
+        do {
+            // Convert characters one at a time in order to recover from
+            // conversion errors
+            wchar_t c;
+            size_t written = mbsrtowcs(&c, &src, 1, &state);
+            if (written == 0) {
+                // completed
+                break;
+            } if (written == (size_t)-1) {
+                // conversion error -- skip 
+                os << "?";
+                do {
+                    ++src;
+                } while (*src & 0x80);
+            } else if ((c == '\"') ||
+                       (c == '\\')) {
+                // escape character
+                os << '\\' << (unsigned char)c;
+            } else if ((c >= 0x20 && c <= 0x7e) ||
+                        c == '\t' ||
+                        c == '\r' ||
+                        c == '\n') {
+                // pass-through character
+                os << (unsigned char)c;
+            } else {
+                // unicode
+                os << "\\u" << std::setfill('0') << std::hex << std::setw(4) << (unsigned)c;
+                os << std::dec;
+            }
+        } while (src);
+
+        setlocale(LC_CTYPE, locale);
+
+        os << "\"";
+    }
+
+    void encodeBase64String(const unsigned char *bytes, size_t size) {
+        const char *table64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+        unsigned char c0, c1, c2, c3;
+        char buf[4];
+        unsigned written;
+
+        os << "\"";
+
+        written = 0;
+        while (size >= 3) {
+            c0 = bytes[0] >> 2;
+            c1 = ((bytes[0] & 0x03) << 4) | ((bytes[1] & 0xf0) >> 4);
+            c2 = ((bytes[1] & 0x0f) << 2) | ((bytes[2] & 0xc0) >> 6);
+            c3 = bytes[2] & 0x3f;
+
+            buf[0] = table64[c0];
+            buf[1] = table64[c1];
+            buf[2] = table64[c2];
+            buf[3] = table64[c3];
+
+            os.write(buf, 4);
+
+            bytes += 3;
+            size -= 3;
+            ++written;
+
+            if (written >= 76/4 && size) {
+                os << "\n";
+                written = 0;
+            }
+        }
+
+        if (size > 0) {
+            c0 = bytes[0] >> 2;
+            c1 = ((bytes[0] & 0x03) << 4);
+            buf[2] = '=';
+            buf[3] = '=';
+            
+            if (size > 1) {
+                c1 |= ((bytes[1] & 0xf0) >> 4);
+                c2 = ((bytes[1] & 0x0f) << 2);
+                if (size > 2) {
+                    c2 |= ((bytes[2] & 0xc0) >> 6);
+                    c3 = bytes[2] & 0x3f;
+                    buf[3] = table64[c3];
+                }
+                buf[2] = table64[c2];
+            }
+            buf[1] = table64[c1];
+            buf[0] = table64[c0];
+
+            os.write(buf, 4);
+        }
+
+        os << "\"";
+    }
+
+public:
+    JSONWriter(std::ostream &_os) : 
+        os(_os), 
+        level(0),
+        value(false),
+        space(0)
+    {
+        beginObject();
+    }
+
+    ~JSONWriter() {
+        endObject();
+        newline();
+    }
+
+    inline void beginObject() {
+        separator();
+        os << "{";
+        ++level;
+        value = false;
+    }
+
+    inline void endObject() {
+        --level;
+        if (value)
+            newline();
+        os << "}";
+        value = true;
+        space = '\n';
+    }
+
+    inline void beginMember(const char * name) {
+        space = 0;
+        separator();
+        newline();
+        escapeAsciiString(name);
+        os << ": ";
+        value = false;
+    }
+
+    inline void beginMember(const std::string &name) {
+        beginMember(name.c_str());
+    }
+
+    inline void endMember(void) {
+        assert(value);
+        value = true;
+        space = 0;
+    }
+
+    inline void beginArray() {
+        separator();
+        os << "[";
+        ++level;
+        value = false;
+        space = 0;
+    }
+
+    inline void endArray(void) {
+        --level;
+        if (space == '\n') {
+            newline();
+        }
+        os << "]";
+        value = true;
+        space = '\n';
+    }
+
+    inline void writeString(const char *s) {
+        if (!s) {
+            writeNull();
+            return;
+        }
+
+        separator();
+        escapeUnicodeString(s);
+        value = true;
+        space = ' ';
+    }
+
+    inline void writeString(const std::string &s) {
+        writeString(s.c_str());
+    }
+
+    inline void writeBase64(const void *bytes, size_t size) {
+        separator();
+        encodeBase64String((const unsigned char *)bytes, size);
+        value = true;
+        space = ' ';
+    }
+
+    inline void writeNull(void) {
+        separator();
+        os << "null";
+        value = true;
+        space = ' ';
+    }
+
+    inline void writeBool(bool b) {
+        separator();
+        os << (b ? "true" : "false");
+        value = true;
+        space = ' ';
+    }
+
+
+    /**
+     * Special case for char to prevent it to be written as a literal
+     * character.
+     */
+    inline void writeNumber(char n) {
+        separator();
+        os << std::dec << static_cast<int>(n);
+        value = true;
+        space = ' ';
+    }
+
+    inline void writeNumber(unsigned char n) {
+        separator();
+        os << std::dec << static_cast<unsigned>(n);
+        value = true;
+        space = ' ';
+    }
+
+    template<class T>
+    inline void writeNumber(T n) {
+        if (n != n) {
+            // NaN
+            writeNull();
+        } else {
+            separator();
+            os << std::dec << std::setprecision(9) << n;
+            value = true;
+            space = ' ';
+        }
+    }
+    
+    inline void writeStringMember(const char *name, const char *s) {
+        beginMember(name);
+        writeString(s);
+        endMember();
+    }
+
+    inline void writeBoolMember(const char *name, bool b) {
+        beginMember(name);
+        writeBool(b);
+        endMember();
+    }
+
+    template<class T>
+    inline void writeNumberMember(const char *name, T n) {
+        beginMember(name);
+        writeNumber(n);
+        endMember();
+    }
+};
+
+#endif /* _JSON_HPP_ */
index af9d91353dcacf54eeb096e50641dca7d5fd3e1f..5e61ed392abc3c5ef5fa260042bbcc94c5344b6d 100644 (file)
@@ -64,7 +64,7 @@ if (WIN32)
                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
         )
-        add_library (d3d8trace MODULE d3d8.def d3d8trace.cpp d3dshader.cpp)
+        add_library (d3d8trace MODULE d3d8.def d3d8trace.cpp d3d9shader.cpp)
         target_link_libraries (d3d8trace
             common
             ${ZLIB_LIBRARIES}
@@ -94,7 +94,7 @@ if (WIN32)
                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
         )
-        add_library (d3d9trace MODULE d3d9.def d3d9trace.cpp d3dshader.cpp)
+        add_library (d3d9trace MODULE d3d9.def d3d9trace.cpp d3d9shader.cpp)
         target_link_libraries (d3d9trace
             common
             ${ZLIB_LIBRARIES}
index 5219094b3e7d56d1e27658985b9abd3df750349a..0bf4bb80fdd81c70a91d34eb878bc92a7fe02e23 100644 (file)
@@ -44,7 +44,7 @@ if __name__ == '__main__':
     print
     print '#include <windows.h>'
     print '#include <d3d8.h>'
-    print '#include "d3dshader.hpp"'
+    print '#include "d3d9shader.hpp"'
     print
     print '#include "trace_writer_local.hpp"'
     print '#include "os.hpp"'
diff --git a/wrappers/d3d9shader.cpp b/wrappers/d3d9shader.cpp
new file mode 100644 (file)
index 0000000..f44cad3
--- /dev/null
@@ -0,0 +1,105 @@
+/**************************************************************************
+ *
+ * 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 <stdio.h>
+
+#include "d3d9shader.hpp"
+#include "d3d9imports.hpp"
+#include "d3dsize.hpp"
+
+
+typedef HRESULT
+(WINAPI *PD3DXDISASSEMBLESHADER)(
+    CONST DWORD *pShader,
+    BOOL EnableColorCode,
+    LPCSTR pComments,
+    LPD3DXBUFFER *ppDisassembly
+);
+
+
+void DumpShader(trace::Writer &writer, const DWORD *tokens)
+{
+    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;
+    }
+
+    LPD3DXBUFFER pDisassembly = NULL;
+    HRESULT hr = E_FAIL;
+
+    if (pfnD3DXDisassembleShader) {
+        hr = pfnD3DXDisassembleShader(tokens, FALSE, NULL, &pDisassembly);
+    }
+
+    if (SUCCEEDED(hr)) {
+        writer.beginRepr();
+        writer.writeString((const char *)pDisassembly->GetBufferPointer(), pDisassembly->GetBufferSize());
+    }
+
+    writer.writeBlob(tokens, _shaderSize(tokens));
+
+    if (pDisassembly) {
+        pDisassembly->Release();
+    }
+    
+    if (SUCCEEDED(hr)) {
+        writer.endRepr();
+    }
+}
diff --git a/wrappers/d3d9shader.hpp b/wrappers/d3d9shader.hpp
new file mode 100644 (file)
index 0000000..340f03b
--- /dev/null
@@ -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 _D3D9SHADER_HPP_
+#define _D3D9SHADER_HPP_
+
+
+#include <windows.h>
+
+#include "trace_writer.hpp"
+
+void DumpShader(trace::Writer &writer, const DWORD *tokens);
+
+
+#endif /* _D3D9SHADER_HPP_ */
index 8d71a3cc90ec202436c07e19a2102b13e3ba765a..6ee059fa3d9f039f28decaec1ec5e15da8554fde 100644 (file)
@@ -77,7 +77,7 @@ if __name__ == '__main__':
     print
     print '#include "d3d9imports.hpp"'
     print '#include "d3dsize.hpp"'
-    print '#include "d3dshader.hpp"'
+    print '#include "d3d9shader.hpp"'
     print
     print '''
 static inline size_t
diff --git a/wrappers/d3dshader.cpp b/wrappers/d3dshader.cpp
deleted file mode 100644 (file)
index b0690dc..0000000
+++ /dev/null
@@ -1,105 +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 <stdio.h>
-
-#include "d3dshader.hpp"
-#include "d3d9imports.hpp"
-#include "d3dsize.hpp"
-
-
-typedef HRESULT
-(WINAPI *PD3DXDISASSEMBLESHADER)(
-    CONST DWORD *pShader,
-    BOOL EnableColorCode,
-    LPCSTR pComments,
-    LPD3DXBUFFER *ppDisassembly
-);
-
-
-void DumpShader(trace::Writer &writer, const DWORD *tokens)
-{
-    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;
-    }
-
-    LPD3DXBUFFER pDisassembly = NULL;
-    HRESULT hr = E_FAIL;
-
-    if (pfnD3DXDisassembleShader) {
-        hr = pfnD3DXDisassembleShader(tokens, FALSE, NULL, &pDisassembly);
-    }
-
-    if (SUCCEEDED(hr)) {
-        writer.beginRepr();
-        writer.writeString((const char *)pDisassembly->GetBufferPointer(), pDisassembly->GetBufferSize());
-    }
-
-    writer.writeBlob(tokens, _shaderSize(tokens));
-
-    if (pDisassembly) {
-        pDisassembly->Release();
-    }
-    
-    if (SUCCEEDED(hr)) {
-        writer.endRepr();
-    }
-}
diff --git a/wrappers/d3dshader.hpp b/wrappers/d3dshader.hpp
deleted file mode 100644 (file)
index 485df05..0000000
+++ /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 _D3DSHADER_HPP_
-#define _D3DSHADER_HPP_
-
-
-#include <windows.h>
-
-#include "trace_writer.hpp"
-
-void DumpShader(trace::Writer &writer, const DWORD *tokens);
-
-
-#endif /* _D3DSHADER_HPP_ */