- consolidated the savegame picture code.
This commit is contained in:
parent
6177ed153d
commit
44d39ef63e
11 changed files with 158 additions and 177 deletions
|
|
@ -61,7 +61,6 @@
|
|||
#include "engineerrors.h"
|
||||
|
||||
void Draw2D(F2DDrawer *drawer, FRenderState &state);
|
||||
void DoWriteSavePic(FileWriter *file, ESSType ssformat, uint8_t *scr, int width, int height, sector_t *viewsector, bool upsidedown);
|
||||
|
||||
EXTERN_CVAR(Bool, r_drawvoxels)
|
||||
EXTERN_CVAR(Int, gl_tonemap)
|
||||
|
|
@ -318,53 +317,6 @@ void VulkanFrameBuffer::WaitForCommands(bool finish)
|
|||
}
|
||||
}
|
||||
|
||||
void VulkanFrameBuffer::WriteSavePic(player_t *player, FileWriter *file, int width, int height)
|
||||
{
|
||||
if (!V_IsHardwareRenderer())
|
||||
{
|
||||
Super::WriteSavePic(player, file, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
IntRect bounds;
|
||||
bounds.left = 0;
|
||||
bounds.top = 0;
|
||||
bounds.width = width;
|
||||
bounds.height = height;
|
||||
|
||||
// we must be sure the GPU finished reading from the buffer before we fill it with new data.
|
||||
WaitForCommands(false);
|
||||
|
||||
// Switch to render buffers dimensioned for the savepic
|
||||
mActiveRenderBuffers = mSaveBuffers.get();
|
||||
|
||||
mPostprocess->ImageTransitionScene(true);
|
||||
|
||||
hw_ClearFakeFlat();
|
||||
GetRenderState()->SetVertexBuffer(screen->mVertexData);
|
||||
screen->mVertexData->Reset();
|
||||
screen->mLights->Clear();
|
||||
screen->mViewpoints->Clear();
|
||||
|
||||
// This shouldn't overwrite the global viewpoint even for a short time.
|
||||
FRenderViewpoint savevp;
|
||||
sector_t *viewsector = RenderViewpoint(savevp, players[consoleplayer].camera, &bounds, r_viewpoint.FieldOfView.Degrees, 1.6f, 1.6f, true, false);
|
||||
GetRenderState()->EnableStencil(false);
|
||||
GetRenderState()->SetNoSoftLightLevel();
|
||||
|
||||
int numpixels = width * height;
|
||||
uint8_t * scr = (uint8_t *)M_Malloc(numpixels * 3);
|
||||
CopyScreenToBuffer(width, height, scr);
|
||||
|
||||
DoWriteSavePic(file, SS_RGB, scr, width, height, viewsector, false);
|
||||
M_Free(scr);
|
||||
|
||||
// Switch back the screen render buffers
|
||||
screen->SetViewportRects(nullptr);
|
||||
mActiveRenderBuffers = mScreenBuffers.get();
|
||||
}
|
||||
}
|
||||
|
||||
sector_t *VulkanFrameBuffer::RenderView(player_t *player)
|
||||
{
|
||||
// To do: this is virtually identical to FGLRenderer::RenderView and should be merged.
|
||||
|
|
@ -634,7 +586,7 @@ FTexture *VulkanFrameBuffer::WipeEndScreen()
|
|||
return tex;
|
||||
}
|
||||
|
||||
void VulkanFrameBuffer::CopyScreenToBuffer(int w, int h, void *data)
|
||||
void VulkanFrameBuffer::CopyScreenToBuffer(int w, int h, uint8_t *data)
|
||||
{
|
||||
VkTextureImage image;
|
||||
|
||||
|
|
@ -866,6 +818,18 @@ void VulkanFrameBuffer::UpdateShadowMap()
|
|||
mPostprocess->UpdateShadowMap();
|
||||
}
|
||||
|
||||
void VulkanFrameBuffer::SetSaveBuffers(bool yes)
|
||||
{
|
||||
if (yes) mActiveRenderBuffers = mSaveBuffers.get();
|
||||
else mActiveRenderBuffers = mScreenBuffers.get();
|
||||
}
|
||||
|
||||
void VulkanFrameBuffer::ImageTransitionScene(bool unknown)
|
||||
{
|
||||
mPostprocess->ImageTransitionScene(unknown);
|
||||
}
|
||||
|
||||
|
||||
FRenderState* VulkanFrameBuffer::RenderState()
|
||||
{
|
||||
return mRenderState.get();
|
||||
|
|
|
|||
|
|
@ -80,7 +80,6 @@ public:
|
|||
uint32_t GetCaps() override;
|
||||
const char* DeviceName() const override;
|
||||
int Backend() override { return 1; }
|
||||
void WriteSavePic(player_t *player, FileWriter *file, int width, int height) override;
|
||||
sector_t *RenderView(player_t *player) override;
|
||||
void SetTextureFilterMode() override;
|
||||
void TextureFilterChanged() override;
|
||||
|
|
@ -91,6 +90,8 @@ public:
|
|||
void AmbientOccludeScene(float m5) override;
|
||||
void SetSceneRenderTarget(bool useSSAO) override;
|
||||
void UpdateShadowMap() override;
|
||||
void SetSaveBuffers(bool yes) override;
|
||||
void ImageTransitionScene(bool unknown) override;
|
||||
|
||||
IHardwareTexture *CreateHardwareTexture() override;
|
||||
FMaterial* CreateMaterial(FGameTexture* tex, int scaleflags) override;
|
||||
|
|
@ -108,7 +109,7 @@ public:
|
|||
|
||||
void Draw2D() override;
|
||||
|
||||
void WaitForCommands(bool finish);
|
||||
void WaitForCommands(bool finish) override;
|
||||
|
||||
void PushGroup(const FString &name);
|
||||
void PopGroup();
|
||||
|
|
@ -118,7 +119,7 @@ private:
|
|||
void RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV);
|
||||
void PrintStartupLog();
|
||||
void CreateFanToTrisIndexBuffer();
|
||||
void CopyScreenToBuffer(int w, int h, void *data);
|
||||
void CopyScreenToBuffer(int w, int h, uint8_t *data) override;
|
||||
void DeleteFrameObjects();
|
||||
void FlushCommands(VulkanCommandBuffer **commands, size_t count, bool finish, bool lastsubmit);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue