add PCDX11RenderTarget::copyFromTexture

This commit is contained in:
Adam Jensen 2023-04-12 03:24:45 +01:00
parent 5c22e2ec63
commit dc5ad022fb
5 changed files with 22 additions and 5 deletions

View File

@ -1,4 +1,7 @@
#include "PCDX11DefaultRenderTarget.h"
#include "../PCDX11DeviceManager.h"
#include "../PCDX11RenderDevice.h"
#include "../PCDX11StateManager.h"
#include <d3d11.h>
namespace cdc {
@ -8,6 +11,7 @@ PCDX11DefaultRenderTarget::PCDX11DefaultRenderTarget(
uint32_t flags, uint32_t format,
PCDX11RenderDevice *renderDevice, ID3D11Texture2D *texture, uint32_t unknown2)
:
renderDevice(renderDevice),
flags14(flags),
renderTexture(width, height, flags, /*isDepthBuffer=*/ false, renderDevice, unknown2)
{
@ -39,8 +43,18 @@ ID3D11RenderTargetView *PCDX11DefaultRenderTarget::getRenderTargetView() {
return static_cast<ID3D11RenderTargetView*>(renderTexture.getView());
}
void PCDX11DefaultRenderTarget::copyFromTexture(void *) {
// TODO
void PCDX11DefaultRenderTarget::copyFromTexture(PCDX11RenderTarget *sourceRT) {
if (sourceRT->method_3C())
sourceRT->method_40();
if (auto *tex = sourceRT->getRenderTexture()) {
float clearColor[4] = {0.f, 0.f, 0.f, 0.f};
auto stateManager = deviceManager->getStateManager();
stateManager->pushRenderTargets(this, nullptr);
renderDevice->clearRenderTargetNow(7, clearColor, 1.f, 0);
renderDevice->copySurface(tex, false, 15);
stateManager->popRenderTargets();
}
}
bool PCDX11DefaultRenderTarget::method_3C() {

View File

@ -15,6 +15,7 @@ public:
uint32_t, uint32_t,
PCDX11RenderDevice*, ID3D11Texture2D*, uint32_t);
PCDX11RenderDevice *renderDevice; // 4, used for copy, renderTexture also has a renderDevice member
uint32_t flags14;
PCDX11RenderTexture renderTexture; // 1C
@ -33,7 +34,7 @@ public:
uint32_t method_2C() override;
ID3D11Resource *getTextureResource() override;
ID3D11RenderTargetView *getRenderTargetView() override;
void copyFromTexture(void *) override;
void copyFromTexture(PCDX11RenderTarget *) override;
bool method_3C() override;
void method_40() override;
};

View File

@ -28,6 +28,8 @@ public:
void registerAtScene(void *ptr) override { /*TODO*/ };
void method_14() override { /*TODO*/ };
void copyFromTexture(IDepthBuffer*) { /* empty, see call from PCDX11Scene::draw */ }
ID3D11DepthStencilView *getRWDepthStencilView() {
return static_cast<ID3D11DepthStencilView*>(renderTexture.getView());
}

View File

@ -13,7 +13,7 @@ public:
virtual uint32_t method_2C() = 0;
virtual ID3D11Resource *getTextureResource() = 0;
virtual ID3D11RenderTargetView *getRenderTargetView() = 0;
virtual void copyFromTexture(void*) = 0;
virtual void copyFromTexture(PCDX11RenderTarget*) = 0;
virtual bool method_3C() = 0;
virtual void method_40() = 0;

View File

@ -41,7 +41,7 @@ public:
uint32_t method_2C() override { return heightC; }
ID3D11Resource *getTextureResource() override { return renderTarget->getTextureResource(); }
ID3D11RenderTargetView *getRenderTargetView() override { return renderTarget->getRenderTargetView(); }
void copyFromTexture(void *ptr) override { return renderTarget->copyFromTexture(ptr); }
void copyFromTexture(PCDX11RenderTarget *ptr) override { return renderTarget->copyFromTexture(ptr); }
bool method_3C() override { return renderTarget->method_3C(); }
void method_40() override { renderTarget->method_40(); }
};