BPFunctions: Move upscaling of scissor rect to VideoCommon

This commit is contained in:
Stenzek 2018-01-21 22:12:32 +10:00
parent 5359396099
commit c1b39ecc58
8 changed files with 17 additions and 44 deletions

View File

@ -258,10 +258,10 @@ bool Renderer::CheckForResize()
return false; return false;
} }
void Renderer::SetScissorRect(const EFBRectangle& rc) void Renderer::SetScissorRect(const MathUtil::Rectangle<int>& rc)
{ {
TargetRectangle trc = ConvertEFBRectangle(rc); const RECT rect = {rc.left, rc.top, rc.right, rc.bottom};
D3D::context->RSSetScissorRects(1, trc.AsRECT()); D3D::context->RSSetScissorRects(1, &rect);
} }
// This function allows the CPU to directly access the EFB. // This function allows the CPU to directly access the EFB.

View File

@ -27,7 +27,7 @@ public:
CreateStagingTexture(StagingTextureType type, const TextureConfig& config) override; CreateStagingTexture(StagingTextureType type, const TextureConfig& config) override;
void SetBlendingState(const BlendingState& state) override; void SetBlendingState(const BlendingState& state) override;
void SetScissorRect(const EFBRectangle& rc) override; void SetScissorRect(const MathUtil::Rectangle<int>& rc) override;
void SetRasterizationState(const RasterizationState& state) override; void SetRasterizationState(const RasterizationState& state) override;
void SetDepthState(const DepthState& state) override; void SetDepthState(const DepthState& state) override;
void SetTexture(u32 index, const AbstractTexture* texture) override; void SetTexture(u32 index, const AbstractTexture* texture) override;

View File

@ -863,20 +863,9 @@ TargetRectangle Renderer::ConvertEFBRectangle(const EFBRectangle& rc)
return result; return result;
} }
// Function: This function handles the OpenGL glScissor() function void Renderer::SetScissorRect(const MathUtil::Rectangle<int>& rc)
// ----------------------------
// Call browser: OpcodeDecoding.cpp ExecuteDisplayList > Decode() > LoadBPReg()
// case 0x52 > SetScissorRect()
// ----------------------------
// bpmem.scissorTL.x, y = 342x342
// bpmem.scissorBR.x, y = 981x821
// Renderer::GetTargetHeight() = the fixed ini file setting
// donkopunchstania - it appears scissorBR is the bottom right pixel inside the scissor box
// therefore the width and height are (scissorBR + 1) - scissorTL
void Renderer::SetScissorRect(const EFBRectangle& rc)
{ {
TargetRectangle trc = ConvertEFBRectangle(rc); glScissor(rc.left, rc.bottom, rc.GetWidth(), rc.GetHeight());
glScissor(trc.left, trc.bottom, trc.GetWidth(), trc.GetHeight());
} }
void ClearEFBCache() void ClearEFBCache()

View File

@ -91,7 +91,7 @@ public:
CreateStagingTexture(StagingTextureType type, const TextureConfig& config) override; CreateStagingTexture(StagingTextureType type, const TextureConfig& config) override;
void SetBlendingState(const BlendingState& state) override; void SetBlendingState(const BlendingState& state) override;
void SetScissorRect(const EFBRectangle& rc) override; void SetScissorRect(const MathUtil::Rectangle<int>& rc) override;
void SetRasterizationState(const RasterizationState& state) override; void SetRasterizationState(const RasterizationState& state) override;
void SetDepthState(const DepthState& state) override; void SetDepthState(const DepthState& state) override;
void SetTexture(u32 index, const AbstractTexture* texture) override; void SetTexture(u32 index, const AbstractTexture* texture) override;

View File

@ -899,14 +899,10 @@ void Renderer::SetInterlacingMode()
{ {
} }
void Renderer::SetScissorRect(const EFBRectangle& rc) void Renderer::SetScissorRect(const MathUtil::Rectangle<int>& rc)
{ {
TargetRectangle target_rc = ConvertEFBRectangle(rc); VkRect2D scissor = {{rc.left, rc.top},
{static_cast<u32>(rc.GetWidth()), static_cast<u32>(rc.GetHeight())}};
VkRect2D scissor = {
{target_rc.left, target_rc.top},
{static_cast<uint32_t>(target_rc.GetWidth()), static_cast<uint32_t>(target_rc.GetHeight())}};
StateTracker::GetInstance()->SetScissor(scissor); StateTracker::GetInstance()->SetScissor(scissor);
} }

View File

@ -60,7 +60,7 @@ public:
void RestoreAPIState() override; void RestoreAPIState() override;
void SetBlendingState(const BlendingState& state) override; void SetBlendingState(const BlendingState& state) override;
void SetScissorRect(const EFBRectangle& rc) override; void SetScissorRect(const MathUtil::Rectangle<int>& rc) override;
void SetRasterizationState(const RasterizationState& state) override; void SetRasterizationState(const RasterizationState& state) override;
void SetDepthState(const DepthState& state) override; void SetDepthState(const DepthState& state) override;
void SetTexture(u32 index, const AbstractTexture* texture) override; void SetTexture(u32 index, const AbstractTexture* texture) override;

View File

@ -49,24 +49,12 @@ void SetScissor()
const int xoff = bpmem.scissorOffset.x * 2; const int xoff = bpmem.scissorOffset.x * 2;
const int yoff = bpmem.scissorOffset.y * 2; const int yoff = bpmem.scissorOffset.y * 2;
EFBRectangle rc(bpmem.scissorTL.x - xoff, bpmem.scissorTL.y - yoff, bpmem.scissorBR.x - xoff + 1, EFBRectangle native_rc(bpmem.scissorTL.x - xoff, bpmem.scissorTL.y - yoff,
bpmem.scissorBR.y - yoff + 1); bpmem.scissorBR.x - xoff + 1, bpmem.scissorBR.y - yoff + 1);
native_rc.ClampUL(0, 0, EFB_WIDTH, EFB_HEIGHT);
if (rc.left < 0) TargetRectangle target_rc = g_renderer->ConvertEFBRectangle(native_rc);
rc.left = 0; g_renderer->SetScissorRect(target_rc);
if (rc.top < 0)
rc.top = 0;
if (rc.right > EFB_WIDTH)
rc.right = EFB_WIDTH;
if (rc.bottom > EFB_HEIGHT)
rc.bottom = EFB_HEIGHT;
if (rc.left > rc.right)
rc.right = rc.left;
if (rc.top > rc.bottom)
rc.bottom = rc.top;
g_renderer->SetScissorRect(rc);
} }
void SetViewport() void SetViewport()

View File

@ -70,7 +70,7 @@ public:
}; };
virtual void SetBlendingState(const BlendingState& state) {} virtual void SetBlendingState(const BlendingState& state) {}
virtual void SetScissorRect(const EFBRectangle& rc) {} virtual void SetScissorRect(const MathUtil::Rectangle<int>& rc) {}
virtual void SetRasterizationState(const RasterizationState& state) {} virtual void SetRasterizationState(const RasterizationState& state) {}
virtual void SetDepthState(const DepthState& state) {} virtual void SetDepthState(const DepthState& state) {}
virtual void SetTexture(u32 index, const AbstractTexture* texture) {} virtual void SetTexture(u32 index, const AbstractTexture* texture) {}