HybridXFB: Fix lint errors

This commit is contained in:
iwubcode 2017-09-02 21:30:34 -05:00
parent 725d14e4c6
commit 53684701fa
39 changed files with 207 additions and 204 deletions

View File

@ -43,7 +43,7 @@ const ConfigInfo<bool> GFX_CONVERT_HIRES_TEXTURES{{System::GFX, "Settings", "Con
const ConfigInfo<bool> GFX_CACHE_HIRES_TEXTURES{{System::GFX, "Settings", "CacheHiresTextures"}, const ConfigInfo<bool> GFX_CACHE_HIRES_TEXTURES{{System::GFX, "Settings", "CacheHiresTextures"},
false}; false};
const ConfigInfo<bool> GFX_DUMP_EFB_TARGET{{System::GFX, "Settings", "DumpEFBTarget"}, false}; const ConfigInfo<bool> GFX_DUMP_EFB_TARGET{{System::GFX, "Settings", "DumpEFBTarget"}, false};
const ConfigInfo<bool> GFX_DUMP_XFB_TARGET{ { System::GFX, "Settings", "DumpXFBTarget" }, false }; const ConfigInfo<bool> GFX_DUMP_XFB_TARGET{{System::GFX, "Settings", "DumpXFBTarget"}, false};
const ConfigInfo<bool> GFX_DUMP_FRAMES_AS_IMAGES{{System::GFX, "Settings", "DumpFramesAsImages"}, const ConfigInfo<bool> GFX_DUMP_FRAMES_AS_IMAGES{{System::GFX, "Settings", "DumpFramesAsImages"},
false}; false};
const ConfigInfo<bool> GFX_FREE_LOOK{{System::GFX, "Settings", "FreeLook"}, false}; const ConfigInfo<bool> GFX_FREE_LOOK{{System::GFX, "Settings", "FreeLook"}, false};

View File

@ -28,17 +28,17 @@ bool IsSettingSaveable(const Config::ConfigLocation& config_location)
// Graphics.Settings // Graphics.Settings
Config::GFX_WIDESCREEN_HACK.location, Config::GFX_ASPECT_RATIO.location, Config::GFX_WIDESCREEN_HACK.location, Config::GFX_ASPECT_RATIO.location,
Config::GFX_CROP.location, Config::GFX_CROP.location, Config::GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES.location,
Config::GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES.location, Config::GFX_SHOW_FPS.location, Config::GFX_SHOW_FPS.location, Config::GFX_SHOW_NETPLAY_PING.location,
Config::GFX_SHOW_NETPLAY_PING.location, Config::GFX_SHOW_NETPLAY_MESSAGES.location, Config::GFX_SHOW_NETPLAY_MESSAGES.location, Config::GFX_LOG_RENDER_TIME_TO_FILE.location,
Config::GFX_LOG_RENDER_TIME_TO_FILE.location, Config::GFX_OVERLAY_STATS.location, Config::GFX_OVERLAY_STATS.location, Config::GFX_OVERLAY_PROJ_STATS.location,
Config::GFX_OVERLAY_PROJ_STATS.location, Config::GFX_DUMP_TEXTURES.location, Config::GFX_DUMP_TEXTURES.location, Config::GFX_HIRES_TEXTURES.location,
Config::GFX_HIRES_TEXTURES.location, Config::GFX_CONVERT_HIRES_TEXTURES.location, Config::GFX_CONVERT_HIRES_TEXTURES.location, Config::GFX_CACHE_HIRES_TEXTURES.location,
Config::GFX_CACHE_HIRES_TEXTURES.location, Config::GFX_DUMP_EFB_TARGET.location, Config::GFX_DUMP_EFB_TARGET.location, Config::GFX_DUMP_FRAMES_AS_IMAGES.location,
Config::GFX_DUMP_FRAMES_AS_IMAGES.location, Config::GFX_FREE_LOOK.location, Config::GFX_FREE_LOOK.location, Config::GFX_USE_FFV1.location,
Config::GFX_USE_FFV1.location, Config::GFX_DUMP_FORMAT.location, Config::GFX_DUMP_FORMAT.location, Config::GFX_DUMP_CODEC.location,
Config::GFX_DUMP_CODEC.location, Config::GFX_DUMP_PATH.location, Config::GFX_DUMP_PATH.location, Config::GFX_BITRATE_KBPS.location,
Config::GFX_BITRATE_KBPS.location, Config::GFX_INTERNAL_RESOLUTION_FRAME_DUMPS.location, Config::GFX_INTERNAL_RESOLUTION_FRAME_DUMPS.location,
Config::GFX_ENABLE_GPU_TEXTURE_DECODING.location, Config::GFX_ENABLE_PIXEL_LIGHTING.location, Config::GFX_ENABLE_GPU_TEXTURE_DECODING.location, Config::GFX_ENABLE_PIXEL_LIGHTING.location,
Config::GFX_FAST_DEPTH_CALC.location, Config::GFX_MSAA.location, Config::GFX_SSAA.location, Config::GFX_FAST_DEPTH_CALC.location, Config::GFX_MSAA.location, Config::GFX_SSAA.location,
Config::GFX_EFB_SCALE.location, Config::GFX_TEXFMT_OVERLAY_ENABLE.location, Config::GFX_EFB_SCALE.location, Config::GFX_TEXFMT_OVERLAY_ENABLE.location,
@ -73,8 +73,7 @@ bool IsSettingSaveable(const Config::ConfigLocation& config_location)
Config::GFX_HACK_EFB_ACCESS_ENABLE.location, Config::GFX_HACK_BBOX_ENABLE.location, Config::GFX_HACK_EFB_ACCESS_ENABLE.location, Config::GFX_HACK_BBOX_ENABLE.location,
Config::GFX_HACK_BBOX_PREFER_STENCIL_IMPLEMENTATION.location, Config::GFX_HACK_BBOX_PREFER_STENCIL_IMPLEMENTATION.location,
Config::GFX_HACK_FORCE_PROGRESSIVE.location, Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM.location, Config::GFX_HACK_FORCE_PROGRESSIVE.location, Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM.location,
Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM.location, Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM.location, Config::GFX_HACK_IMMEDIATE_XFB.location,
Config::GFX_HACK_IMMEDIATE_XFB.location,
Config::GFX_HACK_COPY_EFB_ENABLED.location, Config::GFX_HACK_COPY_EFB_ENABLED.location,
Config::GFX_HACK_EFB_EMULATE_FORMAT_CHANGES.location, Config::GFX_HACK_EFB_EMULATE_FORMAT_CHANGES.location,
Config::GFX_HACK_VERTEX_ROUDING.location, Config::GFX_HACK_VERTEX_ROUDING.location,

View File

@ -39,7 +39,6 @@ static void LoadFromDTM(Config::Layer* config_layer, Movie::DTMHeader* dtm)
else else
config_layer->Set(Config::MAIN_GC_LANGUAGE, static_cast<int>(dtm->language)); config_layer->Set(Config::MAIN_GC_LANGUAGE, static_cast<int>(dtm->language));
config_layer->Set(Config::GFX_HACK_EFB_ACCESS_ENABLE, dtm->bEFBAccessEnable); config_layer->Set(Config::GFX_HACK_EFB_ACCESS_ENABLE, dtm->bEFBAccessEnable);
config_layer->Set(Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM, dtm->bSkipEFBCopyToRam); config_layer->Set(Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM, dtm->bSkipEFBCopyToRam);
config_layer->Set(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM, dtm->bSkipXFBCopyToRam); config_layer->Set(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM, dtm->bSkipXFBCopyToRam);

View File

@ -69,8 +69,7 @@ void HacksWidget::CreateWidgets()
m_store_xfb_copies = new GraphicsBool(tr("Store XFB Copies to Texture Only"), m_store_xfb_copies = new GraphicsBool(tr("Store XFB Copies to Texture Only"),
Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM); Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM);
m_immediate_xfb = new GraphicsBool(tr("Immediately Present XFB"), m_immediate_xfb = new GraphicsBool(tr("Immediately Present XFB"), Config::GFX_HACK_IMMEDIATE_XFB);
Config::GFX_HACK_IMMEDIATE_XFB);
xfb_layout->addWidget(m_store_xfb_copies, 1, 0); xfb_layout->addWidget(m_store_xfb_copies, 1, 0);
@ -171,15 +170,18 @@ void HacksWidget::AddDescriptions()
"from RAM.\nLower accuracies cause in-game text to appear garbled in certain " "from RAM.\nLower accuracies cause in-game text to appear garbled in certain "
"games.\n\nIf unsure, use the rightmost value."); "games.\n\nIf unsure, use the rightmost value.");
static const char* TR_STORE_XFB_TO_TEXTURE_DESCRIPTION = QT_TR_NOOP( static const char* TR_STORE_XFB_TO_TEXTURE_DESCRIPTION = QT_TR_NOOP(
"Stores XFB Copies exclusively on the GPU, bypassing system memory. Causes graphical defects " "Stores XFB Copies exclusively on the GPU, bypassing system memory. Causes graphical defects "
"in a small number of games that need to readback from memory.\n\nEnabled = XFB Copies to Texture\nDisabled = XFB Copies to RAM " "in a small number of games that need to readback from memory.\n\nEnabled = XFB Copies to "
"Texture\nDisabled = XFB Copies to RAM "
"(and Texture)\n\nIf unsure, leave this checked."); "(and Texture)\n\nIf unsure, leave this checked.");
static const char* TR_IMMEDIATE_XFB_DESCRIPTION = QT_TR_NOOP( static const char* TR_IMMEDIATE_XFB_DESCRIPTION =
"Displays the XFB copies as soon as they are created, without waiting for scanout. Can cause graphical defects " QT_TR_NOOP("Displays the XFB copies as soon as they are created, without waiting for "
"in some games if the game doesn't expect all XFB copies to be displayed. However, turning this setting on reduces latency." "scanout. Can cause graphical defects "
"\n\nIf unsure, leave this unchecked."); "in some games if the game doesn't expect all XFB copies to be displayed. "
"However, turning this setting on reduces latency."
"\n\nIf unsure, leave this unchecked.");
static const char* TR_GPU_DECODING_DESCRIPTION = static const char* TR_GPU_DECODING_DESCRIPTION =
QT_TR_NOOP("Enables texture decoding using the GPU instead of the CPU. This may result in " QT_TR_NOOP("Enables texture decoding using the GPU instead of the CPU. This may result in "

View File

@ -1496,7 +1496,7 @@ void CFrame::ParseHotkeys()
OSDChoice = 6; OSDChoice = 6;
// Toggle immediate present of xfb // Toggle immediate present of xfb
Config::SetCurrent(Config::GFX_HACK_IMMEDIATE_XFB, Config::SetCurrent(Config::GFX_HACK_IMMEDIATE_XFB,
!Config::Get(Config::GFX_HACK_IMMEDIATE_XFB)); !Config::Get(Config::GFX_HACK_IMMEDIATE_XFB));
} }
if (IsHotkey(HK_TOGGLE_FOG)) if (IsHotkey(HK_TOGGLE_FOG))
{ {

View File

@ -202,13 +202,16 @@ static wxString skip_efb_copy_to_ram_desc = wxTRANSLATE(
"in a small number of games.\n\nEnabled = EFB Copies to Texture\nDisabled = EFB Copies to RAM " "in a small number of games.\n\nEnabled = EFB Copies to Texture\nDisabled = EFB Copies to RAM "
"(and Texture)\n\nIf unsure, leave this checked."); "(and Texture)\n\nIf unsure, leave this checked.");
static wxString skip_xfb_copy_to_ram_desc = wxTRANSLATE( static wxString skip_xfb_copy_to_ram_desc = wxTRANSLATE(
"Stores XFB Copies exclusively on the GPU, bypassing system memory. Causes graphical defects " "Stores XFB Copies exclusively on the GPU, bypassing system memory. Causes graphical defects "
"in a small number of games that need to readback from memory.\n\nEnabled = XFB Copies to Texture\nDisabled = XFB Copies to RAM " "in a small number of games that need to readback from memory.\n\nEnabled = XFB Copies to "
"(and Texture)\n\nIf unsure, leave this checked."); "Texture\nDisabled = XFB Copies to RAM "
static wxString immediate_xfb_desc = wxTRANSLATE( "(and Texture)\n\nIf unsure, leave this checked.");
"Displays the XFB copies as soon as they are created, without waiting for scanout. Can cause graphical defects " static wxString immediate_xfb_desc =
"in some games if the game doesn't expect all XFB copies to be displayed. However, turning this setting on reduces latency." wxTRANSLATE("Displays the XFB copies as soon as they are created, without waiting for scanout. "
"\n\nIf unsure, leave this unchecked."); "Can cause graphical defects "
"in some games if the game doesn't expect all XFB copies to be displayed. However, "
"turning this setting on reduces latency."
"\n\nIf unsure, leave this unchecked.");
static wxString stc_desc = static wxString stc_desc =
wxTRANSLATE("The \"Safe\" setting eliminates the likelihood of the GPU missing texture updates " wxTRANSLATE("The \"Safe\" setting eliminates the likelihood of the GPU missing texture updates "
"from RAM.\nLower accuracies cause in-game text to appear garbled in certain " "from RAM.\nLower accuracies cause in-game text to appear garbled in certain "
@ -248,7 +251,7 @@ static wxString cache_hires_textures_desc =
static wxString dump_efb_desc = wxTRANSLATE( static wxString dump_efb_desc = wxTRANSLATE(
"Dump the contents of EFB copies to User/Dump/Textures/.\n\nIf unsure, leave this unchecked."); "Dump the contents of EFB copies to User/Dump/Textures/.\n\nIf unsure, leave this unchecked.");
static wxString dump_xfb_desc = wxTRANSLATE( static wxString dump_xfb_desc = wxTRANSLATE(
"Dump the contents of XFB copies to User/Dump/Textures/.\n\nIf unsure, leave this unchecked."); "Dump the contents of XFB copies to User/Dump/Textures/.\n\nIf unsure, leave this unchecked.");
static wxString internal_resolution_frame_dumping_desc = wxTRANSLATE( static wxString internal_resolution_frame_dumping_desc = wxTRANSLATE(
"Create frame dumps and screenshots at the internal resolution of the renderer, rather than " "Create frame dumps and screenshots at the internal resolution of the renderer, rather than "
"the size of the window it is displayed within. If the aspect ratio is widescreen, the output " "the size of the window it is displayed within. If the aspect ratio is widescreen, the output "
@ -779,21 +782,21 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string& title)
szr_hacks->Add(szr_safetex, 0, wxEXPAND | wxLEFT | wxRIGHT, space5); szr_hacks->Add(szr_safetex, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
} }
// - XFB // - XFB
{ {
wxStaticBoxSizer* const group_xfb = wxStaticBoxSizer* const group_xfb =
new wxStaticBoxSizer(wxVERTICAL, page_hacks, _("External Frame Buffer (XFB)")); new wxStaticBoxSizer(wxVERTICAL, page_hacks, _("External Frame Buffer (XFB)"));
group_xfb->Add(CreateCheckBox(page_hacks, _("Store XFB Copies to Texture Only"), group_xfb->Add(CreateCheckBox(page_hacks, _("Store XFB Copies to Texture Only"),
wxGetTranslation(skip_xfb_copy_to_ram_desc), wxGetTranslation(skip_xfb_copy_to_ram_desc),
Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM), Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM),
0, wxLEFT | wxRIGHT, space5); 0, wxLEFT | wxRIGHT, space5);
group_xfb->AddSpacer(space5); group_xfb->AddSpacer(space5);
group_xfb->Add(CreateCheckBox(page_hacks, _("Immediately Present XFB"), group_xfb->Add(CreateCheckBox(page_hacks, _("Immediately Present XFB"),
wxGetTranslation(immediate_xfb_desc), wxGetTranslation(immediate_xfb_desc),
Config::GFX_HACK_IMMEDIATE_XFB), Config::GFX_HACK_IMMEDIATE_XFB),
0, wxLEFT | wxRIGHT, space5); 0, wxLEFT | wxRIGHT, space5);
group_xfb->AddSpacer(space5); group_xfb->AddSpacer(space5);
szr_hacks->AddSpacer(space5); szr_hacks->AddSpacer(space5);
@ -885,8 +888,9 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string& title)
szr_utility->Add(CreateCheckBox(page_advanced, _("Dump EFB Target"), szr_utility->Add(CreateCheckBox(page_advanced, _("Dump EFB Target"),
wxGetTranslation(dump_efb_desc), wxGetTranslation(dump_efb_desc),
Config::GFX_DUMP_EFB_TARGET)); Config::GFX_DUMP_EFB_TARGET));
szr_utility->Add(CreateCheckBox(page_advanced, _("Dump XFB Target"), szr_utility->Add(CreateCheckBox(page_advanced, _("Dump XFB Target"),
wxGetTranslation(dump_xfb_desc), Config::GFX_DUMP_XFB_TARGET)); wxGetTranslation(dump_xfb_desc),
Config::GFX_DUMP_XFB_TARGET));
szr_utility->Add(CreateCheckBox(page_advanced, _("Free Look"), szr_utility->Add(CreateCheckBox(page_advanced, _("Free Look"),
wxGetTranslation(free_look_desc), Config::GFX_FREE_LOOK)); wxGetTranslation(free_look_desc), Config::GFX_FREE_LOOK));
#if defined(HAVE_FFMPEG) #if defined(HAVE_FFMPEG)

View File

@ -46,8 +46,8 @@ void PSTextureEncoder::Init()
// TODO: This Texture is overly large and parts of it are unused // TODO: This Texture is overly large and parts of it are unused
// EFB2RAM copies use max (EFB_WIDTH * 4) by (EFB_HEIGHT / 4) // EFB2RAM copies use max (EFB_WIDTH * 4) by (EFB_HEIGHT / 4)
// XFB2RAM copies use max (EFB_WIDTH / 2) by (EFB_HEIGHT) // XFB2RAM copies use max (EFB_WIDTH / 2) by (EFB_HEIGHT)
D3D11_TEXTURE2D_DESC t2dd = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_B8G8R8A8_UNORM, EFB_WIDTH * 4, D3D11_TEXTURE2D_DESC t2dd = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_B8G8R8A8_UNORM, EFB_WIDTH * 4, 1024,
1024, 1, 1, D3D11_BIND_RENDER_TARGET); 1, 1, D3D11_BIND_RENDER_TARGET);
hr = D3D::device->CreateTexture2D(&t2dd, nullptr, &m_out); hr = D3D::device->CreateTexture2D(&t2dd, nullptr, &m_out);
CHECK(SUCCEEDED(hr), "create efb encode output texture"); CHECK(SUCCEEDED(hr), "create efb encode output texture");
D3D::SetDebugObjectName(m_out, "efb encoder output texture"); D3D::SetDebugObjectName(m_out, "efb encoder output texture");

View File

@ -39,8 +39,8 @@
#include "VideoCommon/RenderState.h" #include "VideoCommon/RenderState.h"
#include "VideoCommon/SamplerCommon.h" #include "VideoCommon/SamplerCommon.h"
#include "VideoCommon/VideoBackendBase.h" #include "VideoCommon/VideoBackendBase.h"
#include "VideoCommon/VideoConfig.h"
#include "VideoCommon/VideoCommon.h" #include "VideoCommon/VideoCommon.h"
#include "VideoCommon/VideoConfig.h"
#include "VideoCommon/XFMemory.h" #include "VideoCommon/XFMemory.h"
namespace DX11 namespace DX11
@ -626,8 +626,8 @@ void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& rc, u64 ti
auto* xfb_texture = static_cast<DXTexture*>(texture); auto* xfb_texture = static_cast<DXTexture*>(texture);
TargetRectangle source_rc = xfb_texture->GetConfig().GetRect(); TargetRectangle source_rc = xfb_texture->GetConfig().GetRect();
BlitScreen(source_rc, targetRc, xfb_texture->GetRawTexIdentifier(), xfb_texture->GetConfig().width, BlitScreen(source_rc, targetRc, xfb_texture->GetRawTexIdentifier(),
xfb_texture->GetConfig().height, Gamma); xfb_texture->GetConfig().width, xfb_texture->GetConfig().height, Gamma);
// Reset viewport for drawing text // Reset viewport for drawing text
D3D11_VIEWPORT vp = D3D11_VIEWPORT vp =

View File

@ -25,7 +25,7 @@ static const char s_vertex_shader[] = "out vec2 uv0;\n"
"void main(void) {\n" "void main(void) {\n"
" vec2 rawpos = vec2(gl_VertexID&1, gl_VertexID&2);\n" " vec2 rawpos = vec2(gl_VertexID&1, gl_VertexID&2);\n"
" gl_Position = vec4(rawpos*2.0-1.0, 0.0, 1.0);\n" " gl_Position = vec4(rawpos*2.0-1.0, 0.0, 1.0);\n"
" uv0 = vec2(mix(src_rect.xy, src_rect.zw, rawpos));\n" " uv0 = vec2(mix(src_rect.xy, src_rect.zw, rawpos));\n"
"}\n"; "}\n";
OpenGLPostProcessing::OpenGLPostProcessing() : m_initialized(false) OpenGLPostProcessing::OpenGLPostProcessing() : m_initialized(false)

View File

@ -1353,7 +1353,8 @@ void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& rc, u64 ti
// Copy the framebuffer to screen. // Copy the framebuffer to screen.
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
BlitScreen(sourceRc, flipped_trc, xfb_texture->GetRawTexIdentifier(), xfb_texture->GetConfig().width, xfb_texture->GetConfig().height); BlitScreen(sourceRc, flipped_trc, xfb_texture->GetRawTexIdentifier(),
xfb_texture->GetConfig().width, xfb_texture->GetConfig().height);
// Finish up the current frame, print some stats // Finish up the current frame, print some stats

View File

@ -111,7 +111,8 @@ private:
void UpdateEFBCache(EFBAccessType type, u32 cacheRectIdx, const EFBRectangle& efbPixelRc, void UpdateEFBCache(EFBAccessType type, u32 cacheRectIdx, const EFBRectangle& efbPixelRc,
const TargetRectangle& targetPixelRc, const void* data); const TargetRectangle& targetPixelRc, const void* data);
void DrawEFB(GLuint framebuffer, const TargetRectangle& target_rc, const TargetRectangle& source_rc); void DrawEFB(GLuint framebuffer, const TargetRectangle& target_rc,
const TargetRectangle& source_rc);
void BlitScreen(TargetRectangle src, TargetRectangle dst, GLuint src_texture, int src_width, void BlitScreen(TargetRectangle src, TargetRectangle dst, GLuint src_texture, int src_width,
int src_height); int src_height);

View File

@ -388,10 +388,10 @@ void main()
void TextureCache::CreateTextureDecodingResources() void TextureCache::CreateTextureDecodingResources()
{ {
static const GLenum gl_view_types[TextureConversionShader::BUFFER_FORMAT_COUNT] = { static const GLenum gl_view_types[TextureConversionShader::BUFFER_FORMAT_COUNT] = {
GL_R8UI, // BUFFER_FORMAT_R8_UINT GL_R8UI, // BUFFER_FORMAT_R8_UINT
GL_R16UI, // BUFFER_FORMAT_R16_UINT GL_R16UI, // BUFFER_FORMAT_R16_UINT
GL_RG32UI, // BUFFER_FORMAT_R32G32_UINT GL_RG32UI, // BUFFER_FORMAT_R32G32_UINT
GL_RGBA8UI, // BUFFER_FORMAT_RGBA8_UINT GL_RGBA8UI, // BUFFER_FORMAT_RGBA8_UINT
}; };
glGenTextures(TextureConversionShader::BUFFER_FORMAT_COUNT, glGenTextures(TextureConversionShader::BUFFER_FORMAT_COUNT,

View File

@ -22,9 +22,9 @@ void copy_region(const T* const source, const MathUtil::Rectangle<int>& srcrect,
int destination_y = i + dstrect.top; int destination_y = i + dstrect.top;
int destination_offset = (destination_y * dstrect.GetWidth()) + destination_x; int destination_offset = (destination_y * dstrect.GetWidth()) + destination_x;
double src_x = std::round(destination_x*x_ratio) + srcrect.left; double src_x = std::round(destination_x * x_ratio) + srcrect.left;
double src_y = std::round(destination_y*y_ratio) + srcrect.top; double src_y = std::round(destination_y * y_ratio) + srcrect.top;
int src_offset = static_cast<int>((src_y*srcrect.GetWidth()) + src_x); int src_offset = static_cast<int>((src_y * srcrect.GetWidth()) + src_x);
destination[destination_offset] = source[src_offset]; destination[destination_offset] = source[src_offset];
} }

View File

@ -14,7 +14,6 @@
namespace EfbCopy namespace EfbCopy
{ {
void ClearEfb() void ClearEfb()
{ {
u32 clearColor = (bpmem.clearcolorAR & 0xff) << 24 | bpmem.clearcolorGB << 8 | u32 clearColor = (bpmem.clearcolorAR & 0xff) << 24 | bpmem.clearcolorGB << 8 |
@ -34,5 +33,4 @@ void ClearEfb()
} }
} }
} }
} }

View File

@ -497,7 +497,8 @@ u8* GetPixelPointer(u16 x, u16 y, bool depth)
return &efb[GetColorOffset(x, y)]; return &efb[GetColorOffset(x, y)];
} }
void EncodeXFB(yuv422_packed* xfb_in_ram, u32 memory_stride, const EFBRectangle& source_rect, float y_scale) void EncodeXFB(yuv422_packed* xfb_in_ram, u32 memory_stride, const EFBRectangle& source_rect,
float y_scale)
{ {
if (!xfb_in_ram) if (!xfb_in_ram)
{ {
@ -543,8 +544,7 @@ void EncodeXFB(yuv422_packed* xfb_in_ram, u32 memory_stride, const EFBRectangle&
src_ptr[x].Y = scanline[i].Y + 16; src_ptr[x].Y = scanline[i].Y + 16;
// we mix our color differences in 10 bit space so it will round more accurately // we mix our color differences in 10 bit space so it will round more accurately
// U[i] = 1/4 * U[i-1] + 1/2 * U[i] + 1/4 * U[i+1] // U[i] = 1/4 * U[i-1] + 1/2 * U[i] + 1/4 * U[i+1]
src_ptr[x].UV = src_ptr[x].UV = 128 + ((scanline[i - 1].U + (scanline[i].U << 1) + scanline[i + 1].U) >> 2);
128 + ((scanline[i - 1].U + (scanline[i].U << 1) + scanline[i + 1].U) >> 2);
// YV pixel // YV pixel
src_ptr[x + 1].Y = scanline[i + 1].Y + 16; src_ptr[x + 1].Y = scanline[i + 1].Y + 16;
@ -556,7 +556,9 @@ void EncodeXFB(yuv422_packed* xfb_in_ram, u32 memory_stride, const EFBRectangle&
} }
// Apply y scaling and copy to the xfb memory location // Apply y scaling and copy to the xfb memory location
SW::copy_region(source.data(), source_rect, xfb_in_ram, EFBRectangle{ source_rect.left, source_rect.top, source_rect.right, static_cast<int>(static_cast<float>(source_rect.bottom) * y_scale) }); SW::copy_region(source.data(), source_rect, xfb_in_ram,
EFBRectangle{source_rect.left, source_rect.top, source_rect.right,
static_cast<int>(static_cast<float>(source_rect.bottom) * y_scale)});
} }
bool ZCompare(u16 x, u16 y, u32 z) bool ZCompare(u16 x, u16 y, u32 z)

View File

@ -57,7 +57,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(yuv422_packed* xfb_in_ram, u32 memory_stride, const EFBRectangle& source_rect, float y_scale); void EncodeXFB(yuv422_packed* xfb_in_ram, u32 memory_stride, const EFBRectangle& source_rect,
float y_scale);
extern u32 perf_values[PQ_NUM_MEMBERS]; extern u32 perf_values[PQ_NUM_MEMBERS];
inline void IncPerfCounterQuadCount(PerfQueryType type) inline void IncPerfCounterQuadCount(PerfQueryType type)

View File

@ -92,7 +92,7 @@ void SWOGLWindow::PrintText(const std::string& text, int x, int y, u32 color)
void SWOGLWindow::ShowImage(AbstractTexture* image, float aspect) void SWOGLWindow::ShowImage(AbstractTexture* image, float aspect)
{ {
SW::SWTexture * sw_image = static_cast<SW::SWTexture*>(image); SW::SWTexture* sw_image = static_cast<SW::SWTexture*>(image);
GLInterface->Update(); // just updates the render window position and the backbuffer size GLInterface->Update(); // just updates the render window position and the backbuffer size
GLsizei glWidth = (GLsizei)GLInterface->GetBackBufferWidth(); GLsizei glWidth = (GLsizei)GLInterface->GetBackBufferWidth();

View File

@ -31,7 +31,6 @@ public:
private: private:
SWOGLWindow() {} SWOGLWindow() {}
struct TextData struct TextData
{ {
std::string text; std::string text;

View File

@ -10,7 +10,6 @@
namespace SW namespace SW
{ {
SWTexture::SWTexture(const TextureConfig& tex_config) : AbstractTexture(tex_config) SWTexture::SWTexture(const TextureConfig& tex_config) : AbstractTexture(tex_config)
{ {
} }
@ -23,11 +22,12 @@ void SWTexture::CopyRectangleFromTexture(const AbstractTexture* source,
const MathUtil::Rectangle<int>& srcrect, const MathUtil::Rectangle<int>& srcrect,
const MathUtil::Rectangle<int>& dstrect) const MathUtil::Rectangle<int>& dstrect)
{ {
const SWTexture * software_source_texture = static_cast<const SWTexture*>(source); const SWTexture* software_source_texture = static_cast<const SWTexture*>(source);
if (srcrect.GetWidth() == dstrect.GetWidth() && srcrect.GetHeight() == dstrect.GetHeight()) if (srcrect.GetWidth() == dstrect.GetWidth() && srcrect.GetHeight() == dstrect.GetHeight())
{ {
m_data.assign(software_source_texture->GetData(), software_source_texture->GetData() + m_data.size()); m_data.assign(software_source_texture->GetData(),
software_source_texture->GetData() + m_data.size());
} }
else else
{ {
@ -53,8 +53,8 @@ u8* SWTexture::GetData()
std::optional<AbstractTexture::RawTextureInfo> SWTexture::MapFullImpl() std::optional<AbstractTexture::RawTextureInfo> SWTexture::MapFullImpl()
{ {
return AbstractTexture::RawTextureInfo{ GetData(), return AbstractTexture::RawTextureInfo{GetData(), m_config.width * 4, m_config.width,
m_config.width * 4, m_config.width, m_config.height }; m_config.height};
} }
} // namespace SW } // namespace SW

View File

@ -30,7 +30,6 @@ public:
u8* GetData(); u8* GetData();
private: private:
std::optional<RawTextureInfo> MapFullImpl() override; std::optional<RawTextureInfo> MapFullImpl() override;
std::vector<u8> m_data; std::vector<u8> m_data;

View File

@ -7,23 +7,21 @@
namespace SW namespace SW
{ {
class TextureCache : public TextureCacheBase class TextureCache : public TextureCacheBase
{ {
public: public:
bool CompileShaders() override { return true; } bool CompileShaders() override { return true; }
void DeleteShaders() override {} void DeleteShaders() override {}
void ConvertTexture(TCacheEntry* entry, TCacheEntry* unconverted, const void* palette, void ConvertTexture(TCacheEntry* entry, TCacheEntry* unconverted, const void* palette,
TLUTFormat format) override TLUTFormat format) override
{ {
} }
void CopyEFB(u8* dst, const EFBCopyParams& params, u32 native_width, u32 bytes_per_row, void CopyEFB(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 EFBRectangle& src_rect,
bool scale_by_half) override bool scale_by_half) override
{ {
TextureEncoder::Encode(dst, params, native_width, bytes_per_row, TextureEncoder::Encode(dst, params, native_width, bytes_per_row, num_blocks_y, memory_stride,
num_blocks_y, memory_stride, src_rect, src_rect, scale_by_half);
scale_by_half);
} }
private: private:
@ -39,4 +37,4 @@ private:
} }
}; };
} // namespace SW } // namespace SW

View File

@ -1419,63 +1419,63 @@ 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 EFBRectangle& src_rect,
bool scale_by_half) bool scale_by_half)
{
const u8* src =
EfbInterface::GetPixelPointer(src_rect.left, src_rect.top, params.depth);
if (scale_by_half)
{
switch (params.efb_format)
{
case PEControl::RGBA6_Z24:
EncodeRGBA6halfscale(dst, src, params.copy_format, params.yuv);
break;
case PEControl::RGB8_Z24:
EncodeRGB8halfscale(dst, src, params.copy_format, params.yuv);
break;
case PEControl::RGB565_Z16:
EncodeRGB8halfscale(dst, src, params.copy_format, params.yuv);
break;
case PEControl::Z24:
EncodeZ24halfscale(dst, src, params.copy_format);
break;
}
}
else
{
switch (params.efb_format)
{
case PEControl::RGBA6_Z24:
EncodeRGBA6(dst, src, params.copy_format, params.yuv);
break;
case PEControl::RGB8_Z24:
EncodeRGB8(dst, src, params.copy_format, params.yuv);
break;
case PEControl::RGB565_Z16:
EncodeRGB8(dst, src, params.copy_format, params.yuv);
break;
case PEControl::Z24:
EncodeZ24(dst, src, params.copy_format);
break;
}
}
}
}
void Encode(u8* dst, const EFBCopyParams& params, u32 native_width, u32 bytes_per_row,
u32 num_blocks_y, u32 memory_stride, const EFBRectangle& src_rect,
bool scale_by_half)
{ {
if (params.copy_format == EFBCopyFormat::XFB) const u8* src = EfbInterface::GetPixelPointer(src_rect.left, src_rect.top, params.depth);
if (scale_by_half)
{ {
EfbInterface::EncodeXFB(reinterpret_cast<EfbInterface::yuv422_packed*>(dst), native_width, src_rect, params.y_scale); switch (params.efb_format)
{
case PEControl::RGBA6_Z24:
EncodeRGBA6halfscale(dst, src, params.copy_format, params.yuv);
break;
case PEControl::RGB8_Z24:
EncodeRGB8halfscale(dst, src, params.copy_format, params.yuv);
break;
case PEControl::RGB565_Z16:
EncodeRGB8halfscale(dst, src, params.copy_format, params.yuv);
break;
case PEControl::Z24:
EncodeZ24halfscale(dst, src, params.copy_format);
break;
}
} }
else else
{ {
EncodeEfbCopy(dst, params, native_width, bytes_per_row, num_blocks_y, memory_stride, src_rect, scale_by_half); switch (params.efb_format)
{
case PEControl::RGBA6_Z24:
EncodeRGBA6(dst, src, params.copy_format, params.yuv);
break;
case PEControl::RGB8_Z24:
EncodeRGB8(dst, src, params.copy_format, params.yuv);
break;
case PEControl::RGB565_Z16:
EncodeRGB8(dst, src, params.copy_format, params.yuv);
break;
case PEControl::Z24:
EncodeZ24(dst, src, params.copy_format);
break;
}
}
}
}
void Encode(u8* dst, const EFBCopyParams& params, u32 native_width, u32 bytes_per_row,
u32 num_blocks_y, u32 memory_stride, const EFBRectangle& src_rect, bool scale_by_half)
{
if (params.copy_format == EFBCopyFormat::XFB)
{
EfbInterface::EncodeXFB(reinterpret_cast<EfbInterface::yuv422_packed*>(dst), native_width,
src_rect, params.y_scale);
}
else
{
EncodeEfbCopy(dst, params, native_width, bytes_per_row, num_blocks_y, memory_stride, src_rect,
scale_by_half);
} }
} }
} }

View File

@ -12,6 +12,5 @@ struct EFBCopyParams;
namespace TextureEncoder namespace TextureEncoder
{ {
void Encode(u8* dst, const EFBCopyParams& params, u32 native_width, u32 bytes_per_row, void Encode(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 EFBRectangle& src_rect, bool scale_by_half);
bool scale_by_half);
} }

View File

@ -33,14 +33,14 @@
namespace Vulkan namespace Vulkan
{ {
namespace namespace
{ {
struct EFBEncodeParams struct EFBEncodeParams
{ {
std::array<s32, 4> position_uniform; std::array<s32, 4> position_uniform;
float y_scale; float y_scale;
}; };
} }
TextureConverter::TextureConverter() TextureConverter::TextureConverter()
{ {
} }
@ -265,8 +265,8 @@ void TextureConverter::EncodeTextureToMemory(VkImageView src_texture, u8* dest_p
// We also linear filtering for both box filtering and downsampling higher resolutions to 1x // We also linear filtering for both box filtering and downsampling higher resolutions to 1x
// TODO: This only produces perfect downsampling for 2x IR, other resolutions will need more // TODO: This only produces perfect downsampling for 2x IR, other resolutions will need more
// complex down filtering to average all pixels and produce the correct result. // complex down filtering to average all pixels and produce the correct result.
bool linear_filter = (scale_by_half && !params.depth) || g_renderer->GetEFBScale() != 1 || bool linear_filter =
params.y_scale > 1.0f; (scale_by_half && !params.depth) || g_renderer->GetEFBScale() != 1 || params.y_scale > 1.0f;
draw.SetPSSampler(0, src_texture, linear_filter ? g_object_cache->GetLinearSampler() : draw.SetPSSampler(0, src_texture, linear_filter ? g_object_cache->GetLinearSampler() :
g_object_cache->GetPointSampler()); g_object_cache->GetPointSampler());
@ -580,7 +580,7 @@ bool TextureConverter::CreateTexelBuffer()
m_texel_buffer_view_r16_uint = CreateTexelBufferView(VK_FORMAT_R16_UINT); m_texel_buffer_view_r16_uint = CreateTexelBufferView(VK_FORMAT_R16_UINT);
m_texel_buffer_view_r32g32_uint = CreateTexelBufferView(VK_FORMAT_R32G32_UINT); m_texel_buffer_view_r32g32_uint = CreateTexelBufferView(VK_FORMAT_R32G32_UINT);
m_texel_buffer_view_rgba8_unorm = CreateTexelBufferView(VK_FORMAT_R8G8B8A8_UNORM); m_texel_buffer_view_rgba8_unorm = CreateTexelBufferView(VK_FORMAT_R8G8B8A8_UNORM);
m_texel_buffer_view_rgba8_uint= CreateTexelBufferView(VK_FORMAT_R8G8B8A8_UINT); m_texel_buffer_view_rgba8_uint = CreateTexelBufferView(VK_FORMAT_R8G8B8A8_UINT);
return m_texel_buffer_view_r8_uint != VK_NULL_HANDLE && return m_texel_buffer_view_r8_uint != VK_NULL_HANDLE &&
m_texel_buffer_view_r16_uint != VK_NULL_HANDLE && m_texel_buffer_view_r16_uint != VK_NULL_HANDLE &&
m_texel_buffer_view_r32g32_uint != VK_NULL_HANDLE && m_texel_buffer_view_r32g32_uint != VK_NULL_HANDLE &&

View File

@ -133,8 +133,8 @@ std::optional<AbstractTexture::RawTextureInfo> VKTexture::MapRegionImpl(u32 leve
// Copy to download buffer. // Copy to download buffer.
m_staging_texture->CopyFromImage(g_command_buffer_mgr->GetCurrentCommandBuffer(), m_staging_texture->CopyFromImage(g_command_buffer_mgr->GetCurrentCommandBuffer(),
m_texture->GetImage(), VK_IMAGE_ASPECT_COLOR_BIT, x, y, width, m_texture->GetImage(), VK_IMAGE_ASPECT_COLOR_BIT, x, y, width,
height, level, 0); height, level, 0);
// Restore original state of texture. // Restore original state of texture.
m_texture->TransitionToLayout(g_command_buffer_mgr->GetCurrentCommandBuffer(), m_texture->TransitionToLayout(g_command_buffer_mgr->GetCurrentCommandBuffer(),

View File

@ -261,8 +261,8 @@ static void BPWritten(const BPCmd& bp)
bool is_depth_copy = bpmem.zcontrol.pixel_format == PEControl::Z24; bool is_depth_copy = bpmem.zcontrol.pixel_format == PEControl::Z24;
g_texture_cache->CopyRenderTargetToTexture(destAddr, EFBCopyFormat::XFB, destStride, g_texture_cache->CopyRenderTargetToTexture(destAddr, EFBCopyFormat::XFB, destStride,
is_depth_copy, srcRect, false, is_depth_copy, srcRect, false, false, yScale,
false, yScale, s_gammaLUT[PE_copy.gamma]); s_gammaLUT[PE_copy.gamma]);
// This stays in to signal end of a "frame" // This stays in to signal end of a "frame"
g_renderer->RenderToXFB(destAddr, srcRect, destStride, height, s_gammaLUT[PE_copy.gamma]); g_renderer->RenderToXFB(destAddr, srcRect, destStride, height, s_gammaLUT[PE_copy.gamma]);

View File

@ -17,4 +17,3 @@ std::unique_ptr<FramebufferManagerBase> g_framebuffer_manager;
unsigned int FramebufferManagerBase::m_EFBLayers = 1; unsigned int FramebufferManagerBase::m_EFBLayers = 1;
FramebufferManagerBase::~FramebufferManagerBase() = default; FramebufferManagerBase::~FramebufferManagerBase() = default;

View File

@ -23,9 +23,7 @@ public:
virtual ~FramebufferManagerBase(); virtual ~FramebufferManagerBase();
static unsigned int GetEFBLayers() { return m_EFBLayers; } static unsigned int GetEFBLayers() { return m_EFBLayers; }
protected: protected:
static unsigned int m_EFBLayers; static unsigned int m_EFBLayers;
}; };

View File

@ -42,8 +42,8 @@
#include "Core/Host.h" #include "Core/Host.h"
#include "Core/Movie.h" #include "Core/Movie.h"
#include "VideoCommon/AbstractTexture.h"
#include "VideoCommon/AVIDump.h" #include "VideoCommon/AVIDump.h"
#include "VideoCommon/AbstractTexture.h"
#include "VideoCommon/BPMemory.h" #include "VideoCommon/BPMemory.h"
#include "VideoCommon/CPMemory.h" #include "VideoCommon/CPMemory.h"
#include "VideoCommon/CommandProcessor.h" #include "VideoCommon/CommandProcessor.h"
@ -336,7 +336,8 @@ void Renderer::DrawDebugText()
"Speed Limit: Unlimited" : "Speed Limit: Unlimited" :
StringFromFormat("Speed Limit: %li%%", StringFromFormat("Speed Limit: %li%%",
std::lround(SConfig::GetInstance().m_EmulationSpeed * 100.f)), std::lround(SConfig::GetInstance().m_EmulationSpeed * 100.f)),
std::string("Copy XFB: ") + xfbcopy_text + (g_ActiveConfig.bImmediateXFB ? " (Immediate)" : ""), std::string("Copy XFB: ") + xfbcopy_text +
(g_ActiveConfig.bImmediateXFB ? " (Immediate)" : ""),
}; };
enum enum
@ -691,7 +692,8 @@ bool Renderer::IsFrameDumping()
void Renderer::UpdateFrameDumpTexture(float horizontal_scale) void Renderer::UpdateFrameDumpTexture(float horizontal_scale)
{ {
int target_width, target_height; int target_width, target_height;
std::tie(target_width, target_height) = CalculateOutputDimensions(m_last_xfb_texture->GetConfig().width, m_last_xfb_texture->GetConfig().height); std::tie(target_width, target_height) = CalculateOutputDimensions(
m_last_xfb_texture->GetConfig().width, m_last_xfb_texture->GetConfig().height);
if (m_dump_texture == nullptr || if (m_dump_texture == nullptr ||
m_dump_texture->GetConfig().width != static_cast<u32>(target_width) || m_dump_texture->GetConfig().width != static_cast<u32>(target_width) ||
m_dump_texture->GetConfig().height != static_cast<u32>(target_height)) m_dump_texture->GetConfig().height != static_cast<u32>(target_height))
@ -720,7 +722,7 @@ void Renderer::ShutdownFrameDumping()
void Renderer::DumpFrameData(const u8* data, int w, int h, int stride, const AVIDump::Frame& state) void Renderer::DumpFrameData(const u8* data, int w, int h, int stride, const AVIDump::Frame& state)
{ {
m_frame_dump_config = FrameDumpConfig{ m_last_xfb_texture, data, w, h, stride, state }; m_frame_dump_config = FrameDumpConfig{m_last_xfb_texture, data, w, h, stride, state};
if (!m_frame_dump_thread_running.IsSet()) if (!m_frame_dump_thread_running.IsSet())
{ {

View File

@ -208,7 +208,7 @@ private:
AVIDump::Frame state; AVIDump::Frame state;
} m_frame_dump_config; } m_frame_dump_config;
AbstractTexture * m_last_xfb_texture; AbstractTexture* m_last_xfb_texture;
u64 m_last_xfb_id = 0; u64 m_last_xfb_id = 0;
std::unique_ptr<AbstractTexture> m_dump_texture; std::unique_ptr<AbstractTexture> m_dump_texture;

View File

@ -376,16 +376,17 @@ TextureCacheBase::DoPartialTextureUpdates(TCacheEntry* entry_to_update, u8* pale
u32 copy_width = u32 copy_width =
std::min(entry->native_width - src_x, entry_to_update->native_width - dst_x); std::min(entry->native_width - src_x, entry_to_update->native_width - dst_x);
u32 copy_height = u32 copy_height =
std::min((entry->native_height * entry->y_scale) - src_y, (entry_to_update->native_height * entry_to_update->y_scale) - dst_y); std::min((entry->native_height * entry->y_scale) - src_y,
(entry_to_update->native_height * entry_to_update->y_scale) - dst_y);
// If one of the textures is scaled, scale both with the current efb scaling factor // If one of the textures is scaled, scale both with the current efb scaling factor
if (entry_to_update->native_width != entry_to_update->GetWidth() || if (entry_to_update->native_width != entry_to_update->GetWidth() ||
entry_to_update->native_height != entry_to_update->GetHeight() || entry_to_update->native_height != entry_to_update->GetHeight() ||
entry->native_width != entry->GetWidth() || entry->native_height != entry->GetHeight()) entry->native_width != entry->GetWidth() || entry->native_height != entry->GetHeight())
{ {
ScaleTextureCacheEntryTo(entry_to_update, ScaleTextureCacheEntryTo(
g_renderer->EFBToScaledX(entry_to_update->native_width), entry_to_update, g_renderer->EFBToScaledX(entry_to_update->native_width),
g_renderer->EFBToScaledY(entry_to_update->native_height * entry_to_update->y_scale)); g_renderer->EFBToScaledY(entry_to_update->native_height * entry_to_update->y_scale));
ScaleTextureCacheEntryTo(entry, g_renderer->EFBToScaledX(entry->native_width), ScaleTextureCacheEntryTo(entry, g_renderer->EFBToScaledX(entry->native_width),
g_renderer->EFBToScaledY(entry->native_height * entry->y_scale)); g_renderer->EFBToScaledY(entry->native_height * entry->y_scale));
@ -632,8 +633,7 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::Load(const u32 stage)
auto entry = GetTexture(address, width, height, texformat, auto entry = GetTexture(address, width, height, texformat,
g_ActiveConfig.iSafeTextureCache_ColorSamples, tlutaddr, tlutfmt, g_ActiveConfig.iSafeTextureCache_ColorSamples, tlutaddr, tlutfmt,
use_mipmaps, tex_levels, from_tmem, tmem_address_even, use_mipmaps, tex_levels, from_tmem, tmem_address_even, tmem_address_odd);
tmem_address_odd);
if (!entry) if (!entry)
return nullptr; return nullptr;
@ -643,7 +643,8 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::Load(const u32 stage)
GFX_DEBUGGER_PAUSE_AT(NEXT_TEXTURE_CHANGE, true); GFX_DEBUGGER_PAUSE_AT(NEXT_TEXTURE_CHANGE, true);
// We need to keep track of invalided textures until they have actually been replaced or re-loaded // We need to keep track of invalided textures until they have actually been replaced or
// re-loaded
valid_bind_points.set(stage); valid_bind_points.set(stage);
return entry; return entry;
@ -728,8 +729,8 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::GetTexture(u32 address, u32 wid
if (isPaletteTexture) if (isPaletteTexture)
{ {
palette_size = TexDecoder_GetPaletteSize(texformat); palette_size = TexDecoder_GetPaletteSize(texformat);
full_hash = base_hash ^ GetHash64(&texMem[tlutaddr], palette_size, full_hash =
textureCacheSafetyColorSampleSize); base_hash ^ GetHash64(&texMem[tlutaddr], palette_size, textureCacheSafetyColorSampleSize);
} }
else else
{ {
@ -794,7 +795,8 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::GetTexture(u32 address, u32 wid
// Do not load strided EFB copies, they are not meant to be used directly. // Do not load strided EFB copies, they are not meant to be used directly.
// Also do not directly load EFB copies, which were partly overwritten. // Also do not directly load EFB copies, which were partly overwritten.
if (entry->IsCopy() && entry->native_width == nativeW && static_cast<unsigned int>(entry->native_height * entry->y_scale) == nativeH && if (entry->IsCopy() && entry->native_width == nativeW &&
static_cast<unsigned int>(entry->native_height * entry->y_scale) == nativeH &&
entry->memory_stride == entry->BytesPerRow() && !entry->may_have_overlapping_textures) entry->memory_stride == entry->BytesPerRow() && !entry->may_have_overlapping_textures)
{ {
// EFB copies have slightly different rules as EFB copy formats have different // EFB copies have slightly different rules as EFB copy formats have different
@ -829,7 +831,7 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::GetTexture(u32 address, u32 wid
else else
{ {
// For normal textures, all texture parameters need to match // For normal textures, all texture parameters need to match
if (!entry->IsCopy() && entry->hash == full_hash && entry->format == full_format && if (!entry->IsCopy() && entry->hash == full_hash && entry->format == full_format &&
entry->native_levels >= tex_levels && entry->native_width == nativeW && entry->native_levels >= tex_levels && entry->native_width == nativeW &&
entry->native_height == nativeH) entry->native_height == nativeH)
{ {
@ -871,8 +873,7 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::GetTexture(u32 address, u32 wid
// Example: Tales of Symphonia (GC) uses over 500 small textures in menus, but only around 70 // Example: Tales of Symphonia (GC) uses over 500 small textures in menus, but only around 70
// different ones // different ones
if (textureCacheSafetyColorSampleSize == 0 || if (textureCacheSafetyColorSampleSize == 0 ||
std::max(texture_size, palette_size) <= std::max(texture_size, palette_size) <= (u32)textureCacheSafetyColorSampleSize * 8)
(u32)textureCacheSafetyColorSampleSize * 8)
{ {
auto hash_range = textures_by_hash.equal_range(full_hash); auto hash_range = textures_by_hash.equal_range(full_hash);
TexHashCache::iterator hash_iter = hash_range.first; TexHashCache::iterator hash_iter = hash_range.first;
@ -961,9 +962,9 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::GetTexture(u32 address, u32 wid
if (decode_on_gpu) if (decode_on_gpu)
{ {
u32 row_stride = bytes_per_block * (expandedWidth / bsw); u32 row_stride = bytes_per_block * (expandedWidth / bsw);
g_texture_cache->DecodeTextureOnGPU( g_texture_cache->DecodeTextureOnGPU(entry, 0, src_data, texture_size, texformat, width,
entry, 0, src_data, texture_size, texformat, width, height, height, expandedWidth, expandedHeight, row_stride, tlut,
expandedWidth, expandedHeight, row_stride, tlut, tlutfmt); tlutfmt);
} }
else else
{ {
@ -989,13 +990,11 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::GetTexture(u32 address, u32 wid
dst_buffer = temp; dst_buffer = temp;
if (!(texformat == TextureFormat::RGBA8 && from_tmem)) if (!(texformat == TextureFormat::RGBA8 && from_tmem))
{ {
TexDecoder_Decode(dst_buffer, src_data, expandedWidth, expandedHeight, texformat, tlut, TexDecoder_Decode(dst_buffer, src_data, expandedWidth, expandedHeight, texformat, tlut, tlutfmt);
tlutfmt);
} }
else else
{ {
u8* src_data_gb = u8* src_data_gb = &texMem[tmem_address_odd];
&texMem[tmem_address_odd];
TexDecoder_DecodeRGBA8FromTmem(dst_buffer, src_data, src_data_gb, expandedWidth, expandedHeight); TexDecoder_DecodeRGBA8FromTmem(dst_buffer, src_data, src_data_gb, expandedWidth, expandedHeight);
} }
@ -1009,8 +1008,7 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::GetTexture(u32 address, u32 wid
iter = textures_by_address.emplace(address, entry); iter = textures_by_address.emplace(address, entry);
if (textureCacheSafetyColorSampleSize == 0 || if (textureCacheSafetyColorSampleSize == 0 ||
std::max(texture_size, palette_size) <= std::max(texture_size, palette_size) <= (u32)textureCacheSafetyColorSampleSize * 8)
(u32)textureCacheSafetyColorSampleSize * 8)
{ {
entry->textures_by_hash_iter = textures_by_hash.emplace(full_hash, entry); entry->textures_by_hash_iter = textures_by_hash.emplace(full_hash, entry);
} }
@ -1181,7 +1179,8 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, EFBCopyFormat dstF
PEControl::PixelFormat srcFormat = bpmem.zcontrol.pixel_format; PEControl::PixelFormat srcFormat = bpmem.zcontrol.pixel_format;
bool efbHasAlpha = srcFormat == PEControl::RGBA6_Z24; bool efbHasAlpha = srcFormat == PEControl::RGBA6_Z24;
bool copy_to_ram = !g_ActiveConfig.bSkipEFBCopyToRam || g_ActiveConfig.backend_info.bForceCopyToRam; bool copy_to_ram =
!g_ActiveConfig.bSkipEFBCopyToRam || g_ActiveConfig.backend_info.bForceCopyToRam;
bool copy_to_vram = g_ActiveConfig.backend_info.bSupportsCopyToVram; bool copy_to_vram = g_ActiveConfig.backend_info.bSupportsCopyToVram;
bool is_xfb_copy = false; bool is_xfb_copy = false;
@ -1418,7 +1417,8 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, EFBCopyFormat dstF
ColorMask[3] = 0.0f; ColorMask[3] = 0.0f;
fConstAdd[3] = 1.0f; fConstAdd[3] = 1.0f;
cbufid = 30; // just re-use the RGBX8 cbufid from above cbufid = 30; // just re-use the RGBX8 cbufid from above
copy_to_ram = !g_ActiveConfig.bSkipXFBCopyToRam || g_ActiveConfig.backend_info.bForceCopyToRam; copy_to_ram =
!g_ActiveConfig.bSkipXFBCopyToRam || g_ActiveConfig.backend_info.bForceCopyToRam;
is_xfb_copy = true; is_xfb_copy = true;
break; break;
@ -1587,7 +1587,7 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, EFBCopyFormat dstF
0); 0);
} }
if (g_ActiveConfig.bDumpXFBTarget && is_xfb_copy) if (g_ActiveConfig.bDumpXFBTarget && is_xfb_copy)
{ {
static int xfb_count = 0; static int xfb_count = 0;
entry->texture->Save(StringFromFormat("%sxfb_frame_%i.png", entry->texture->Save(StringFromFormat("%sxfb_frame_%i.png",

View File

@ -46,7 +46,8 @@ struct EFBCopyParams
{ {
EFBCopyParams(PEControl::PixelFormat efb_format_, EFBCopyFormat copy_format_, bool depth_, EFBCopyParams(PEControl::PixelFormat efb_format_, EFBCopyFormat copy_format_, bool depth_,
bool yuv_, float y_scale_) bool yuv_, float y_scale_)
: efb_format(efb_format_), copy_format(copy_format_), depth(depth_), yuv(yuv_), y_scale(y_scale_) : efb_format(efb_format_), copy_format(copy_format_), depth(depth_), yuv(yuv_),
y_scale(y_scale_)
{ {
} }
@ -111,7 +112,8 @@ public:
~TCacheEntry(); ~TCacheEntry();
void SetGeneralParameters(u32 _addr, u32 _size, TextureAndTLUTFormat _format, bool force_safe_hashing) void SetGeneralParameters(u32 _addr, u32 _size, TextureAndTLUTFormat _format,
bool force_safe_hashing)
{ {
addr = _addr; addr = _addr;
size_in_bytes = _size; size_in_bytes = _size;
@ -150,7 +152,6 @@ public:
bool IsEfbCopy() const { return is_efb_copy; } bool IsEfbCopy() const { return is_efb_copy; }
bool IsCopy() const { return is_xfb_copy || is_efb_copy; } bool IsCopy() const { return is_xfb_copy || is_efb_copy; }
u32 NumBlocksY() const; u32 NumBlocksY() const;
u32 BytesPerRow() const; u32 BytesPerRow() const;
@ -186,7 +187,7 @@ public:
static bool IsValidBindPoint(u32 i) { return valid_bind_points.test(i); } static bool IsValidBindPoint(u32 i) { return valid_bind_points.test(i); }
TCacheEntry* GetTexture(u32 address, u32 width, u32 height, const TextureFormat texformat, TCacheEntry* GetTexture(u32 address, u32 width, u32 height, const TextureFormat texformat,
const int textureCacheSafetyColorSampleSize, u32 tlutaddr = 0, const int textureCacheSafetyColorSampleSize, u32 tlutaddr = 0,
TLUTFormat tlutfmt = TLUTFormat::IA8, bool use_mipmaps = false, TLUTFormat tlutfmt = TLUTFormat::IA8, bool use_mipmaps = false,
u32 tex_levels = 1, bool from_tmem = false, u32 tmem_address_even = 0, u32 tex_levels = 1, bool from_tmem = false, u32 tmem_address_even = 0,
u32 tmem_address_odd = 0); u32 tmem_address_odd = 0);
virtual void BindTextures(); virtual void BindTextures();

View File

@ -64,7 +64,8 @@ static void WriteSwizzler(char*& p, EFBCopyFormat format, APIType ApiType)
// left, top, of source rectangle within source texture // left, top, of source rectangle within source texture
// width of the destination rectangle, scale_factor (1 or 2) // width of the destination rectangle, scale_factor (1 or 2)
if (ApiType == APIType::Vulkan) if (ApiType == APIType::Vulkan)
WRITE(p, "layout(std140, push_constant) uniform PCBlock { int4 position; float y_scale; } PC;\n"); WRITE(p,
"layout(std140, push_constant) uniform PCBlock { int4 position; float y_scale; } PC;\n");
else else
{ {
WRITE(p, "uniform int4 position;\n"); WRITE(p, "uniform int4 position;\n");
@ -154,7 +155,7 @@ static void WriteSwizzler(char*& p, EFBCopyFormat format, APIType ApiType)
// pixel) // pixel)
WRITE(p, " uv0 += float2(position.xy);\n"); // move to copied rect WRITE(p, " uv0 += float2(position.xy);\n"); // move to copied rect
WRITE(p, " uv0 /= float2(%d, %d);\n", EFB_WIDTH, EFB_HEIGHT); // normalize to [0:1] WRITE(p, " uv0 /= float2(%d, %d);\n", EFB_WIDTH, EFB_HEIGHT); // normalize to [0:1]
WRITE(p, " uv0 /= float2(1, y_scale);\n"); // apply the y scaling WRITE(p, " uv0 /= float2(1, y_scale);\n"); // apply the y scaling
if (ApiType == APIType::OpenGL) // ogl has to flip up and down if (ApiType == APIType::OpenGL) // ogl has to flip up and down
{ {
WRITE(p, " uv0.y = 1.0-uv0.y;\n"); WRITE(p, " uv0.y = 1.0-uv0.y;\n");
@ -1264,11 +1265,11 @@ static const std::map<TextureFormat, DecodingShaderInfo> s_decoding_shader_info{
} }
)"}}, )"}},
// We do the inverse BT.601 conversion for YCbCr to RGB // We do the inverse BT.601 conversion for YCbCr to RGB
// http://www.equasys.de/colorconversion.html#YCbCr-RGBColorFormatConversion // http://www.equasys.de/colorconversion.html#YCbCr-RGBColorFormatConversion
{ TextureFormat::XFB, {TextureFormat::XFB,
{ BUFFER_FORMAT_RGBA8_UINT, 0, 8, 8, false, {BUFFER_FORMAT_RGBA8_UINT, 0, 8, 8, false,
R"( R"(
layout(local_size_x = 8, local_size_y = 8) in; layout(local_size_x = 8, local_size_y = 8) in;
void main() void main()

View File

@ -3,8 +3,8 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <algorithm> #include <algorithm>
#include <cstddef>
#include <cmath> #include <cmath>
#include <cstddef>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/MathUtil.h" #include "Common/MathUtil.h"

View File

@ -55,7 +55,7 @@ struct TargetRectangle : public MathUtil::Rectangle<int>
return (RECT*)this; return (RECT*)this;
} }
#endif #endif
TargetRectangle(const MathUtil::Rectangle<int> &other) : MathUtil::Rectangle<int>(other) {} TargetRectangle(const MathUtil::Rectangle<int>& other) : MathUtil::Rectangle<int>(other) {}
TargetRectangle() = default; TargetRectangle() = default;
}; };

View File

@ -223,7 +223,7 @@ struct VideoConfig final
bool bSupportsGPUTextureDecoding; bool bSupportsGPUTextureDecoding;
bool bSupportsST3CTextures; bool bSupportsST3CTextures;
bool bSupportsCopyToVram; bool bSupportsCopyToVram;
bool bForceCopyToRam; // Needed by Software Renderer bool bForceCopyToRam; // Needed by Software Renderer
bool bSupportsBitfield; // Needed by UberShaders, so must stay in VideoCommon bool bSupportsBitfield; // Needed by UberShaders, so must stay in VideoCommon
bool bSupportsDynamicSamplerIndexing; // Needed by UberShaders, so must stay in VideoCommon bool bSupportsDynamicSamplerIndexing; // Needed by UberShaders, so must stay in VideoCommon
bool bSupportsBPTCTextures; bool bSupportsBPTCTextures;