diff --git a/src/rendering/polyrenderer/backend/poly_hwtexture.cpp b/src/rendering/polyrenderer/backend/poly_hwtexture.cpp index a16b58287..4f7b255d3 100644 --- a/src/rendering/polyrenderer/backend/poly_hwtexture.cpp +++ b/src/rendering/polyrenderer/backend/poly_hwtexture.cpp @@ -101,6 +101,7 @@ void PolyHardwareTexture::AllocateBuffer(int w, int h, int texelsize) { mCanvas.reset(new DCanvas(0, 0, texelsize == 4)); mCanvas->Resize(w, h, false); + bufferpitch = mCanvas->GetPitch(); } } diff --git a/src/rendering/polyrenderer/drawers/poly_triangle.cpp b/src/rendering/polyrenderer/drawers/poly_triangle.cpp index 5cae9821c..a4bef00f6 100644 --- a/src/rendering/polyrenderer/drawers/poly_triangle.cpp +++ b/src/rendering/polyrenderer/drawers/poly_triangle.cpp @@ -39,13 +39,6 @@ #include "screen_triangle.h" #include "x86.h" -static bool isBgraRenderTarget = false; - -bool PolyTriangleDrawer::IsBgra() -{ - return isBgraRenderTarget; -} - void PolyTriangleDrawer::ClearDepth(const DrawerCommandQueuePtr &queue, float value) { queue->Push(value); @@ -63,7 +56,6 @@ void PolyTriangleDrawer::SetViewport(const DrawerCommandQueuePtr &queue, int x, int dest_height = canvas->GetHeight(); int dest_pitch = canvas->GetPitch(); bool dest_bgra = canvas->IsBgra(); - isBgraRenderTarget = dest_bgra; queue->Push(x, y, width, height, dest, dest_width, dest_height, dest_pitch, dest_bgra, depthstencil); } @@ -413,7 +405,7 @@ void PolyTriangleThreadData::SetTexture(int unit, const void *pixels, int width, textures[unit].pixels = pixels; textures[unit].width = width; textures[unit].height = height; - textures[unit].bgra = true; + textures[unit].bgra = bgra; } void PolyTriangleThreadData::DrawIndexed(int index, int vcount, PolyDrawMode drawmode) diff --git a/src/rendering/polyrenderer/drawers/poly_triangle.h b/src/rendering/polyrenderer/drawers/poly_triangle.h index f5a351994..9d7501cc7 100644 --- a/src/rendering/polyrenderer/drawers/poly_triangle.h +++ b/src/rendering/polyrenderer/drawers/poly_triangle.h @@ -73,7 +73,6 @@ public: static void ClearStencil(const DrawerCommandQueuePtr &queue, uint8_t value); static void Draw(const DrawerCommandQueuePtr &queue, int index, int vcount, PolyDrawMode mode = PolyDrawMode::Triangles); static void DrawIndexed(const DrawerCommandQueuePtr &queue, int index, int count, PolyDrawMode mode = PolyDrawMode::Triangles); - static bool IsBgra(); }; class PolyDepthStencil diff --git a/src/rendering/polyrenderer/drawers/screen_triangle.cpp b/src/rendering/polyrenderer/drawers/screen_triangle.cpp index d1a2ae621..7c19604d9 100644 --- a/src/rendering/polyrenderer/drawers/screen_triangle.cpp +++ b/src/rendering/polyrenderer/drawers/screen_triangle.cpp @@ -363,7 +363,7 @@ static uint32_t sampleTexture(float u, float v, const void* texPixels, int texWi else { uint32_t c = static_cast(texPixels)[texelOffset]; - return c | 0xff000000; + return (c << 16) | 0xff000000; } } diff --git a/src/rendering/swrenderer/r_swscene.cpp b/src/rendering/swrenderer/r_swscene.cpp index fcabe745c..68318f7f5 100644 --- a/src/rendering/swrenderer/r_swscene.cpp +++ b/src/rendering/swrenderer/r_swscene.cpp @@ -86,7 +86,7 @@ SWSceneDrawer::~SWSceneDrawer() sector_t *SWSceneDrawer::RenderView(player_t *player) { - if (!screen->IsPoly()) + if (!V_IsTrueColor() || !screen->IsPoly()) { // Avoid using the pixel buffer from the last frame FBTextureIndex = (FBTextureIndex + 1) % 2; diff --git a/src/rendering/swrenderer/scene/r_scene.cpp b/src/rendering/swrenderer/scene/r_scene.cpp index 280c9c1d0..a434bf6b6 100644 --- a/src/rendering/swrenderer/scene/r_scene.cpp +++ b/src/rendering/swrenderer/scene/r_scene.cpp @@ -136,9 +136,12 @@ namespace swrenderer RenderActorView(player->mo, true, false); - auto copyqueue = std::make_shared(MainThread()->FrameMemory.get()); - copyqueue->Push(videobuffer, bufferpitch, target->GetPixels(), target->GetWidth(), target->GetHeight(), target->GetPitch(), target->IsBgra() ? 4 : 1); - DrawerThreads::Execute(copyqueue); + if (videobuffer != target->GetPixels()) + { + auto copyqueue = std::make_shared(MainThread()->FrameMemory.get()); + copyqueue->Push(videobuffer, bufferpitch, target->GetPixels(), target->GetWidth(), target->GetHeight(), target->GetPitch(), target->IsBgra() ? 4 : 1); + DrawerThreads::Execute(copyqueue); + } DrawerWaitCycles.Clock(); DrawerThreads::WaitForWorkers();