Skip to content

Commit

Permalink
OpenGL: Remove "-legacy" flag
Browse files Browse the repository at this point in the history
"Intel legacy mode" was a special mode to workaround various Intel OpenGL driver limitations during the earlier years of Cemu. It's been unmaintained for years and no longer serves a purpose.

If we ever bring back compatibility with ancient Intel GPUs it should be done in a more structured way than a blunt yes/no flag.
  • Loading branch information
Exzap committed Mar 14, 2024
1 parent 193767e commit 731713d
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 126 deletions.
3 changes: 0 additions & 3 deletions src/Cafe/GraphicPack/GraphicPack2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -878,9 +878,6 @@ bool GraphicPack2::Activate()
if (m_gfx_vendor.has_value())
{
auto vendor = g_renderer->GetVendor();
if (vendor == GfxVendor::IntelLegacy || vendor == GfxVendor::IntelNoLegacy)
vendor = GfxVendor::Intel;

if (m_gfx_vendor.value() != vendor)
return false;
}
Expand Down
2 changes: 0 additions & 2 deletions src/Cafe/HW/Latte/Core/LatteConst.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@
#define GLVENDOR_UNKNOWN (0)
#define GLVENDOR_AMD (1) // AMD/ATI
#define GLVENDOR_NVIDIA (2)
#define GLVENDOR_INTEL_LEGACY (3)
#define GLVENDOR_INTEL_NOLEGACY (4)
#define GLVENDOR_INTEL (5)
#define GLVENDOR_APPLE (6)

Expand Down
21 changes: 8 additions & 13 deletions src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,21 +229,16 @@ void LatteTexture_updateTexturesForStage(LatteDecompilerShader* shaderContext, u
// if this texture is bound multiple times then use alternative views
if (textureView->lastTextureBindIndex == LatteGPUState.textureBindCounter)
{
// Intel driver has issues with textures that have multiple views bound and used by a shader, causes a softlock in BotW
// therefore we disable this on Intel
if (LatteGPUState.glVendor != GLVENDOR_INTEL_NOLEGACY)
LatteTextureViewGL* textureViewGL = (LatteTextureViewGL*)textureView;
// get next unused alternative texture view
while (true)
{
LatteTextureViewGL* textureViewGL = (LatteTextureViewGL*)textureView;
// get next unused alternative texture view
while (true)
{
textureViewGL = textureViewGL->GetAlternativeView();
if (textureViewGL->lastTextureBindIndex != LatteGPUState.textureBindCounter)
break;
}
textureView = textureViewGL;
textureViewGL = textureViewGL->GetAlternativeView();
if (textureViewGL->lastTextureBindIndex != LatteGPUState.textureBindCounter)
break;
}
}
textureView = textureViewGL;
}
textureView->lastTextureBindIndex = LatteGPUState.textureBindCounter;
rendererGL->renderstate_updateTextureSettingsGL(shaderContext, textureView, textureIndex + glBackendBaseTexUnit, word4, textureIndex, isDepthSampler);
}
Expand Down
8 changes: 1 addition & 7 deletions src/Cafe/HW/Latte/Core/LatteThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,7 @@ int Latte_ThreadEntry()
case GfxVendor::AMD:
LatteGPUState.glVendor = GLVENDOR_AMD;
break;
case GfxVendor::IntelLegacy:
LatteGPUState.glVendor = GLVENDOR_INTEL_LEGACY;
break;
case GfxVendor::IntelNoLegacy:
LatteGPUState.glVendor = GLVENDOR_INTEL_NOLEGACY;
break;
case GfxVendor::Intel:
case GfxVendor::Intel:
LatteGPUState.glVendor = GLVENDOR_INTEL;
break;
case GfxVendor::Nvidia:
Expand Down
62 changes: 15 additions & 47 deletions src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ void LatteTextureGL::GetOpenGLFormatInfo(bool isDepth, Latte::E_GX2SURFFMT forma
sint32 glInternalFormat;
sint32 glSuppliedFormat;
sint32 glSuppliedFormatType;
// check if compressed textures should be used
bool allowCompressedGLFormat = true;
if (LatteGPUState.glVendor == GLVENDOR_INTEL_LEGACY)
allowCompressedGLFormat = false; // compressed formats seem to cause more harm than good on Intel
// get format information
if (format == Latte::E_GX2SURFFMT::R4_G4_UNORM)
{
Expand Down Expand Up @@ -149,20 +145,11 @@ void LatteTextureGL::GetOpenGLFormatInfo(bool isDepth, Latte::E_GX2SURFFMT forma
else if (format == Latte::E_GX2SURFFMT::BC1_UNORM ||
format == Latte::E_GX2SURFFMT::BC1_SRGB)
{
if (allowCompressedGLFormat)
{
if (format == Latte::E_GX2SURFFMT::BC1_SRGB)
formatInfoOut->setCompressed(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, -1, -1);
else
formatInfoOut->setCompressed(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, -1, -1);
return;
}
if (format == Latte::E_GX2SURFFMT::BC1_SRGB)
formatInfoOut->setCompressed(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, -1, -1);
else
{
formatInfoOut->setFormat(GL_RGBA16F, GL_RGBA, GL_FLOAT);
formatInfoOut->markAsAlternativeFormat();
return;
}
formatInfoOut->setCompressed(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, -1, -1);
return;
}
else if (format == Latte::E_GX2SURFFMT::BC2_UNORM || format == Latte::E_GX2SURFFMT::BC2_SRGB)
{
Expand All @@ -173,28 +160,18 @@ void LatteTextureGL::GetOpenGLFormatInfo(bool isDepth, Latte::E_GX2SURFFMT forma
}
else if (format == Latte::E_GX2SURFFMT::BC3_UNORM || format == Latte::E_GX2SURFFMT::BC3_SRGB)
{
if (allowCompressedGLFormat)
{
if (format == Latte::E_GX2SURFFMT::BC3_SRGB)
formatInfoOut->setCompressed(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, -1, -1);
else
formatInfoOut->setCompressed(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, -1, -1);
return;
}
if (format == Latte::E_GX2SURFFMT::BC3_SRGB)
formatInfoOut->setCompressed(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, -1, -1);
else
{
// todo: SRGB support
formatInfoOut->setFormat(GL_RGBA16F, GL_RGBA, GL_FLOAT);
formatInfoOut->markAsAlternativeFormat();
return;
}
formatInfoOut->setCompressed(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, -1, -1);
return;
}
else if (format == Latte::E_GX2SURFFMT::BC4_UNORM || format == Latte::E_GX2SURFFMT::BC4_SNORM)
{
bool allowCompressed = true;
if (dim != Latte::E_DIM::DIM_2D && dim != Latte::E_DIM::DIM_2D_ARRAY)
allowCompressedGLFormat = false; // RGTC1 does not support non-2D textures

if (allowCompressedGLFormat)
allowCompressed = false; // RGTC1 does not support non-2D textures
if (allowCompressed)
{
if (format == Latte::E_GX2SURFFMT::BC4_UNORM)
formatInfoOut->setCompressed(GL_COMPRESSED_RED_RGTC1, -1, -1);
Expand All @@ -211,20 +188,11 @@ void LatteTextureGL::GetOpenGLFormatInfo(bool isDepth, Latte::E_GX2SURFFMT forma
}
else if (format == Latte::E_GX2SURFFMT::BC5_UNORM || format == Latte::E_GX2SURFFMT::BC5_SNORM)
{
if (allowCompressedGLFormat)
{
if (format == Latte::E_GX2SURFFMT::BC5_SNORM)
formatInfoOut->setCompressed(GL_COMPRESSED_SIGNED_RG_RGTC2, -1, -1);
else
formatInfoOut->setCompressed(GL_COMPRESSED_RG_RGTC2, -1, -1);
return;
}
if (format == Latte::E_GX2SURFFMT::BC5_SNORM)
formatInfoOut->setCompressed(GL_COMPRESSED_SIGNED_RG_RGTC2, -1, -1);
else
{
formatInfoOut->setFormat(GL_RG16F, GL_RG, GL_FLOAT);
formatInfoOut->markAsAlternativeFormat();
return;
}
formatInfoOut->setCompressed(GL_COMPRESSED_RG_RGTC2, -1, -1);
return;
}
else if (format == Latte::E_GX2SURFFMT::R32_FLOAT)
{
Expand Down
44 changes: 1 addition & 43 deletions src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,7 @@ void OpenGLRenderer::GetVendorInformation()
}
else if (memcmp(glVendorString, "Intel", 5) == 0)
{
if (LaunchSettings::ForceIntelLegacyEnabled())
m_vendor = GfxVendor::IntelLegacy;
else
m_vendor = GfxVendor::IntelNoLegacy;
m_vendor = GfxVendor::Intel;
return;
}
}
Expand Down Expand Up @@ -849,45 +846,6 @@ TextureDecoder* OpenGLRenderer::texture_chooseDecodedFormat(Latte::E_GX2SURFFMT
}
return nullptr;
}

if (LatteGPUState.glVendor == GLVENDOR_INTEL_LEGACY)
{
if (format == Latte::E_GX2SURFFMT::BC1_UNORM)
{
texDecoder = TextureDecoder_BC1_UNORM_uncompress::getInstance();
}
else if (format == Latte::E_GX2SURFFMT::BC1_SRGB)
{
texDecoder = TextureDecoder_BC1_SRGB_uncompress::getInstance();
}
else if (format == Latte::E_GX2SURFFMT::BC3_UNORM)
{
texDecoder = TextureDecoder_BC3_UNORM_uncompress::getInstance();
}
else if (format == Latte::E_GX2SURFFMT::BC3_SRGB)
{
texDecoder = TextureDecoder_BC3_SRGB_uncompress::getInstance();
}
else if (format == Latte::E_GX2SURFFMT::BC4_UNORM)
{
texDecoder = TextureDecoder_BC4_UNORM_uncompress::getInstance();
}
else if (format == Latte::E_GX2SURFFMT::BC4_SNORM)
{
cemu_assert_debug(false); // todo
}
else if (format == Latte::E_GX2SURFFMT::BC5_UNORM)
{
texDecoder = TextureDecoder_BC5_UNORM_uncompress::getInstance();
}
else if (format == Latte::E_GX2SURFFMT::BC5_SNORM)
{
texDecoder = TextureDecoder_BC5_SNORM_uncompress::getInstance();
}
if (texDecoder)
return texDecoder;
}

if (format == Latte::E_GX2SURFFMT::R4_G4_UNORM)
texDecoder = TextureDecoder_R4_G4_UNORM_To_RGBA4::getInstance();
else if (format == Latte::E_GX2SURFFMT::R4_G4_B4_A4_UNORM)
Expand Down
2 changes: 1 addition & 1 deletion src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRendererCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ void OpenGLRenderer::draw_genericDrawHandler(uint32 baseVertex, uint32 baseInsta
bool streamoutEnable = LatteGPUState.contextRegister[mmVGT_STRMOUT_EN] != 0;
if (streamoutEnable)
{
if (glBeginTransformFeedback == nullptr || LatteGPUState.glVendor == GLVENDOR_INTEL_NOLEGACY)
if (glBeginTransformFeedback == nullptr)
{
cemu_assert_debug(false);
return; // transform feedback not supported
Expand Down
2 changes: 0 additions & 2 deletions src/Cafe/HW/Latte/Renderer/Renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ enum class GfxVendor
Generic,

AMD,
IntelLegacy,
IntelNoLegacy,
Intel,
Nvidia,
Apple,
Expand Down
2 changes: 0 additions & 2 deletions src/config/LaunchSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ bool LaunchSettings::HandleCommandline(const std::vector<std::wstring>& args)

if (vm.count("nsight"))
s_nsight_mode = vm["nsight"].as<bool>();
if (vm.count("legacy"))
s_force_intel_legacy = vm["legacy"].as<bool>();

if(vm.count("force-interpreter"))
s_force_interpreter = vm["force-interpreter"].as<bool>();
Expand Down
2 changes: 0 additions & 2 deletions src/config/LaunchSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class LaunchSettings

static bool GDBStubEnabled() { return s_enable_gdbstub; }
static bool NSightModeEnabled() { return s_nsight_mode; }
static bool ForceIntelLegacyEnabled() { return s_force_intel_legacy; }

static bool ForceInterpreter() { return s_force_interpreter; };

Expand All @@ -44,7 +43,6 @@ class LaunchSettings

inline static bool s_enable_gdbstub = false;
inline static bool s_nsight_mode = false;
inline static bool s_force_intel_legacy = false;

inline static bool s_force_interpreter = false;

Expand Down
4 changes: 0 additions & 4 deletions src/gui/guiWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ void gui_updateWindowTitles(bool isIdle, bool isLoading, double fps)
const char* graphicMode = "[Generic]";
if (LatteGPUState.glVendor == GLVENDOR_AMD)
graphicMode = "[AMD GPU]";
else if (LatteGPUState.glVendor == GLVENDOR_INTEL_LEGACY)
graphicMode = "[Intel GPU - Legacy]";
else if (LatteGPUState.glVendor == GLVENDOR_INTEL_NOLEGACY)
graphicMode = "[Intel GPU]";
else if (LatteGPUState.glVendor == GLVENDOR_INTEL)
graphicMode = "[Intel GPU]";
else if (LatteGPUState.glVendor == GLVENDOR_NVIDIA)
Expand Down

0 comments on commit 731713d

Please sign in to comment.