mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 07:12:02 +00:00
- reworked canvas texture updater to avoid passing game data to the render backends.
These are now handled one level above using a callback to perform the actual rendering.
This commit is contained in:
parent
44d39ef63e
commit
730d07fbf7
7 changed files with 37 additions and 21 deletions
|
@ -210,23 +210,21 @@ void OpenGLFrameBuffer::CopyScreenToBuffer(int width, int height, uint8_t* scr)
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
void OpenGLFrameBuffer::RenderTextureView(FCanvasTexture* tex, AActor* Viewpoint, double FOV)
|
void OpenGLFrameBuffer::RenderTextureView(FCanvasTexture* tex, std::function<void(IntRect &)> renderFunc)
|
||||||
|
|
||||||
{
|
{
|
||||||
// This doesn't need to clear the fake flat cache. It can be shared between camera textures and the main view of a scene.
|
|
||||||
|
|
||||||
float ratio = tex->aspectRatio;
|
|
||||||
|
|
||||||
GLRenderer->StartOffscreen();
|
GLRenderer->StartOffscreen();
|
||||||
GLRenderer->BindToFrameBuffer(tex);
|
GLRenderer->BindToFrameBuffer(tex);
|
||||||
|
|
||||||
|
// This doesn't need to clear the fake flat cache. It can be shared between camera textures and the main view of a scene.
|
||||||
|
float ratio = tex->aspectRatio;
|
||||||
|
|
||||||
IntRect bounds;
|
IntRect bounds;
|
||||||
bounds.left = bounds.top = 0;
|
bounds.left = bounds.top = 0;
|
||||||
bounds.width = FHardwareTexture::GetTexDimension(tex->GetWidth());
|
bounds.width = FHardwareTexture::GetTexDimension(tex->GetWidth());
|
||||||
bounds.height = FHardwareTexture::GetTexDimension(tex->GetHeight());
|
bounds.height = FHardwareTexture::GetTexDimension(tex->GetHeight());
|
||||||
|
|
||||||
FRenderViewpoint texvp;
|
renderFunc(bounds);
|
||||||
RenderViewpoint(texvp, Viewpoint, &bounds, FOV, ratio, ratio, false, false);
|
|
||||||
|
|
||||||
GLRenderer->EndOffscreen();
|
GLRenderer->EndOffscreen();
|
||||||
|
|
||||||
tex->SetUpdated(true);
|
tex->SetUpdated(true);
|
||||||
|
@ -283,7 +281,12 @@ sector_t *OpenGLFrameBuffer::RenderView(player_t *player)
|
||||||
{
|
{
|
||||||
Level->canvasTextureInfo.UpdateAll([&](AActor* camera, FCanvasTexture* camtex, double fov)
|
Level->canvasTextureInfo.UpdateAll([&](AActor* camera, FCanvasTexture* camtex, double fov)
|
||||||
{
|
{
|
||||||
RenderTextureView(camtex, camera, fov);
|
RenderTextureView(camtex, [=](IntRect &bounds)
|
||||||
|
{
|
||||||
|
FRenderViewpoint texvp;
|
||||||
|
float ratio = camtex->aspectRatio;
|
||||||
|
RenderViewpoint(texvp, camera, &bounds, fov, ratio, ratio, false, false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
NoInterpolateView = saved_niv;
|
NoInterpolateView = saved_niv;
|
||||||
|
|
|
@ -16,7 +16,7 @@ class OpenGLFrameBuffer : public SystemGLFrameBuffer
|
||||||
{
|
{
|
||||||
typedef SystemGLFrameBuffer Super;
|
typedef SystemGLFrameBuffer Super;
|
||||||
|
|
||||||
void RenderTextureView(FCanvasTexture* tex, AActor* Viewpoint, double FOV);
|
void RenderTextureView(FCanvasTexture* tex, std::function<void(IntRect &)> renderFunc) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -261,7 +261,12 @@ sector_t *PolyFrameBuffer::RenderView(player_t *player)
|
||||||
{
|
{
|
||||||
Level->canvasTextureInfo.UpdateAll([&](AActor *camera, FCanvasTexture *camtex, double fov)
|
Level->canvasTextureInfo.UpdateAll([&](AActor *camera, FCanvasTexture *camtex, double fov)
|
||||||
{
|
{
|
||||||
RenderTextureView(camtex, camera, fov);
|
RenderTextureView(camtex, [=](IntRect &bounds)
|
||||||
|
{
|
||||||
|
FRenderViewpoint texvp;
|
||||||
|
float ratio = camtex->aspectRatio;
|
||||||
|
RenderViewpoint(texvp, camera, &bounds, fov, ratio, ratio, false, false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
NoInterpolateView = saved_niv;
|
NoInterpolateView = saved_niv;
|
||||||
|
@ -285,7 +290,7 @@ sector_t *PolyFrameBuffer::RenderView(player_t *player)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PolyFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV)
|
void PolyFrameBuffer::RenderTextureView(FCanvasTexture* tex, std::function<void(IntRect &)> renderFunc)
|
||||||
{
|
{
|
||||||
// This doesn't need to clear the fake flat cache. It can be shared between camera textures and the main view of a scene.
|
// This doesn't need to clear the fake flat cache. It can be shared between camera textures and the main view of a scene.
|
||||||
auto BaseLayer = static_cast<PolyHardwareTexture*>(tex->GetHardwareTexture(0, 0));
|
auto BaseLayer = static_cast<PolyHardwareTexture*>(tex->GetHardwareTexture(0, 0));
|
||||||
|
@ -300,8 +305,7 @@ void PolyFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint,
|
||||||
bounds.width = std::min(tex->GetWidth(), image->GetWidth());
|
bounds.width = std::min(tex->GetWidth(), image->GetWidth());
|
||||||
bounds.height = std::min(tex->GetHeight(), image->GetHeight());
|
bounds.height = std::min(tex->GetHeight(), image->GetHeight());
|
||||||
|
|
||||||
FRenderViewpoint texvp;
|
renderFunc(bounds);
|
||||||
RenderViewpoint(texvp, Viewpoint, &bounds, FOV, ratio, ratio, false, false);
|
|
||||||
|
|
||||||
FlushDrawCommands();
|
FlushDrawCommands();
|
||||||
DrawerThreads::WaitForWorkers();
|
DrawerThreads::WaitForWorkers();
|
||||||
|
|
|
@ -70,7 +70,7 @@ public:
|
||||||
} FrameDeleteList;
|
} FrameDeleteList;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV);
|
void RenderTextureView(FCanvasTexture* tex, std::function<void(IntRect &)> renderFunc) override;
|
||||||
void UpdateShadowMap();
|
void UpdateShadowMap();
|
||||||
|
|
||||||
void CheckCanvas();
|
void CheckCanvas();
|
||||||
|
|
|
@ -320,6 +320,7 @@ public:
|
||||||
virtual void ImageTransitionScene(bool unknown) {}
|
virtual void ImageTransitionScene(bool unknown) {}
|
||||||
virtual void CopyScreenToBuffer(int width, int height, uint8_t* buffer) { memset(buffer, 0, width* height); }
|
virtual void CopyScreenToBuffer(int width, int height, uint8_t* buffer) { memset(buffer, 0, width* height); }
|
||||||
virtual bool FlipSavePic() const { return false; }
|
virtual bool FlipSavePic() const { return false; }
|
||||||
|
virtual void RenderTextureView(FCanvasTexture* tex, std::function<void(IntRect&)> renderFunc) {}
|
||||||
|
|
||||||
|
|
||||||
// Screen wiping
|
// Screen wiping
|
||||||
|
|
|
@ -363,7 +363,12 @@ sector_t *VulkanFrameBuffer::RenderView(player_t *player)
|
||||||
{
|
{
|
||||||
Level->canvasTextureInfo.UpdateAll([&](AActor *camera, FCanvasTexture *camtex, double fov)
|
Level->canvasTextureInfo.UpdateAll([&](AActor *camera, FCanvasTexture *camtex, double fov)
|
||||||
{
|
{
|
||||||
RenderTextureView(camtex, camera, fov);
|
RenderTextureView(camtex, [=](IntRect &bounds)
|
||||||
|
{
|
||||||
|
FRenderViewpoint texvp;
|
||||||
|
float ratio = camtex->aspectRatio;
|
||||||
|
RenderViewpoint(texvp, camera, &bounds, fov, ratio, ratio, false, false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
NoInterpolateView = saved_niv;
|
NoInterpolateView = saved_niv;
|
||||||
|
@ -388,11 +393,12 @@ sector_t *VulkanFrameBuffer::RenderView(player_t *player)
|
||||||
return retsec;
|
return retsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV)
|
void VulkanFrameBuffer::RenderTextureView(FCanvasTexture* tex, std::function<void(IntRect &)> renderFunc)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
// This doesn't need to clear the fake flat cache. It can be shared between camera textures and the main view of a scene.
|
||||||
auto BaseLayer = static_cast<VkHardwareTexture*>(tex->GetHardwareTexture(0, 0));
|
auto BaseLayer = static_cast<VkHardwareTexture*>(tex->GetHardwareTexture(0, 0));
|
||||||
|
|
||||||
float ratio = tex->aspectRatio;
|
|
||||||
VkTextureImage *image = BaseLayer->GetImage(tex, 0, 0);
|
VkTextureImage *image = BaseLayer->GetImage(tex, 0, 0);
|
||||||
VkTextureImage *depthStencil = BaseLayer->GetDepthStencil(tex);
|
VkTextureImage *depthStencil = BaseLayer->GetDepthStencil(tex);
|
||||||
|
|
||||||
|
@ -404,13 +410,13 @@ void VulkanFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint
|
||||||
|
|
||||||
mRenderState->SetRenderTarget(image, depthStencil->View.get(), image->Image->width, image->Image->height, VK_FORMAT_R8G8B8A8_UNORM, VK_SAMPLE_COUNT_1_BIT);
|
mRenderState->SetRenderTarget(image, depthStencil->View.get(), image->Image->width, image->Image->height, VK_FORMAT_R8G8B8A8_UNORM, VK_SAMPLE_COUNT_1_BIT);
|
||||||
|
|
||||||
|
float ratio = tex->aspectRatio;
|
||||||
IntRect bounds;
|
IntRect bounds;
|
||||||
bounds.left = bounds.top = 0;
|
bounds.left = bounds.top = 0;
|
||||||
bounds.width = std::min(tex->GetWidth(), image->Image->width);
|
bounds.width = std::min(tex->GetWidth(), image->Image->width);
|
||||||
bounds.height = std::min(tex->GetHeight(), image->Image->height);
|
bounds.height = std::min(tex->GetHeight(), image->Image->height);
|
||||||
|
|
||||||
FRenderViewpoint texvp;
|
renderFunc(bounds);
|
||||||
RenderViewpoint(texvp, Viewpoint, &bounds, FOV, ratio, ratio, false, false);
|
|
||||||
|
|
||||||
mRenderState->EndRenderPass();
|
mRenderState->EndRenderPass();
|
||||||
|
|
||||||
|
|
|
@ -114,9 +114,11 @@ public:
|
||||||
void PushGroup(const FString &name);
|
void PushGroup(const FString &name);
|
||||||
void PopGroup();
|
void PopGroup();
|
||||||
void UpdateGpuStats();
|
void UpdateGpuStats();
|
||||||
|
IntRect SetupTextureView(FCanvasTexture* tex);
|
||||||
|
void FinishTextureView(FCanvasTexture* tex);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV);
|
void RenderTextureView(FCanvasTexture* tex, std::function<void(IntRect &)> renderFunc) override;
|
||||||
void PrintStartupLog();
|
void PrintStartupLog();
|
||||||
void CreateFanToTrisIndexBuffer();
|
void CreateFanToTrisIndexBuffer();
|
||||||
void CopyScreenToBuffer(int w, int h, uint8_t *data) override;
|
void CopyScreenToBuffer(int w, int h, uint8_t *data) override;
|
||||||
|
|
Loading…
Reference in a new issue