mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Hook Direct3D execute buffer interface
This commit is contained in:
parent
652bf67706
commit
d06fe4e6ba
@ -195,6 +195,7 @@
|
||||
<ClInclude Include="Direct3d\DepthBuffer.h" />
|
||||
<ClInclude Include="Direct3d\Direct3d.h" />
|
||||
<ClInclude Include="Direct3d\Direct3dDevice.h" />
|
||||
<ClInclude Include="Direct3d\Direct3dExecuteBuffer.h" />
|
||||
<ClInclude Include="Direct3d\Direct3dLight.h" />
|
||||
<ClInclude Include="Direct3d\Direct3dMaterial.h" />
|
||||
<ClInclude Include="Direct3d\Direct3dTexture.h" />
|
||||
@ -204,6 +205,7 @@
|
||||
<ClInclude Include="Direct3d\Log.h" />
|
||||
<ClInclude Include="Direct3d\Types.h" />
|
||||
<ClInclude Include="Direct3d\Visitors\Direct3dDeviceVtblVisitor.h" />
|
||||
<ClInclude Include="Direct3d\Visitors\Direct3dExecuteBufferVtblVisitor.h" />
|
||||
<ClInclude Include="Direct3d\Visitors\Direct3dLightVtblVisitor.h" />
|
||||
<ClInclude Include="Direct3d\Visitors\Direct3dMaterialVtblVisitor.h" />
|
||||
<ClInclude Include="Direct3d\Visitors\Direct3dTextureVtblVisitor.h" />
|
||||
@ -271,6 +273,7 @@
|
||||
<ClCompile Include="Direct3d\DepthBuffer.cpp" />
|
||||
<ClCompile Include="Direct3d\Direct3d.cpp" />
|
||||
<ClCompile Include="Direct3d\Direct3dDevice.cpp" />
|
||||
<ClCompile Include="Direct3d\Direct3dExecuteBuffer.cpp" />
|
||||
<ClCompile Include="Direct3d\Direct3dLight.cpp" />
|
||||
<ClCompile Include="Direct3d\Direct3dMaterial.cpp" />
|
||||
<ClCompile Include="Direct3d\Direct3dTexture.cpp" />
|
||||
|
@ -381,6 +381,12 @@
|
||||
<ClInclude Include="Direct3d\Direct3dLight.h">
|
||||
<Filter>Header Files\Direct3d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Direct3d\Visitors\Direct3dExecuteBufferVtblVisitor.h">
|
||||
<Filter>Header Files\Direct3d\Visitors</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Direct3d\Direct3dExecuteBuffer.h">
|
||||
<Filter>Header Files\Direct3d</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Gdi\Gdi.cpp">
|
||||
@ -587,6 +593,9 @@
|
||||
<ClCompile Include="Direct3d\Direct3dLight.cpp">
|
||||
<Filter>Source Files\Direct3d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Direct3d\Direct3dExecuteBuffer.cpp">
|
||||
<Filter>Source Files\Direct3d</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Dll\DDrawCompat.def">
|
||||
|
8
DDrawCompat/Direct3d/Direct3dExecuteBuffer.cpp
Normal file
8
DDrawCompat/Direct3d/Direct3dExecuteBuffer.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include <Direct3d/Direct3dExecuteBuffer.h>
|
||||
|
||||
namespace Direct3d
|
||||
{
|
||||
void Direct3dExecuteBuffer::setCompatVtable(IDirect3DExecuteBufferVtbl& /*vtable*/)
|
||||
{
|
||||
}
|
||||
}
|
16
DDrawCompat/Direct3d/Direct3dExecuteBuffer.h
Normal file
16
DDrawCompat/Direct3d/Direct3dExecuteBuffer.h
Normal file
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <Common/CompatVtable.h>
|
||||
#include <Direct3d/Log.h>
|
||||
#include <Direct3d/Visitors/Direct3dExecuteBufferVtblVisitor.h>
|
||||
|
||||
namespace Direct3d
|
||||
{
|
||||
class Direct3dExecuteBuffer : public CompatVtable<IDirect3DExecuteBufferVtbl>
|
||||
{
|
||||
public:
|
||||
static void setCompatVtable(IDirect3DExecuteBufferVtbl& vtable);
|
||||
};
|
||||
}
|
||||
|
||||
SET_COMPAT_VTABLE(IDirect3DExecuteBufferVtbl, Direct3d::Direct3dExecuteBuffer);
|
@ -4,6 +4,7 @@
|
||||
#include <Common/Log.h>
|
||||
#include <Direct3d/Direct3d.h>
|
||||
#include <Direct3d/Direct3dDevice.h>
|
||||
#include <Direct3d/Direct3dExecuteBuffer.h>
|
||||
#include <Direct3d/Direct3dLight.h>
|
||||
#include <Direct3d/Direct3dMaterial.h>
|
||||
#include <Direct3d/Direct3dTexture.h>
|
||||
@ -14,6 +15,7 @@
|
||||
namespace
|
||||
{
|
||||
void hookDirect3dDevice(CompatRef<IDirect3D3> d3d, CompatRef<IDirectDrawSurface4> renderTarget);
|
||||
void hookDirect3dExecuteBuffer(CompatRef<IDirect3DDevice> dev);
|
||||
void hookDirect3dLight(CompatRef<IDirect3D3> d3d);
|
||||
void hookDirect3dMaterial(CompatRef<IDirect3D3> d3d);
|
||||
void hookDirect3dTexture(CompatRef<IDirectDraw> dd);
|
||||
@ -106,6 +108,30 @@ namespace
|
||||
hookVtable<IDirect3DDevice>(d3dDevice);
|
||||
hookVtable<IDirect3DDevice2>(d3dDevice);
|
||||
hookVtable<IDirect3DDevice3>(d3dDevice);
|
||||
|
||||
CompatPtr<IDirect3DDevice> dev(d3dDevice);
|
||||
if (dev)
|
||||
{
|
||||
hookDirect3dExecuteBuffer(*dev);
|
||||
}
|
||||
}
|
||||
|
||||
void hookDirect3dExecuteBuffer(CompatRef<IDirect3DDevice> dev)
|
||||
{
|
||||
D3DEXECUTEBUFFERDESC desc = {};
|
||||
desc.dwSize = sizeof(desc);
|
||||
desc.dwFlags = D3DDEB_BUFSIZE;
|
||||
desc.dwBufferSize = 1;
|
||||
|
||||
CompatPtr<IDirect3DExecuteBuffer> buffer;
|
||||
HRESULT result = dev->CreateExecuteBuffer(&dev, &desc, &buffer.getRef(), nullptr);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Compat::Log() << "ERROR: Failed to create an execute buffer for hooking: " << Compat::hex(result);
|
||||
return;
|
||||
}
|
||||
|
||||
hookVtable<IDirect3DExecuteBuffer>(buffer);
|
||||
}
|
||||
|
||||
void hookDirect3dLight(CompatRef<IDirect3D3> d3d)
|
||||
|
@ -26,6 +26,26 @@ std::ostream& operator<<(std::ostream& os, const D3DDRAWPRIMITIVESTRIDEDDATA& da
|
||||
<< Compat::array(data.textureCoords, D3DDP_MAXTEXCOORD);
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const D3DEXECUTEBUFFERDESC& data)
|
||||
{
|
||||
return Compat::LogStruct(os)
|
||||
<< Compat::hex(data.dwFlags)
|
||||
<< Compat::hex(data.dwCaps)
|
||||
<< data.dwBufferSize
|
||||
<< data.lpData;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const D3DEXECUTEDATA& data)
|
||||
{
|
||||
return Compat::LogStruct(os)
|
||||
<< data.dwVertexOffset
|
||||
<< data.dwVertexCount
|
||||
<< data.dwInstructionOffset
|
||||
<< data.dwInstructionLength
|
||||
<< data.dwHVertexOffset
|
||||
<< data.dsStatus;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const D3DLIGHT& data)
|
||||
{
|
||||
D3DLIGHT2 light = {};
|
||||
@ -87,6 +107,23 @@ std::ostream& operator<<(std::ostream& os, const D3DMATERIAL7& data)
|
||||
return os << material;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const D3DRECT& data)
|
||||
{
|
||||
return Compat::LogStruct(os)
|
||||
<< data.x1
|
||||
<< data.y1
|
||||
<< data.x2
|
||||
<< data.y2;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const D3DSTATUS& data)
|
||||
{
|
||||
return Compat::LogStruct(os)
|
||||
<< Compat::hex(data.dwFlags)
|
||||
<< Compat::hex(data.dwStatus)
|
||||
<< data.drExtent;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const D3DVERTEXBUFFERDESC& data)
|
||||
{
|
||||
return Compat::LogStruct(os)
|
||||
|
@ -7,9 +7,13 @@
|
||||
std::ostream& operator<<(std::ostream& os, const D3DCOLORVALUE& data);
|
||||
std::ostream& operator<<(std::ostream& os, const D3DDP_PTRSTRIDE& data);
|
||||
std::ostream& operator<<(std::ostream& os, const D3DDRAWPRIMITIVESTRIDEDDATA& data);
|
||||
std::ostream& operator<<(std::ostream& os, const D3DEXECUTEBUFFERDESC& data);
|
||||
std::ostream& operator<<(std::ostream& os, const D3DEXECUTEDATA& data);
|
||||
std::ostream& operator<<(std::ostream& os, const D3DLIGHT& data);
|
||||
std::ostream& operator<<(std::ostream& os, const D3DLIGHT2& data);
|
||||
std::ostream& operator<<(std::ostream& os, const D3DLIGHT7& data);
|
||||
std::ostream& operator<<(std::ostream& os, const D3DMATERIAL& data);
|
||||
std::ostream& operator<<(std::ostream& os, const D3DMATERIAL7& data);
|
||||
std::ostream& operator<<(std::ostream& os, const D3DRECT& data);
|
||||
std::ostream& operator<<(std::ostream& os, const D3DSTATUS& data);
|
||||
std::ostream& operator<<(std::ostream& os, const D3DVERTEXBUFFERDESC& data);
|
||||
|
@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3d.h>
|
||||
|
||||
#include <Common/VtableVisitor.h>
|
||||
|
||||
template <>
|
||||
struct VtableForEach<IDirect3DExecuteBufferVtbl>
|
||||
{
|
||||
template <typename Vtable, typename Visitor>
|
||||
static void forEach(Visitor& visitor)
|
||||
{
|
||||
VtableForEach<IUnknownVtbl>::forEach<Vtable>(visitor);
|
||||
|
||||
DD_VISIT(Initialize);
|
||||
DD_VISIT(Lock);
|
||||
DD_VISIT(Unlock);
|
||||
DD_VISIT(SetExecuteData);
|
||||
DD_VISIT(GetExecuteData);
|
||||
DD_VISIT(Validate);
|
||||
DD_VISIT(Optimize);
|
||||
}
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user