+.*.sw?
+.scons*
*.obj
*.dll
*.lib
*.exp
-.scons*
+*.xml
#env['PDB'] = '${TARGET.base}.pdb'
cflags = [
- '/W3', # warning level
+ '/W3', # warning level
]
if env['debug']:
- cflags += [
- '/Od', # disable optimizations
- '/Oi', # enable intrinsic functions
- '/Oy-', # disable frame pointer omission
- ]
+ cflags += [
+ '/Od', # disable optimizations
+ '/Oi', # enable intrinsic functions
+ '/Oy-', # disable frame pointer omission
+ ]
else:
- cflags += [
- '/Ox', # maximum optimizations
- '/Oi', # enable intrinsic functions
- '/Os', # favor code space
- ]
+ cflags += [
+ '/Ox', # maximum optimizations
+ '/Oi', # enable intrinsic functions
+ '/Os', # favor code space
+ ]
env.Append(CFLAGS = cflags)
env.Append(CXXFLAGS = cflags)
'kernel32',
'user32',
'gdi32',
- 'winspool',
'comdlg32',
'advapi32',
'shell32',
- 'ole32',
- 'oleaut32',
- 'uuid',
- 'odbc32',
- 'odbccp32',
])
env.Append(CPPPATH = [
os.path.join(env['dxsdk'], 'Include'),
+ '#common',
])
Export('env')
-SConscript('d3d8/SConscript')
-SConscript('d3d9/SConscript')
+SConscript([
+ 'common/SConscript',
+ 'd3d8/SConscript',
+ 'd3d9/SConscript',
+])
--- /dev/null
+Import('env')
+
--- /dev/null
+
+#ifndef LOG_HPP_
+#define LOG_HPP_
+
+#include <windows.h>
+
+#include <d3d8.h>
+
+#include <stdio.h>
+
+
+class Log
+{
+public:
+ Log(const char *filename) {
+ file = fopen(filename, "wt");
+ write("<?xml version='1.0' encoding='UTF-8'?>\n");
+ write("<?xml-stylesheet type='text/xsl' href='d3dtrace.xsl'?>\n");
+ write("<trace>\n");
+ }
+
+ ~Log() {
+ write("</trace>\n");
+ fclose(file);
+ }
+
+ void write(const char *s) {
+ fputs(s, file);
+ }
+
+ void writef(const char *f, ...) {
+ va_list ap;
+ va_start(ap, f);
+ vfprintf(file, f, ap);
+ va_end(ap);
+ }
+
+ void eol(void) {
+ fputs("\n", file);
+ }
+
+ void tag(const char *name) {
+ write("<");
+ write(name);
+ write(">");
+ }
+
+ void tag_begin(const char *name) {
+ write("<");
+ write(name);
+ }
+
+ void tag_attr(const char *name, const char *value) {
+ write(" ");
+ write(name);
+ write("=\"");
+ write(value);
+ write("\"");
+ }
+
+ void tag_end(void) {
+ write(">");
+ }
+
+ void tag_close(const char *name) {
+ write("</");
+ write(name);
+ write(">");
+ }
+
+ void call_begin(const char *function) {
+ write("\t");
+ tag_begin("call");
+ tag_attr("name", function);
+ tag_end();
+ eol();
+ }
+
+ void call_end() {
+ write("\t");
+ tag_close("call");
+ eol();
+ }
+
+ void param_begin(const char *type, const char *name) {
+ write("\t\t");
+ tag_begin("param");
+ tag_attr("type", type);
+ tag_attr("name", name);
+ tag_end();
+ }
+
+ void param_end(void) {
+ tag_close("param");
+ eol();
+ }
+
+ void param_uint(const char *name, UINT value) {
+ param_begin("UINT", name);
+ writef("%u", value);
+ param_end();
+ }
+
+ void param_dword(const char *name, DWORD value) {
+ param_begin("DWORD", name);
+ writef("0x%08lx", value);
+ param_end();
+ }
+
+protected:
+ FILE *file;
+};
+
+
+#endif /* LOG_HPP_ */
// TraceDirect3DDevice8.cpp
#include "stdafx.h"
+#include "log.hpp"
TraceDirect3DDevice8::TraceDirect3DDevice8(IDirect3DDevice8* pOriginal) {
m_pIDirect3DDevice8 = pOriginal; // store the pointer to original object
+ log = new Log("d3d8trace.xml");
}
TraceDirect3DDevice8::~TraceDirect3DDevice8() {
-
+ delete log;
}
HRESULT __stdcall TraceDirect3DDevice8::QueryInterface(REFIID riid, void** ppvObj) {
}
HRESULT __stdcall TraceDirect3DDevice8::CreateTexture(UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture8** ppTexture) {
- return (m_pIDirect3DDevice8->CreateTexture(Width, Height, Levels, Usage, Format, Pool, ppTexture));
+ HRESULT hr;
+ log->call_begin("IDirect3DDevice9::CreateTexture");
+ log->param_uint("Width", Width);
+ log->param_uint("Height", Height);
+ log->param_uint("Levels", Levels);
+ log->param_dword("Usage", Usage);
+ log->param_dword("Format", Format);
+ log->param_dword("Pool", Pool);
+ hr = m_pIDirect3DDevice8->CreateTexture(Width, Height, Levels, Usage, Format, Pool, ppTexture);
+ log->call_end();
+ return hr;
}
HRESULT __stdcall TraceDirect3DDevice8::CreateVolumeTexture(UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture8** ppVolumeTexture) {
return (m_pIDirect3DDevice8->GetPixelShaderFunction(Handle, pData, pSizeOfData));
}
-HRESULT __stdcall TraceDirect3DDevice8::DrawRectPatch( UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo)
+HRESULT __stdcall TraceDirect3DDevice8::DrawRectPatch( UINT Handle, CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo)
{ return (m_pIDirect3DDevice8->DrawRectPatch(Handle, pNumSegs, pRectPatchInfo) );}
-HRESULT __stdcall TraceDirect3DDevice8::DrawTriPatch( UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo)
+HRESULT __stdcall TraceDirect3DDevice8::DrawTriPatch( UINT Handle, CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo)
{ return (m_pIDirect3DDevice8->DrawTriPatch(Handle, pNumSegs, pTriPatchInfo) );}
HRESULT __stdcall TraceDirect3DDevice8::DeletePatch(UINT Handle) {
// TraceDirect3DDevice8.h
#pragma once
+class Log;
+
class TraceDirect3DDevice8: public IDirect3DDevice8 {
public:
private:
IDirect3DDevice8 *m_pIDirect3DDevice8;
+ Log *log;
// This is our test function
void ShowWeAreHere(void);
--- /dev/null
+body {
+ font-family: sans;
+ font-size: 11px;
+ font-weight: normal;
+ text-align : left;
+}
+
+.fun {
+ font-weight: bold;
+}
+
+.var {
+ font-style: italic;
+}
+
+.typ {
+ display: none;
+}
+
+.lit {
+ color: #0000ff;
+}
--- /dev/null
+<?xml version="1.0"?>
+
+<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:output method="html" />
+
+ <xsl:template match="/trace">
+ <html>
+ <head>
+ <title>D3D Trace</title>
+ <link rel="stylesheet" type="text/css" href="d3dtrace.css"/>
+ </head>
+ <body>
+ <ul>
+ <xsl:apply-templates/>
+ </ul>
+ </body>
+ </html>
+ </xsl:template>
+
+ <xsl:template match="call">
+ <li>
+ <span class="fun">
+ <xsl:value-of select="@name"/>
+ </span>
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates/>
+ <xsl:text>)</xsl:text>
+ </li>
+ </xsl:template>
+
+ <xsl:template match="param">
+ <span class="typ">
+ <xsl:value-of select="@type"/>
+ <xsl:text> </xsl:text>
+ </span>
+ <span class="var">
+ <xsl:value-of select="@name"/>
+ </span>
+ <xsl:text> = </xsl:text>
+ <span class="lit">
+ <xsl:value-of select="."/>
+ </span>
+ <xsl:if test="position() != last()">
+ <xsl:text>, </xsl:text>
+ </xsl:if>
+ </xsl:template>
+
+</xsl:transform>