diff --git a/src/rendering/polyrenderer/backend/poly_framebuffer.h b/src/rendering/polyrenderer/backend/poly_framebuffer.h index b779beb58..8e2eae427 100644 --- a/src/rendering/polyrenderer/backend/poly_framebuffer.h +++ b/src/rendering/polyrenderer/backend/poly_framebuffer.h @@ -17,7 +17,7 @@ class PolyFrameBuffer : public SystemBaseFrameBuffer public: RenderMemory *GetFrameMemory() { return &mFrameMemory; } PolyRenderState *GetRenderState() { return mRenderState.get(); } - DCanvas *GetCanvas() { return mCanvas.get(); } + DCanvas *GetCanvas() override { return mCanvas.get(); } PolyDepthStencil *GetDepthStencil() { return mDepthStencil.get(); } const DrawerCommandQueuePtr &GetDrawCommands(); void FlushDrawCommands(); @@ -31,6 +31,8 @@ public: void Update(); + bool IsPoly() override { return true; } + void InitializeState() override; void CleanForRestart() override; diff --git a/src/rendering/swrenderer/r_swscene.cpp b/src/rendering/swrenderer/r_swscene.cpp index cf4a54ecb..fcabe745c 100644 --- a/src/rendering/swrenderer/r_swscene.cpp +++ b/src/rendering/swrenderer/r_swscene.cpp @@ -86,41 +86,53 @@ SWSceneDrawer::~SWSceneDrawer() sector_t *SWSceneDrawer::RenderView(player_t *player) { - // Avoid using the pixel buffer from the last frame - FBTextureIndex = (FBTextureIndex + 1) % 2; - auto &fbtex = FBTexture[FBTextureIndex]; - - if (fbtex == nullptr || fbtex->GetSystemTexture() == nullptr || - fbtex->GetDisplayWidth() != screen->GetWidth() || - fbtex->GetDisplayHeight() != screen->GetHeight() || - (V_IsTrueColor() ? 1:0) != fbtex->GetColorFormat()) + if (!screen->IsPoly()) { - // This manually constructs its own material here. - fbtex.reset(); - fbtex.reset(new FWrapperTexture(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor())); - fbtex->GetSystemTexture()->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1); - auto mat = FMaterial::ValidateTexture(fbtex.get(), false); - mat->AddTextureLayer(PaletteTexture); + // Avoid using the pixel buffer from the last frame + FBTextureIndex = (FBTextureIndex + 1) % 2; + auto &fbtex = FBTexture[FBTextureIndex]; - Canvas.reset(); - Canvas.reset(new DCanvas(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor())); + if (fbtex == nullptr || fbtex->GetSystemTexture() == nullptr || + fbtex->GetDisplayWidth() != screen->GetWidth() || + fbtex->GetDisplayHeight() != screen->GetHeight() || + (V_IsTrueColor() ? 1:0) != fbtex->GetColorFormat()) + { + // This manually constructs its own material here. + fbtex.reset(); + fbtex.reset(new FWrapperTexture(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor())); + fbtex->GetSystemTexture()->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1); + auto mat = FMaterial::ValidateTexture(fbtex.get(), false); + mat->AddTextureLayer(PaletteTexture); + + Canvas.reset(); + Canvas.reset(new DCanvas(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor())); + } + + IHardwareTexture *systemTexture = fbtex->GetSystemTexture(); + auto buf = systemTexture->MapBuffer(); + if (!buf) I_FatalError("Unable to map buffer for software rendering"); + SWRenderer->RenderView(player, Canvas.get(), buf, systemTexture->GetBufferPitch()); + systemTexture->CreateTexture(nullptr, screen->GetWidth(), screen->GetHeight(), 0, false, 0, "swbuffer"); + + auto map = swrenderer::CameraLight::Instance()->ShaderColormap(); + screen->DrawTexture(fbtex.get(), 0, 0, DTA_SpecialColormap, map, TAG_DONE); + screen->Draw2D(); + screen->Clear2D(); + screen->PostProcessScene(CM_DEFAULT, [&]() { + SWRenderer->DrawRemainingPlayerSprites(); + screen->Draw2D(); + screen->Clear2D(); + }); } - - IHardwareTexture *systemTexture = fbtex->GetSystemTexture(); - auto buf = systemTexture->MapBuffer(); - if (!buf) I_FatalError("Unable to map buffer for software rendering"); - SWRenderer->RenderView(player, Canvas.get(), buf, systemTexture->GetBufferPitch()); - systemTexture->CreateTexture(nullptr, screen->GetWidth(), screen->GetHeight(), 0, false, 0, "swbuffer"); - - auto map = swrenderer::CameraLight::Instance()->ShaderColormap(); - screen->DrawTexture(fbtex.get(), 0, 0, DTA_SpecialColormap, map, TAG_DONE); - screen->Draw2D(); - screen->Clear2D(); - screen->PostProcessScene(CM_DEFAULT, [&]() { + else + { + DCanvas *canvas = screen->GetCanvas(); + SWRenderer->RenderView(player, canvas, canvas->GetPixels(), canvas->GetPitch()); + // To do: apply swrenderer::CameraLight::Instance()->ShaderColormap(); SWRenderer->DrawRemainingPlayerSprites(); screen->Draw2D(); screen->Clear2D(); - }); + } return r_viewpoint.sector; } diff --git a/src/rendering/v_video.h b/src/rendering/v_video.h index fb2227ffc..f6324826b 100644 --- a/src/rendering/v_video.h +++ b/src/rendering/v_video.h @@ -394,6 +394,9 @@ public: virtual ~DFrameBuffer(); virtual void InitializeState() = 0; // For stuff that needs 'screen' set. virtual bool IsVulkan() { return false; } + virtual bool IsPoly() { return false; } + + virtual DCanvas* GetCanvas() { return nullptr; } void SetSize(int width, int height); void SetVirtualSize(int width, int height)