mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-22 15:40:02 +00:00
Replace EFBRectangle/TargetRectangle with MathUtil::Rectangle
This commit is contained in:
parent
6ea43235d5
commit
f8c1ba409c
@ -327,7 +327,7 @@ void Renderer::WaitForGPUIdle()
|
|||||||
D3D::context->Flush();
|
D3D::context->Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::RenderXFBToScreen(const AbstractTexture* texture, const EFBRectangle& rc)
|
void Renderer::RenderXFBToScreen(const AbstractTexture* texture, const MathUtil::Rectangle<int>& rc)
|
||||||
{
|
{
|
||||||
if (g_ActiveConfig.stereo_mode != StereoMode::Nvidia3DVision)
|
if (g_ActiveConfig.stereo_mode != StereoMode::Nvidia3DVision)
|
||||||
return ::Renderer::RenderXFBToScreen(texture, rc);
|
return ::Renderer::RenderXFBToScreen(texture, rc);
|
||||||
|
@ -67,7 +67,8 @@ public:
|
|||||||
void Flush() override;
|
void Flush() override;
|
||||||
void WaitForGPUIdle() override;
|
void WaitForGPUIdle() override;
|
||||||
|
|
||||||
void RenderXFBToScreen(const AbstractTexture* texture, const EFBRectangle& rc) override;
|
void RenderXFBToScreen(const AbstractTexture* texture,
|
||||||
|
const MathUtil::Rectangle<int>& rc) override;
|
||||||
void OnConfigChanged(u32 bits) override;
|
void OnConfigChanged(u32 bits) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -132,7 +132,7 @@ void Renderer::WaitForGPUIdle()
|
|||||||
ExecuteCommandList(true);
|
ExecuteCommandList(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::ClearScreen(const EFBRectangle& rc, bool color_enable, bool alpha_enable,
|
void Renderer::ClearScreen(const MathUtil::Rectangle<int>& rc, bool color_enable, bool alpha_enable,
|
||||||
bool z_enable, u32 color, u32 z)
|
bool z_enable, u32 color, u32 z)
|
||||||
{
|
{
|
||||||
// Use a fast path without the shader if both color/alpha are enabled.
|
// Use a fast path without the shader if both color/alpha are enabled.
|
||||||
|
@ -52,8 +52,8 @@ public:
|
|||||||
void Flush() override;
|
void Flush() override;
|
||||||
void WaitForGPUIdle() override;
|
void WaitForGPUIdle() override;
|
||||||
|
|
||||||
void ClearScreen(const EFBRectangle& rc, bool color_enable, bool alpha_enable, bool z_enable,
|
void ClearScreen(const MathUtil::Rectangle<int>& rc, bool color_enable, bool alpha_enable,
|
||||||
u32 color, u32 z) override;
|
bool z_enable, u32 color, u32 z) override;
|
||||||
|
|
||||||
void SetPipeline(const AbstractPipeline* pipeline) override;
|
void SetPipeline(const AbstractPipeline* pipeline) override;
|
||||||
void SetFramebuffer(AbstractFramebuffer* framebuffer) override;
|
void SetFramebuffer(AbstractFramebuffer* framebuffer) override;
|
||||||
|
@ -37,8 +37,8 @@ public:
|
|||||||
u16 BBoxRead(int index) override { return 0; }
|
u16 BBoxRead(int index) override { return 0; }
|
||||||
void BBoxWrite(int index, u16 value) override {}
|
void BBoxWrite(int index, u16 value) override {}
|
||||||
|
|
||||||
void ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable,
|
void ClearScreen(const MathUtil::Rectangle<int>& rc, bool colorEnable, bool alphaEnable,
|
||||||
u32 color, u32 z) override
|
bool zEnable, u32 color, u32 z) override
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,15 +21,17 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void CopyEFB(AbstractStagingTexture* dst, const EFBCopyParams& params, u32 native_width,
|
void CopyEFB(AbstractStagingTexture* dst, const EFBCopyParams& params, u32 native_width,
|
||||||
u32 bytes_per_row, u32 num_blocks_y, u32 memory_stride, const EFBRectangle& src_rect,
|
u32 bytes_per_row, u32 num_blocks_y, u32 memory_stride,
|
||||||
bool scale_by_half, bool linear_filter, float y_scale, float gamma, bool clamp_top,
|
const MathUtil::Rectangle<int>& src_rect, bool scale_by_half, bool linear_filter,
|
||||||
bool clamp_bottom, const EFBCopyFilterCoefficients& filter_coefficients) override
|
float y_scale, float gamma, bool clamp_top, bool clamp_bottom,
|
||||||
|
const EFBCopyFilterCoefficients& filter_coefficients) override
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopyEFBToCacheEntry(TCacheEntry* entry, bool is_depth_copy, const EFBRectangle& src_rect,
|
void CopyEFBToCacheEntry(TCacheEntry* entry, bool is_depth_copy,
|
||||||
bool scale_by_half, bool linear_filter, EFBCopyFormat dst_format,
|
const MathUtil::Rectangle<int>& src_rect, bool scale_by_half,
|
||||||
bool is_intensity, float gamma, bool clamp_top, bool clamp_bottom,
|
bool linear_filter, EFBCopyFormat dst_format, bool is_intensity,
|
||||||
|
float gamma, bool clamp_top, bool clamp_bottom,
|
||||||
const EFBCopyFilterCoefficients& filter_coefficients) override
|
const EFBCopyFilterCoefficients& filter_coefficients) override
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -932,8 +932,8 @@ void Renderer::DispatchComputeShader(const AbstractShader* shader, u32 groups_x,
|
|||||||
glMemoryBarrier(GL_TEXTURE_UPDATE_BARRIER_BIT);
|
glMemoryBarrier(GL_TEXTURE_UPDATE_BARRIER_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable,
|
void Renderer::ClearScreen(const MathUtil::Rectangle<int>& rc, bool colorEnable, bool alphaEnable,
|
||||||
u32 color, u32 z)
|
bool zEnable, u32 color, u32 z)
|
||||||
{
|
{
|
||||||
g_framebuffer_manager->FlushEFBPokes();
|
g_framebuffer_manager->FlushEFBPokes();
|
||||||
g_framebuffer_manager->FlagPeekCacheAsOutOfDate();
|
g_framebuffer_manager->FlagPeekCacheAsOutOfDate();
|
||||||
@ -974,7 +974,7 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaE
|
|||||||
BPFunctions::SetScissor();
|
BPFunctions::SetScissor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::RenderXFBToScreen(const AbstractTexture* texture, const EFBRectangle& rc)
|
void Renderer::RenderXFBToScreen(const AbstractTexture* texture, const MathUtil::Rectangle<int>& rc)
|
||||||
{
|
{
|
||||||
// Quad-buffered stereo is annoying on GL.
|
// Quad-buffered stereo is annoying on GL.
|
||||||
if (g_ActiveConfig.stereo_mode != StereoMode::QuadBuffer)
|
if (g_ActiveConfig.stereo_mode != StereoMode::QuadBuffer)
|
||||||
|
@ -134,11 +134,12 @@ public:
|
|||||||
|
|
||||||
void Flush() override;
|
void Flush() override;
|
||||||
void WaitForGPUIdle() override;
|
void WaitForGPUIdle() override;
|
||||||
void RenderXFBToScreen(const AbstractTexture* texture, const EFBRectangle& rc) override;
|
void RenderXFBToScreen(const AbstractTexture* texture,
|
||||||
|
const MathUtil::Rectangle<int>& rc) override;
|
||||||
void OnConfigChanged(u32 bits) override;
|
void OnConfigChanged(u32 bits) override;
|
||||||
|
|
||||||
void ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable,
|
void ClearScreen(const MathUtil::Rectangle<int>& rc, bool colorEnable, bool alphaEnable,
|
||||||
u32 color, u32 z) override;
|
bool zEnable, u32 color, u32 z) override;
|
||||||
|
|
||||||
std::unique_ptr<VideoCommon::AsyncShaderCompiler> CreateAsyncShaderCompiler() override;
|
std::unique_ptr<VideoCommon::AsyncShaderCompiler> CreateAsyncShaderCompiler() override;
|
||||||
|
|
||||||
|
@ -549,8 +549,8 @@ u8* GetPixelPointer(u16 x, u16 y, bool depth)
|
|||||||
return &efb[GetColorOffset(x, y)];
|
return &efb[GetColorOffset(x, y)];
|
||||||
}
|
}
|
||||||
|
|
||||||
void EncodeXFB(u8* xfb_in_ram, u32 memory_stride, const EFBRectangle& source_rect, float y_scale,
|
void EncodeXFB(u8* xfb_in_ram, u32 memory_stride, const MathUtil::Rectangle<int>& source_rect,
|
||||||
float gamma)
|
float y_scale, float gamma)
|
||||||
{
|
{
|
||||||
if (!xfb_in_ram)
|
if (!xfb_in_ram)
|
||||||
{
|
{
|
||||||
@ -628,8 +628,9 @@ void EncodeXFB(u8* xfb_in_ram, u32 memory_stride, const EFBRectangle& source_rec
|
|||||||
src_ptr += memory_stride;
|
src_ptr += memory_stride;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto dest_rect = EFBRectangle{source_rect.left, source_rect.top, source_rect.right,
|
auto dest_rect =
|
||||||
static_cast<int>(static_cast<float>(source_rect.bottom) * y_scale)};
|
MathUtil::Rectangle<int>{source_rect.left, source_rect.top, source_rect.right,
|
||||||
|
static_cast<int>(static_cast<float>(source_rect.bottom) * y_scale)};
|
||||||
|
|
||||||
const std::size_t destination_size = dest_rect.GetWidth() * dest_rect.GetHeight() * 2;
|
const std::size_t destination_size = dest_rect.GetWidth() * dest_rect.GetHeight() * 2;
|
||||||
static std::vector<yuv422_packed> destination;
|
static std::vector<yuv422_packed> destination;
|
||||||
|
@ -54,8 +54,8 @@ u32 GetDepth(u16 x, u16 y);
|
|||||||
|
|
||||||
u8* GetPixelPointer(u16 x, u16 y, bool depth);
|
u8* GetPixelPointer(u16 x, u16 y, bool depth);
|
||||||
|
|
||||||
void EncodeXFB(u8* xfb_in_ram, u32 memory_stride, const EFBRectangle& source_rect, float y_scale,
|
void EncodeXFB(u8* xfb_in_ram, u32 memory_stride, const MathUtil::Rectangle<int>& source_rect,
|
||||||
float gamma);
|
float y_scale, float gamma);
|
||||||
|
|
||||||
u32 GetPerfQueryResult(PerfQueryType type);
|
u32 GetPerfQueryResult(PerfQueryType type);
|
||||||
void ResetPerfQuery();
|
void ResetPerfQuery();
|
||||||
|
@ -84,7 +84,8 @@ bool SWOGLWindow::Initialize(const WindowSystemInfo& wsi)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SWOGLWindow::ShowImage(const AbstractTexture* image, const EFBRectangle& xfb_region)
|
void SWOGLWindow::ShowImage(const AbstractTexture* image,
|
||||||
|
const MathUtil::Rectangle<int>& xfb_region)
|
||||||
{
|
{
|
||||||
const SW::SWTexture* sw_image = static_cast<const SW::SWTexture*>(image);
|
const SW::SWTexture* sw_image = static_cast<const SW::SWTexture*>(image);
|
||||||
m_gl_context->Update(); // just updates the render window position and the backbuffer size
|
m_gl_context->Update(); // just updates the render window position and the backbuffer size
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
bool IsHeadless() const;
|
bool IsHeadless() const;
|
||||||
|
|
||||||
// Image to show, will be swapped immediately
|
// Image to show, will be swapped immediately
|
||||||
void ShowImage(const AbstractTexture* image, const EFBRectangle& xfb_region);
|
void ShowImage(const AbstractTexture* image, const MathUtil::Rectangle<int>& xfb_region);
|
||||||
|
|
||||||
static std::unique_ptr<SWOGLWindow> Create(const WindowSystemInfo& wsi);
|
static std::unique_ptr<SWOGLWindow> Create(const WindowSystemInfo& wsi);
|
||||||
|
|
||||||
|
@ -94,7 +94,8 @@ std::unique_ptr<AbstractPipeline> SWRenderer::CreatePipeline(const AbstractPipel
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Called on the GPU thread
|
// Called on the GPU thread
|
||||||
void SWRenderer::RenderXFBToScreen(const AbstractTexture* texture, const EFBRectangle& xfb_region)
|
void SWRenderer::RenderXFBToScreen(const AbstractTexture* texture,
|
||||||
|
const MathUtil::Rectangle<int>& xfb_region)
|
||||||
{
|
{
|
||||||
if (!IsHeadless())
|
if (!IsHeadless())
|
||||||
m_window->ShowImage(texture, xfb_region);
|
m_window->ShowImage(texture, xfb_region);
|
||||||
@ -136,7 +137,7 @@ void SWRenderer::BBoxWrite(int index, u16 value)
|
|||||||
BoundingBox::coords[index] = value;
|
BoundingBox::coords[index] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SWRenderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable,
|
void SWRenderer::ClearScreen(const MathUtil::Rectangle<int>& rc, bool colorEnable, bool alphaEnable,
|
||||||
bool zEnable, u32 color, u32 z)
|
bool zEnable, u32 color, u32 z)
|
||||||
{
|
{
|
||||||
EfbCopy::ClearEfb();
|
EfbCopy::ClearEfb();
|
||||||
|
@ -42,10 +42,11 @@ public:
|
|||||||
u16 BBoxRead(int index) override;
|
u16 BBoxRead(int index) override;
|
||||||
void BBoxWrite(int index, u16 value) override;
|
void BBoxWrite(int index, u16 value) override;
|
||||||
|
|
||||||
void RenderXFBToScreen(const AbstractTexture* texture, const EFBRectangle& rc) override;
|
void RenderXFBToScreen(const AbstractTexture* texture,
|
||||||
|
const MathUtil::Rectangle<int>& rc) override;
|
||||||
|
|
||||||
void ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable,
|
void ClearScreen(const MathUtil::Rectangle<int>& rc, bool colorEnable, bool alphaEnable,
|
||||||
u32 color, u32 z) override;
|
bool zEnable, u32 color, u32 z) override;
|
||||||
|
|
||||||
void ReinterpretPixelData(EFBReinterpretType convtype) override {}
|
void ReinterpretPixelData(EFBReinterpretType convtype) override {}
|
||||||
|
|
||||||
|
@ -11,16 +11,18 @@ class TextureCache : public TextureCacheBase
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
void CopyEFB(AbstractStagingTexture* dst, const EFBCopyParams& params, u32 native_width,
|
void CopyEFB(AbstractStagingTexture* dst, const EFBCopyParams& params, u32 native_width,
|
||||||
u32 bytes_per_row, u32 num_blocks_y, u32 memory_stride, const EFBRectangle& src_rect,
|
u32 bytes_per_row, u32 num_blocks_y, u32 memory_stride,
|
||||||
bool scale_by_half, bool linear_filter, float y_scale, float gamma, bool clamp_top,
|
const MathUtil::Rectangle<int>& src_rect, bool scale_by_half, bool linear_filter,
|
||||||
bool clamp_bottom, const EFBCopyFilterCoefficients& filter_coefficients) override
|
float y_scale, float gamma, bool clamp_top, bool clamp_bottom,
|
||||||
|
const EFBCopyFilterCoefficients& filter_coefficients) override
|
||||||
{
|
{
|
||||||
TextureEncoder::Encode(dst, params, native_width, bytes_per_row, num_blocks_y, memory_stride,
|
TextureEncoder::Encode(dst, params, native_width, bytes_per_row, num_blocks_y, memory_stride,
|
||||||
src_rect, scale_by_half, y_scale, gamma);
|
src_rect, scale_by_half, y_scale, gamma);
|
||||||
}
|
}
|
||||||
void CopyEFBToCacheEntry(TCacheEntry* entry, bool is_depth_copy, const EFBRectangle& src_rect,
|
void CopyEFBToCacheEntry(TCacheEntry* entry, bool is_depth_copy,
|
||||||
bool scale_by_half, bool linear_filter, EFBCopyFormat dst_format,
|
const MathUtil::Rectangle<int>& src_rect, bool scale_by_half,
|
||||||
bool is_intensity, float gamma, bool clamp_top, bool clamp_bottom,
|
bool linear_filter, EFBCopyFormat dst_format, bool is_intensity,
|
||||||
|
float gamma, bool clamp_top, bool clamp_bottom,
|
||||||
const EFBCopyFilterCoefficients& filter_coefficients) override
|
const EFBCopyFilterCoefficients& filter_coefficients) override
|
||||||
{
|
{
|
||||||
// TODO: If we ever want to "fake" vram textures, we would need to implement this
|
// TODO: If we ever want to "fake" vram textures, we would need to implement this
|
||||||
|
@ -1422,7 +1422,7 @@ static void EncodeZ24halfscale(u8* dst, const u8* src, EFBCopyFormat format)
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
void EncodeEfbCopy(u8* dst, const EFBCopyParams& params, u32 native_width, u32 bytes_per_row,
|
void EncodeEfbCopy(u8* dst, const EFBCopyParams& params, u32 native_width, u32 bytes_per_row,
|
||||||
u32 num_blocks_y, u32 memory_stride, const EFBRectangle& src_rect,
|
u32 num_blocks_y, u32 memory_stride, const MathUtil::Rectangle<int>& src_rect,
|
||||||
bool scale_by_half)
|
bool scale_by_half)
|
||||||
{
|
{
|
||||||
const u8* src = EfbInterface::GetPixelPointer(src_rect.left, src_rect.top, params.depth);
|
const u8* src = EfbInterface::GetPixelPointer(src_rect.left, src_rect.top, params.depth);
|
||||||
@ -1471,8 +1471,9 @@ void EncodeEfbCopy(u8* dst, const EFBCopyParams& params, u32 native_width, u32 b
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Encode(AbstractStagingTexture* dst, const EFBCopyParams& params, u32 native_width,
|
void Encode(AbstractStagingTexture* dst, const EFBCopyParams& params, u32 native_width,
|
||||||
u32 bytes_per_row, u32 num_blocks_y, u32 memory_stride, const EFBRectangle& src_rect,
|
u32 bytes_per_row, u32 num_blocks_y, u32 memory_stride,
|
||||||
bool scale_by_half, float y_scale, float gamma)
|
const MathUtil::Rectangle<int>& src_rect, bool scale_by_half, float y_scale,
|
||||||
|
float gamma)
|
||||||
{
|
{
|
||||||
// HACK: Override the memory stride for this staging texture with new copy stride.
|
// HACK: Override the memory stride for this staging texture with new copy stride.
|
||||||
// This is required because the texture encoder assumes that we're writing directly to memory,
|
// This is required because the texture encoder assumes that we're writing directly to memory,
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
namespace TextureEncoder
|
namespace TextureEncoder
|
||||||
{
|
{
|
||||||
void Encode(AbstractStagingTexture* dst, const EFBCopyParams& params, u32 native_width,
|
void Encode(AbstractStagingTexture* dst, const EFBCopyParams& params, u32 native_width,
|
||||||
u32 bytes_per_row, u32 num_blocks_y, u32 memory_stride, const EFBRectangle& src_rect,
|
u32 bytes_per_row, u32 num_blocks_y, u32 memory_stride,
|
||||||
bool scale_by_half, float y_scale, float gamma);
|
const MathUtil::Rectangle<int>& src_rect, bool scale_by_half, float y_scale,
|
||||||
|
float gamma);
|
||||||
}
|
}
|
||||||
|
@ -147,14 +147,14 @@ void Renderer::BBoxFlush()
|
|||||||
m_bounding_box->Invalidate();
|
m_bounding_box->Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::ClearScreen(const EFBRectangle& rc, bool color_enable, bool alpha_enable,
|
void Renderer::ClearScreen(const MathUtil::Rectangle<int>& rc, bool color_enable, bool alpha_enable,
|
||||||
bool z_enable, u32 color, u32 z)
|
bool z_enable, u32 color, u32 z)
|
||||||
{
|
{
|
||||||
g_framebuffer_manager->FlushEFBPokes();
|
g_framebuffer_manager->FlushEFBPokes();
|
||||||
g_framebuffer_manager->FlagPeekCacheAsOutOfDate();
|
g_framebuffer_manager->FlagPeekCacheAsOutOfDate();
|
||||||
|
|
||||||
// Native -> EFB coordinates
|
// Native -> EFB coordinates
|
||||||
TargetRectangle target_rc = Renderer::ConvertEFBRectangle(rc);
|
MathUtil::Rectangle<int> target_rc = Renderer::ConvertEFBRectangle(rc);
|
||||||
|
|
||||||
// Size we pass this size to vkBeginRenderPass, it has to be clamped to the framebuffer
|
// Size we pass this size to vkBeginRenderPass, it has to be clamped to the framebuffer
|
||||||
// dimensions. The other backends just silently ignore this case.
|
// dimensions. The other backends just silently ignore this case.
|
||||||
|
@ -62,8 +62,8 @@ public:
|
|||||||
void WaitForGPUIdle() override;
|
void WaitForGPUIdle() override;
|
||||||
void OnConfigChanged(u32 bits) override;
|
void OnConfigChanged(u32 bits) override;
|
||||||
|
|
||||||
void ClearScreen(const EFBRectangle& rc, bool color_enable, bool alpha_enable, bool z_enable,
|
void ClearScreen(const MathUtil::Rectangle<int>& rc, bool color_enable, bool alpha_enable,
|
||||||
u32 color, u32 z) override;
|
bool z_enable, u32 color, u32 z) override;
|
||||||
|
|
||||||
void SetPipeline(const AbstractPipeline* pipeline) override;
|
void SetPipeline(const AbstractPipeline* pipeline) override;
|
||||||
void SetFramebuffer(AbstractFramebuffer* framebuffer) override;
|
void SetFramebuffer(AbstractFramebuffer* framebuffer) override;
|
||||||
|
@ -49,8 +49,8 @@ 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 native_rc(bpmem.scissorTL.x - xoff, bpmem.scissorTL.y - yoff,
|
MathUtil::Rectangle<int> native_rc(bpmem.scissorTL.x - xoff, bpmem.scissorTL.y - yoff,
|
||||||
bpmem.scissorBR.x - xoff + 1, bpmem.scissorBR.y - yoff + 1);
|
bpmem.scissorBR.x - xoff + 1, bpmem.scissorBR.y - yoff + 1);
|
||||||
native_rc.ClampUL(0, 0, EFB_WIDTH, EFB_HEIGHT);
|
native_rc.ClampUL(0, 0, EFB_WIDTH, EFB_HEIGHT);
|
||||||
|
|
||||||
auto target_rc = g_renderer->ConvertEFBRectangle(native_rc);
|
auto target_rc = g_renderer->ConvertEFBRectangle(native_rc);
|
||||||
@ -172,7 +172,7 @@ void SetBlendMode()
|
|||||||
- convert the RGBA8 color to RGBA6/RGB8/RGB565 and convert it to RGBA8 again
|
- convert the RGBA8 color to RGBA6/RGB8/RGB565 and convert it to RGBA8 again
|
||||||
- convert the Z24 depth value to Z16 and back to Z24
|
- convert the Z24 depth value to Z16 and back to Z24
|
||||||
*/
|
*/
|
||||||
void ClearScreen(const EFBRectangle& rc)
|
void ClearScreen(const MathUtil::Rectangle<int>& rc)
|
||||||
{
|
{
|
||||||
bool colorEnable = (bpmem.blendmode.colorupdate != 0);
|
bool colorEnable = (bpmem.blendmode.colorupdate != 0);
|
||||||
bool alphaEnable = (bpmem.blendmode.alphaupdate != 0);
|
bool alphaEnable = (bpmem.blendmode.alphaupdate != 0);
|
||||||
|
@ -20,7 +20,7 @@ void SetScissor();
|
|||||||
void SetViewport();
|
void SetViewport();
|
||||||
void SetDepthMode();
|
void SetDepthMode();
|
||||||
void SetBlendMode();
|
void SetBlendMode();
|
||||||
void ClearScreen(const EFBRectangle& rc);
|
void ClearScreen(const MathUtil::Rectangle<int>& rc);
|
||||||
void OnPixelFormatChange();
|
void OnPixelFormatChange();
|
||||||
void SetInterlacingMode(const BPCmd& bp);
|
void SetInterlacingMode(const BPCmd& bp);
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ static void BPWritten(const BPCmd& bp)
|
|||||||
u32 destAddr = bpmem.copyTexDest << 5;
|
u32 destAddr = bpmem.copyTexDest << 5;
|
||||||
u32 destStride = bpmem.copyMipMapStrideChannels << 5;
|
u32 destStride = bpmem.copyMipMapStrideChannels << 5;
|
||||||
|
|
||||||
EFBRectangle srcRect;
|
MathUtil::Rectangle<int> srcRect;
|
||||||
srcRect.left = static_cast<int>(bpmem.copyTexSrcXY.x);
|
srcRect.left = static_cast<int>(bpmem.copyTexSrcXY.x);
|
||||||
srcRect.top = static_cast<int>(bpmem.copyTexSrcXY.y);
|
srcRect.top = static_cast<int>(bpmem.copyTexSrcXY.y);
|
||||||
|
|
||||||
|
@ -158,8 +158,8 @@ bool Renderer::EFBHasAlphaChannel() const
|
|||||||
return m_prev_efb_format == PEControl::RGBA6_Z24;
|
return m_prev_efb_format == PEControl::RGBA6_Z24;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable,
|
void Renderer::ClearScreen(const MathUtil::Rectangle<int>& rc, bool colorEnable, bool alphaEnable,
|
||||||
u32 color, u32 z)
|
bool zEnable, u32 color, u32 z)
|
||||||
{
|
{
|
||||||
g_framebuffer_manager->ClearEFB(rc, colorEnable, alphaEnable, zEnable, color, z);
|
g_framebuffer_manager->ClearEFB(rc, colorEnable, alphaEnable, zEnable, color, z);
|
||||||
}
|
}
|
||||||
@ -258,8 +258,8 @@ void Renderer::PokeEFB(EFBAccessType type, const EfbPokeData* points, size_t num
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::RenderToXFB(u32 xfbAddr, const EFBRectangle& sourceRc, u32 fbStride, u32 fbHeight,
|
void Renderer::RenderToXFB(u32 xfbAddr, const MathUtil::Rectangle<int>& sourceRc, u32 fbStride,
|
||||||
float Gamma)
|
u32 fbHeight, float Gamma)
|
||||||
{
|
{
|
||||||
CheckFifoRecording();
|
CheckFifoRecording();
|
||||||
|
|
||||||
@ -332,11 +332,11 @@ bool Renderer::CalculateTargetSize()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::tuple<TargetRectangle, TargetRectangle>
|
std::tuple<MathUtil::Rectangle<int>, MathUtil::Rectangle<int>>
|
||||||
Renderer::ConvertStereoRectangle(const TargetRectangle& rc) const
|
Renderer::ConvertStereoRectangle(const MathUtil::Rectangle<int>& rc) const
|
||||||
{
|
{
|
||||||
// Resize target to half its original size
|
// Resize target to half its original size
|
||||||
TargetRectangle draw_rc = rc;
|
auto draw_rc = rc;
|
||||||
if (g_ActiveConfig.stereo_mode == StereoMode::TAB)
|
if (g_ActiveConfig.stereo_mode == StereoMode::TAB)
|
||||||
{
|
{
|
||||||
// The height may be negative due to flipped rectangles
|
// The height may be negative due to flipped rectangles
|
||||||
@ -352,8 +352,8 @@ Renderer::ConvertStereoRectangle(const TargetRectangle& rc) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create two target rectangle offset to the sides of the backbuffer
|
// Create two target rectangle offset to the sides of the backbuffer
|
||||||
TargetRectangle left_rc = draw_rc;
|
auto left_rc = draw_rc;
|
||||||
TargetRectangle right_rc = draw_rc;
|
auto right_rc = draw_rc;
|
||||||
if (g_ActiveConfig.stereo_mode == StereoMode::TAB)
|
if (g_ActiveConfig.stereo_mode == StereoMode::TAB)
|
||||||
{
|
{
|
||||||
left_rc.top -= m_backbuffer_height / 4;
|
left_rc.top -= m_backbuffer_height / 4;
|
||||||
@ -649,9 +649,9 @@ MathUtil::Rectangle<int> Renderer::ConvertFramebufferRectangle(const MathUtil::R
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
TargetRectangle Renderer::ConvertEFBRectangle(const EFBRectangle& rc)
|
MathUtil::Rectangle<int> Renderer::ConvertEFBRectangle(const MathUtil::Rectangle<int>& rc)
|
||||||
{
|
{
|
||||||
TargetRectangle result;
|
MathUtil::Rectangle<int> result;
|
||||||
result.left = EFBToScaledX(rc.left);
|
result.left = EFBToScaledX(rc.left);
|
||||||
result.top = EFBToScaledY(rc.top);
|
result.top = EFBToScaledY(rc.top);
|
||||||
result.right = EFBToScaledX(rc.right);
|
result.right = EFBToScaledX(rc.right);
|
||||||
@ -1285,13 +1285,13 @@ void Renderer::Swap(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, u6
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::RenderXFBToScreen(const AbstractTexture* texture, const EFBRectangle& rc)
|
void Renderer::RenderXFBToScreen(const AbstractTexture* texture, const MathUtil::Rectangle<int>& rc)
|
||||||
{
|
{
|
||||||
const auto target_rc = GetTargetRectangle();
|
const auto target_rc = GetTargetRectangle();
|
||||||
if (g_ActiveConfig.stereo_mode == StereoMode::SBS ||
|
if (g_ActiveConfig.stereo_mode == StereoMode::SBS ||
|
||||||
g_ActiveConfig.stereo_mode == StereoMode::TAB)
|
g_ActiveConfig.stereo_mode == StereoMode::TAB)
|
||||||
{
|
{
|
||||||
TargetRectangle left_rc, right_rc;
|
MathUtil::Rectangle<int> left_rc, right_rc;
|
||||||
std::tie(left_rc, right_rc) = ConvertStereoRectangle(target_rc);
|
std::tie(left_rc, right_rc) = ConvertStereoRectangle(target_rc);
|
||||||
|
|
||||||
m_post_processor->BlitFromTexture(left_rc, rc, texture, 0);
|
m_post_processor->BlitFromTexture(left_rc, rc, texture, 0);
|
||||||
|
@ -167,17 +167,17 @@ public:
|
|||||||
|
|
||||||
// EFB coordinate conversion functions
|
// EFB coordinate conversion functions
|
||||||
// Use this to convert a whole native EFB rect to backbuffer coordinates
|
// Use this to convert a whole native EFB rect to backbuffer coordinates
|
||||||
TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc);
|
MathUtil::Rectangle<int> ConvertEFBRectangle(const MathUtil::Rectangle<int>& rc);
|
||||||
|
|
||||||
const TargetRectangle& GetTargetRectangle() const { return m_target_rectangle; }
|
const MathUtil::Rectangle<int>& GetTargetRectangle() const { return m_target_rectangle; }
|
||||||
float CalculateDrawAspectRatio() const;
|
float CalculateDrawAspectRatio() const;
|
||||||
|
|
||||||
std::tuple<float, float> ScaleToDisplayAspectRatio(int width, int height) const;
|
std::tuple<float, float> ScaleToDisplayAspectRatio(int width, int height) const;
|
||||||
void UpdateDrawRectangle();
|
void UpdateDrawRectangle();
|
||||||
|
|
||||||
// Use this to convert a single target rectangle to two stereo rectangles
|
// Use this to convert a single target rectangle to two stereo rectangles
|
||||||
std::tuple<TargetRectangle, TargetRectangle>
|
std::tuple<MathUtil::Rectangle<int>, MathUtil::Rectangle<int>>
|
||||||
ConvertStereoRectangle(const TargetRectangle& rc) const;
|
ConvertStereoRectangle(const MathUtil::Rectangle<int>& rc) const;
|
||||||
|
|
||||||
unsigned int GetEFBScale() const;
|
unsigned int GetEFBScale() const;
|
||||||
|
|
||||||
@ -196,11 +196,11 @@ public:
|
|||||||
// ImGui initialization depends on being able to create textures and pipelines, so do it last.
|
// ImGui initialization depends on being able to create textures and pipelines, so do it last.
|
||||||
bool InitializeImGui();
|
bool InitializeImGui();
|
||||||
|
|
||||||
virtual void ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable,
|
virtual void ClearScreen(const MathUtil::Rectangle<int>& rc, bool colorEnable, bool alphaEnable,
|
||||||
u32 color, u32 z);
|
bool zEnable, u32 color, u32 z);
|
||||||
virtual void ReinterpretPixelData(EFBReinterpretType convtype);
|
virtual void ReinterpretPixelData(EFBReinterpretType convtype);
|
||||||
void RenderToXFB(u32 xfbAddr, const EFBRectangle& sourceRc, u32 fbStride, u32 fbHeight,
|
void RenderToXFB(u32 xfbAddr, const MathUtil::Rectangle<int>& sourceRc, u32 fbStride,
|
||||||
float Gamma = 1.0f);
|
u32 fbHeight, float Gamma = 1.0f);
|
||||||
|
|
||||||
virtual u32 AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data);
|
virtual u32 AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data);
|
||||||
virtual void PokeEFB(EFBAccessType type, const EfbPokeData* points, size_t num_points);
|
virtual void PokeEFB(EFBAccessType type, const EfbPokeData* points, size_t num_points);
|
||||||
@ -217,7 +217,8 @@ public:
|
|||||||
|
|
||||||
// Draws the specified XFB buffer to the screen, performing any post-processing.
|
// Draws the specified XFB buffer to the screen, performing any post-processing.
|
||||||
// Assumes that the backbuffer has already been bound and cleared.
|
// Assumes that the backbuffer has already been bound and cleared.
|
||||||
virtual void RenderXFBToScreen(const AbstractTexture* texture, const EFBRectangle& rc);
|
virtual void RenderXFBToScreen(const AbstractTexture* texture,
|
||||||
|
const MathUtil::Rectangle<int>& rc);
|
||||||
|
|
||||||
// Called when the configuration changes, and backend structures need to be updated.
|
// Called when the configuration changes, and backend structures need to be updated.
|
||||||
virtual void OnConfigChanged(u32 bits) {}
|
virtual void OnConfigChanged(u32 bits) {}
|
||||||
@ -295,7 +296,7 @@ protected:
|
|||||||
int m_backbuffer_height = 0;
|
int m_backbuffer_height = 0;
|
||||||
float m_backbuffer_scale = 1.0f;
|
float m_backbuffer_scale = 1.0f;
|
||||||
AbstractTextureFormat m_backbuffer_format = AbstractTextureFormat::Undefined;
|
AbstractTextureFormat m_backbuffer_format = AbstractTextureFormat::Undefined;
|
||||||
TargetRectangle m_target_rectangle = {};
|
MathUtil::Rectangle<int> m_target_rectangle = {};
|
||||||
int m_frame_count = 0;
|
int m_frame_count = 0;
|
||||||
|
|
||||||
FPSCounter m_fps_counter;
|
FPSCounter m_fps_counter;
|
||||||
|
@ -1527,8 +1527,9 @@ bool TextureCacheBase::NeedsCopyFilterInShader(const EFBCopyFilterCoefficients&
|
|||||||
|
|
||||||
void TextureCacheBase::CopyRenderTargetToTexture(
|
void TextureCacheBase::CopyRenderTargetToTexture(
|
||||||
u32 dstAddr, EFBCopyFormat dstFormat, u32 width, u32 height, u32 dstStride, bool is_depth_copy,
|
u32 dstAddr, EFBCopyFormat dstFormat, u32 width, u32 height, u32 dstStride, bool is_depth_copy,
|
||||||
const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf, float y_scale, float gamma,
|
const MathUtil::Rectangle<int>& srcRect, bool isIntensity, bool scaleByHalf, float y_scale,
|
||||||
bool clamp_top, bool clamp_bottom, const CopyFilterCoefficients::Values& filter_coefficients)
|
float gamma, bool clamp_top, bool clamp_bottom,
|
||||||
|
const CopyFilterCoefficients::Values& filter_coefficients)
|
||||||
{
|
{
|
||||||
// Emulation methods:
|
// Emulation methods:
|
||||||
//
|
//
|
||||||
@ -2158,10 +2159,10 @@ bool TextureCacheBase::CreateUtilityTextures()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TextureCacheBase::CopyEFBToCacheEntry(TCacheEntry* entry, bool is_depth_copy,
|
void TextureCacheBase::CopyEFBToCacheEntry(TCacheEntry* entry, bool is_depth_copy,
|
||||||
const EFBRectangle& src_rect, bool scale_by_half,
|
const MathUtil::Rectangle<int>& src_rect,
|
||||||
bool linear_filter, EFBCopyFormat dst_format,
|
bool scale_by_half, bool linear_filter,
|
||||||
bool is_intensity, float gamma, bool clamp_top,
|
EFBCopyFormat dst_format, bool is_intensity, float gamma,
|
||||||
bool clamp_bottom,
|
bool clamp_top, bool clamp_bottom,
|
||||||
const EFBCopyFilterCoefficients& filter_coefficients)
|
const EFBCopyFilterCoefficients& filter_coefficients)
|
||||||
{
|
{
|
||||||
// Flush EFB pokes first, as they're expected to be included.
|
// Flush EFB pokes first, as they're expected to be included.
|
||||||
@ -2229,9 +2230,9 @@ void TextureCacheBase::CopyEFBToCacheEntry(TCacheEntry* entry, bool is_depth_cop
|
|||||||
|
|
||||||
void TextureCacheBase::CopyEFB(AbstractStagingTexture* dst, const EFBCopyParams& params,
|
void TextureCacheBase::CopyEFB(AbstractStagingTexture* dst, const EFBCopyParams& params,
|
||||||
u32 native_width, u32 bytes_per_row, u32 num_blocks_y,
|
u32 native_width, u32 bytes_per_row, u32 num_blocks_y,
|
||||||
u32 memory_stride, const EFBRectangle& src_rect, bool scale_by_half,
|
u32 memory_stride, const MathUtil::Rectangle<int>& src_rect,
|
||||||
bool linear_filter, float y_scale, float gamma, bool clamp_top,
|
bool scale_by_half, bool linear_filter, float y_scale, float gamma,
|
||||||
bool clamp_bottom,
|
bool clamp_top, bool clamp_bottom,
|
||||||
const EFBCopyFilterCoefficients& filter_coefficients)
|
const EFBCopyFilterCoefficients& filter_coefficients)
|
||||||
{
|
{
|
||||||
// Flush EFB pokes first, as they're expected to be included.
|
// Flush EFB pokes first, as they're expected to be included.
|
||||||
|
@ -213,9 +213,10 @@ public:
|
|||||||
|
|
||||||
virtual void BindTextures();
|
virtual void BindTextures();
|
||||||
void CopyRenderTargetToTexture(u32 dstAddr, EFBCopyFormat dstFormat, u32 width, u32 height,
|
void CopyRenderTargetToTexture(u32 dstAddr, EFBCopyFormat dstFormat, u32 width, u32 height,
|
||||||
u32 dstStride, bool is_depth_copy, const EFBRectangle& srcRect,
|
u32 dstStride, bool is_depth_copy,
|
||||||
bool isIntensity, bool scaleByHalf, float y_scale, float gamma,
|
const MathUtil::Rectangle<int>& srcRect, bool isIntensity,
|
||||||
bool clamp_top, bool clamp_bottom,
|
bool scaleByHalf, float y_scale, float gamma, bool clamp_top,
|
||||||
|
bool clamp_bottom,
|
||||||
const CopyFilterCoefficients::Values& filter_coefficients);
|
const CopyFilterCoefficients::Values& filter_coefficients);
|
||||||
|
|
||||||
void ScaleTextureCacheEntryTo(TCacheEntry* entry, u32 new_width, u32 new_height);
|
void ScaleTextureCacheEntryTo(TCacheEntry* entry, u32 new_width, u32 new_height);
|
||||||
@ -243,11 +244,11 @@ protected:
|
|||||||
|
|
||||||
virtual void CopyEFB(AbstractStagingTexture* dst, const EFBCopyParams& params, u32 native_width,
|
virtual void CopyEFB(AbstractStagingTexture* dst, const EFBCopyParams& params, u32 native_width,
|
||||||
u32 bytes_per_row, u32 num_blocks_y, u32 memory_stride,
|
u32 bytes_per_row, u32 num_blocks_y, u32 memory_stride,
|
||||||
const EFBRectangle& src_rect, bool scale_by_half, bool linear_filter,
|
const MathUtil::Rectangle<int>& src_rect, bool scale_by_half,
|
||||||
float y_scale, float gamma, bool clamp_top, bool clamp_bottom,
|
bool linear_filter, float y_scale, float gamma, bool clamp_top,
|
||||||
const EFBCopyFilterCoefficients& filter_coefficients);
|
bool clamp_bottom, const EFBCopyFilterCoefficients& filter_coefficients);
|
||||||
virtual void CopyEFBToCacheEntry(TCacheEntry* entry, bool is_depth_copy,
|
virtual void CopyEFBToCacheEntry(TCacheEntry* entry, bool is_depth_copy,
|
||||||
const EFBRectangle& src_rect, bool scale_by_half,
|
const MathUtil::Rectangle<int>& src_rect, bool scale_by_half,
|
||||||
bool linear_filter, EFBCopyFormat dst_format, bool is_intensity,
|
bool linear_filter, EFBCopyFormat dst_format, bool is_intensity,
|
||||||
float gamma, bool clamp_top, bool clamp_bottom,
|
float gamma, bool clamp_top, bool clamp_bottom,
|
||||||
const EFBCopyFilterCoefficients& filter_coefficients);
|
const EFBCopyFilterCoefficients& filter_coefficients);
|
||||||
|
@ -3,11 +3,6 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Common/MathUtil.h"
|
#include "Common/MathUtil.h"
|
||||||
|
|
||||||
@ -31,34 +26,6 @@ const u32 MAX_XFB_WIDTH = 720;
|
|||||||
// that are next to each other in memory (TODO: handle that situation).
|
// that are next to each other in memory (TODO: handle that situation).
|
||||||
const u32 MAX_XFB_HEIGHT = 576;
|
const u32 MAX_XFB_HEIGHT = 576;
|
||||||
|
|
||||||
// This structure should only be used to represent a rectangle in EFB
|
|
||||||
// coordinates, where the origin is at the upper left and the frame dimensions
|
|
||||||
// are 640 x 528.
|
|
||||||
typedef MathUtil::Rectangle<int> EFBRectangle;
|
|
||||||
|
|
||||||
// This structure should only be used to represent a rectangle in standard target
|
|
||||||
// coordinates, where the origin is at the lower left and the frame dimensions
|
|
||||||
// depend on the resolution settings. Use Renderer::ConvertEFBRectangle to
|
|
||||||
// convert an EFBRectangle to a TargetRectangle.
|
|
||||||
struct TargetRectangle : public MathUtil::Rectangle<int>
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
// Only used by D3D backend.
|
|
||||||
const RECT* AsRECT() const
|
|
||||||
{
|
|
||||||
// The types are binary compatible so this works.
|
|
||||||
return (const RECT*)this;
|
|
||||||
}
|
|
||||||
RECT* AsRECT()
|
|
||||||
{
|
|
||||||
// The types are binary compatible so this works.
|
|
||||||
return (RECT*)this;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
TargetRectangle(const MathUtil::Rectangle<int>& other) : MathUtil::Rectangle<int>(other) {}
|
|
||||||
TargetRectangle() = default;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define PRIM_LOG(...) DEBUG_LOG(VIDEO, __VA_ARGS__)
|
#define PRIM_LOG(...) DEBUG_LOG(VIDEO, __VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user