2022-03-27 23:07:11 +00:00
|
|
|
#pragma once
|
2022-05-06 19:12:59 +00:00
|
|
|
#include <d3d11.h>
|
2022-03-27 23:07:11 +00:00
|
|
|
#include "CommonRenderDevice.h"
|
2022-05-08 16:52:08 +00:00
|
|
|
#include "PCDX11InternalResource.h"
|
2022-05-28 17:14:37 +00:00
|
|
|
#include "PCDX11StreamDeclCache.h"
|
2022-11-08 16:00:30 +00:00
|
|
|
#include "VertexDeclaration.h"
|
2022-05-28 12:08:10 +00:00
|
|
|
#include "shaders/PCDX11ShaderLib.h"
|
|
|
|
#include "shaders/PCDX11ShaderTable.h" // for PixelShaderTable and VertexShaderTable
|
2023-04-21 00:21:19 +00:00
|
|
|
#include "surfaces/PCDX11DepthBuffer.h" // for covariant return type
|
|
|
|
#include "surfaces/PCDX11RenderTarget.h" // for covariant return type
|
2022-03-27 23:07:11 +00:00
|
|
|
|
|
|
|
namespace cdc {
|
|
|
|
|
2022-05-06 20:16:33 +00:00
|
|
|
class IRenderDrawable;
|
2022-05-12 16:52:59 +00:00
|
|
|
class PCDX11BaseTexture;
|
2022-05-28 22:58:20 +00:00
|
|
|
class PCDX11LightManager;
|
2022-09-26 19:34:27 +00:00
|
|
|
class PCDX11Pool;
|
2022-05-29 00:15:11 +00:00
|
|
|
class PCDX11RenderContext;
|
2023-04-12 02:22:52 +00:00
|
|
|
class PCDX11RenderTexture;
|
2022-09-26 19:34:27 +00:00
|
|
|
class PCDX11StaticPool;
|
2022-10-21 16:45:57 +00:00
|
|
|
class PCDX11SimpleDynamicVertexBuffer;
|
2023-04-12 02:22:52 +00:00
|
|
|
class PCDX11SimpleStaticVertexBuffer;
|
2022-05-29 00:15:11 +00:00
|
|
|
class PCDX11Texture;
|
2022-05-28 22:58:20 +00:00
|
|
|
struct LightManagerSubB;
|
2022-05-06 20:16:33 +00:00
|
|
|
|
2022-03-27 23:07:11 +00:00
|
|
|
class PCDX11RenderDevice :
|
|
|
|
public PCDX11InternalResource,
|
|
|
|
public CommonRenderDevice
|
|
|
|
{
|
2022-05-08 18:09:56 +00:00
|
|
|
public:
|
2022-05-13 00:19:17 +00:00
|
|
|
struct RenderList {
|
2022-05-29 00:15:11 +00:00
|
|
|
RenderList(PCDX11RenderDevice *renderDevice, uint32_t *dimensions);
|
2022-05-13 00:19:17 +00:00
|
|
|
|
2022-05-29 00:15:11 +00:00
|
|
|
uint32_t dword0;
|
|
|
|
uint32_t dword4;
|
|
|
|
uint32_t widthMaybe8;
|
|
|
|
uint32_t heightMaybeC;
|
|
|
|
PCDX11RenderTarget *renderTarget; // 10
|
2024-09-03 23:58:09 +00:00
|
|
|
PCDX11DepthBuffer *depthBuffer; // 14
|
2022-05-13 00:19:17 +00:00
|
|
|
DrawableList drawableList; // 18
|
2022-05-28 22:58:20 +00:00
|
|
|
LightManagerSubB *lightManagerSubB; // 28
|
2022-05-13 00:19:17 +00:00
|
|
|
// uint8_t byte2C;
|
|
|
|
// uint8_t byte2D;
|
|
|
|
RenderList *next;
|
|
|
|
};
|
|
|
|
|
2022-05-29 00:15:11 +00:00
|
|
|
PCDX11RenderContext *renderContext_10CE8 = nullptr;
|
|
|
|
PCDX11RenderContext *renderContext_10CEC;
|
|
|
|
|
2022-05-13 00:19:17 +00:00
|
|
|
RenderList *renderList_current = nullptr; // 10CF8
|
2022-05-13 13:24:04 +00:00
|
|
|
RenderList *renderList_processing = nullptr; // 10CFC
|
2022-05-13 00:19:17 +00:00
|
|
|
RenderList *renderList_first = nullptr; // 10D00
|
2022-05-29 00:15:11 +00:00
|
|
|
RenderList *renderList_last = nullptr; // 10D04
|
2022-06-26 16:02:40 +00:00
|
|
|
RenderList *renderList_override = nullptr; // own addition
|
2022-05-13 00:19:17 +00:00
|
|
|
|
2024-07-31 19:18:20 +00:00
|
|
|
PCDX11Pool *m_pDynamicVertexPool = nullptr; // 10D08
|
|
|
|
PCDX11Pool *m_pDynamicIndexPool = nullptr; // 10D0C
|
|
|
|
PCDX11StaticPool *m_pStaticVertexPool = nullptr; // 10D10
|
|
|
|
PCDX11StaticPool *m_pStaticIndexPool = nullptr; // 10D14
|
2022-09-26 19:34:27 +00:00
|
|
|
|
2022-11-08 16:00:30 +00:00
|
|
|
VertexDecl *drawVertexDecls[7] = {}; // 10BBC
|
2022-10-21 16:53:34 +00:00
|
|
|
|
2023-04-12 02:22:52 +00:00
|
|
|
PCDX11StreamDecl *vertex2DStreamDecl; // 10BDC, assigned in createDefaultVertexAttribLayouts
|
|
|
|
PCDX11StreamDecl *position3DStreamDecl; // 10BE0, assigned in createDefaultVertexAttribLayouts
|
2022-10-21 16:45:57 +00:00
|
|
|
|
2022-10-21 16:35:07 +00:00
|
|
|
PCDX11ShaderLib *shlib_22; // 10BE4, ps
|
|
|
|
PCDX11ShaderLib *shlib_21; // 10BE8, vs
|
|
|
|
PCDX11ShaderLib *shlib_20; // 10BEC, vs
|
|
|
|
PCDX11ShaderLib *shlib_19; // 10BF0, vs
|
2023-04-12 02:22:52 +00:00
|
|
|
PCDX11ShaderLib *shlib_18; // 10BF4, vs (copy surface)
|
2022-10-21 16:35:07 +00:00
|
|
|
PCDX11ShaderLib *shlib_17; // 10BF8, ps
|
|
|
|
PCDX11ShaderLib *shlib_16; // 10BFC, ps
|
|
|
|
PCDX11ShaderLib *shlib_14; // 10C00, vs
|
|
|
|
PCDX11ShaderLib *shlib_15; // 10C04, vs
|
2023-04-21 00:54:04 +00:00
|
|
|
PCDX11ShaderLib *shlib_13; // 10C08, ps (mlaa step 1)
|
|
|
|
PCDX11ShaderLib *shlib_11; // 10C0C, ps (mlaa step 2)
|
|
|
|
PCDX11ShaderLib *shlib_10; // 10C10, ps (mlaa step 3)
|
|
|
|
PCDX11ShaderLib *shlib_12; // 10C14, ps (fxaa, all qualities)
|
2022-05-08 16:52:08 +00:00
|
|
|
PCDX11ShaderLib *shlib_9;
|
|
|
|
PCDX11ShaderLib *shlib_8;
|
|
|
|
PCDX11ShaderLib *shlib_7;
|
|
|
|
PCDX11ShaderLib *shlib_6;
|
|
|
|
PCDX11ShaderLib *shlib_5;
|
2022-10-21 16:35:07 +00:00
|
|
|
PCDX11ShaderLib *shlib_4; // 10C2C, cs (fast blur)
|
|
|
|
PCDX11ShaderLib *shlib_3; // 10C30, cs (fast blur)
|
|
|
|
PCDX11ShaderLib *shlib_2; // 10C34, cs (bilateral blur)
|
2022-05-08 16:52:08 +00:00
|
|
|
PCDX11ShaderLib *shlib_1;
|
|
|
|
PCDX11ShaderLib *shlib_0;
|
|
|
|
PCDX11VertexShaderTable shtab_vs_wvp_1_0; // 10D1C
|
|
|
|
PCDX11VertexShaderTable shtab_vs_ui; // 10D38
|
|
|
|
PCDX11VertexShaderTable shtab_vs_wvp; // 10D54
|
|
|
|
PCDX11PixelShaderTable shtab_ps_white_27; // 10D70
|
|
|
|
PCDX11PixelShaderTable shtab_ps_passthrough; // 10D90
|
|
|
|
PCDX11PixelShaderTable shtab_ps_white_25; // 10DB0
|
|
|
|
PCDX11PixelShaderTable shtab_ps_fogColor; // 10DD0
|
|
|
|
PCDX11PixelShaderTable shtab_ps_errorColor; // 10DF0
|
|
|
|
|
2022-05-28 17:14:37 +00:00
|
|
|
PCDX11StreamDeclCache streamDeclCache; // 1112D4
|
2022-05-12 16:52:59 +00:00
|
|
|
PCDX11Texture *missingTexture; // 1112F0
|
|
|
|
|
2023-04-12 02:22:52 +00:00
|
|
|
PCDX11SimpleStaticVertexBuffer *fullScreenQuadVB; // 11156C
|
2022-10-21 16:45:57 +00:00
|
|
|
PCDX11SimpleDynamicVertexBuffer *quadVB; // 111570
|
|
|
|
|
2022-06-06 17:22:35 +00:00
|
|
|
ID3D11DeviceContext *deviceContext; // 111580
|
|
|
|
|
2022-03-27 23:07:11 +00:00
|
|
|
public:
|
2022-05-29 00:15:11 +00:00
|
|
|
PCDX11RenderDevice(HWND hwnd, uint32_t width, uint32_t height);
|
2022-05-08 16:52:08 +00:00
|
|
|
void createDefaultResources();
|
|
|
|
void createDefaultVertexAttribLayouts();
|
2022-05-10 13:02:42 +00:00
|
|
|
void setupPassCallbacks();
|
|
|
|
void registerComparatorsAndDrawersModel();
|
2022-09-20 00:20:04 +00:00
|
|
|
void registerComparatorsAndDrawersTerrain();
|
|
|
|
void registerComparatorsAndDrawersNGAPrim();
|
2024-05-15 16:32:48 +00:00
|
|
|
~PCDX11RenderDevice();
|
2022-06-06 17:22:35 +00:00
|
|
|
void setupShadowBuffer();
|
2022-05-08 16:52:08 +00:00
|
|
|
|
|
|
|
// incomplete
|
2022-05-11 12:48:51 +00:00
|
|
|
void refCountDec() override;
|
|
|
|
void method_08() override;
|
2024-07-07 01:26:30 +00:00
|
|
|
void resetRenderLists(float timeDelta) override;
|
2022-05-13 00:19:17 +00:00
|
|
|
void drawRenderLists() override;
|
2022-05-29 00:15:11 +00:00
|
|
|
bool beginRenderList(float*) override;
|
2022-05-13 00:19:17 +00:00
|
|
|
bool endRenderList() override;
|
|
|
|
bool hasRenderList() override;
|
2022-12-06 19:27:34 +00:00
|
|
|
uint32_t getSubFrameWidth() override;
|
|
|
|
uint32_t getSubFrameHeight() override;
|
2022-05-11 12:48:51 +00:00
|
|
|
void method_30() override;
|
2022-05-13 00:19:17 +00:00
|
|
|
CommonScene *createSubScene(
|
2022-07-18 15:08:59 +00:00
|
|
|
RenderViewport *renderViewport,
|
2022-05-11 12:17:28 +00:00
|
|
|
CommonRenderTarget *renderTarget,
|
2023-04-12 02:33:52 +00:00
|
|
|
CommonDepthBuffer *depthBuffer,
|
|
|
|
CommonRenderTarget *sourceColor,
|
|
|
|
CommonDepthBuffer *sourceDepth) override;
|
2022-05-13 00:19:17 +00:00
|
|
|
void finishScene() override;
|
2023-04-21 00:21:19 +00:00
|
|
|
PCDX11RenderTarget *getSceneRenderTarget() override; // covariant
|
|
|
|
PCDX11DepthBuffer *getSceneDepthBuffer() override; // covariant
|
|
|
|
uint32_t getContextWidth() override;
|
|
|
|
uint32_t getContextHeight() override;
|
2022-05-11 12:48:51 +00:00
|
|
|
void method_A8() override;
|
2022-05-06 20:16:33 +00:00
|
|
|
void clearRenderTarget(
|
|
|
|
uint32_t flags,
|
|
|
|
uint32_t unknown1,
|
|
|
|
float unknown2,
|
|
|
|
float *clearColor,
|
|
|
|
float clearDepth,
|
2022-05-11 12:48:51 +00:00
|
|
|
uint32_t clearStencil) override;
|
|
|
|
void setRenderTarget() override;
|
2024-06-30 19:22:54 +00:00
|
|
|
void DrawPrimitive(Matrix*, TextureMap*, RenderVertex*, uint32_t, uint32_t, float) override;
|
|
|
|
void DrawIndexedPrimitive(PrimitiveContext*, uint32_t, uint32_t, float) override;
|
|
|
|
void DrawIndexedPrimitive(PrimitiveContext*, void*, VertexDecl*, uint32_t, uint16_t*, uint32_t, float) override;
|
2022-05-11 12:48:51 +00:00
|
|
|
void method_CC() override;
|
|
|
|
void method_D0() override;
|
|
|
|
void method_D4() override;
|
|
|
|
void method_D8() override;
|
|
|
|
void method_DC() override;
|
|
|
|
void method_EC() override;
|
2022-05-28 09:48:00 +00:00
|
|
|
IMaterial *createMaterial() override;
|
2022-05-11 12:48:51 +00:00
|
|
|
TextureMap *createTexture(uint32_t) override;
|
|
|
|
void createProceduralTexture() override;
|
|
|
|
IShaderLib *createShaderLib(uint32_t) override;
|
2022-09-20 00:20:04 +00:00
|
|
|
RenderMesh *createRenderModel(uint32_t) override;
|
2022-05-20 17:55:23 +00:00
|
|
|
RenderModelInstance *createRenderModelInstance(RenderMesh*) override;
|
2022-09-20 00:20:04 +00:00
|
|
|
IRenderTerrain *createRenderTerrain(uint32_t) override;
|
|
|
|
IRenderTerrainInstance *createRenderTerrainInstance(IRenderTerrain*) override;
|
2022-05-11 12:48:51 +00:00
|
|
|
void createRenderImage() override;
|
|
|
|
void createWaterSurface() override;
|
|
|
|
void createLightResource() override;
|
|
|
|
void createRenderLight() override;
|
2022-08-09 18:15:18 +00:00
|
|
|
IMatrixState *createMatrixState() override;
|
2022-05-11 12:48:51 +00:00
|
|
|
void createVertexBuffer() override;
|
|
|
|
void createIndexBuffer() override;
|
2023-04-20 21:36:08 +00:00
|
|
|
IRenderTarget *createRenderTarget(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, TextureClass) override;
|
2022-07-11 18:45:16 +00:00
|
|
|
IDepthBuffer *createDepthBuffer() override;
|
2022-05-11 12:48:51 +00:00
|
|
|
void method_174() override;
|
2023-01-12 16:39:52 +00:00
|
|
|
void getWindowSize(uint32_t *width, uint32_t *height) override;
|
2022-05-11 12:48:51 +00:00
|
|
|
void method_17C() override;
|
|
|
|
void method_180() override;
|
2022-03-27 23:07:11 +00:00
|
|
|
|
2022-06-26 16:02:40 +00:00
|
|
|
// our own additions
|
|
|
|
void *captureRenderLists() override;
|
|
|
|
void revisitRenderLists(void*) override;
|
|
|
|
void freeRenderLists(void*) override;
|
|
|
|
|
2022-05-11 12:48:51 +00:00
|
|
|
bool internalCreate() override;
|
|
|
|
void internalRelease() override;
|
|
|
|
|
|
|
|
virtual void dx11_method_0();
|
|
|
|
virtual void dx11_method_4();
|
|
|
|
virtual void dx11_method_8();
|
|
|
|
virtual void dx11_method_C();
|
|
|
|
virtual void dx11_method_10();
|
|
|
|
virtual void dx11_method_14();
|
|
|
|
virtual void dx11_method_18();
|
|
|
|
virtual void dx11_method_1C();
|
2022-05-29 00:15:11 +00:00
|
|
|
virtual PCDX11RenderContext *getRenderContextAny();
|
2022-05-11 12:48:51 +00:00
|
|
|
virtual void dx11_method_24();
|
|
|
|
virtual void dx11_method_28();
|
|
|
|
virtual void dx11_method_2C();
|
|
|
|
virtual void dx11_method_30();
|
2022-07-11 18:45:16 +00:00
|
|
|
virtual PCDX11RenderTarget *dx11_createRenderTarget(
|
|
|
|
uint32_t width,
|
|
|
|
uint32_t height,
|
|
|
|
uint32_t dxgiFormat,
|
|
|
|
uint32_t,
|
2023-04-20 21:36:08 +00:00
|
|
|
TextureClass);
|
2022-05-11 12:48:51 +00:00
|
|
|
virtual void dx11_method_38();
|
|
|
|
virtual void dx11_method_3C();
|
|
|
|
virtual void dx11_method_40();
|
2022-06-16 17:19:40 +00:00
|
|
|
virtual void handleResize(int32_t width, int32_t height);
|
2022-05-11 12:48:51 +00:00
|
|
|
virtual void dx11_method_48();
|
2022-05-05 18:53:20 +00:00
|
|
|
|
|
|
|
ID3D11DeviceContext *d3dDeviceContext111580;
|
|
|
|
ID3D11DeviceContext *getD3DDeviceContext() { return d3dDeviceContext111580; }
|
2022-05-28 22:58:20 +00:00
|
|
|
PCDX11LightManager *getLightManager();
|
2024-09-03 23:58:54 +00:00
|
|
|
PCDX11RenderTarget *GetDefaultRenderTarget(bool isFlush);
|
|
|
|
PCDX11DepthBuffer *GetDefaultDepthBuffer(bool isFlush);
|
2022-05-20 22:11:56 +00:00
|
|
|
void recordDrawable(IRenderDrawable *drawable, uint32_t mask, bool addToNextScene);
|
2022-05-06 20:16:33 +00:00
|
|
|
void clearRenderTargetNow(char mode, float *color, float depth, uint32_t stencil);
|
2022-05-12 16:52:59 +00:00
|
|
|
void setTexture(uint32_t slot, PCDX11BaseTexture *tex, uint32_t filter, float unknown);
|
2022-05-13 13:24:04 +00:00
|
|
|
void drawRenderListsInternal(void *arg);
|
2022-10-21 16:45:57 +00:00
|
|
|
void drawQuadInternal(
|
|
|
|
float x0, float y0, float x1, float y1,
|
|
|
|
float u0, float v0, float u1, float v1,
|
|
|
|
uint32_t color);
|
|
|
|
void drawQuad(
|
|
|
|
float x0, float y0, float x1, float y1,
|
|
|
|
float u0, float v0, float u1, float v1,
|
|
|
|
uint32_t color, uint32_t flags, uint32_t blendMode, bool writeDepth);
|
2023-04-12 02:22:52 +00:00
|
|
|
void copySurface(PCDX11RenderTexture *texture, bool writeDepth, uint8_t rtMask);
|
2023-04-21 00:54:04 +00:00
|
|
|
void ApplyFXAA(uint32_t quality, PCDX11BaseTexture *texture, PCDX11RenderTarget *renderTarget);
|
|
|
|
void ApplyMLAA(PCDX11BaseTexture *texture, PCDX11RenderTarget *renderTarget);
|
2023-06-18 14:52:20 +00:00
|
|
|
void fastBlur(
|
|
|
|
PCDX11BaseTexture *texture, PCDX11RenderTarget *renderTarget,
|
|
|
|
uint32_t passMask, bool isHorizontal, bool weighted);
|
|
|
|
PCDX11ComputeShader *getBlurShader(bool horizontal, uint32_t kind);
|
2022-03-27 23:07:11 +00:00
|
|
|
};
|
|
|
|
|
2023-01-12 16:39:52 +00:00
|
|
|
CommonRenderDevice *createPCDX11RenderDevice(HWND hwnd, uint32_t width, uint32_t height, bool unknown);
|
2022-03-27 23:07:11 +00:00
|
|
|
|
|
|
|
}
|