Maintenance: [forced, user-approved] R7a: remove the invented D3DX9Runtime (LoadLibraryA D3DX9_43.dll + GetProcAddress table) and its
Batch #10241 by ragnarok-clanker: forced by an admin (1 lower score(s), 23 changed function(s)); checked with 303 compiled unit(s), including every includer of Source/Render/DX9/D3DX9Runtime.h, Source/Render/DX9/DeviceOwnerDX9.h, Source/Render/DX9/RenderSystemDX9.h, Source/Render/DX9/RendererDX9.h, Source/Render/DX9/RendererFogDX9.h, Source/Render/DX9/TextureDX9.h.
This commit is contained in:
parent
6cb0bdedfe
commit
b2e04b8f13
13 changed files with 26 additions and 66 deletions
|
|
@ -2,51 +2,17 @@
|
|||
#define RAGNAROK_SOURCE_RENDER_DX9_D3DX9RUNTIME_H
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <system_error>
|
||||
|
||||
class D3DX9Runtime {
|
||||
public:
|
||||
D3DX9Runtime();
|
||||
~D3DX9Runtime();
|
||||
D3DX9Runtime(const D3DX9Runtime&) = delete;
|
||||
D3DX9Runtime& operator=(const D3DX9Runtime&) = delete;
|
||||
|
||||
HRESULT(WINAPI* filterTexture)(IDirect3DBaseTexture9*, const PALETTEENTRY*, UINT, DWORD);
|
||||
HRESULT(WINAPI* loadSurfaceFromMemory)(
|
||||
IDirect3DSurface9*, const PALETTEENTRY*, const RECT*, const void*, D3DFORMAT, UINT, const PALETTEENTRY*, const RECT*, DWORD, D3DCOLOR
|
||||
);
|
||||
HRESULT(WINAPI* loadSurfaceFromSurface)(
|
||||
IDirect3DSurface9*, const PALETTEENTRY*, const RECT*, IDirect3DSurface9*, const PALETTEENTRY*, const RECT*, DWORD, D3DCOLOR
|
||||
);
|
||||
D3DMATRIX*(WINAPI* perspectiveFovLH)(D3DMATRIX*, float, float, float, float);
|
||||
HRESULT(WINAPI* saveSurfaceToFileA)(const char*, int, IDirect3DSurface9*, const PALETTEENTRY*, const RECT*);
|
||||
|
||||
private:
|
||||
HMODULE m_module;
|
||||
};
|
||||
|
||||
// INLINED
|
||||
inline D3DX9Runtime::D3DX9Runtime() : m_module(LoadLibraryA("D3DX9_43.dll")) {
|
||||
|
||||
if (!this->m_module) {
|
||||
throw std::system_error(GetLastError(), std::system_category(), "D3DX9_43.dll");
|
||||
}
|
||||
|
||||
this->filterTexture = reinterpret_cast<decltype(this->filterTexture)>(GetProcAddress(this->m_module, "D3DXFilterTexture"));
|
||||
this->loadSurfaceFromMemory = reinterpret_cast<decltype(this->loadSurfaceFromMemory)>(GetProcAddress(this->m_module, "D3DXLoadSurfaceFromMemory"));
|
||||
this->loadSurfaceFromSurface = reinterpret_cast<decltype(this->loadSurfaceFromSurface)>(GetProcAddress(this->m_module, "D3DXLoadSurfaceFromSurface"));
|
||||
this->perspectiveFovLH = reinterpret_cast<decltype(this->perspectiveFovLH)>(GetProcAddress(this->m_module, "D3DXMatrixPerspectiveFovLH"));
|
||||
this->saveSurfaceToFileA = reinterpret_cast<decltype(this->saveSurfaceToFileA)>(GetProcAddress(this->m_module, "D3DXSaveSurfaceToFileA"));
|
||||
|
||||
if (!this->filterTexture || !this->loadSurfaceFromMemory || !this->loadSurfaceFromSurface || !this->perspectiveFovLH || !this->saveSurfaceToFileA) {
|
||||
FreeLibrary(this->m_module);
|
||||
throw std::system_error(ERROR_PROC_NOT_FOUND, std::system_category(), "D3DX9_43 exports");
|
||||
}
|
||||
}
|
||||
|
||||
// INLINED
|
||||
inline D3DX9Runtime::~D3DX9Runtime() {
|
||||
FreeLibrary(this->m_module);
|
||||
}
|
||||
HRESULT WINAPI D3DXFilterTexture(IDirect3DBaseTexture9* texture, const PALETTEENTRY* palette, UINT level, DWORD filter);
|
||||
HRESULT WINAPI D3DXLoadSurfaceFromMemory(
|
||||
IDirect3DSurface9* destination, const PALETTEENTRY* destinationPalette, const RECT* destinationRect, const void* source, D3DFORMAT format,
|
||||
UINT pitch, const PALETTEENTRY* sourcePalette, const RECT* sourceRect, DWORD filter, D3DCOLOR colorKey
|
||||
);
|
||||
HRESULT WINAPI D3DXLoadSurfaceFromSurface(
|
||||
IDirect3DSurface9* destination, const PALETTEENTRY* destinationPalette, const RECT* destinationRect, IDirect3DSurface9* source,
|
||||
const PALETTEENTRY* sourcePalette, const RECT* sourceRect, DWORD filter, D3DCOLOR colorKey
|
||||
);
|
||||
D3DMATRIX* WINAPI D3DXMatrixPerspectiveFovLH(D3DMATRIX* output, float fovy, float aspect, float nearPlane, float farPlane);
|
||||
HRESULT WINAPI D3DXSaveSurfaceToFileA(const char* filename, int format, IDirect3DSurface9* surface, const PALETTEENTRY* palette, const RECT* rectangle);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -281,8 +281,8 @@ SurfaceDX9Context DeviceOwnerDX9::SurfaceContext() const {
|
|||
|
||||
// INLINED
|
||||
TextureDX9Context DeviceOwnerDX9::TextureContext(
|
||||
D3DX9Runtime& d3dx, RenderPrimitivePool& primitives, RenderQueues& queues, bool depthAlpha, float depthStart, float depthEnd
|
||||
RenderPrimitivePool& primitives, RenderQueues& queues, bool depthAlpha, float depthStart, float depthEnd
|
||||
) const {
|
||||
return {this->direct3D, this->device, this->adapter, this->presentation.BackBufferFormat, this->caps, this->dynamicTextures, &d3dx, &primitives, &queues,
|
||||
return {this->direct3D, this->device, this->adapter, this->presentation.BackBufferFormat, this->caps, this->dynamicTextures, nullptr, &primitives, &queues,
|
||||
depthAlpha, depthStart, depthEnd};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public:
|
|||
ScopedDeviceStateDX9 SaveState();
|
||||
SurfaceDX9Context SurfaceContext() const;
|
||||
TextureDX9Context
|
||||
TextureContext(D3DX9Runtime& d3dx, class RenderPrimitivePool& primitives, RenderQueues& queues, bool depthAlpha, float depthStart, float depthEnd) const;
|
||||
TextureContext(class RenderPrimitivePool& primitives, RenderQueues& queues, bool depthAlpha, float depthStart, float depthEnd) const;
|
||||
|
||||
/* 0000 */ HWND window;
|
||||
/* 0004 */ IDirect3D9Ex* direct3D;
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ void RendererDX9Operations::DrawQueues(
|
|||
RenderQueues& queues, const ServiceOptions& options, unsigned char multitexture, unsigned char twoPass, RendererFogDX9& fog, const float& aspect,
|
||||
const FogConfiguration& configuration
|
||||
) {
|
||||
fog.Apply(this->context, this->state, *this->context.d3dx, aspect, configuration);
|
||||
fog.Apply(this->context, this->state, aspect, configuration);
|
||||
this->state.SetRenderState(D3DRS_ALPHATESTENABLE, 1);
|
||||
this->state.SetRenderState(D3DRS_ALPHAREF, 207);
|
||||
this->state.SetRenderState(D3DRS_ALPHABLENDENABLE, 0);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
// FUNCTION: fn_02353
|
||||
CRenderSystemDX9::CRenderSystemDX9(RenderSystemDX9Context& context)
|
||||
: m_device(new DeviceOwnerDX9), m_defaultTexture(nullptr), m_context(&context),
|
||||
m_rendererContext{*this, context.d3dx, context.options, context.multitexture,
|
||||
m_rendererContext{*this, context.options, context.multitexture,
|
||||
context.fog, context.worldFlag, context.overlayColor, context.diagnostic},
|
||||
m_textureContext{}, m_surfaceContext{} {
|
||||
this->RefreshContexts();
|
||||
|
|
@ -33,7 +33,6 @@ void CRenderSystemDX9::RefreshContexts() {
|
|||
context.displayFormat = this->m_device->presentation.BackBufferFormat;
|
||||
context.caps = this->m_device->caps;
|
||||
context.dynamicTextures = this->m_device->dynamicTextures;
|
||||
context.d3dx = &this->m_context->d3dx;
|
||||
context.depthStart = this->m_context->fog.start;
|
||||
context.depthEnd = this->m_context->fog.end;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ struct RenderSystemDX9Context {
|
|||
const DeviceOptionsDX9& deviceOptions;
|
||||
const AdapterConfiguration& adapter;
|
||||
const bool& serviceUsesDX7;
|
||||
D3DX9Runtime& d3dx;
|
||||
const ServiceOptions& options;
|
||||
const unsigned char& multitexture;
|
||||
FogConfiguration& fog;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
// FUNCTION: fn_02209
|
||||
CRendererDX9::CRendererDX9(DeviceOwnerDX9& owner, RendererDX9Context& context)
|
||||
: CRenderer(context.system), device(&owner), nativeDevice(owner.device), clearColor(0), lastTick(0), frames(0), fps(0.0f), m_context(&context),
|
||||
m_textureContext(owner.TextureContext(context.d3dx, this->primitives, this->queues, false, context.fog.start, context.fog.end)) {
|
||||
m_textureContext(owner.TextureContext(this->primitives, this->queues, false, context.fog.start, context.fog.end)) {
|
||||
}
|
||||
|
||||
// OFFSET: 0x00564FE0
|
||||
|
|
|
|||
|
|
@ -7,12 +7,10 @@
|
|||
#include "Render/DX9/TextureDX9.h"
|
||||
|
||||
class DeviceOwnerDX9;
|
||||
class D3DX9Runtime;
|
||||
struct ServiceOptions;
|
||||
|
||||
struct RendererDX9Context {
|
||||
CRenderSystemBase& system;
|
||||
D3DX9Runtime& d3dx;
|
||||
const ServiceOptions& options;
|
||||
const unsigned char& multitexture;
|
||||
FogConfiguration& fog;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ void RendererFogDX9::Set(int value, const D3DCAPS9& caps, FogConfiguration& conf
|
|||
// OFFSET: 0x005654D0
|
||||
// FUNCTION: fn_02217
|
||||
void RendererFogDX9::Apply(
|
||||
const TextureDX9Context& context, DeviceStateDX9& state, D3DX9Runtime& d3dx, const float& aspect, const FogConfiguration& configuration
|
||||
const TextureDX9Context& context, DeviceStateDX9& state, const float& aspect, const FogConfiguration& configuration
|
||||
) {
|
||||
if (this->dirty == 1) {
|
||||
const float inverseAspect = 1.0f / aspect;
|
||||
|
|
@ -29,7 +29,7 @@ void RendererFogDX9::Apply(
|
|||
const float start = configuration.start * 1490.0f + 10.0f;
|
||||
const float end = configuration.end * 1490.0f + 10.0f;
|
||||
D3DMATRIX projection;
|
||||
d3dx.perspectiveFovLH(&projection, 0.2617994f, inverseAspect, 10.0f, 1500.0f);
|
||||
D3DXMatrixPerspectiveFovLH(&projection, 0.2617994f, inverseAspect, 10.0f, 1500.0f);
|
||||
context.device->SetTransform(D3DTS_WORLD, &identity);
|
||||
context.device->SetTransform(D3DTS_PROJECTION, &projection);
|
||||
context.device->SetTransform(D3DTS_VIEW, &identity);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
#include <cstddef>
|
||||
#include <d3d9.h>
|
||||
|
||||
class D3DX9Runtime;
|
||||
struct TextureDX9Context;
|
||||
struct DeviceStateDX9;
|
||||
|
||||
|
|
@ -16,7 +15,7 @@ struct RendererFogDX9 {
|
|||
/* 0158 */ int supported;
|
||||
|
||||
void Set(int enabled, const D3DCAPS9& caps, FogConfiguration& configuration);
|
||||
void Apply(const TextureDX9Context& context, DeviceStateDX9& state, D3DX9Runtime& d3dx, const float& aspect, const FogConfiguration& configuration);
|
||||
void Apply(const TextureDX9Context& context, DeviceStateDX9& state, const float& aspect, const FogConfiguration& configuration);
|
||||
};
|
||||
|
||||
static_assert(sizeof(RendererFogDX9) == 12);
|
||||
|
|
|
|||
|
|
@ -46,5 +46,5 @@ bool RendererDX9Operations::SaveScreenshot(
|
|||
}
|
||||
}
|
||||
|
||||
return SUCCEEDED(this->context.d3dx->saveSurfaceToFileA(filename, format, owner.backBuffer, nullptr, rectangle));
|
||||
return SUCCEEDED(D3DXSaveSurfaceToFileA(filename, format, owner.backBuffer, nullptr, rectangle));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ SurfaceLock CTextureDX9::Lock() {
|
|||
// FUNCTION: fn_02482
|
||||
void CTextureDX9::Filter() {
|
||||
if (!this->m_dynamic && !this->m_renderTarget && this->m_texture && this->m_texture->GetLevelCount() > 1) {
|
||||
this->m_context->d3dx->filterTexture(this->m_texture, nullptr, UINT(-1), DWORD(-1));
|
||||
D3DXFilterTexture(this->m_texture, nullptr, UINT(-1), DWORD(-1));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -265,7 +265,7 @@ void CTextureDX9::Update(const RECT*) {
|
|||
void CTextureDX9::Fill(const RECT* rectangle, std::uint32_t color) {
|
||||
if (this->m_surface) {
|
||||
const RECT pixel{0, 0, 1, 1};
|
||||
if (SUCCEEDED(this->m_context->d3dx->loadSurfaceFromMemory(this->m_surface, nullptr, rectangle, &color, D3DFMT_A8R8G8B8, 4, nullptr, &pixel, 2, 0))) {
|
||||
if (SUCCEEDED(D3DXLoadSurfaceFromMemory(this->m_surface, nullptr, rectangle, &color, D3DFMT_A8R8G8B8, 4, nullptr, &pixel, 2, 0))) {
|
||||
this->Filter();
|
||||
}
|
||||
}
|
||||
|
|
@ -391,7 +391,7 @@ void CTextureDX9::Upload(int x, int y, int width, int height, const std::uint32_
|
|||
this->UploadSurface(surface, x, y, width, height, pixels, option != 0, sourceWidth);
|
||||
if (this->m_renderTarget && temporary) {
|
||||
if (temporary->GetLevelCount() > 1) {
|
||||
this->m_context->d3dx->filterTexture(temporary, nullptr, UINT(-1), DWORD(-1));
|
||||
D3DXFilterTexture(temporary, nullptr, UINT(-1), DWORD(-1));
|
||||
}
|
||||
|
||||
this->m_context->device->UpdateTexture(temporary, this->m_texture);
|
||||
|
|
@ -467,7 +467,7 @@ bool CTextureDX9::CopyTexture(CTexture* source, int sourceX, int sourceY, int so
|
|||
RECT src{sourceX, sourceY, sourceX + sourceWidth, sourceY + sourceHeight};
|
||||
RECT dst{x, y, x + width, y + height};
|
||||
if (FAILED(
|
||||
this->m_context->d3dx->loadSurfaceFromSurface(this->m_surface, nullptr, &dst, static_cast<CTextureDX9*>(source)->m_surface, nullptr, &src, 3, 0)
|
||||
D3DXLoadSurfaceFromSurface(this->m_surface, nullptr, &dst, static_cast<CTextureDX9*>(source)->m_surface, nullptr, &src, 3, 0)
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include <d3d9.h>
|
||||
|
||||
class D3DX9Runtime;
|
||||
struct RenderQueues;
|
||||
class RenderPrimitivePool;
|
||||
|
||||
|
|
@ -16,7 +15,7 @@ struct TextureDX9Context {
|
|||
D3DFORMAT displayFormat;
|
||||
D3DCAPS9 caps;
|
||||
bool dynamicTextures;
|
||||
D3DX9Runtime* d3dx;
|
||||
void* unknown_d3dx;
|
||||
RenderPrimitivePool* primitives;
|
||||
RenderQueues* queues;
|
||||
bool depthAlpha;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue