Merge pull request #6316 from stenzek/videocommon-viewport

Move guest viewport conversion to VideoCommon
This commit is contained in:
Stenzek 2018-02-20 01:01:06 +10:00 committed by GitHub
commit 456c2f42c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 126 additions and 207 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.
@ -445,59 +445,17 @@ void Renderer::PokeEFB(EFBAccessType type, const EfbPokeData* points, size_t num
RestoreAPIState(); RestoreAPIState();
} }
void Renderer::SetViewport() void Renderer::SetViewport(float x, float y, float width, float height, float near_depth,
float far_depth)
{ {
// reversed gxsetviewport(xorig, yorig, width, height, nearz, farz)
// [0] = width/2
// [1] = height/2
// [2] = 16777215 * (farz - nearz)
// [3] = xorig + width/2 + 342
// [4] = yorig + height/2 + 342
// [5] = 16777215 * farz
// D3D crashes for zero viewports
if (xfmem.viewport.wd == 0 || xfmem.viewport.ht == 0)
return;
int scissorXOff = bpmem.scissorOffset.x * 2;
int scissorYOff = bpmem.scissorOffset.y * 2;
float X = Renderer::EFBToScaledXf(xfmem.viewport.xOrig - xfmem.viewport.wd - scissorXOff);
float Y = Renderer::EFBToScaledYf(xfmem.viewport.yOrig + xfmem.viewport.ht - scissorYOff);
float Wd = Renderer::EFBToScaledXf(2.0f * xfmem.viewport.wd);
float Ht = Renderer::EFBToScaledYf(-2.0f * xfmem.viewport.ht);
float min_depth = (xfmem.viewport.farZ - xfmem.viewport.zRange) / 16777216.0f;
float max_depth = xfmem.viewport.farZ / 16777216.0f;
if (Wd < 0.0f)
{
X += Wd;
Wd = -Wd;
}
if (Ht < 0.0f)
{
Y += Ht;
Ht = -Ht;
}
// If an inverted or oversized depth range is used, we need to calculate the depth range in the
// vertex shader.
if (UseVertexDepthRange())
{
// We need to ensure depth values are clamped the maximum value supported by the console GPU.
min_depth = 0.0f;
max_depth = GX_MAX_DEPTH;
}
// In D3D, the viewport rectangle must fit within the render target. // In D3D, the viewport rectangle must fit within the render target.
X = (X >= 0.f) ? X : 0.f; D3D11_VIEWPORT vp;
Y = (Y >= 0.f) ? Y : 0.f; vp.TopLeftX = MathUtil::Clamp(x, 0.0f, static_cast<float>(m_target_width - 1));
Wd = (X + Wd <= GetTargetWidth()) ? Wd : (GetTargetWidth() - X); vp.TopLeftY = MathUtil::Clamp(y, 0.0f, static_cast<float>(m_target_height - 1));
Ht = (Y + Ht <= GetTargetHeight()) ? Ht : (GetTargetHeight() - Y); vp.Width = MathUtil::Clamp(width, 1.0f, static_cast<float>(m_target_width) - vp.TopLeftX);
vp.Height = MathUtil::Clamp(height, 1.0f, static_cast<float>(m_target_height) - vp.TopLeftY);
// We use an inverted depth range here to apply the Reverse Z trick. vp.MinDepth = near_depth;
// This trick makes sure we match the precision provided by the 1:0 vp.MaxDepth = far_depth;
// clipping depth range on the hardware.
D3D11_VIEWPORT vp = CD3D11_VIEWPORT(X, Y, Wd, Ht, 1.0f - max_depth, 1.0f - min_depth);
D3D::context->RSSetViewports(1, &vp); D3D::context->RSSetViewports(1, &vp);
} }
@ -673,7 +631,6 @@ void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region
// begin next frame // begin next frame
RestoreAPIState(); RestoreAPIState();
FramebufferManager::BindEFBRenderTarget(); FramebufferManager::BindEFBRenderTarget();
SetViewport();
} }
// ALWAYS call RestoreAPIState for each ResetAPIState call you're doing // ALWAYS call RestoreAPIState for each ResetAPIState call you're doing
@ -690,7 +647,7 @@ void Renderer::RestoreAPIState()
D3D::stateman->PopBlendState(); D3D::stateman->PopBlendState();
D3D::stateman->PopDepthState(); D3D::stateman->PopDepthState();
D3D::stateman->PopRasterizerState(); D3D::stateman->PopRasterizerState();
SetViewport(); BPFunctions::SetViewport();
BPFunctions::SetScissor(); BPFunctions::SetScissor();
} }

View File

@ -27,14 +27,15 @@ 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;
void SetSamplerState(u32 index, const SamplerState& state) override; void SetSamplerState(u32 index, const SamplerState& state) override;
void UnbindTexture(const AbstractTexture* texture) override; void UnbindTexture(const AbstractTexture* texture) override;
void SetInterlacingMode() override; void SetInterlacingMode() override;
void SetViewport() override; void SetViewport(float x, float y, float width, float height, float near_depth,
float far_depth) override;
void SetFullscreen(bool enable_fullscreen) override; void SetFullscreen(bool enable_fullscreen) override;
bool IsFullscreen() const override; bool IsFullscreen() const 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()
@ -1136,75 +1125,23 @@ void Renderer::BBoxWrite(int index, u16 _value)
BoundingBox::Set(index, value); BoundingBox::Set(index, value);
} }
void Renderer::SetViewport() void Renderer::SetViewport(float x, float y, float width, float height, float near_depth,
float far_depth)
{ {
// reversed gxsetviewport(xorig, yorig, width, height, nearz, farz) // The x/y parameters here assume a upper-left origin. glViewport takes an offset from the
// [0] = width/2 // lower-left of the framebuffer, so we must set y to the distance from the lower-left.
// [1] = height/2 y = static_cast<float>(m_target_height) - y - height;
// [2] = 16777215 * (farz - nearz)
// [3] = xorig + width/2 + 342
// [4] = yorig + height/2 + 342
// [5] = 16777215 * farz
int scissorXOff = bpmem.scissorOffset.x * 2;
int scissorYOff = bpmem.scissorOffset.y * 2;
// TODO: ceil, floor or just cast to int?
float X = EFBToScaledXf(xfmem.viewport.xOrig - xfmem.viewport.wd - (float)scissorXOff);
float Y = EFBToScaledYf((float)EFB_HEIGHT - xfmem.viewport.yOrig + xfmem.viewport.ht +
(float)scissorYOff);
float Width = EFBToScaledXf(2.0f * xfmem.viewport.wd);
float Height = EFBToScaledYf(-2.0f * xfmem.viewport.ht);
float min_depth = (xfmem.viewport.farZ - xfmem.viewport.zRange) / 16777216.0f;
float max_depth = xfmem.viewport.farZ / 16777216.0f;
if (Width < 0)
{
X += Width;
Width *= -1;
}
if (Height < 0)
{
Y += Height;
Height *= -1;
}
// Update the view port
if (g_ogl_config.bSupportViewportFloat) if (g_ogl_config.bSupportViewportFloat)
{ {
glViewportIndexedf(0, X, Y, Width, Height); glViewportIndexedf(0, x, y, width, height);
} }
else else
{ {
auto iceilf = [](float f) { return static_cast<GLint>(ceilf(f)); }; auto iceilf = [](float f) { return static_cast<GLint>(std::ceil(f)); };
glViewport(iceilf(X), iceilf(Y), iceilf(Width), iceilf(Height)); glViewport(iceilf(x), iceilf(y), iceilf(width), iceilf(height));
} }
if (!g_ActiveConfig.backend_info.bSupportsDepthClamp) glDepthRangef(near_depth, far_depth);
{
// There's no way to support oversized depth ranges in this situation. Let's just clamp the
// range to the maximum value supported by the console GPU and hope for the best.
min_depth = MathUtil::Clamp(min_depth, 0.0f, GX_MAX_DEPTH);
max_depth = MathUtil::Clamp(max_depth, 0.0f, GX_MAX_DEPTH);
}
if (UseVertexDepthRange())
{
// We need to ensure depth values are clamped the maximum value supported by the console GPU.
// Taking into account whether the depth range is inverted or not.
if (xfmem.viewport.zRange < 0.0f)
{
min_depth = GX_MAX_DEPTH;
max_depth = 0.0f;
}
else
{
min_depth = 0.0f;
max_depth = GX_MAX_DEPTH;
}
}
// Set the reversed depth range.
glDepthRangef(max_depth, min_depth);
} }
void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable,
@ -1563,9 +1500,9 @@ void Renderer::RestoreAPIState()
} }
BPFunctions::SetGenerationMode(); BPFunctions::SetGenerationMode();
BPFunctions::SetScissor(); BPFunctions::SetScissor();
BPFunctions::SetViewport();
BPFunctions::SetDepthMode(); BPFunctions::SetDepthMode();
BPFunctions::SetBlendMode(); BPFunctions::SetBlendMode();
SetViewport();
ProgramShaderCache::BindLastVertexFormat(); ProgramShaderCache::BindLastVertexFormat();
const VertexManager* const vm = static_cast<VertexManager*>(g_vertex_manager.get()); const VertexManager* const vm = static_cast<VertexManager*>(g_vertex_manager.get());

View File

@ -91,14 +91,15 @@ 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;
void SetSamplerState(u32 index, const SamplerState& state) override; void SetSamplerState(u32 index, const SamplerState& state) override;
void UnbindTexture(const AbstractTexture* texture) override; void UnbindTexture(const AbstractTexture* texture) override;
void SetInterlacingMode() override; void SetInterlacingMode() override;
void SetViewport() override; void SetViewport(float x, float y, float width, float height, float near_depth,
float far_depth) override;
void RenderText(const std::string& text, int left, int top, u32 color) override; void RenderText(const std::string& text, int left, int top, u32 color) override;

View File

@ -810,7 +810,7 @@ void Renderer::RecreateEFBFramebuffer()
BindEFBToStateTracker(); BindEFBToStateTracker();
// Viewport and scissor rect have to be reset since they will be scaled differently. // Viewport and scissor rect have to be reset since they will be scaled differently.
SetViewport(); BPFunctions::SetViewport();
BPFunctions::SetScissor(); BPFunctions::SetScissor();
} }
@ -899,53 +899,18 @@ 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);
} }
void Renderer::SetViewport() void Renderer::SetViewport(float x, float y, float width, float height, float near_depth,
float far_depth)
{ {
int scissor_x_offset = bpmem.scissorOffset.x * 2; VkViewport viewport = {x, y, std::max(width, 1.0f), std::max(height, 1.0f),
int scissor_y_offset = bpmem.scissorOffset.y * 2; near_depth, far_depth};
float x = Renderer::EFBToScaledXf(xfmem.viewport.xOrig - xfmem.viewport.wd - scissor_x_offset);
float y = Renderer::EFBToScaledYf(xfmem.viewport.yOrig + xfmem.viewport.ht - scissor_y_offset);
float width = Renderer::EFBToScaledXf(2.0f * xfmem.viewport.wd);
float height = Renderer::EFBToScaledYf(-2.0f * xfmem.viewport.ht);
float min_depth = (xfmem.viewport.farZ - xfmem.viewport.zRange) / 16777216.0f;
float max_depth = xfmem.viewport.farZ / 16777216.0f;
if (width < 0.0f)
{
x += width;
width = -width;
}
if (height < 0.0f)
{
y += height;
height = -height;
}
// If an oversized or inverted depth range is used, we need to calculate the depth range in the
// vertex shader.
// TODO: Inverted depth ranges are bugged in all drivers, which should be added to DriverDetails.
if (UseVertexDepthRange())
{
// We need to ensure depth values are clamped the maximum value supported by the console GPU.
min_depth = 0.0f;
max_depth = GX_MAX_DEPTH;
}
// We use an inverted depth range here to apply the Reverse Z trick.
// This trick makes sure we match the precision provided by the 1:0
// clipping depth range on the hardware.
VkViewport viewport = {x, y, width, height, 1.0f - max_depth, 1.0f - min_depth};
StateTracker::GetInstance()->SetViewport(viewport); StateTracker::GetInstance()->SetViewport(viewport);
} }

View File

@ -60,14 +60,15 @@ 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;
void SetSamplerState(u32 index, const SamplerState& state) override; void SetSamplerState(u32 index, const SamplerState& state) override;
void UnbindTexture(const AbstractTexture* texture) override; void UnbindTexture(const AbstractTexture* texture) override;
void SetInterlacingMode() override; void SetInterlacingMode() override;
void SetViewport() override; void SetViewport(float x, float y, float width, float height, float near_depth,
float far_depth) override;
void ChangeSurface(void* new_surface_handle) override; void ChangeSurface(void* new_surface_handle) override;

View File

@ -12,6 +12,7 @@
#include "VideoCommon/VertexManagerBase.h" #include "VideoCommon/VertexManagerBase.h"
#include "VideoCommon/VideoCommon.h" #include "VideoCommon/VideoCommon.h"
#include "VideoCommon/VideoConfig.h" #include "VideoCommon/VideoConfig.h"
#include "VideoCommon/XFMemory.h"
namespace BPFunctions namespace BPFunctions
{ {
@ -48,24 +49,82 @@ 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) void SetViewport()
rc.right = rc.left; {
if (rc.top > rc.bottom) int scissor_x_off = bpmem.scissorOffset.x * 2;
rc.bottom = rc.top; int scissor_y_off = bpmem.scissorOffset.y * 2;
float x = g_renderer->EFBToScaledXf(xfmem.viewport.xOrig - xfmem.viewport.wd - scissor_x_off);
float y = g_renderer->EFBToScaledYf(xfmem.viewport.yOrig + xfmem.viewport.ht - scissor_y_off);
g_renderer->SetScissorRect(rc); float width = g_renderer->EFBToScaledXf(2.0f * xfmem.viewport.wd);
float height = g_renderer->EFBToScaledYf(-2.0f * xfmem.viewport.ht);
float min_depth = (xfmem.viewport.farZ - xfmem.viewport.zRange) / 16777216.0f;
float max_depth = xfmem.viewport.farZ / 16777216.0f;
if (width < 0.f)
{
x += width;
width *= -1;
}
if (height < 0.f)
{
y += height;
height *= -1;
}
// The maximum depth that is written to the depth buffer should never exceed this value.
// This is necessary because we use a 2^24 divisor for all our depth values to prevent
// floating-point round-trip errors. However the console GPU doesn't ever write a value
// to the depth buffer that exceeds 2^24 - 1.
constexpr float GX_MAX_DEPTH = 16777215.0f / 16777216.0f;
if (!g_ActiveConfig.backend_info.bSupportsDepthClamp)
{
// There's no way to support oversized depth ranges in this situation. Let's just clamp the
// range to the maximum value supported by the console GPU and hope for the best.
min_depth = MathUtil::Clamp(min_depth, 0.0f, GX_MAX_DEPTH);
max_depth = MathUtil::Clamp(max_depth, 0.0f, GX_MAX_DEPTH);
}
if (g_renderer->UseVertexDepthRange())
{
// We need to ensure depth values are clamped the maximum value supported by the console GPU.
// Taking into account whether the depth range is inverted or not.
if (xfmem.viewport.zRange < 0.0f && g_ActiveConfig.backend_info.bSupportsReversedDepthRange)
{
min_depth = GX_MAX_DEPTH;
max_depth = 0.0f;
}
else
{
min_depth = 0.0f;
max_depth = GX_MAX_DEPTH;
}
}
float near_depth, far_depth;
if (g_ActiveConfig.backend_info.bSupportsReversedDepthRange)
{
// Set the reversed depth range.
near_depth = max_depth;
far_depth = min_depth;
}
else
{
// We use an inverted depth range here to apply the Reverse Z trick.
// This trick makes sure we match the precision provided by the 1:0
// clipping depth range on the hardware.
near_depth = 1.0f - max_depth;
far_depth = 1.0f - min_depth;
}
g_renderer->SetViewport(x, y, width, height, near_depth, far_depth);
} }
void SetDepthMode() void SetDepthMode()

View File

@ -17,6 +17,7 @@ namespace BPFunctions
void FlushPipeline(); void FlushPipeline();
void SetGenerationMode(); void SetGenerationMode();
void SetScissor(); void SetScissor();
void SetViewport();
void SetDepthMode(); void SetDepthMode();
void SetBlendMode(); void SetBlendMode();
void ClearScreen(const EFBRectangle& rc); void ClearScreen(const EFBRectangle& rc);

View File

@ -130,6 +130,7 @@ static void BPWritten(const BPCmd& bp)
case BPMEM_SCISSORBR: // Scissor Rectable Bottom, Right case BPMEM_SCISSORBR: // Scissor Rectable Bottom, Right
case BPMEM_SCISSOROFFSET: // Scissor Offset case BPMEM_SCISSOROFFSET: // Scissor Offset
SetScissor(); SetScissor();
SetViewport();
VertexShaderManager::SetViewportChanged(); VertexShaderManager::SetViewportChanged();
GeometryShaderManager::SetViewportChanged(); GeometryShaderManager::SetViewportChanged();
return; return;
@ -1415,6 +1416,7 @@ void BPReload()
// note that PixelShaderManager is already covered since it has its own DoState. // note that PixelShaderManager is already covered since it has its own DoState.
SetGenerationMode(); SetGenerationMode();
SetScissor(); SetScissor();
SetViewport();
SetDepthMode(); SetDepthMode();
SetBlendMode(); SetBlendMode();
OnPixelFormatChange(); OnPixelFormatChange();

View File

@ -71,12 +71,6 @@ static int OSDTime;
std::unique_ptr<Renderer> g_renderer; std::unique_ptr<Renderer> g_renderer;
// The maximum depth that is written to the depth buffer should never exceed this value.
// This is necessary because we use a 2^24 divisor for all our depth values to prevent
// floating-point round-trip errors. However the console GPU doesn't ever write a value
// to the depth buffer that exceeds 2^24 - 1.
const float Renderer::GX_MAX_DEPTH = 16777215.0f / 16777216.0f;
static float AspectToWidescreen(float aspect) static float AspectToWidescreen(float aspect)
{ {
return aspect * ((16.0f / 9.0f) / (4.0f / 3.0f)); return aspect * ((16.0f / 9.0f) / (4.0f / 3.0f));

View File

@ -70,14 +70,17 @@ 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) {}
virtual void SetSamplerState(u32 index, const SamplerState& state) {} virtual void SetSamplerState(u32 index, const SamplerState& state) {}
virtual void UnbindTexture(const AbstractTexture* texture) {} virtual void UnbindTexture(const AbstractTexture* texture) {}
virtual void SetInterlacingMode() {} virtual void SetInterlacingMode() {}
virtual void SetViewport() {} virtual void SetViewport(float x, float y, float width, float height, float near_depth,
float far_depth)
{
}
virtual void SetFullscreen(bool enable_fullscreen) {} virtual void SetFullscreen(bool enable_fullscreen) {}
virtual bool IsFullscreen() const { return false; } virtual bool IsFullscreen() const { return false; }
virtual void ApplyState() {} virtual void ApplyState() {}
@ -184,8 +187,6 @@ protected:
std::unique_ptr<PostProcessingShaderImplementation> m_post_processor; std::unique_ptr<PostProcessingShaderImplementation> m_post_processor;
static const float GX_MAX_DEPTH;
void* m_surface_handle = nullptr; void* m_surface_handle = nullptr;
void* m_new_surface_handle = nullptr; void* m_new_surface_handle = nullptr;
Common::Flag m_surface_needs_change; Common::Flag m_surface_needs_change;

View File

@ -16,6 +16,7 @@
#include "Common/MathUtil.h" #include "Common/MathUtil.h"
#include "Core/ConfigManager.h" #include "Core/ConfigManager.h"
#include "Core/Core.h" #include "Core/Core.h"
#include "VideoCommon/BPFunctions.h"
#include "VideoCommon/BPMemory.h" #include "VideoCommon/BPMemory.h"
#include "VideoCommon/CPMemory.h" #include "VideoCommon/CPMemory.h"
#include "VideoCommon/RenderBase.h" #include "VideoCommon/RenderBase.h"
@ -420,8 +421,7 @@ void VertexShaderManager::SetConstants()
} }
dirty = true; dirty = true;
// This is so implementation-dependent that we can't have it here. BPFunctions::SetViewport();
g_renderer->SetViewport();
// Update projection if the viewport isn't 1:1 useable // Update projection if the viewport isn't 1:1 useable
if (!g_ActiveConfig.backend_info.bSupportsOversizedViewports) if (!g_ActiveConfig.backend_info.bSupportsOversizedViewports)