mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 12:32:34 +00:00
Draw 8-bit software renderer with polybackend (well, sort of!)
This commit is contained in:
parent
4a2b763aaa
commit
44c2223c2f
6 changed files with 10 additions and 15 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<PolyClearDepthCommand>(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<PolySetViewportCommand>(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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -363,7 +363,7 @@ static uint32_t sampleTexture(float u, float v, const void* texPixels, int texWi
|
|||
else
|
||||
{
|
||||
uint32_t c = static_cast<const uint8_t*>(texPixels)[texelOffset];
|
||||
return c | 0xff000000;
|
||||
return (c << 16) | 0xff000000;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -136,9 +136,12 @@ namespace swrenderer
|
|||
|
||||
RenderActorView(player->mo, true, false);
|
||||
|
||||
auto copyqueue = std::make_shared<DrawerCommandQueue>(MainThread()->FrameMemory.get());
|
||||
copyqueue->Push<MemcpyCommand>(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<DrawerCommandQueue>(MainThread()->FrameMemory.get());
|
||||
copyqueue->Push<MemcpyCommand>(videobuffer, bufferpitch, target->GetPixels(), target->GetWidth(), target->GetHeight(), target->GetPitch(), target->IsBgra() ? 4 : 1);
|
||||
DrawerThreads::Execute(copyqueue);
|
||||
}
|
||||
|
||||
DrawerWaitCycles.Clock();
|
||||
DrawerThreads::WaitForWorkers();
|
||||
|
|
Loading…
Reference in a new issue