cdcEngineDXHR/cdcRender/PCDX11RenderDevice.h

241 lines
8.8 KiB
C
Raw Permalink Normal View History

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"
#include "VertexDeclaration.h"
#include "shaders/PCDX11ShaderLib.h"
#include "shaders/PCDX11ShaderTable.h" // for PixelShaderTable and VertexShaderTable
#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 {
class IRenderDrawable;
2022-05-12 16:52:59 +00:00
class PCDX11BaseTexture;
class PCDX11LightManager;
class PCDX11Pool;
class PCDX11RenderContext;
2023-04-12 02:22:52 +00:00
class PCDX11RenderTexture;
class PCDX11StaticPool;
2022-10-21 16:45:57 +00:00
class PCDX11SimpleDynamicVertexBuffer;
2023-04-12 02:22:52 +00:00
class PCDX11SimpleStaticVertexBuffer;
class PCDX11Texture;
struct LightManagerSubB;
2022-03-27 23:07:11 +00:00
class PCDX11RenderDevice :
public PCDX11InternalResource,
public CommonRenderDevice
{
public:
2022-05-13 00:19:17 +00:00
struct RenderList {
RenderList(PCDX11RenderDevice *renderDevice, uint32_t *dimensions);
2022-05-13 00:19:17 +00:00
uint32_t dword0;
uint32_t dword4;
uint32_t widthMaybe8;
uint32_t heightMaybeC;
PCDX11RenderTarget *renderTarget; // 10
PCDX11DepthBuffer *depthBuffer; // 14
2022-05-13 00:19:17 +00:00
DrawableList drawableList; // 18
LightManagerSubB *lightManagerSubB; // 28
2022-05-13 00:19:17 +00:00
// uint8_t byte2C;
// uint8_t byte2D;
RenderList *next;
};
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
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
PCDX11Pool *m_pDynamicVertexPool = nullptr; // 10D08
PCDX11Pool *m_pDynamicIndexPool = nullptr; // 10D0C
PCDX11StaticPool *m_pStaticVertexPool = nullptr; // 10D10
PCDX11StaticPool *m_pStaticIndexPool = nullptr; // 10D14
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
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)
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;
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:
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();
~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;
bool beginRenderList(float*) override;
2022-05-13 00:19:17 +00:00
bool endRenderList() override;
bool hasRenderList() override;
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(
RenderViewport *renderViewport,
CommonRenderTarget *renderTarget,
CommonDepthBuffer *depthBuffer,
CommonRenderTarget *sourceColor,
CommonDepthBuffer *sourceDepth) override;
2022-05-13 00:19:17 +00:00
void finishScene() override;
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;
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;
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;
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;
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();
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();
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; }
PCDX11LightManager *getLightManager();
PCDX11RenderTarget *GetDefaultRenderTarget(bool isFlush);
PCDX11DepthBuffer *GetDefaultDepthBuffer(bool isFlush);
void recordDrawable(IRenderDrawable *drawable, uint32_t mask, bool addToNextScene);
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
}