mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-12-02 17:02:49 +00:00
- fix viewport location
- add scissor support
This commit is contained in:
parent
8db5e72254
commit
0d8d50c23e
5 changed files with 36 additions and 25 deletions
|
@ -128,7 +128,7 @@ void PolyRenderState::SetScissor(int x, int y, int w, int h)
|
||||||
w = fb->GetCanvas()->GetWidth();
|
w = fb->GetCanvas()->GetWidth();
|
||||||
h = fb->GetCanvas()->GetHeight();
|
h = fb->GetCanvas()->GetHeight();
|
||||||
}
|
}
|
||||||
PolyTriangleDrawer::SetScissor(fb->GetDrawCommands(), x, y, w, h);
|
PolyTriangleDrawer::SetScissor(fb->GetDrawCommands(), x, fb->GetCanvas()->GetHeight() - y - h, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyRenderState::SetViewport(int x, int y, int w, int h)
|
void PolyRenderState::SetViewport(int x, int y, int w, int h)
|
||||||
|
@ -141,7 +141,7 @@ void PolyRenderState::SetViewport(int x, int y, int w, int h)
|
||||||
w = fb->GetCanvas()->GetWidth();
|
w = fb->GetCanvas()->GetWidth();
|
||||||
h = fb->GetCanvas()->GetHeight();
|
h = fb->GetCanvas()->GetHeight();
|
||||||
}
|
}
|
||||||
PolyTriangleDrawer::SetViewport(fb->GetDrawCommands(), x, y, w, h, fb->GetCanvas());
|
PolyTriangleDrawer::SetViewport(fb->GetDrawCommands(), x, fb->GetCanvas()->GetHeight() - y - h, w, h, fb->GetCanvas());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyRenderState::EnableDepthTest(bool on)
|
void PolyRenderState::EnableDepthTest(bool on)
|
||||||
|
|
|
@ -71,19 +71,7 @@ void PolyTriangleDrawer::SetViewport(const DrawerCommandQueuePtr &queue, int x,
|
||||||
bool dest_bgra = canvas->IsBgra();
|
bool dest_bgra = canvas->IsBgra();
|
||||||
isBgraRenderTarget = dest_bgra;
|
isBgraRenderTarget = dest_bgra;
|
||||||
|
|
||||||
int offsetx = clamp(x, 0, dest_width);
|
queue->Push<PolySetViewportCommand>(x, y, width, height, dest, dest_width, dest_height, dest_pitch, dest_bgra);
|
||||||
int pixelsize = dest_bgra ? 4 : 1;
|
|
||||||
|
|
||||||
int viewport_x = x - offsetx;
|
|
||||||
int viewport_y = y;
|
|
||||||
int viewport_width = width;
|
|
||||||
int viewport_height = height;
|
|
||||||
|
|
||||||
dest += offsetx * pixelsize;
|
|
||||||
dest_width = clamp(viewport_x + viewport_width, 0, dest_width - offsetx);
|
|
||||||
dest_height = clamp(viewport_y + viewport_height, 0, dest_height);
|
|
||||||
|
|
||||||
queue->Push<PolySetViewportCommand>(viewport_x, viewport_y, viewport_width, viewport_height, dest, dest_width, dest_height, dest_pitch, dest_bgra);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyTriangleDrawer::SetInputAssembly(const DrawerCommandQueuePtr &queue, PolyInputAssembly *input)
|
void PolyTriangleDrawer::SetInputAssembly(const DrawerCommandQueuePtr &queue, PolyInputAssembly *input)
|
||||||
|
@ -276,8 +264,24 @@ void PolyTriangleThreadData::SetViewport(int x, int y, int width, int height, ui
|
||||||
dest_height = new_dest_height;
|
dest_height = new_dest_height;
|
||||||
dest_pitch = new_dest_pitch;
|
dest_pitch = new_dest_pitch;
|
||||||
dest_bgra = new_dest_bgra;
|
dest_bgra = new_dest_bgra;
|
||||||
ccw = true;
|
UpdateClip();
|
||||||
weaponScene = false;
|
}
|
||||||
|
|
||||||
|
void PolyTriangleThreadData::SetScissor(int x, int y, int w, int h)
|
||||||
|
{
|
||||||
|
scissor.left = x;
|
||||||
|
scissor.right = x + w;
|
||||||
|
scissor.top = y;
|
||||||
|
scissor.bottom = y + h;
|
||||||
|
UpdateClip();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PolyTriangleThreadData::UpdateClip()
|
||||||
|
{
|
||||||
|
clip.left = MAX(MAX(viewport_x, scissor.left), 0);
|
||||||
|
clip.top = MAX(MAX(viewport_y, scissor.top), 0);
|
||||||
|
clip.right = MIN(MIN(viewport_x + viewport_width, scissor.right), dest_width);
|
||||||
|
clip.bottom = MIN(MIN(viewport_y + viewport_height, scissor.bottom), dest_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyTriangleThreadData::SetTransform(const Mat4f *newObjectToClip, const Mat4f *newObjectToWorld)
|
void PolyTriangleThreadData::SetTransform(const Mat4f *newObjectToClip, const Mat4f *newObjectToWorld)
|
||||||
|
@ -378,10 +382,6 @@ void PolyTriangleThreadData::EnableStencil(bool on)
|
||||||
drawargs.SetWriteStencil(on && drawargs.StencilTestValue() != drawargs.StencilWriteValue(), drawargs.StencilWriteValue());
|
drawargs.SetWriteStencil(on && drawargs.StencilTestValue() != drawargs.StencilWriteValue(), drawargs.StencilWriteValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyTriangleThreadData::SetScissor(int x, int y, int w, int h)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void PolyTriangleThreadData::EnableDepthTest(bool on)
|
void PolyTriangleThreadData::EnableDepthTest(bool on)
|
||||||
{
|
{
|
||||||
drawargs.SetDepthTest(on);
|
drawargs.SetDepthTest(on);
|
||||||
|
|
|
@ -143,6 +143,8 @@ public:
|
||||||
void SetRenderStyle(FRenderStyle style);
|
void SetRenderStyle(FRenderStyle style);
|
||||||
void SetTexture(void *pixels, int width, int height);
|
void SetTexture(void *pixels, int width, int height);
|
||||||
|
|
||||||
|
void UpdateClip();
|
||||||
|
|
||||||
void PushDrawArgs(const PolyDrawArgs &args);
|
void PushDrawArgs(const PolyDrawArgs &args);
|
||||||
void PushStreamData(const StreamData &data, const PolyPushConstants &constants);
|
void PushStreamData(const StreamData &data, const PolyPushConstants &constants);
|
||||||
void PushMatrices(const VSMatrix &modelMatrix, const VSMatrix &normalModelMatrix, const VSMatrix &textureMatrix);
|
void PushMatrices(const VSMatrix &modelMatrix, const VSMatrix &normalModelMatrix, const VSMatrix &textureMatrix);
|
||||||
|
@ -197,6 +199,14 @@ public:
|
||||||
|
|
||||||
int viewport_y = 0;
|
int viewport_y = 0;
|
||||||
|
|
||||||
|
struct ClipRect
|
||||||
|
{
|
||||||
|
int left = 0;
|
||||||
|
int top = 0;
|
||||||
|
int right = 0;
|
||||||
|
int bottom = 0;
|
||||||
|
} clip, scissor;
|
||||||
|
|
||||||
PolyDrawArgs drawargs;
|
PolyDrawArgs drawargs;
|
||||||
|
|
||||||
const void *vertices = nullptr;
|
const void *vertices = nullptr;
|
||||||
|
|
|
@ -60,10 +60,10 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs *args, PolyTriangleThreadDat
|
||||||
ScreenTriVertex *sortedVertices[3];
|
ScreenTriVertex *sortedVertices[3];
|
||||||
SortVertices(args, sortedVertices);
|
SortVertices(args, sortedVertices);
|
||||||
|
|
||||||
int clipleft = 0;
|
int clipleft = thread->clip.left;
|
||||||
int cliptop = MAX(thread->viewport_y, thread->numa_start_y);
|
int cliptop = MAX(thread->clip.top, thread->numa_start_y);
|
||||||
int clipright = thread->dest_width;
|
int clipright = thread->clip.right;
|
||||||
int clipbottom = MIN(thread->dest_height, thread->numa_end_y);
|
int clipbottom = MIN(thread->clip.bottom, thread->numa_end_y);
|
||||||
|
|
||||||
int topY = (int)(sortedVertices[0]->y + 0.5f);
|
int topY = (int)(sortedVertices[0]->y + 0.5f);
|
||||||
int midY = (int)(sortedVertices[1]->y + 0.5f);
|
int midY = (int)(sortedVertices[1]->y + 0.5f);
|
||||||
|
|
|
@ -276,6 +276,7 @@ namespace swrenderer
|
||||||
PolyTriangleDrawer::ClearStencil(MainThread()->DrawQueue, 0);
|
PolyTriangleDrawer::ClearStencil(MainThread()->DrawQueue, 0);
|
||||||
|
|
||||||
PolyTriangleDrawer::SetViewport(thread->DrawQueue, viewwindowx, viewwindowy, viewwidth, viewheight, thread->Viewport->RenderTarget);
|
PolyTriangleDrawer::SetViewport(thread->DrawQueue, viewwindowx, viewwindowy, viewwidth, viewheight, thread->Viewport->RenderTarget);
|
||||||
|
PolyTriangleDrawer::SetScissor(thread->DrawQueue, viewwindowx, viewwindowy, viewwidth, viewheight);
|
||||||
|
|
||||||
// Cull things outside the range seen by this thread
|
// Cull things outside the range seen by this thread
|
||||||
VisibleSegmentRenderer visitor;
|
VisibleSegmentRenderer visitor;
|
||||||
|
|
Loading…
Reference in a new issue