mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-12-12 05:11:45 +00:00
- enable the depth buffer
- support vid_scalefactor
This commit is contained in:
parent
48d2d423f6
commit
d724b623d1
5 changed files with 65 additions and 4 deletions
|
@ -105,6 +105,7 @@ void PolyFrameBuffer::CheckCanvas()
|
|||
mCanvas.reset(new DCanvas(0, 0, true));
|
||||
mCanvas->Resize(GetWidth(), GetHeight(), false);
|
||||
|
||||
PolyTriangleDrawer::ResizeBuffers(mCanvas.get());
|
||||
PolyTriangleDrawer::SetViewport(GetDrawCommands(), 0, 0, mCanvas->GetWidth(), mCanvas->GetHeight(), mCanvas.get());
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +142,7 @@ void PolyFrameBuffer::Update()
|
|||
DrawerThreads::WaitForWorkers();
|
||||
mFrameMemory.Clear();
|
||||
|
||||
if (mCanvas && GetClientWidth() == mCanvas->GetWidth() && GetClientHeight() == mCanvas->GetHeight())
|
||||
if (mCanvas)
|
||||
{
|
||||
I_PresentPolyImage(mCanvas->GetWidth(), mCanvas->GetHeight(), mCanvas->GetPixels());
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ bool PolyRenderState::SetDepthClamp(bool on)
|
|||
|
||||
void PolyRenderState::SetDepthMask(bool on)
|
||||
{
|
||||
args.SetWriteDepth(on);
|
||||
}
|
||||
|
||||
void PolyRenderState::SetDepthFunc(int func)
|
||||
|
@ -94,6 +95,12 @@ void PolyRenderState::EnableClipDistance(int num, bool state)
|
|||
|
||||
void PolyRenderState::Clear(int targets)
|
||||
{
|
||||
//if (targets & CT_Color)
|
||||
// PolyTriangleDrawer::ClearColor(GetPolyFrameBuffer()->GetDrawCommands());
|
||||
if (targets & CT_Depth)
|
||||
PolyTriangleDrawer::ClearDepth(GetPolyFrameBuffer()->GetDrawCommands(), 0.0f);
|
||||
if (targets & CT_Stencil)
|
||||
PolyTriangleDrawer::ClearStencil(GetPolyFrameBuffer()->GetDrawCommands(), 0);
|
||||
}
|
||||
|
||||
void PolyRenderState::EnableStencil(bool on)
|
||||
|
@ -110,6 +117,7 @@ void PolyRenderState::SetViewport(int x, int y, int w, int h)
|
|||
|
||||
void PolyRenderState::EnableDepthTest(bool on)
|
||||
{
|
||||
args.SetDepthTest(on);
|
||||
}
|
||||
|
||||
void PolyRenderState::EnableMultisampling(bool on)
|
||||
|
@ -129,9 +137,7 @@ void PolyRenderState::Apply()
|
|||
drawcalls.Clock();
|
||||
|
||||
args.SetStencilTest(false);
|
||||
args.SetDepthTest(false);
|
||||
args.SetWriteStencil(false);
|
||||
args.SetWriteDepth(false);
|
||||
args.SetNoColormap();
|
||||
|
||||
args.SetColor(MAKEARGB(
|
||||
|
|
|
@ -52,6 +52,11 @@ bool PolyTriangleDrawer::IsBgra()
|
|||
return isBgraRenderTarget;
|
||||
}
|
||||
|
||||
void PolyTriangleDrawer::ClearDepth(const DrawerCommandQueuePtr &queue, float value)
|
||||
{
|
||||
queue->Push<PolyClearDepthCommand>(value);
|
||||
}
|
||||
|
||||
void PolyTriangleDrawer::ClearStencil(const DrawerCommandQueuePtr &queue, uint8_t value)
|
||||
{
|
||||
queue->Push<PolyClearStencilCommand>(value);
|
||||
|
@ -118,6 +123,25 @@ void PolyTriangleDrawer::DrawElements(const DrawerCommandQueuePtr &queue, const
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void PolyTriangleThreadData::ClearDepth(float value)
|
||||
{
|
||||
auto buffer = PolyZBuffer::Instance();
|
||||
int width = buffer->Width();
|
||||
int height = buffer->Height();
|
||||
float *data = buffer->Values();
|
||||
|
||||
int skip = skipped_by_thread(0);
|
||||
int count = count_for_thread(0, height);
|
||||
|
||||
data += skip * width;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
data[x] = value;
|
||||
data += num_cores * width;
|
||||
}
|
||||
}
|
||||
|
||||
void PolyTriangleThreadData::ClearStencil(uint8_t value)
|
||||
{
|
||||
auto buffer = PolyStencilBuffer::Instance();
|
||||
|
@ -686,6 +710,17 @@ void PolySetModelVertexShaderCommand::Execute(DrawerThread *thread)
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PolyClearDepthCommand::PolyClearDepthCommand(float value) : value(value)
|
||||
{
|
||||
}
|
||||
|
||||
void PolyClearDepthCommand::Execute(DrawerThread *thread)
|
||||
{
|
||||
PolyTriangleThreadData::Get(thread)->ClearDepth(value);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PolyClearStencilCommand::PolyClearStencilCommand(uint8_t value) : value(value)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ class PolyTriangleDrawer
|
|||
{
|
||||
public:
|
||||
static void ResizeBuffers(DCanvas *canvas);
|
||||
static void ClearDepth(const DrawerCommandQueuePtr &queue, float value);
|
||||
static void ClearStencil(const DrawerCommandQueuePtr &queue, uint8_t value);
|
||||
static void SetViewport(const DrawerCommandQueuePtr &queue, int x, int y, int width, int height, DCanvas *canvas);
|
||||
static void SetCullCCW(const DrawerCommandQueuePtr &queue, bool ccw);
|
||||
|
@ -53,6 +54,7 @@ class PolyTriangleThreadData
|
|||
public:
|
||||
PolyTriangleThreadData(int32_t core, int32_t num_cores, int32_t numa_node, int32_t num_numa_nodes, int numa_start_y, int numa_end_y) : core(core), num_cores(num_cores), numa_node(numa_node), num_numa_nodes(num_numa_nodes), numa_start_y(numa_start_y), numa_end_y(numa_end_y) { }
|
||||
|
||||
void ClearDepth(float value);
|
||||
void ClearStencil(uint8_t value);
|
||||
void SetViewport(int x, int y, int width, int height, uint8_t *dest, int dest_width, int dest_height, int dest_pitch, bool dest_bgra);
|
||||
void SetTransform(const Mat4f *objectToClip, const Mat4f *objectToWorld);
|
||||
|
@ -195,6 +197,17 @@ private:
|
|||
float interpolationFactor;
|
||||
};
|
||||
|
||||
class PolyClearDepthCommand : public PolyDrawerCommand
|
||||
{
|
||||
public:
|
||||
PolyClearDepthCommand(float value);
|
||||
|
||||
void Execute(DrawerThread *thread) override;
|
||||
|
||||
private:
|
||||
float value;
|
||||
};
|
||||
|
||||
class PolyClearStencilCommand : public PolyDrawerCommand
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -17,7 +17,13 @@ void I_PresentPolyImage(int w, int h, const void *pixels)
|
|||
info.bV5SizeImage = 0;
|
||||
info.bV5CSType = LCS_WINDOWS_COLOR_SPACE;
|
||||
|
||||
RECT box = {};
|
||||
GetClientRect(Window, &box);
|
||||
|
||||
HDC dc = GetDC(Window);
|
||||
if (box.right == w && box.bottom == h)
|
||||
SetDIBitsToDevice(dc, 0, 0, w, h, 0, 0, 0, h, pixels, (const BITMAPINFO *)&info, DIB_RGB_COLORS);
|
||||
else
|
||||
StretchDIBits(dc, 0, 0, box.right, box.bottom, 0, 0, w, h, pixels, (const BITMAPINFO *)&info, DIB_RGB_COLORS, SRCCOPY);
|
||||
ReleaseDC(Window, dc);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue