Add initial D3D8 driver

Implemented overlay, but no capture or replay yet, so this is
functionally equivalent to the current D3D9 implementation.
This commit is contained in:
Tim Jones
2017-06-22 09:35:06 +08:00
committed by Baldur Karlsson
parent 08cbddf063
commit bcad28b4d0
19 changed files with 5346 additions and 0 deletions
+11
View File
@@ -77,6 +77,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AMD", "renderdoc\driver\ihv
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IHV", "IHV", "{4DA2F3E3-9A65-45DD-A69B-82C7757D4904}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "d3d8", "renderdoc\driver\d3d8\renderdoc_d3d8.vcxproj", "{9C4487E8-EEB0-4A7F-BD81-23F81CD24E22}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Development|x64 = Development|x64
@@ -222,6 +224,14 @@ Global
{5DE5A561-548A-4DD7-90F0-06A2B39EAE9A}.Release|x64.Build.0 = Release|x64
{5DE5A561-548A-4DD7-90F0-06A2B39EAE9A}.Release|x86.ActiveCfg = Release|Win32
{5DE5A561-548A-4DD7-90F0-06A2B39EAE9A}.Release|x86.Build.0 = Release|Win32
{9C4487E8-EEB0-4A7F-BD81-23F81CD24E22}.Development|x64.ActiveCfg = Development|x64
{9C4487E8-EEB0-4A7F-BD81-23F81CD24E22}.Development|x64.Build.0 = Development|x64
{9C4487E8-EEB0-4A7F-BD81-23F81CD24E22}.Development|x86.ActiveCfg = Development|Win32
{9C4487E8-EEB0-4A7F-BD81-23F81CD24E22}.Development|x86.Build.0 = Development|Win32
{9C4487E8-EEB0-4A7F-BD81-23F81CD24E22}.Release|x64.ActiveCfg = Release|x64
{9C4487E8-EEB0-4A7F-BD81-23F81CD24E22}.Release|x64.Build.0 = Release|x64
{9C4487E8-EEB0-4A7F-BD81-23F81CD24E22}.Release|x86.ActiveCfg = Release|Win32
{9C4487E8-EEB0-4A7F-BD81-23F81CD24E22}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -249,5 +259,6 @@ Global
{44044776-9469-4079-B587-ABFFF6574AA4} = {864A44B0-5612-451A-857F-41E3EF785EF6}
{5DE5A561-548A-4DD7-90F0-06A2B39EAE9A} = {4DA2F3E3-9A65-45DD-A69B-82C7757D4904}
{4DA2F3E3-9A65-45DD-A69B-82C7757D4904} = {864A44B0-5612-451A-857F-41E3EF785EF6}
{9C4487E8-EEB0-4A7F-BD81-23F81CD24E22} = {864A44B0-5612-451A-857F-41E3EF785EF6}
EndGlobalSection
EndGlobal
+1
View File
@@ -71,6 +71,7 @@ string ToStrHelper<false, RDCDriver>::Get(const RDCDriver &el)
case RDC_D3D11: return "D3D11";
case RDC_D3D10: return "D3D10";
case RDC_D3D9: return "D3D9";
case RDC_D3D8: return "D3D8";
case RDC_Image: return "Image";
case RDC_Vulkan: return "Vulkan";
default: break;
+1
View File
@@ -107,6 +107,7 @@ enum RDCDriver
RDC_Image = 7,
RDC_Vulkan = 8,
RDC_OpenGLES = 9,
RDC_D3D8 = 10,
RDC_Custom = 100000,
RDC_Custom0 = RDC_Custom,
RDC_Custom1,
+58
View File
@@ -0,0 +1,58 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2017 Baldur Karlsson
*
* 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 "d3d8_common.h"
#include "d3d8_device.h"
unsigned int RefCounter8::SoftRef(WrappedD3DDevice8 *device)
{
unsigned int ret = AddRef();
if(device)
device->SoftRef();
else
RDCWARN("No device pointer, is a deleted resource being AddRef()d?");
return ret;
}
unsigned int RefCounter8::SoftRelease(WrappedD3DDevice8 *device)
{
unsigned int ret = Release();
if(device)
device->SoftRelease();
else
RDCWARN("No device pointer, is a deleted resource being Release()d?");
return ret;
}
void RefCounter8::AddDeviceSoftref(WrappedD3DDevice8 *device)
{
if(device)
device->SoftRef();
}
void RefCounter8::ReleaseDeviceSoftref(WrappedD3DDevice8 *device)
{
if(device)
device->SoftRelease();
}
+79
View File
@@ -0,0 +1,79 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2017 Baldur Karlsson
*
* 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.
******************************************************************************/
#pragma once
#include "api/replay/renderdoc_replay.h"
#include "core/core.h"
#include "driver/dx/official/d3d8.h"
class WrappedD3DDevice8;
class RefCounter8
{
private:
IUnknown *m_pReal;
unsigned int m_iRefcount;
bool m_SelfDeleting;
protected:
void SetSelfDeleting(bool selfDelete) { m_SelfDeleting = selfDelete; }
// used for derived classes that need to soft ref but are handling their
// own self-deletion
static void AddDeviceSoftref(WrappedD3DDevice8 *device);
static void ReleaseDeviceSoftref(WrappedD3DDevice8 *device);
public:
RefCounter8(IUnknown *real, bool selfDelete = true)
: m_pReal(real), m_iRefcount(1), m_SelfDeleting(selfDelete)
{
}
virtual ~RefCounter8() {}
unsigned int GetRefCount() { return m_iRefcount; }
//////////////////////////////
// implement IUnknown
HRESULT STDMETHODCALLTYPE QueryInterface(
/* [in] */ REFIID riid,
/* [annotation][iid_is][out] */
__RPC__deref_out void **ppvObject)
{
return E_NOINTERFACE;
}
ULONG STDMETHODCALLTYPE AddRef()
{
InterlockedIncrement(&m_iRefcount);
return m_iRefcount;
}
ULONG STDMETHODCALLTYPE Release()
{
unsigned int ret = InterlockedDecrement(&m_iRefcount);
if(ret == 0 && m_SelfDeleting)
delete this;
return ret;
}
unsigned int SoftRef(WrappedD3DDevice8 *device);
unsigned int SoftRelease(WrappedD3DDevice8 *device);
};
+318
View File
@@ -0,0 +1,318 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2017 Baldur Karlsson
*
* 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 "d3d8_debug.h"
#include "os/os_specific.h"
#include "stb/stb_truetype.h"
D3D8DebugManager::D3D8DebugManager(WrappedD3DDevice8 *wrapper)
: m_WrappedDevice(wrapper), m_fvf(D3DFVF_XYZ | D3DFVF_TEX1)
{
InitFontRendering();
}
D3D8DebugManager::~D3D8DebugManager()
{
ShutdownFontRendering();
}
bool D3D8DebugManager::InitFontRendering()
{
HRESULT hr = S_OK;
int width = FONT_TEX_WIDTH;
int height = FONT_TEX_HEIGHT;
string font = GetEmbeddedResource(sourcecodepro_ttf);
byte *ttfdata = (byte *)font.c_str();
const int firstChar = int(' ') + 1;
const int lastChar = 127;
const int numChars = lastChar - firstChar;
byte *buf = new byte[width * height];
const float pixelHeight = 20.0f;
stbtt_BakeFontBitmap(ttfdata, 0, pixelHeight, buf, width, height, firstChar, numChars,
m_Font.charData);
stbtt_fontinfo f = {0};
stbtt_InitFont(&f, ttfdata, 0);
int ascent = 0;
stbtt_GetFontVMetrics(&f, &ascent, NULL, NULL);
m_Font.maxHeight = float(ascent) * stbtt_ScaleForPixelHeight(&f, pixelHeight);
IDirect3DTexture8 *fontTex = NULL;
hr = m_WrappedDevice->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8,
D3DPOOL_DEFAULT, &fontTex);
if(FAILED(hr))
{
RDCERR("Failed to create font texture %08x", hr);
}
D3DLOCKED_RECT lockedRegion;
hr = fontTex->LockRect(0, &lockedRegion, NULL, D3DLOCK_DISCARD);
if(FAILED(hr))
{
RDCERR("Failed to lock font texture %08x", hr);
}
else
{
BYTE *texBase = (BYTE *)lockedRegion.pBits;
for(int y = 0; y < height; y++)
{
byte *curRow = (texBase + (y * lockedRegion.Pitch));
for(int x = 0; x < width; x++)
{
curRow[x * 4 + 0] = buf[(y * width) + x];
curRow[x * 4 + 1] = buf[(y * width) + x];
curRow[x * 4 + 2] = buf[(y * width) + x];
curRow[x * 4 + 3] = buf[(y * width) + x];
}
}
hr = fontTex->UnlockRect(0);
if(hr != S_OK)
{
RDCERR("Failed to unlock font texture %08x", hr);
}
}
m_Font.Tex = fontTex;
delete[] buf;
return true;
}
void D3D8DebugManager::ShutdownFontRendering()
{
SAFE_RELEASE(m_Font.Tex);
}
void D3D8DebugManager::SetOutputWindow(HWND w)
{
// RECT rect;
// GetClientRect(w, &rect);
// m_supersamplingX = float(m_width) / float(rect.right - rect.left);
// m_supersamplingY = float(m_height) / float(rect.bottom - rect.top);
}
void D3D8DebugManager::RenderText(float x, float y, const char *textfmt, ...)
{
static char tmpBuf[4096];
va_list args;
va_start(args, textfmt);
StringFormat::vsnprintf(tmpBuf, 4095, textfmt, args);
tmpBuf[4095] = '\0';
va_end(args);
RenderTextInternal(x, y, tmpBuf);
}
void D3D8DebugManager::RenderTextInternal(float x, float y, const char *text)
{
if(char *t = strchr((char *)text, '\n'))
{
*t = 0;
RenderTextInternal(x, y, text);
RenderTextInternal(x, y + 1.0f, t + 1);
*t = '\n';
return;
}
if(strlen(text) == 0)
return;
RDCASSERT(strlen(text) < FONT_MAX_CHARS);
// transforms
float width = (float)m_width;
float height = (float)m_height;
float nearPlane = 0.001f;
float farPlane = 1.f;
D3DMATRIX identity = {1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f,
0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f};
D3DMATRIX ortho = {2.f / width,
0.f,
0.f,
0.f,
0.f,
-(2.f / height),
0.f,
0.f,
0.f,
0.f,
1.f / (farPlane - nearPlane),
0.f,
0.f,
0.f,
nearPlane / (nearPlane - farPlane),
1.f};
HRESULT res = S_OK;
res |= m_WrappedDevice->SetTransform(D3DTS_PROJECTION, &ortho);
res |= m_WrappedDevice->SetTransform(D3DTS_WORLD, &identity);
res |= m_WrappedDevice->SetTransform(D3DTS_VIEW, &identity);
// enable fixed function pipeline
res |= m_WrappedDevice->SetVertexShader(NULL);
res |= m_WrappedDevice->SetPixelShader(NULL);
// default render states
res |= m_WrappedDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
res |= m_WrappedDevice->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
res |= m_WrappedDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
res |= m_WrappedDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE);
res |= m_WrappedDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, FALSE);
res |= m_WrappedDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
res |= m_WrappedDevice->SetRenderState(D3DRS_CLIPPING, FALSE);
res |= m_WrappedDevice->SetRenderState(D3DRS_FOGENABLE, FALSE);
res |= m_WrappedDevice->SetRenderState(D3DRS_COLORWRITEENABLE, 0x0000000F);
res |= m_WrappedDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
res |= m_WrappedDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
res |= m_WrappedDevice->SetRenderState(D3DRS_VERTEXBLEND, D3DVBF_DISABLE);
res |= m_WrappedDevice->SetRenderState(D3DRS_INDEXEDVERTEXBLENDENABLE, FALSE);
// texture stage states
res |= m_WrappedDevice->SetTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
res |= m_WrappedDevice->SetTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
res |= m_WrappedDevice->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR /*D3DTEXF_POINT*/);
res |= m_WrappedDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR /*D3DTEXF_POINT*/);
res |= m_WrappedDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTEXF_LINEAR /*D3DTEXF_POINT*/);
res |= m_WrappedDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
res |= m_WrappedDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
res |= m_WrappedDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT);
res |= m_WrappedDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
res |= m_WrappedDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
res |= m_WrappedDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
res |= m_WrappedDevice->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
res |= m_WrappedDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
res |= m_WrappedDevice->SetTextureStageState(0, D3DTSS_COLORARG0, D3DTA_CURRENT);
res |= m_WrappedDevice->SetTextureStageState(0, D3DTSS_ALPHAARG0, D3DTA_CURRENT);
res |= m_WrappedDevice->SetTextureStageState(0, D3DTSS_RESULTARG, D3DTA_CURRENT);
res |= m_WrappedDevice->SetVertexShader(m_fvf);
res |= m_WrappedDevice->SetTexture(0, m_Font.Tex);
for(uint32_t stage = 1; stage < 8; stage++)
{
res |= m_WrappedDevice->SetTexture(stage, NULL);
}
struct Vertex
{
float pos[3];
float uv[2];
Vertex() {}
Vertex(float posx, float posy, float posz, float texu, float texv)
{
pos[0] = posx;
pos[1] = posy;
pos[2] = posz;
uv[0] = texu;
uv[1] = texv;
}
};
struct Quad
{
Vertex vertices[6];
Quad() {}
Quad(float x0, float y0, float z, float s0, float t0, float x1, float y1, float s1, float t1)
{
vertices[0] = Vertex(x0, y0, z, s0, t0);
vertices[1] = Vertex(x1, y0, z, s1, t0);
vertices[2] = Vertex(x0, y1, z, s0, t1);
vertices[3] = Vertex(x1, y0, z, s1, t0);
vertices[4] = Vertex(x1, y1, z, s1, t1);
vertices[5] = Vertex(x0, y1, z, s0, t1);
}
};
Quad *quads = NULL;
Quad background;
UINT triangleCount = 0;
{
UINT quadCount = (UINT)strlen(text); // calculate string length
triangleCount = quadCount * 2;
// create text VB
quads = new Quad[quadCount];
float textStartingPositionX = (-width / 2.f) + (x * m_Font.charData->xadvance);
float textStartingPositionY = (-height / 2.f) + ((y + 1.f) * m_Font.maxHeight);
float textPositionX = textStartingPositionX;
float textPositionY = textStartingPositionY;
for(UINT i = 0; i < quadCount; ++i)
{
char glyphIndex = text[i] - (' ' + 1);
if(glyphIndex < 0)
{
float currentX = textPositionX;
textPositionX += m_Font.charData->xadvance;
quads[i] = Quad(currentX, textPositionY - m_Font.maxHeight, 0.5f, 0.f, 0.f, textPositionX,
textPositionY, 0.f, 0.f);
}
else
{
stbtt_aligned_quad quad;
stbtt_GetBakedQuad(m_Font.charData, 256, 128, glyphIndex, &textPositionX, &textPositionY,
&quad, 0);
quads[i] = Quad(quad.x0, quad.y0, 0.5f, quad.s0, quad.t0, quad.x1, quad.y1, quad.s1, quad.t1);
}
}
background = Quad(textStartingPositionX, textStartingPositionY - m_Font.maxHeight, 0.6f, 0.f,
0.f, textPositionX, textPositionY + 3.f, 0.f, 0.f);
}
if(quads != NULL)
{
// overlay render states
res |= m_WrappedDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
res |= m_WrappedDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, &background, sizeof(Vertex));
//// overlay render states
res |= m_WrappedDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
res |= m_WrappedDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
res |= m_WrappedDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
res |= m_WrappedDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, triangleCount, &quads[0],
sizeof(Vertex));
delete[] quads;
}
}
+76
View File
@@ -0,0 +1,76 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2017 Baldur Karlsson
*
* 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.
******************************************************************************/
#pragma once
#include <list>
#include <map>
#include <utility>
#include "driver/dx/official/d3d8.h"
#include "stb/stb_truetype.h"
#include "d3d8_common.h"
#include "d3d8_device.h"
class D3D8DebugManager
{
public:
D3D8DebugManager(WrappedD3DDevice8 *wrapper);
~D3D8DebugManager();
void RenderText(float x, float y, const char *textfmt, ...);
void SetOutputDimensions(int w, int h)
{
m_width = w;
m_height = h;
}
void SetOutputWindow(HWND w);
// font/text rendering
bool InitFontRendering();
void ShutdownFontRendering();
void RenderTextInternal(float x, float y, const char *text);
static const int FONT_TEX_WIDTH = 256;
static const int FONT_TEX_HEIGHT = 128;
static const int FONT_MAX_CHARS = 256;
static const uint32_t STAGE_BUFFER_BYTE_SIZE = 4 * 1024 * 1024;
struct FontData
{
FontData() { RDCEraseMem(this, sizeof(FontData)); }
~FontData() { SAFE_RELEASE(Tex); }
IDirect3DTexture8 *Tex;
stbtt_bakedchar charData[FONT_MAX_CHARS];
float maxHeight;
} m_Font;
DWORD m_fvf;
int m_width;
int m_height;
WrappedD3DDevice8 *m_WrappedDevice;
};
+840
View File
@@ -0,0 +1,840 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2017 Baldur Karlsson
*
* 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 "d3d8_device.h"
#include "core/core.h"
#include "serialise/serialiser.h"
#include "d3d8_debug.h"
WrappedD3DDevice8::WrappedD3DDevice8(IDirect3DDevice8 *device, HWND wnd,
D3DPRESENT_PARAMETERS *pPresentationParameters)
: m_RefCounter(device, false),
m_SoftRefCounter(NULL, false),
m_device(device),
m_DebugManager(NULL),
m_PresentParameters(*pPresentationParameters)
{
m_FrameCounter = 0;
// refcounters implicitly construct with one reference, but we don't start with any soft
// references.
m_SoftRefCounter.Release();
m_InternalRefcount = 0;
m_Alive = true;
if(!RenderDoc::Inst().IsReplayApp())
{
RenderDoc::Inst().AddDeviceFrameCapturer((IDirect3DDevice8 *)this, this);
m_Wnd = wnd;
if(wnd != NULL)
RenderDoc::Inst().AddFrameCapturer((IDirect3DDevice8 *)this, wnd, this);
}
}
void WrappedD3DDevice8::CheckForDeath()
{
if(!m_Alive)
return;
if(m_RefCounter.GetRefCount() == 0)
{
RDCASSERT(m_SoftRefCounter.GetRefCount() >= m_InternalRefcount);
if(m_SoftRefCounter.GetRefCount() <= m_InternalRefcount)
{
m_Alive = false;
delete this;
}
}
}
WrappedD3DDevice8::~WrappedD3DDevice8()
{
RenderDoc::Inst().RemoveDeviceFrameCapturer((IDirect3DDevice8 *)this);
if(m_Wnd != NULL)
RenderDoc::Inst().RemoveFrameCapturer((IDirect3DDevice8 *)this, m_Wnd);
SAFE_DELETE(m_DebugManager);
SAFE_RELEASE(m_device);
}
HRESULT WrappedD3DDevice8::QueryInterface(REFIID riid, void **ppvObject)
{
// RenderDoc UUID {A7AA6116-9C8D-4BBA-9083-B4D816B71B78}
static const GUID IRenderDoc_uuid = {
0xa7aa6116, 0x9c8d, 0x4bba, {0x90, 0x83, 0xb4, 0xd8, 0x16, 0xb7, 0x1b, 0x78}};
if(riid == IRenderDoc_uuid)
{
AddRef();
*ppvObject = (IUnknown *)this;
return S_OK;
}
else
{
string guid = ToStr::Get(riid);
RDCWARN("Querying IDirect3DDevice8 for interface: %s", guid.c_str());
}
return m_device->QueryInterface(riid, ppvObject);
}
void WrappedD3DDevice8::LazyInit()
{
m_DebugManager = new D3D8DebugManager(this);
}
void WrappedD3DDevice8::StartFrameCapture(void *dev, void *wnd)
{
RDCERR("Capture not supported on D3D8");
}
bool WrappedD3DDevice8::EndFrameCapture(void *dev, void *wnd)
{
RDCERR("Capture not supported on D3D8");
return false;
}
HRESULT __stdcall WrappedD3DDevice8::TestCooperativeLevel()
{
return m_device->TestCooperativeLevel();
}
UINT __stdcall WrappedD3DDevice8::GetAvailableTextureMem()
{
return m_device->GetAvailableTextureMem();
}
HRESULT __stdcall WrappedD3DDevice8::ResourceManagerDiscardBytes(DWORD Bytes)
{
return m_device->ResourceManagerDiscardBytes(Bytes);
}
HRESULT __stdcall WrappedD3DDevice8::GetDirect3D(IDirect3D8 **ppD3D8)
{
return m_device->GetDirect3D(ppD3D8);
}
HRESULT __stdcall WrappedD3DDevice8::GetDeviceCaps(D3DCAPS8 *pCaps)
{
return m_device->GetDeviceCaps(pCaps);
}
HRESULT __stdcall WrappedD3DDevice8::GetDisplayMode(D3DDISPLAYMODE *pMode)
{
return m_device->GetDisplayMode(pMode);
}
HRESULT __stdcall WrappedD3DDevice8::GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS *pParameters)
{
return m_device->GetCreationParameters(pParameters);
}
HRESULT __stdcall WrappedD3DDevice8::SetCursorProperties(UINT XHotSpot, UINT YHotSpot,
IDirect3DSurface8 *pCursorBitmap)
{
return m_device->SetCursorProperties(XHotSpot, YHotSpot, pCursorBitmap);
}
void __stdcall WrappedD3DDevice8::SetCursorPosition(int X, int Y, DWORD Flags)
{
m_device->SetCursorPosition(X, Y, Flags);
}
BOOL __stdcall WrappedD3DDevice8::ShowCursor(BOOL bShow)
{
return m_device->ShowCursor(bShow);
}
HRESULT __stdcall WrappedD3DDevice8::CreateAdditionalSwapChain(
D3DPRESENT_PARAMETERS *pPresentationParameters, IDirect3DSwapChain8 **pSwapChain)
{
return m_device->CreateAdditionalSwapChain(pPresentationParameters, pSwapChain);
}
HRESULT __stdcall WrappedD3DDevice8::Reset(D3DPRESENT_PARAMETERS *pPresentationParameters)
{
m_PresentParameters = *pPresentationParameters;
return m_device->Reset(pPresentationParameters);
}
HRESULT __stdcall WrappedD3DDevice8::Present(CONST RECT *pSourceRect, CONST RECT *pDestRect,
HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion)
{
// if(m_State == WRITING_IDLE)
RenderDoc::Inst().Tick();
HWND wnd = m_PresentParameters.hDeviceWindow;
if(hDestWindowOverride != NULL)
wnd = hDestWindowOverride;
bool activeWindow = RenderDoc::Inst().IsActiveWindow((IDirect3DDevice8 *)this, wnd);
m_FrameCounter++;
// if (m_State == WRITING_IDLE)
{
uint32_t overlay = RenderDoc::Inst().GetOverlayBits();
static bool debugRenderOverlay = true;
if(overlay & eRENDERDOC_Overlay_Enabled && debugRenderOverlay)
{
HRESULT res = S_OK;
res = m_device->BeginScene();
DWORD stateBlock;
HRESULT stateBlockRes = m_device->CreateStateBlock(D3DSBT_ALL, &stateBlock);
IDirect3DSurface8 *backBuffer;
res |= m_device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &backBuffer);
res |= m_device->SetRenderTarget(0, backBuffer);
D3DSURFACE_DESC bbDesc;
backBuffer->GetDesc(&bbDesc);
//
D3DVIEWPORT8 viewport = {0, 0, bbDesc.Width, bbDesc.Height, 0.f, 1.f};
res |= m_device->SetViewport(&viewport);
GetDebugManager()->SetOutputDimensions(bbDesc.Width, bbDesc.Height);
GetDebugManager()->SetOutputWindow(m_PresentParameters.hDeviceWindow);
int flags = activeWindow ? RenderDoc::eOverlay_ActiveWindow : 0;
flags |= RenderDoc::eOverlay_CaptureDisabled;
string overlayText = RenderDoc::Inst().GetOverlayText(RDC_D3D8, m_FrameCounter, flags);
overlayText += "Captures not supported with D3D8\n";
if(!overlayText.empty())
GetDebugManager()->RenderText(0.0f, 0.0f, overlayText.c_str());
stateBlockRes = m_device->ApplyStateBlock(stateBlock);
res |= m_device->EndScene();
}
}
if(activeWindow)
{
RenderDoc::Inst().SetCurrentDriver(RDC_D3D8);
}
return m_device->Present(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
}
HRESULT __stdcall WrappedD3DDevice8::GetBackBuffer(UINT iBackBuffer, D3DBACKBUFFER_TYPE Type,
IDirect3DSurface8 **ppBackBuffer)
{
return m_device->GetBackBuffer(iBackBuffer, Type, ppBackBuffer);
}
HRESULT __stdcall WrappedD3DDevice8::GetRasterStatus(D3DRASTER_STATUS *pRasterStatus)
{
return m_device->GetRasterStatus(pRasterStatus);
}
void __stdcall WrappedD3DDevice8::SetGammaRamp(DWORD Flags, CONST D3DGAMMARAMP *pRamp)
{
m_device->SetGammaRamp(Flags, pRamp);
}
void __stdcall WrappedD3DDevice8::GetGammaRamp(D3DGAMMARAMP *pRamp)
{
m_device->GetGammaRamp(pRamp);
}
HRESULT __stdcall WrappedD3DDevice8::CreateTexture(UINT Width, UINT Height, UINT Levels,
DWORD Usage, D3DFORMAT Format, D3DPOOL Pool,
IDirect3DTexture8 **ppTexture)
{
return m_device->CreateTexture(Width, Height, Levels, Usage, Format, Pool, ppTexture);
}
HRESULT __stdcall WrappedD3DDevice8::CreateVolumeTexture(UINT Width, UINT Height, UINT Depth,
UINT Levels, DWORD Usage, D3DFORMAT Format,
D3DPOOL Pool,
IDirect3DVolumeTexture8 **ppVolumeTexture)
{
return m_device->CreateVolumeTexture(Width, Height, Depth, Levels, Usage, Format, Pool,
ppVolumeTexture);
}
HRESULT __stdcall WrappedD3DDevice8::CreateCubeTexture(UINT EdgeLength, UINT Levels, DWORD Usage,
D3DFORMAT Format, D3DPOOL Pool,
IDirect3DCubeTexture8 **ppCubeTexture)
{
return m_device->CreateCubeTexture(EdgeLength, Levels, Usage, Format, Pool, ppCubeTexture);
}
HRESULT __stdcall WrappedD3DDevice8::CreateVertexBuffer(UINT Length, DWORD Usage, DWORD FVF,
D3DPOOL Pool,
IDirect3DVertexBuffer8 **ppVertexBuffer)
{
return m_device->CreateVertexBuffer(Length, Usage, FVF, Pool, ppVertexBuffer);
}
HRESULT __stdcall WrappedD3DDevice8::CreateIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format,
D3DPOOL Pool,
IDirect3DIndexBuffer8 **ppIndexBuffer)
{
return m_device->CreateIndexBuffer(Length, Usage, Format, Pool, ppIndexBuffer);
}
HRESULT __stdcall WrappedD3DDevice8::CreateRenderTarget(UINT Width, UINT Height, D3DFORMAT Format,
D3DMULTISAMPLE_TYPE MultiSample,
BOOL Lockable, IDirect3DSurface8 **ppSurface)
{
return m_device->CreateRenderTarget(Width, Height, Format, MultiSample, Lockable, ppSurface);
}
HRESULT __stdcall WrappedD3DDevice8::CreateDepthStencilSurface(UINT Width, UINT Height,
D3DFORMAT Format,
D3DMULTISAMPLE_TYPE MultiSample,
IDirect3DSurface8 **ppSurface)
{
return m_device->CreateDepthStencilSurface(Width, Height, Format, MultiSample, ppSurface);
}
HRESULT __stdcall WrappedD3DDevice8::CreateImageSurface(UINT Width, UINT Height, D3DFORMAT Format,
IDirect3DSurface8 **ppSurface)
{
return m_device->CreateImageSurface(Width, Height, Format, ppSurface);
}
HRESULT __stdcall WrappedD3DDevice8::CopyRects(IDirect3DSurface8 *pSourceSurface,
CONST RECT *pSourceRectsArray, UINT NumRects,
IDirect3DSurface8 *pDestinationSurface,
CONST POINT *pDestPointsArray)
{
return m_device->CopyRects(pSourceSurface, pSourceRectsArray, NumRects, pDestinationSurface,
pDestPointsArray);
}
HRESULT __stdcall WrappedD3DDevice8::UpdateTexture(IDirect3DBaseTexture8 *pSourceTexture,
IDirect3DBaseTexture8 *pDestinationTexture)
{
return m_device->UpdateTexture(pSourceTexture, pDestinationTexture);
}
HRESULT __stdcall WrappedD3DDevice8::GetFrontBuffer(IDirect3DSurface8 *pDestSurface)
{
return m_device->GetFrontBuffer(pDestSurface);
}
HRESULT __stdcall WrappedD3DDevice8::SetRenderTarget(IDirect3DSurface8 *pRenderTarget,
IDirect3DSurface8 *pNewZStencil)
{
return m_device->SetRenderTarget(pRenderTarget, pNewZStencil);
}
HRESULT __stdcall WrappedD3DDevice8::GetRenderTarget(IDirect3DSurface8 **ppRenderTarget)
{
return m_device->GetRenderTarget(ppRenderTarget);
}
HRESULT __stdcall WrappedD3DDevice8::GetDepthStencilSurface(IDirect3DSurface8 **ppZStencilSurface)
{
return m_device->GetDepthStencilSurface(ppZStencilSurface);
}
HRESULT __stdcall WrappedD3DDevice8::BeginScene()
{
return m_device->BeginScene();
}
HRESULT __stdcall WrappedD3DDevice8::EndScene()
{
return m_device->EndScene();
}
HRESULT __stdcall WrappedD3DDevice8::Clear(DWORD Count, CONST D3DRECT *pRects, DWORD Flags,
D3DCOLOR Color, float Z, DWORD Stencil)
{
return m_device->Clear(Count, pRects, Flags, Color, Z, Stencil);
}
HRESULT __stdcall WrappedD3DDevice8::SetTransform(D3DTRANSFORMSTATETYPE State,
CONST D3DMATRIX *pMatrix)
{
return m_device->SetTransform(State, pMatrix);
}
HRESULT __stdcall WrappedD3DDevice8::GetTransform(D3DTRANSFORMSTATETYPE State, D3DMATRIX *pMatrix)
{
return m_device->GetTransform(State, pMatrix);
}
HRESULT __stdcall WrappedD3DDevice8::MultiplyTransform(D3DTRANSFORMSTATETYPE _arg1,
CONST D3DMATRIX *_arg2)
{
return m_device->MultiplyTransform(_arg1, _arg2);
}
HRESULT __stdcall WrappedD3DDevice8::SetViewport(CONST D3DVIEWPORT8 *pViewport)
{
return m_device->SetViewport(pViewport);
}
HRESULT __stdcall WrappedD3DDevice8::GetViewport(D3DVIEWPORT8 *pViewport)
{
return m_device->GetViewport(pViewport);
}
HRESULT __stdcall WrappedD3DDevice8::SetMaterial(CONST D3DMATERIAL8 *pMaterial)
{
return m_device->SetMaterial(pMaterial);
}
HRESULT __stdcall WrappedD3DDevice8::GetMaterial(D3DMATERIAL8 *pMaterial)
{
return m_device->GetMaterial(pMaterial);
}
HRESULT __stdcall WrappedD3DDevice8::SetLight(DWORD Index, CONST D3DLIGHT8 *_arg2)
{
return m_device->SetLight(Index, _arg2);
}
HRESULT __stdcall WrappedD3DDevice8::GetLight(DWORD Index, D3DLIGHT8 *_arg2)
{
return m_device->GetLight(Index, _arg2);
}
HRESULT __stdcall WrappedD3DDevice8::LightEnable(DWORD Index, BOOL Enable)
{
return m_device->LightEnable(Index, Enable);
}
HRESULT __stdcall WrappedD3DDevice8::GetLightEnable(DWORD Index, BOOL *pEnable)
{
return m_device->GetLightEnable(Index, pEnable);
}
HRESULT __stdcall WrappedD3DDevice8::SetClipPlane(DWORD Index, CONST float *pPlane)
{
return m_device->SetClipPlane(Index, pPlane);
}
HRESULT __stdcall WrappedD3DDevice8::GetClipPlane(DWORD Index, float *pPlane)
{
return m_device->GetClipPlane(Index, pPlane);
}
HRESULT __stdcall WrappedD3DDevice8::SetRenderState(D3DRENDERSTATETYPE State, DWORD Value)
{
return m_device->SetRenderState(State, Value);
}
HRESULT __stdcall WrappedD3DDevice8::GetRenderState(D3DRENDERSTATETYPE State, DWORD *pValue)
{
return m_device->GetRenderState(State, pValue);
}
HRESULT __stdcall WrappedD3DDevice8::BeginStateBlock()
{
return m_device->BeginStateBlock();
}
HRESULT __stdcall WrappedD3DDevice8::EndStateBlock(DWORD *pToken)
{
return m_device->EndStateBlock(pToken);
}
HRESULT __stdcall WrappedD3DDevice8::ApplyStateBlock(DWORD Token)
{
return m_device->ApplyStateBlock(Token);
}
HRESULT __stdcall WrappedD3DDevice8::CaptureStateBlock(DWORD Token)
{
return m_device->CaptureStateBlock(Token);
}
HRESULT __stdcall WrappedD3DDevice8::DeleteStateBlock(DWORD Token)
{
return m_device->DeleteStateBlock(Token);
}
HRESULT __stdcall WrappedD3DDevice8::CreateStateBlock(D3DSTATEBLOCKTYPE Type, DWORD *pToken)
{
return m_device->CreateStateBlock(Type, pToken);
}
HRESULT __stdcall WrappedD3DDevice8::SetClipStatus(CONST D3DCLIPSTATUS8 *pClipStatus)
{
return m_device->SetClipStatus(pClipStatus);
}
HRESULT __stdcall WrappedD3DDevice8::GetClipStatus(D3DCLIPSTATUS8 *pClipStatus)
{
return m_device->GetClipStatus(pClipStatus);
}
HRESULT __stdcall WrappedD3DDevice8::GetTexture(DWORD Stage, IDirect3DBaseTexture8 **ppTexture)
{
return m_device->GetTexture(Stage, ppTexture);
}
HRESULT __stdcall WrappedD3DDevice8::SetTexture(DWORD Stage, IDirect3DBaseTexture8 *pTexture)
{
return m_device->SetTexture(Stage, pTexture);
}
HRESULT __stdcall WrappedD3DDevice8::GetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type,
DWORD *pValue)
{
return m_device->GetTextureStageState(Stage, Type, pValue);
}
HRESULT __stdcall WrappedD3DDevice8::SetTextureStageState(DWORD Stage,
D3DTEXTURESTAGESTATETYPE Type, DWORD Value)
{
return m_device->SetTextureStageState(Stage, Type, Value);
}
HRESULT __stdcall WrappedD3DDevice8::ValidateDevice(DWORD *pNumPasses)
{
return m_device->ValidateDevice(pNumPasses);
}
HRESULT __stdcall WrappedD3DDevice8::GetInfo(DWORD DevInfoID, void *pDevInfoStruct,
DWORD DevInfoStructSize)
{
return m_device->GetInfo(DevInfoID, pDevInfoStruct, DevInfoStructSize);
}
HRESULT __stdcall WrappedD3DDevice8::SetPaletteEntries(UINT PaletteNumber,
CONST PALETTEENTRY *pEntries)
{
return m_device->SetPaletteEntries(PaletteNumber, pEntries);
}
HRESULT __stdcall WrappedD3DDevice8::GetPaletteEntries(UINT PaletteNumber, PALETTEENTRY *pEntries)
{
return m_device->GetPaletteEntries(PaletteNumber, pEntries);
}
HRESULT __stdcall WrappedD3DDevice8::SetCurrentTexturePalette(UINT PaletteNumber)
{
return m_device->SetCurrentTexturePalette(PaletteNumber);
}
HRESULT __stdcall WrappedD3DDevice8::GetCurrentTexturePalette(UINT *PaletteNumber)
{
return m_device->GetCurrentTexturePalette(PaletteNumber);
}
HRESULT __stdcall WrappedD3DDevice8::DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex,
UINT PrimitiveCount)
{
return m_device->DrawPrimitive(PrimitiveType, StartVertex, PrimitiveCount);
}
HRESULT __stdcall WrappedD3DDevice8::DrawIndexedPrimitive(D3DPRIMITIVETYPE _arg1,
UINT MinVertexIndex, UINT NumVertices,
UINT startIndex, UINT primCount)
{
return m_device->DrawIndexedPrimitive(_arg1, MinVertexIndex, NumVertices, startIndex, primCount);
}
HRESULT __stdcall WrappedD3DDevice8::DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,
UINT PrimitiveCount,
CONST void *pVertexStreamZeroData,
UINT VertexStreamZeroStride)
{
return m_device->DrawPrimitiveUP(PrimitiveType, PrimitiveCount, pVertexStreamZeroData,
VertexStreamZeroStride);
}
HRESULT __stdcall WrappedD3DDevice8::DrawIndexedPrimitiveUP(
D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount,
CONST void *pIndexData, D3DFORMAT IndexDataFormat, CONST void *pVertexStreamZeroData,
UINT VertexStreamZeroStride)
{
return m_device->DrawIndexedPrimitiveUP(PrimitiveType, MinVertexIndex, NumVertices,
PrimitiveCount, pIndexData, IndexDataFormat,
pVertexStreamZeroData, VertexStreamZeroStride);
}
HRESULT __stdcall WrappedD3DDevice8::ProcessVertices(UINT SrcStartIndex, UINT DestIndex,
UINT VertexCount,
IDirect3DVertexBuffer8 *pDestBuffer, DWORD Flags)
{
return m_device->ProcessVertices(SrcStartIndex, DestIndex, VertexCount, pDestBuffer, Flags);
}
HRESULT __stdcall WrappedD3DDevice8::CreateVertexShader(CONST DWORD *pDeclaration,
CONST DWORD *pFunction, DWORD *pHandle,
DWORD Usage)
{
return m_device->CreateVertexShader(pDeclaration, pFunction, pHandle, Usage);
}
HRESULT __stdcall WrappedD3DDevice8::SetVertexShader(DWORD Handle)
{
return m_device->SetVertexShader(Handle);
}
HRESULT __stdcall WrappedD3DDevice8::GetVertexShader(DWORD *pHandle)
{
return m_device->GetVertexShader(pHandle);
}
HRESULT __stdcall WrappedD3DDevice8::DeleteVertexShader(DWORD Handle)
{
return m_device->DeleteVertexShader(Handle);
}
HRESULT __stdcall WrappedD3DDevice8::SetVertexShaderConstant(DWORD Register,
CONST void *pConstantData,
DWORD ConstantCount)
{
return m_device->SetVertexShaderConstant(Register, pConstantData, ConstantCount);
}
HRESULT __stdcall WrappedD3DDevice8::GetVertexShaderConstant(DWORD Register, void *pConstantData,
DWORD ConstantCount)
{
return m_device->GetVertexShaderConstant(Register, pConstantData, ConstantCount);
}
HRESULT __stdcall WrappedD3DDevice8::GetVertexShaderDeclaration(DWORD Handle, void *pData,
DWORD *pSizeOfData)
{
return m_device->GetVertexShaderDeclaration(Handle, pData, pSizeOfData);
}
HRESULT __stdcall WrappedD3DDevice8::GetVertexShaderFunction(DWORD Handle, void *pData,
DWORD *pSizeOfData)
{
return m_device->GetVertexShaderFunction(Handle, pData, pSizeOfData);
}
HRESULT __stdcall WrappedD3DDevice8::SetStreamSource(UINT StreamNumber,
IDirect3DVertexBuffer8 *pStreamData, UINT Stride)
{
return m_device->SetStreamSource(StreamNumber, pStreamData, Stride);
}
HRESULT __stdcall WrappedD3DDevice8::GetStreamSource(UINT StreamNumber,
IDirect3DVertexBuffer8 **ppStreamData,
UINT *pStride)
{
return m_device->GetStreamSource(StreamNumber, ppStreamData, pStride);
}
HRESULT __stdcall WrappedD3DDevice8::SetIndices(IDirect3DIndexBuffer8 *pIndexData,
UINT BaseVertexIndex)
{
return m_device->SetIndices(pIndexData, BaseVertexIndex);
}
HRESULT __stdcall WrappedD3DDevice8::GetIndices(IDirect3DIndexBuffer8 **ppIndexData,
UINT *pBaseVertexIndex)
{
return m_device->GetIndices(ppIndexData, pBaseVertexIndex);
}
HRESULT __stdcall WrappedD3DDevice8::CreatePixelShader(CONST DWORD *pFunction, DWORD *pHandle)
{
return m_device->CreatePixelShader(pFunction, pHandle);
}
HRESULT __stdcall WrappedD3DDevice8::SetPixelShader(DWORD Handle)
{
return m_device->SetPixelShader(Handle);
}
HRESULT __stdcall WrappedD3DDevice8::GetPixelShader(DWORD *pHandle)
{
return m_device->GetPixelShader(pHandle);
}
HRESULT __stdcall WrappedD3DDevice8::DeletePixelShader(DWORD Handle)
{
return m_device->DeletePixelShader(Handle);
}
HRESULT __stdcall WrappedD3DDevice8::SetPixelShaderConstant(DWORD Register, CONST void *pConstantData,
DWORD ConstantCount)
{
return m_device->SetPixelShaderConstant(Register, pConstantData, ConstantCount);
}
HRESULT __stdcall WrappedD3DDevice8::GetPixelShaderConstant(DWORD Register, void *pConstantData,
DWORD ConstantCount)
{
return m_device->GetPixelShaderConstant(Register, pConstantData, ConstantCount);
}
HRESULT __stdcall WrappedD3DDevice8::GetPixelShaderFunction(DWORD Handle, void *pData,
DWORD *pSizeOfData)
{
return m_device->GetPixelShaderFunction(Handle, pData, pSizeOfData);
}
HRESULT __stdcall WrappedD3DDevice8::DrawRectPatch(UINT Handle, CONST float *pNumSegs,
CONST D3DRECTPATCH_INFO *pRectPatchInfo)
{
return m_device->DrawRectPatch(Handle, pNumSegs, pRectPatchInfo);
}
HRESULT __stdcall WrappedD3DDevice8::DrawTriPatch(UINT Handle, CONST float *pNumSegs,
CONST D3DTRIPATCH_INFO *pTriPatchInfo)
{
return m_device->DrawTriPatch(Handle, pNumSegs, pTriPatchInfo);
}
HRESULT __stdcall WrappedD3DDevice8::DeletePatch(UINT Handle)
{
return m_device->DeletePatch(Handle);
}
HRESULT __stdcall WrappedD3D8::QueryInterface(REFIID riid, void **ppvObj)
{
return m_direct3D->QueryInterface(riid, ppvObj);
}
ULONG __stdcall WrappedD3D8::AddRef()
{
ULONG refCount;
refCount = m_direct3D->AddRef();
return refCount;
}
ULONG __stdcall WrappedD3D8::Release()
{
ULONG refCount = m_direct3D->Release();
if(refCount == 0)
{
delete this;
}
return refCount;
}
HRESULT __stdcall WrappedD3D8::RegisterSoftwareDevice(void *pInitializeFunction)
{
return m_direct3D->RegisterSoftwareDevice(pInitializeFunction);
}
UINT __stdcall WrappedD3D8::GetAdapterCount()
{
return m_direct3D->GetAdapterCount();
}
HRESULT __stdcall WrappedD3D8::GetAdapterIdentifier(UINT Adapter, DWORD Flags,
D3DADAPTER_IDENTIFIER8 *pIdentifier)
{
return m_direct3D->GetAdapterIdentifier(Adapter, Flags, pIdentifier);
}
UINT __stdcall WrappedD3D8::GetAdapterModeCount(UINT Adapter)
{
return m_direct3D->GetAdapterModeCount(Adapter);
}
HRESULT __stdcall WrappedD3D8::EnumAdapterModes(UINT Adapter, UINT Mode, D3DDISPLAYMODE *pMode)
{
return m_direct3D->EnumAdapterModes(Adapter, Mode, pMode);
}
HRESULT __stdcall WrappedD3D8::GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE *pMode)
{
return m_direct3D->GetAdapterDisplayMode(Adapter, pMode);
}
HRESULT __stdcall WrappedD3D8::CheckDeviceType(UINT Adapter, D3DDEVTYPE DevType,
D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat,
BOOL bWindowed)
{
return m_direct3D->CheckDeviceType(Adapter, DevType, AdapterFormat, BackBufferFormat, bWindowed);
}
HRESULT __stdcall WrappedD3D8::CheckDeviceFormat(UINT Adapter, D3DDEVTYPE DeviceType,
D3DFORMAT AdapterFormat, DWORD Usage,
D3DRESOURCETYPE RType, D3DFORMAT CheckFormat)
{
return m_direct3D->CheckDeviceFormat(Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat);
}
HRESULT __stdcall WrappedD3D8::CheckDeviceMultiSampleType(UINT Adapter, D3DDEVTYPE DeviceType,
D3DFORMAT SurfaceFormat, BOOL Windowed,
D3DMULTISAMPLE_TYPE MultiSampleType)
{
return m_direct3D->CheckDeviceMultiSampleType(Adapter, DeviceType, SurfaceFormat, Windowed,
MultiSampleType);
}
HRESULT __stdcall WrappedD3D8::CheckDepthStencilMatch(UINT Adapter, D3DDEVTYPE DeviceType,
D3DFORMAT AdapterFormat,
D3DFORMAT RenderTargetFormat,
D3DFORMAT DepthStencilFormat)
{
return m_direct3D->CheckDepthStencilMatch(Adapter, DeviceType, AdapterFormat, RenderTargetFormat,
DepthStencilFormat);
}
HRESULT __stdcall WrappedD3D8::GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS8 *pCaps)
{
return m_direct3D->GetDeviceCaps(Adapter, DeviceType, pCaps);
}
HMONITOR __stdcall WrappedD3D8::GetAdapterMonitor(UINT Adapter)
{
return m_direct3D->GetAdapterMonitor(Adapter);
}
HRESULT __stdcall WrappedD3D8::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow,
DWORD BehaviorFlags,
D3DPRESENT_PARAMETERS *pPresentationParameters,
IDirect3DDevice8 **ppReturnedDeviceInterface)
{
IDirect3DDevice8 *device = NULL;
HRESULT res = m_direct3D->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags,
pPresentationParameters, &device);
if(res == S_OK)
{
RDCLOG("App creating d3d8 device");
HWND wnd = pPresentationParameters->hDeviceWindow;
if(wnd == NULL)
wnd = hFocusWindow;
if(!wnd)
RDCWARN("Couldn't find valid non-NULL window at CreateDevice time");
WrappedD3DDevice8 *wrappedDevice = new WrappedD3DDevice8(device, wnd, pPresentationParameters);
wrappedDevice->LazyInit(); // TODO this can be moved later probably
*ppReturnedDeviceInterface = wrappedDevice;
}
else
{
*ppReturnedDeviceInterface = NULL;
}
return res;
}
+264
View File
@@ -0,0 +1,264 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2017 Baldur Karlsson
*
* 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.
******************************************************************************/
#pragma once
#include "common/timing.h"
#include "d3d8_common.h"
class D3D8DebugManager;
class WrappedD3DDevice8 : public IDirect3DDevice8, public IFrameCapturer
{
public:
WrappedD3DDevice8(IDirect3DDevice8 *device, HWND wnd,
D3DPRESENT_PARAMETERS *pPresentationParameters);
~WrappedD3DDevice8();
void LazyInit();
void StartFrameCapture(void *dev, void *wnd);
bool EndFrameCapture(void *dev, void *wnd);
void InternalRef() { InterlockedIncrement(&m_InternalRefcount); }
void InternalRelease() { InterlockedDecrement(&m_InternalRefcount); }
void SoftRef() { m_SoftRefCounter.AddRef(); }
void SoftRelease()
{
m_SoftRefCounter.Release();
CheckForDeath();
}
D3D8DebugManager *GetDebugManager() { return m_DebugManager; }
/*** IUnknown methods ***/
ULONG STDMETHODCALLTYPE AddRef() { return m_RefCounter.AddRef(); }
ULONG STDMETHODCALLTYPE Release()
{
unsigned int ret = m_RefCounter.Release();
CheckForDeath();
return ret;
}
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject);
/*** IDirect3DDevice8 methods ***/
virtual HRESULT __stdcall TestCooperativeLevel();
virtual UINT __stdcall GetAvailableTextureMem();
virtual HRESULT __stdcall ResourceManagerDiscardBytes(DWORD Bytes);
virtual HRESULT __stdcall GetDirect3D(IDirect3D8 **ppD3D8);
virtual HRESULT __stdcall GetDeviceCaps(D3DCAPS8 *pCaps);
virtual HRESULT __stdcall GetDisplayMode(D3DDISPLAYMODE *pMode);
virtual HRESULT __stdcall GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS *pParameters);
virtual HRESULT __stdcall SetCursorProperties(UINT XHotSpot, UINT YHotSpot,
IDirect3DSurface8 *pCursorBitmap);
virtual void __stdcall SetCursorPosition(int X, int Y, DWORD Flags);
virtual BOOL __stdcall ShowCursor(BOOL bShow);
virtual HRESULT __stdcall CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS *pPresentationParameters,
IDirect3DSwapChain8 **pSwapChain);
virtual HRESULT __stdcall Reset(D3DPRESENT_PARAMETERS *pPresentationParameters);
virtual HRESULT __stdcall Present(CONST RECT *pSourceRect, CONST RECT *pDestRect,
HWND hDestWindow, CONST RGNDATA *pDirtyRegion);
virtual HRESULT __stdcall GetBackBuffer(UINT iBackBuffer, D3DBACKBUFFER_TYPE Type,
IDirect3DSurface8 **ppBackBuffer);
virtual HRESULT __stdcall GetRasterStatus(D3DRASTER_STATUS *pRasterStatus);
virtual void __stdcall SetGammaRamp(DWORD Flags, CONST D3DGAMMARAMP *pRamp);
virtual void __stdcall GetGammaRamp(D3DGAMMARAMP *pRamp);
virtual HRESULT __stdcall CreateTexture(UINT Width, UINT Height, UINT Levels, DWORD Usage,
D3DFORMAT Format, D3DPOOL Pool,
IDirect3DTexture8 **ppTexture);
virtual HRESULT __stdcall CreateVolumeTexture(UINT Width, UINT Height, UINT Depth, UINT Levels,
DWORD Usage, D3DFORMAT Format, D3DPOOL Pool,
IDirect3DVolumeTexture8 **ppVolumeTexture);
virtual HRESULT __stdcall CreateCubeTexture(UINT EdgeLength, UINT Levels, DWORD Usage,
D3DFORMAT Format, D3DPOOL Pool,
IDirect3DCubeTexture8 **ppCubeTexture);
virtual HRESULT __stdcall CreateVertexBuffer(UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool,
IDirect3DVertexBuffer8 **ppVertexBuffer);
virtual HRESULT __stdcall CreateIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format,
D3DPOOL Pool, IDirect3DIndexBuffer8 **ppIndexBuffer);
virtual HRESULT __stdcall CreateRenderTarget(UINT Width, UINT Height, D3DFORMAT Format,
D3DMULTISAMPLE_TYPE MultiSample, BOOL Lockable,
IDirect3DSurface8 **ppSurface);
virtual HRESULT __stdcall CreateDepthStencilSurface(UINT Width, UINT Height, D3DFORMAT Format,
D3DMULTISAMPLE_TYPE MultiSample,
IDirect3DSurface8 **ppSurface);
virtual HRESULT __stdcall CreateImageSurface(UINT Width, UINT Height, D3DFORMAT Format,
IDirect3DSurface8 **ppSurface);
virtual HRESULT __stdcall CopyRects(IDirect3DSurface8 *pSourceSurface,
CONST RECT *pSourceRectsArray, UINT NumRects,
IDirect3DSurface8 *pDestinationSurface,
CONST POINT *pDestPointsArray);
virtual HRESULT __stdcall UpdateTexture(IDirect3DBaseTexture8 *pSourceTexture,
IDirect3DBaseTexture8 *pDestinationTexture);
virtual HRESULT __stdcall GetFrontBuffer(IDirect3DSurface8 *pDestSurface);
virtual HRESULT __stdcall SetRenderTarget(IDirect3DSurface8 *pRenderTarget,
IDirect3DSurface8 *pNewZStencil);
virtual HRESULT __stdcall GetRenderTarget(IDirect3DSurface8 **ppRenderTarget);
virtual HRESULT __stdcall GetDepthStencilSurface(IDirect3DSurface8 **ppZStencilSurface);
virtual HRESULT __stdcall BeginScene();
virtual HRESULT __stdcall EndScene();
virtual HRESULT __stdcall Clear(DWORD Count, CONST D3DRECT *pRects, DWORD Flags, D3DCOLOR Color,
float Z, DWORD Stencil);
virtual HRESULT __stdcall SetTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX *pMatrix);
virtual HRESULT __stdcall GetTransform(D3DTRANSFORMSTATETYPE State, D3DMATRIX *pMatrix);
virtual HRESULT __stdcall MultiplyTransform(D3DTRANSFORMSTATETYPE, CONST D3DMATRIX *);
virtual HRESULT __stdcall SetViewport(CONST D3DVIEWPORT8 *pViewport);
virtual HRESULT __stdcall GetViewport(D3DVIEWPORT8 *pViewport);
virtual HRESULT __stdcall SetMaterial(CONST D3DMATERIAL8 *pMaterial);
virtual HRESULT __stdcall GetMaterial(D3DMATERIAL8 *pMaterial);
virtual HRESULT __stdcall SetLight(DWORD Index, CONST D3DLIGHT8 *);
virtual HRESULT __stdcall GetLight(DWORD Index, D3DLIGHT8 *);
virtual HRESULT __stdcall LightEnable(DWORD Index, BOOL Enable);
virtual HRESULT __stdcall GetLightEnable(DWORD Index, BOOL *pEnable);
virtual HRESULT __stdcall SetClipPlane(DWORD Index, CONST float *pPlane);
virtual HRESULT __stdcall GetClipPlane(DWORD Index, float *pPlane);
virtual HRESULT __stdcall SetRenderState(D3DRENDERSTATETYPE State, DWORD Value);
virtual HRESULT __stdcall GetRenderState(D3DRENDERSTATETYPE State, DWORD *pValue);
virtual HRESULT __stdcall BeginStateBlock();
virtual HRESULT __stdcall EndStateBlock(DWORD *pToken);
virtual HRESULT __stdcall ApplyStateBlock(DWORD Token);
virtual HRESULT __stdcall CaptureStateBlock(DWORD Token);
virtual HRESULT __stdcall DeleteStateBlock(DWORD Token);
virtual HRESULT __stdcall CreateStateBlock(D3DSTATEBLOCKTYPE Type, DWORD *pToken);
virtual HRESULT __stdcall SetClipStatus(CONST D3DCLIPSTATUS8 *pClipStatus);
virtual HRESULT __stdcall GetClipStatus(D3DCLIPSTATUS8 *pClipStatus);
virtual HRESULT __stdcall GetTexture(DWORD Stage, IDirect3DBaseTexture8 **ppTexture);
virtual HRESULT __stdcall SetTexture(DWORD Stage, IDirect3DBaseTexture8 *pTexture);
virtual HRESULT __stdcall GetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type,
DWORD *pValue);
virtual HRESULT __stdcall SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type,
DWORD Value);
virtual HRESULT __stdcall ValidateDevice(DWORD *pNumPasses);
virtual HRESULT __stdcall GetInfo(DWORD DevInfoID, void *pDevInfoStruct, DWORD DevInfoStructSize);
virtual HRESULT __stdcall SetPaletteEntries(UINT PaletteNumber, CONST PALETTEENTRY *pEntries);
virtual HRESULT __stdcall GetPaletteEntries(UINT PaletteNumber, PALETTEENTRY *pEntries);
virtual HRESULT __stdcall SetCurrentTexturePalette(UINT PaletteNumber);
virtual HRESULT __stdcall GetCurrentTexturePalette(UINT *PaletteNumber);
virtual HRESULT __stdcall DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex,
UINT PrimitiveCount);
virtual HRESULT __stdcall DrawIndexedPrimitive(D3DPRIMITIVETYPE, UINT MinVertexIndex,
UINT NumVertices, UINT startIndex, UINT primCount);
virtual HRESULT __stdcall DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount,
CONST void *pVertexStreamZeroData,
UINT VertexStreamZeroStride);
virtual HRESULT __stdcall DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,
UINT MinVertexIndex, UINT NumVertices,
UINT PrimitiveCount, CONST void *pIndexData,
D3DFORMAT IndexDataFormat,
CONST void *pVertexStreamZeroData,
UINT VertexStreamZeroStride);
virtual HRESULT __stdcall ProcessVertices(UINT SrcStartIndex, UINT DestIndex, UINT VertexCount,
IDirect3DVertexBuffer8 *pDestBuffer, DWORD Flags);
virtual HRESULT __stdcall CreateVertexShader(CONST DWORD *pDeclaration, CONST DWORD *pFunction,
DWORD *pHandle, DWORD Usage);
virtual HRESULT __stdcall SetVertexShader(DWORD Handle);
virtual HRESULT __stdcall GetVertexShader(DWORD *pHandle);
virtual HRESULT __stdcall DeleteVertexShader(DWORD HHandle);
virtual HRESULT __stdcall SetVertexShaderConstant(DWORD Register, CONST void *pConstantData,
DWORD ConstantCount);
virtual HRESULT __stdcall GetVertexShaderConstant(DWORD Register, void *pConstantData,
DWORD ConstantCount);
virtual HRESULT __stdcall GetVertexShaderDeclaration(DWORD Handle, void *pData, DWORD *pSizeOfData);
virtual HRESULT __stdcall GetVertexShaderFunction(DWORD Handle, void *pData, DWORD *pSizeOfData);
virtual HRESULT __stdcall SetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer8 *pStreamData,
UINT Stride);
virtual HRESULT __stdcall GetStreamSource(UINT StreamNumber,
IDirect3DVertexBuffer8 **ppStreamData, UINT *pStride);
virtual HRESULT __stdcall SetIndices(IDirect3DIndexBuffer8 *pIndexData, UINT BaseVertexIndex);
virtual HRESULT __stdcall GetIndices(IDirect3DIndexBuffer8 **ppIndexData, UINT *pBaseVertexIndex);
virtual HRESULT __stdcall CreatePixelShader(CONST DWORD *pFunction, DWORD *pHandle);
virtual HRESULT __stdcall SetPixelShader(DWORD Handle);
virtual HRESULT __stdcall GetPixelShader(DWORD *pHandle);
virtual HRESULT __stdcall DeletePixelShader(DWORD Handle);
virtual HRESULT __stdcall SetPixelShaderConstant(DWORD Register, CONST void *pConstantData,
DWORD ConstantCount);
virtual HRESULT __stdcall GetPixelShaderConstant(DWORD Register, void *pConstantData,
DWORD ConstantCount);
virtual HRESULT __stdcall GetPixelShaderFunction(DWORD Handle, void *pData, DWORD *pSizeOfData);
virtual HRESULT __stdcall DrawRectPatch(UINT Handle, CONST float *pNumSegs,
CONST D3DRECTPATCH_INFO *pRectPatchInfo);
virtual HRESULT __stdcall DrawTriPatch(UINT Handle, CONST float *pNumSegs,
CONST D3DTRIPATCH_INFO *pTriPatchInfo);
virtual HRESULT __stdcall DeletePatch(UINT Handle);
private:
void CheckForDeath();
IDirect3DDevice8 *m_device;
D3D8DebugManager *m_DebugManager;
D3DPRESENT_PARAMETERS m_PresentParameters;
HWND m_Wnd;
unsigned int m_InternalRefcount;
RefCounter8 m_RefCounter;
RefCounter8 m_SoftRefCounter;
bool m_Alive;
uint32_t m_FrameCounter;
};
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// WrappedD3D8
class WrappedD3D8 : public IDirect3D8
{
public:
WrappedD3D8(IDirect3D8 *direct3D8) : m_direct3D(direct3D8) {}
/*** IUnknown methods ***/
virtual HRESULT __stdcall QueryInterface(REFIID riid, void **ppvObj);
virtual ULONG __stdcall AddRef();
virtual ULONG __stdcall Release();
/*** IDirect3D8 methods ***/
virtual HRESULT __stdcall RegisterSoftwareDevice(void *pInitializeFunction);
virtual UINT __stdcall GetAdapterCount();
virtual HRESULT __stdcall GetAdapterIdentifier(UINT Adapter, DWORD Flags,
D3DADAPTER_IDENTIFIER8 *pIdentifier);
virtual UINT __stdcall GetAdapterModeCount(UINT Adapter);
virtual HRESULT __stdcall EnumAdapterModes(UINT Adapter, UINT Mode, D3DDISPLAYMODE *pMode);
virtual HRESULT __stdcall GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE *pMode);
virtual HRESULT __stdcall CheckDeviceType(UINT Adapter, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat,
D3DFORMAT BackBufferFormat, BOOL bWindowed);
virtual HRESULT __stdcall CheckDeviceFormat(UINT Adapter, D3DDEVTYPE DeviceType,
D3DFORMAT AdapterFormat, DWORD Usage,
D3DRESOURCETYPE RType, D3DFORMAT CheckFormat);
virtual HRESULT __stdcall CheckDeviceMultiSampleType(UINT Adapter, D3DDEVTYPE DeviceType,
D3DFORMAT SurfaceFormat, BOOL Windowed,
D3DMULTISAMPLE_TYPE MultiSampleType);
virtual HRESULT __stdcall CheckDepthStencilMatch(UINT Adapter, D3DDEVTYPE DeviceType,
D3DFORMAT AdapterFormat,
D3DFORMAT RenderTargetFormat,
D3DFORMAT DepthStencilFormat);
virtual HRESULT __stdcall GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS8 *pCaps);
virtual HMONITOR __stdcall GetAdapterMonitor(UINT Adapter);
virtual HRESULT __stdcall CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow,
DWORD BehaviorFlags,
D3DPRESENT_PARAMETERS *pPresentationParameters,
IDirect3DDevice8 **ppReturnedDeviceInterface);
private:
IDirect3D8 *m_direct3D;
};
+78
View File
@@ -0,0 +1,78 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2017 Baldur Karlsson
*
* 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 "driver/dx/official/d3d8.h"
#include "hooks/hooks.h"
#include "d3d8_device.h"
#define DLL_NAME "d3d8.dll"
typedef IDirect3D8 *(WINAPI *PFN_D3D8_CREATE)(UINT);
class D3D8Hook : LibraryHook
{
public:
D3D8Hook()
{
LibraryHooks::GetInstance().RegisterHook(DLL_NAME, this);
m_HasHooks = false;
m_EnabledHooks = true;
}
bool CreateHooks(const char *libName)
{
bool success = true;
success &= Create8.Initialize("Direct3DCreate8", DLL_NAME, Create8_hook);
if(!success)
return false;
m_HasHooks = true;
m_EnabledHooks = true;
return true;
}
void EnableHooks(const char *libName, bool enable) { m_EnabledHooks = enable; }
void OptionsUpdated(const char *libName) {}
private:
static D3D8Hook d3d8hooks;
bool m_HasHooks;
bool m_EnabledHooks;
Hook<PFN_D3D8_CREATE> Create8;
static IDirect3D8 *WINAPI Create8_hook(UINT SDKVersion)
{
RDCLOG("App creating d3d8 %x", SDKVersion);
IDirect3D8 *realD3D = d3d8hooks.Create8()(SDKVersion);
return new WrappedD3D8(realD3D);
}
};
D3D8Hook D3D8Hook::d3d8hooks;
+33
View File
@@ -0,0 +1,33 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2017 Baldur Karlsson
*
* 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 "d3d8_common.h"
ReplayStatus D3D8_CreateReplayDevice(const char *logfile, IReplayDriver **driver)
{
RDCERR("D3D8 captures are not currently supported");
return ReplayStatus::APIUnsupported;
}
static DriverRegistration D3D8DriverRegistration(RDC_D3D8, "D3D8", &D3D8_CreateReplayDevice);
+25
View File
@@ -0,0 +1,25 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2017 Baldur Karlsson
*
* 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 "precompiled.h"
+31
View File
@@ -0,0 +1,31 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2017 Baldur Karlsson
*
* 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.
******************************************************************************/
#pragma once
#include "api/app/renderdoc_app.h"
#include "api/replay/renderdoc_replay.h"
#include "common/common.h"
#include "d3d8_common.h"
@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Development|Win32">
<Configuration>Development</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Development|x64">
<Configuration>Development</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{9C4487E8-EEB0-4A7F-BD81-23F81CD24E22}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>renderdoc_d3d8</RootNamespace>
<ProjectName>d3d8</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<ExecutablePath>$(ExecutablePath)</ExecutablePath>
<IncludePath>$(SolutionDir)\breakpad;$(IncludePath)</IncludePath>
<LibraryPath>$(LibraryPath)</LibraryPath>
<ExcludePath>$(ExcludePath)</ExcludePath>
<TargetName>driver_$(ProjectName)</TargetName>
</PropertyGroup>
<PropertyGroup>
<IntDir>$(SolutionDir)$(Platform)\$(Configuration)\obj\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='x64'">
<ClCompile>
<PreprocessorDefinitions>WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<PreprocessorDefinitions>RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup>
<ClCompile>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>$(SolutionDir)renderdoc\;$(SolutionDir)renderdoc\3rdparty\</AdditionalIncludeDirectories>
<PreprocessorDefinitions>RENDERDOC_EXPORTS;RENDERDOC_PLATFORM_WIN32;WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<DisableSpecificWarnings>4100</DisableSpecificWarnings>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile>
<ForcedIncludeFiles>precompiled.h</ForcedIncludeFiles>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Development'">
<ClCompile>
<Optimization>Disabled</Optimization>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="d3d8_common.cpp" />
<ClCompile Include="d3d8_debug.cpp" />
<ClCompile Include="d3d8_device.cpp" />
<ClCompile Include="d3d8_hooks.cpp" />
<ClCompile Include="d3d8_replay.cpp" />
<ClCompile Include="precompiled.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\dx\official\d3d8.h" />
<ClInclude Include="..\dx\official\d3d8caps.h" />
<ClInclude Include="..\dx\official\d3d8types.h" />
<ClInclude Include="..\dx\official\d3dcommon.h" />
<ClInclude Include="..\dx\official\d3dcompiler.h" />
<ClInclude Include="d3d8_common.h" />
<ClInclude Include="d3d8_debug.h" />
<ClInclude Include="d3d8_device.h" />
<ClInclude Include="precompiled.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Hooks">
<UniqueIdentifier>{5CAAA42F-25FF-43DD-B545-E7ADB5135418}</UniqueIdentifier>
</Filter>
<Filter Include="official">
<UniqueIdentifier>{87CAD3D6-BA09-4D6E-84CF-29B8DC5A5B0A}</UniqueIdentifier>
</Filter>
<Filter Include="Debug">
<UniqueIdentifier>{6056F6EB-A9BC-4B50-B205-461B7580977B}</UniqueIdentifier>
</Filter>
<Filter Include="Common">
<UniqueIdentifier>{B9341B0E-2A54-415C-AF54-29D67D2325A2}</UniqueIdentifier>
</Filter>
<Filter Include="Replay">
<UniqueIdentifier>{7D6E973E-947D-4EAA-AFB4-DA33987ED452}</UniqueIdentifier>
</Filter>
<Filter Include="PCH">
<UniqueIdentifier>{74FA3D85-A524-442D-9682-BB832AB5E136}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="d3d8_hooks.cpp">
<Filter>Hooks</Filter>
</ClCompile>
<ClCompile Include="d3d8_debug.cpp">
<Filter>Debug</Filter>
</ClCompile>
<ClCompile Include="d3d8_device.cpp">
<Filter>Common</Filter>
</ClCompile>
<ClCompile Include="d3d8_common.cpp">
<Filter>Common</Filter>
</ClCompile>
<ClCompile Include="d3d8_replay.cpp">
<Filter>Replay</Filter>
</ClCompile>
<ClCompile Include="precompiled.cpp">
<Filter>PCH</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\dx\official\d3d8.h">
<Filter>official</Filter>
</ClInclude>
<ClInclude Include="..\dx\official\d3dcommon.h">
<Filter>official</Filter>
</ClInclude>
<ClInclude Include="..\dx\official\d3dcompiler.h">
<Filter>official</Filter>
</ClInclude>
<ClInclude Include="..\dx\official\d3d8caps.h">
<Filter>official</Filter>
</ClInclude>
<ClInclude Include="..\dx\official\d3d8types.h">
<Filter>official</Filter>
</ClInclude>
<ClInclude Include="d3d8_debug.h">
<Filter>Debug</Filter>
</ClInclude>
<ClInclude Include="d3d8_device.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="d3d8_common.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="precompiled.h">
<Filter>PCH</Filter>
</ClInclude>
</ItemGroup>
</Project>
File diff suppressed because it is too large Load Diff
+364
View File
@@ -0,0 +1,364 @@
/*==========================================================================;
*
* Copyright (C) Microsoft Corporation. All Rights Reserved.
*
* File: d3d8caps.h
* Content: Direct3D capabilities include file
*
***************************************************************************/
#ifndef _D3D8CAPS_H
#define _D3D8CAPS_H
#ifndef DIRECT3D_VERSION
#define DIRECT3D_VERSION 0x0800
#endif //DIRECT3D_VERSION
// include this file content only if compiling for DX8 interfaces
#if(DIRECT3D_VERSION >= 0x0800)
#if defined(_X86_) || defined(_IA64_)
#pragma pack(4)
#endif
typedef struct _D3DCAPS8
{
/* Device Info */
D3DDEVTYPE DeviceType;
UINT AdapterOrdinal;
/* Caps from DX7 Draw */
DWORD Caps;
DWORD Caps2;
DWORD Caps3;
DWORD PresentationIntervals;
/* Cursor Caps */
DWORD CursorCaps;
/* 3D Device Caps */
DWORD DevCaps;
DWORD PrimitiveMiscCaps;
DWORD RasterCaps;
DWORD ZCmpCaps;
DWORD SrcBlendCaps;
DWORD DestBlendCaps;
DWORD AlphaCmpCaps;
DWORD ShadeCaps;
DWORD TextureCaps;
DWORD TextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DTexture8's
DWORD CubeTextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DCubeTexture8's
DWORD VolumeTextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DVolumeTexture8's
DWORD TextureAddressCaps; // D3DPTADDRESSCAPS for IDirect3DTexture8's
DWORD VolumeTextureAddressCaps; // D3DPTADDRESSCAPS for IDirect3DVolumeTexture8's
DWORD LineCaps; // D3DLINECAPS
DWORD MaxTextureWidth, MaxTextureHeight;
DWORD MaxVolumeExtent;
DWORD MaxTextureRepeat;
DWORD MaxTextureAspectRatio;
DWORD MaxAnisotropy;
float MaxVertexW;
float GuardBandLeft;
float GuardBandTop;
float GuardBandRight;
float GuardBandBottom;
float ExtentsAdjust;
DWORD StencilCaps;
DWORD FVFCaps;
DWORD TextureOpCaps;
DWORD MaxTextureBlendStages;
DWORD MaxSimultaneousTextures;
DWORD VertexProcessingCaps;
DWORD MaxActiveLights;
DWORD MaxUserClipPlanes;
DWORD MaxVertexBlendMatrices;
DWORD MaxVertexBlendMatrixIndex;
float MaxPointSize;
DWORD MaxPrimitiveCount; // max number of primitives per DrawPrimitive call
DWORD MaxVertexIndex;
DWORD MaxStreams;
DWORD MaxStreamStride; // max stride for SetStreamSource
DWORD VertexShaderVersion;
DWORD MaxVertexShaderConst; // number of vertex shader constant registers
DWORD PixelShaderVersion;
float MaxPixelShaderValue; // max value of pixel shader arithmetic component
} D3DCAPS8;
//
// BIT DEFINES FOR D3DCAPS8 DWORD MEMBERS
//
//
// Caps
//
#define D3DCAPS_READ_SCANLINE 0x00020000L
//
// Caps2
//
#define D3DCAPS2_NO2DDURING3DSCENE 0x00000002L
#define D3DCAPS2_FULLSCREENGAMMA 0x00020000L
#define D3DCAPS2_CANRENDERWINDOWED 0x00080000L
#define D3DCAPS2_CANCALIBRATEGAMMA 0x00100000L
#define D3DCAPS2_RESERVED 0x02000000L
#define D3DCAPS2_CANMANAGERESOURCE 0x10000000L
#define D3DCAPS2_DYNAMICTEXTURES 0x20000000L
//
// Caps3
//
#define D3DCAPS3_RESERVED 0x8000001fL
// Indicates that the device can respect the ALPHABLENDENABLE render state
// when fullscreen while using the FLIP or DISCARD swap effect.
// COPY and COPYVSYNC swap effects work whether or not this flag is set.
#define D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD 0x00000020L
//
// PresentationIntervals
//
#define D3DPRESENT_INTERVAL_DEFAULT 0x00000000L
#define D3DPRESENT_INTERVAL_ONE 0x00000001L
#define D3DPRESENT_INTERVAL_TWO 0x00000002L
#define D3DPRESENT_INTERVAL_THREE 0x00000004L
#define D3DPRESENT_INTERVAL_FOUR 0x00000008L
#define D3DPRESENT_INTERVAL_IMMEDIATE 0x80000000L
//
// CursorCaps
//
// Driver supports HW color cursor in at least hi-res modes(height >=400)
#define D3DCURSORCAPS_COLOR 0x00000001L
// Driver supports HW cursor also in low-res modes(height < 400)
#define D3DCURSORCAPS_LOWRES 0x00000002L
//
// DevCaps
//
#define D3DDEVCAPS_EXECUTESYSTEMMEMORY 0x00000010L /* Device can use execute buffers from system memory */
#define D3DDEVCAPS_EXECUTEVIDEOMEMORY 0x00000020L /* Device can use execute buffers from video memory */
#define D3DDEVCAPS_TLVERTEXSYSTEMMEMORY 0x00000040L /* Device can use TL buffers from system memory */
#define D3DDEVCAPS_TLVERTEXVIDEOMEMORY 0x00000080L /* Device can use TL buffers from video memory */
#define D3DDEVCAPS_TEXTURESYSTEMMEMORY 0x00000100L /* Device can texture from system memory */
#define D3DDEVCAPS_TEXTUREVIDEOMEMORY 0x00000200L /* Device can texture from device memory */
#define D3DDEVCAPS_DRAWPRIMTLVERTEX 0x00000400L /* Device can draw TLVERTEX primitives */
#define D3DDEVCAPS_CANRENDERAFTERFLIP 0x00000800L /* Device can render without waiting for flip to complete */
#define D3DDEVCAPS_TEXTURENONLOCALVIDMEM 0x00001000L /* Device can texture from nonlocal video memory */
#define D3DDEVCAPS_DRAWPRIMITIVES2 0x00002000L /* Device can support DrawPrimitives2 */
#define D3DDEVCAPS_SEPARATETEXTUREMEMORIES 0x00004000L /* Device is texturing from separate memory pools */
#define D3DDEVCAPS_DRAWPRIMITIVES2EX 0x00008000L /* Device can support Extended DrawPrimitives2 i.e. DX7 compliant driver*/
#define D3DDEVCAPS_HWTRANSFORMANDLIGHT 0x00010000L /* Device can support transformation and lighting in hardware and DRAWPRIMITIVES2EX must be also */
#define D3DDEVCAPS_CANBLTSYSTONONLOCAL 0x00020000L /* Device supports a Tex Blt from system memory to non-local vidmem */
#define D3DDEVCAPS_HWRASTERIZATION 0x00080000L /* Device has HW acceleration for rasterization */
#define D3DDEVCAPS_PUREDEVICE 0x00100000L /* Device supports D3DCREATE_PUREDEVICE */
#define D3DDEVCAPS_QUINTICRTPATCHES 0x00200000L /* Device supports quintic Beziers and BSplines */
#define D3DDEVCAPS_RTPATCHES 0x00400000L /* Device supports Rect and Tri patches */
#define D3DDEVCAPS_RTPATCHHANDLEZERO 0x00800000L /* Indicates that RT Patches may be drawn efficiently using handle 0 */
#define D3DDEVCAPS_NPATCHES 0x01000000L /* Device supports N-Patches */
//
// PrimitiveMiscCaps
//
#define D3DPMISCCAPS_MASKZ 0x00000002L
#define D3DPMISCCAPS_LINEPATTERNREP 0x00000004L
#define D3DPMISCCAPS_CULLNONE 0x00000010L
#define D3DPMISCCAPS_CULLCW 0x00000020L
#define D3DPMISCCAPS_CULLCCW 0x00000040L
#define D3DPMISCCAPS_COLORWRITEENABLE 0x00000080L
#define D3DPMISCCAPS_CLIPPLANESCALEDPOINTS 0x00000100L /* Device correctly clips scaled points to clip planes */
#define D3DPMISCCAPS_CLIPTLVERTS 0x00000200L /* device will clip post-transformed vertex primitives */
#define D3DPMISCCAPS_TSSARGTEMP 0x00000400L /* device supports D3DTA_TEMP for temporary register */
#define D3DPMISCCAPS_BLENDOP 0x00000800L /* device supports D3DRS_BLENDOP */
#define D3DPMISCCAPS_NULLREFERENCE 0x00001000L /* Reference Device that doesnt render */
//
// LineCaps
//
#define D3DLINECAPS_TEXTURE 0x00000001L
#define D3DLINECAPS_ZTEST 0x00000002L
#define D3DLINECAPS_BLEND 0x00000004L
#define D3DLINECAPS_ALPHACMP 0x00000008L
#define D3DLINECAPS_FOG 0x00000010L
//
// RasterCaps
//
#define D3DPRASTERCAPS_DITHER 0x00000001L
#define D3DPRASTERCAPS_PAT 0x00000008L
#define D3DPRASTERCAPS_ZTEST 0x00000010L
#define D3DPRASTERCAPS_FOGVERTEX 0x00000080L
#define D3DPRASTERCAPS_FOGTABLE 0x00000100L
#define D3DPRASTERCAPS_ANTIALIASEDGES 0x00001000L
#define D3DPRASTERCAPS_MIPMAPLODBIAS 0x00002000L
#define D3DPRASTERCAPS_ZBIAS 0x00004000L
#define D3DPRASTERCAPS_ZBUFFERLESSHSR 0x00008000L
#define D3DPRASTERCAPS_FOGRANGE 0x00010000L
#define D3DPRASTERCAPS_ANISOTROPY 0x00020000L
#define D3DPRASTERCAPS_WBUFFER 0x00040000L
#define D3DPRASTERCAPS_WFOG 0x00100000L
#define D3DPRASTERCAPS_ZFOG 0x00200000L
#define D3DPRASTERCAPS_COLORPERSPECTIVE 0x00400000L /* Device iterates colors perspective correct */
#define D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE 0x00800000L
//
// ZCmpCaps, AlphaCmpCaps
//
#define D3DPCMPCAPS_NEVER 0x00000001L
#define D3DPCMPCAPS_LESS 0x00000002L
#define D3DPCMPCAPS_EQUAL 0x00000004L
#define D3DPCMPCAPS_LESSEQUAL 0x00000008L
#define D3DPCMPCAPS_GREATER 0x00000010L
#define D3DPCMPCAPS_NOTEQUAL 0x00000020L
#define D3DPCMPCAPS_GREATEREQUAL 0x00000040L
#define D3DPCMPCAPS_ALWAYS 0x00000080L
//
// SourceBlendCaps, DestBlendCaps
//
#define D3DPBLENDCAPS_ZERO 0x00000001L
#define D3DPBLENDCAPS_ONE 0x00000002L
#define D3DPBLENDCAPS_SRCCOLOR 0x00000004L
#define D3DPBLENDCAPS_INVSRCCOLOR 0x00000008L
#define D3DPBLENDCAPS_SRCALPHA 0x00000010L
#define D3DPBLENDCAPS_INVSRCALPHA 0x00000020L
#define D3DPBLENDCAPS_DESTALPHA 0x00000040L
#define D3DPBLENDCAPS_INVDESTALPHA 0x00000080L
#define D3DPBLENDCAPS_DESTCOLOR 0x00000100L
#define D3DPBLENDCAPS_INVDESTCOLOR 0x00000200L
#define D3DPBLENDCAPS_SRCALPHASAT 0x00000400L
#define D3DPBLENDCAPS_BOTHSRCALPHA 0x00000800L
#define D3DPBLENDCAPS_BOTHINVSRCALPHA 0x00001000L
//
// ShadeCaps
//
#define D3DPSHADECAPS_COLORGOURAUDRGB 0x00000008L
#define D3DPSHADECAPS_SPECULARGOURAUDRGB 0x00000200L
#define D3DPSHADECAPS_ALPHAGOURAUDBLEND 0x00004000L
#define D3DPSHADECAPS_FOGGOURAUD 0x00080000L
//
// TextureCaps
//
#define D3DPTEXTURECAPS_PERSPECTIVE 0x00000001L /* Perspective-correct texturing is supported */
#define D3DPTEXTURECAPS_POW2 0x00000002L /* Power-of-2 texture dimensions are required - applies to non-Cube/Volume textures only. */
#define D3DPTEXTURECAPS_ALPHA 0x00000004L /* Alpha in texture pixels is supported */
#define D3DPTEXTURECAPS_SQUAREONLY 0x00000020L /* Only square textures are supported */
#define D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE 0x00000040L /* Texture indices are not scaled by the texture size prior to interpolation */
#define D3DPTEXTURECAPS_ALPHAPALETTE 0x00000080L /* Device can draw alpha from texture palettes */
// Device can use non-POW2 textures if:
// 1) D3DTEXTURE_ADDRESS is set to CLAMP for this texture's stage
// 2) D3DRS_WRAP(N) is zero for this texture's coordinates
// 3) mip mapping is not enabled (use magnification filter only)
#define D3DPTEXTURECAPS_NONPOW2CONDITIONAL 0x00000100L
#define D3DPTEXTURECAPS_PROJECTED 0x00000400L /* Device can do D3DTTFF_PROJECTED */
#define D3DPTEXTURECAPS_CUBEMAP 0x00000800L /* Device can do cubemap textures */
#define D3DPTEXTURECAPS_VOLUMEMAP 0x00002000L /* Device can do volume textures */
#define D3DPTEXTURECAPS_MIPMAP 0x00004000L /* Device can do mipmapped textures */
#define D3DPTEXTURECAPS_MIPVOLUMEMAP 0x00008000L /* Device can do mipmapped volume textures */
#define D3DPTEXTURECAPS_MIPCUBEMAP 0x00010000L /* Device can do mipmapped cube maps */
#define D3DPTEXTURECAPS_CUBEMAP_POW2 0x00020000L /* Device requires that cubemaps be power-of-2 dimension */
#define D3DPTEXTURECAPS_VOLUMEMAP_POW2 0x00040000L /* Device requires that volume maps be power-of-2 dimension */
//
// TextureFilterCaps
//
#define D3DPTFILTERCAPS_MINFPOINT 0x00000100L /* Min Filter */
#define D3DPTFILTERCAPS_MINFLINEAR 0x00000200L
#define D3DPTFILTERCAPS_MINFANISOTROPIC 0x00000400L
#define D3DPTFILTERCAPS_MIPFPOINT 0x00010000L /* Mip Filter */
#define D3DPTFILTERCAPS_MIPFLINEAR 0x00020000L
#define D3DPTFILTERCAPS_MAGFPOINT 0x01000000L /* Mag Filter */
#define D3DPTFILTERCAPS_MAGFLINEAR 0x02000000L
#define D3DPTFILTERCAPS_MAGFANISOTROPIC 0x04000000L
#define D3DPTFILTERCAPS_MAGFAFLATCUBIC 0x08000000L
#define D3DPTFILTERCAPS_MAGFGAUSSIANCUBIC 0x10000000L
//
// TextureAddressCaps
//
#define D3DPTADDRESSCAPS_WRAP 0x00000001L
#define D3DPTADDRESSCAPS_MIRROR 0x00000002L
#define D3DPTADDRESSCAPS_CLAMP 0x00000004L
#define D3DPTADDRESSCAPS_BORDER 0x00000008L
#define D3DPTADDRESSCAPS_INDEPENDENTUV 0x00000010L
#define D3DPTADDRESSCAPS_MIRRORONCE 0x00000020L
//
// StencilCaps
//
#define D3DSTENCILCAPS_KEEP 0x00000001L
#define D3DSTENCILCAPS_ZERO 0x00000002L
#define D3DSTENCILCAPS_REPLACE 0x00000004L
#define D3DSTENCILCAPS_INCRSAT 0x00000008L
#define D3DSTENCILCAPS_DECRSAT 0x00000010L
#define D3DSTENCILCAPS_INVERT 0x00000020L
#define D3DSTENCILCAPS_INCR 0x00000040L
#define D3DSTENCILCAPS_DECR 0x00000080L
//
// TextureOpCaps
//
#define D3DTEXOPCAPS_DISABLE 0x00000001L
#define D3DTEXOPCAPS_SELECTARG1 0x00000002L
#define D3DTEXOPCAPS_SELECTARG2 0x00000004L
#define D3DTEXOPCAPS_MODULATE 0x00000008L
#define D3DTEXOPCAPS_MODULATE2X 0x00000010L
#define D3DTEXOPCAPS_MODULATE4X 0x00000020L
#define D3DTEXOPCAPS_ADD 0x00000040L
#define D3DTEXOPCAPS_ADDSIGNED 0x00000080L
#define D3DTEXOPCAPS_ADDSIGNED2X 0x00000100L
#define D3DTEXOPCAPS_SUBTRACT 0x00000200L
#define D3DTEXOPCAPS_ADDSMOOTH 0x00000400L
#define D3DTEXOPCAPS_BLENDDIFFUSEALPHA 0x00000800L
#define D3DTEXOPCAPS_BLENDTEXTUREALPHA 0x00001000L
#define D3DTEXOPCAPS_BLENDFACTORALPHA 0x00002000L
#define D3DTEXOPCAPS_BLENDTEXTUREALPHAPM 0x00004000L
#define D3DTEXOPCAPS_BLENDCURRENTALPHA 0x00008000L
#define D3DTEXOPCAPS_PREMODULATE 0x00010000L
#define D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR 0x00020000L
#define D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA 0x00040000L
#define D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR 0x00080000L
#define D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA 0x00100000L
#define D3DTEXOPCAPS_BUMPENVMAP 0x00200000L
#define D3DTEXOPCAPS_BUMPENVMAPLUMINANCE 0x00400000L
#define D3DTEXOPCAPS_DOTPRODUCT3 0x00800000L
#define D3DTEXOPCAPS_MULTIPLYADD 0x01000000L
#define D3DTEXOPCAPS_LERP 0x02000000L
//
// FVFCaps
//
#define D3DFVFCAPS_TEXCOORDCOUNTMASK 0x0000ffffL /* mask for texture coordinate count field */
#define D3DFVFCAPS_DONOTSTRIPELEMENTS 0x00080000L /* Device prefers that vertex elements not be stripped */
#define D3DFVFCAPS_PSIZE 0x00100000L /* Device can receive point size */
//
// VertexProcessingCaps
//
#define D3DVTXPCAPS_TEXGEN 0x00000001L /* device can do texgen */
#define D3DVTXPCAPS_MATERIALSOURCE7 0x00000002L /* device can do DX7-level colormaterialsource ops */
#define D3DVTXPCAPS_DIRECTIONALLIGHTS 0x00000008L /* device can do directional lights */
#define D3DVTXPCAPS_POSITIONALLIGHTS 0x00000010L /* device can do positional lights (includes point and spot) */
#define D3DVTXPCAPS_LOCALVIEWER 0x00000020L /* device can do local viewer */
#define D3DVTXPCAPS_TWEENING 0x00000040L /* device can do vertex tweening */
#define D3DVTXPCAPS_NO_VSDT_UBYTE4 0x00000080L /* device does not support D3DVSDT_UBYTE4 */
#pragma pack()
#endif /* (DIRECT3D_VERSION >= 0x0800) */
#endif /* _D3D8CAPS_H_ */
File diff suppressed because it is too large Load Diff
+8
View File
@@ -355,6 +355,14 @@
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>true</UseLibraryDependencyInputs>
</ProjectReference>
<ProjectReference Include="driver\d3d8\renderdoc_d3d8.vcxproj">
<Project>{9c4487e8-eeb0-4a7f-bd81-23f81cd24e22}</Project>
<Private>false</Private>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>true</UseLibraryDependencyInputs>
</ProjectReference>
<ProjectReference Include="driver\d3d9\renderdoc_d3d9.vcxproj">
<Project>{44044776-9469-4079-b587-abfff6574aa4}</Project>
<Private>false</Private>