diff options
| author | Lioncash <mathew1800@gmail.com> | 2014-08-17 15:17:04 -0400 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2014-08-17 15:17:04 -0400 |
| commit | 15a3b30e27121ad89805b2e3ac8920d3a5e92960 (patch) | |
| tree | 1758da2240fd1f73bb5801f6f95e2b3a5c4a4bf4 /Source/Core/VideoBackends/OGL/Render.cpp | |
| parent | e3e1869493d95ea88c68941642c785553b833fa1 (diff) | |
| parent | 7e3d1050f0f25f659dded00a9df787195b47e7b5 (diff) | |
Merge pull request #790 from lioncash/ogl-cleanup
Small OGL cleanup
Diffstat (limited to 'Source/Core/VideoBackends/OGL/Render.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/OGL/Render.cpp | 87 |
1 files changed, 73 insertions, 14 deletions
diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index 61429d41e8..f605d276e7 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -64,7 +64,8 @@ static int OSDInternalW, OSDInternalH; namespace OGL { -enum MultisampleMode { +enum MultisampleMode +{ MULTISAMPLE_OFF, MULTISAMPLE_2X, MULTISAMPLE_4X, @@ -125,26 +126,34 @@ static int GetNumMSAASamples(int MSAAMode) samples = 1; } - if (samples <= g_ogl_config.max_samples) return samples; + if (samples <= g_ogl_config.max_samples) + return samples; // TODO: move this to InitBackendInfo OSD::AddMessage(StringFromFormat("%d Anti Aliasing samples selected, but only %d supported by your GPU.", samples, g_ogl_config.max_samples), 10000); return g_ogl_config.max_samples; } -static void ApplySSAASettings() { +static void ApplySSAASettings() +{ // GLES3 doesn't support SSAA if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGL) { - if (g_ActiveConfig.iMultisampleMode == MULTISAMPLE_SSAA_4X) { - if (g_ogl_config.bSupportSampleShading) { + if (g_ActiveConfig.iMultisampleMode == MULTISAMPLE_SSAA_4X) + { + if (g_ogl_config.bSupportSampleShading) + { glEnable(GL_SAMPLE_SHADING_ARB); glMinSampleShadingARB(s_MSAASamples); - } else { + } + else + { // TODO: move this to InitBackendInfo OSD::AddMessage("SSAA Anti Aliasing isn't supported by your GPU.", 10000); } - } else if (g_ogl_config.bSupportSampleShading) { + } + else if (g_ogl_config.bSupportSampleShading) + { glDisable(GL_SAMPLE_SHADING_ARB); } } @@ -208,28 +217,46 @@ static void InitDriverInfo() // Get the vendor first if (svendor == "NVIDIA Corporation" && srenderer != "NVIDIA Tegra") + { vendor = DriverDetails::VENDOR_NVIDIA; + } else if (svendor == "ATI Technologies Inc." || svendor == "Advanced Micro Devices, Inc.") + { vendor = DriverDetails::VENDOR_ATI; + } else if (std::string::npos != sversion.find("Mesa")) + { vendor = DriverDetails::VENDOR_MESA; + } else if (std::string::npos != svendor.find("Intel")) + { vendor = DriverDetails::VENDOR_INTEL; + } else if (svendor == "ARM") + { vendor = DriverDetails::VENDOR_ARM; + } else if (svendor == "http://limadriver.org/") { vendor = DriverDetails::VENDOR_ARM; driver = DriverDetails::DRIVER_LIMA; } else if (svendor == "Qualcomm") + { vendor = DriverDetails::VENDOR_QUALCOMM; + } else if (svendor == "Imagination Technologies") + { vendor = DriverDetails::VENDOR_IMGTEC; + } else if (svendor == "NVIDIA Corporation" && srenderer == "NVIDIA Tegra") + { vendor = DriverDetails::VENDOR_TEGRA; + } else if (svendor == "Vivante Corporation") + { vendor = DriverDetails::VENDOR_VIVANTE; + } // Get device family and driver version...if we care about it switch (vendor) @@ -588,8 +615,11 @@ Renderer::Renderer() if (g_ActiveConfig.backend_info.bSupportsPrimitiveRestart) { if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES3) + { glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX); + } else + { if (g_ogl_config.bSupportOGL31) { glEnable(GL_PRIMITIVE_RESTART); @@ -600,6 +630,7 @@ Renderer::Renderer() glEnableClientState(GL_PRIMITIVE_RESTART_NV); glPrimitiveRestartIndexNV(65535); } + } } UpdateActiveConfig(); ClearEFBCache(); @@ -1045,9 +1076,21 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) { color |= 0xFF000000; } - if (alpha_read_mode.ReadMode == 2) return color; // GX_READ_NONE - else if (alpha_read_mode.ReadMode == 1) return (color | 0xFF000000); // GX_READ_FF - else /*if(alpha_read_mode.ReadMode == 0)*/ return (color & 0x00FFFFFF); // GX_READ_00 + if (alpha_read_mode.ReadMode == 2) + { + // GX_READ_NONE + return color; + } + else if (alpha_read_mode.ReadMode == 1) + { + // GX_READ_FF + return (color | 0xFF000000); + } + else /*if(alpha_read_mode.ReadMode == 0)*/ + { + // GX_READ_00 + return (color & 0x00FFFFFF); + } } case POKE_COLOR: @@ -1232,7 +1275,9 @@ void Renderer::SetBlendMode(bool forceUpdate) newval |= bpmem.blendmode.subtract << 2; if (bpmem.blendmode.subtract) + { newval |= 0x0049; // enable blending src 1 dst 1 + } else if (bpmem.blendmode.blendenable) { newval |= 1; // enable blending @@ -1243,8 +1288,10 @@ void Renderer::SetBlendMode(bool forceUpdate) u32 changes = forceUpdate ? 0xFFFFFFFF : newval ^ s_blendMode; if (changes & 1) + { // blend enable change (newval & 1) ? glEnable(GL_BLEND) : glDisable(GL_BLEND); + } if (changes & 4) { @@ -1271,12 +1318,16 @@ void Renderer::SetBlendMode(bool forceUpdate) else { // we can't use GL_DST_COLOR or GL_ONE_MINUS_DST_COLOR for source in alpha channel so use their alpha equivalent instead - if (srcidx == BlendMode::DSTCLR) srcidx = BlendMode::DSTALPHA; - if (srcidx == BlendMode::INVDSTCLR) srcidx = BlendMode::INVDSTALPHA; + if (srcidx == BlendMode::DSTCLR) + srcidx = BlendMode::DSTALPHA; + else if (srcidx == BlendMode::INVDSTCLR) + srcidx = BlendMode::INVDSTALPHA; // we can't use GL_SRC_COLOR or GL_ONE_MINUS_SRC_COLOR for destination in alpha channel so use their alpha equivalent instead - if (dstidx == BlendMode::SRCCLR) dstidx = BlendMode::SRCALPHA; - if (dstidx == BlendMode::INVSRCCLR) dstidx = BlendMode::INVSRCALPHA; + if (dstidx == BlendMode::SRCCLR) + dstidx = BlendMode::SRCALPHA; + else if (dstidx == BlendMode::INVSRCCLR) + dstidx = BlendMode::INVSRCALPHA; } GLenum srcFactorAlpha = glSrcFactors[srcidx]; GLenum dstFactorAlpha = glDestFactors[dstidx]; @@ -1452,7 +1503,9 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl bAVIDumping = AVIDump::Start(w, h); #endif if (!bAVIDumping) + { OSD::AddMessage("AVIDump Start failed", 2000); + } else { OSD::AddMessage(StringFromFormat( @@ -1472,7 +1525,9 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl bLastFrameDumped = true; } else + { NOTICE_LOG(VIDEO, "Error reading framebuffer"); + } } else { @@ -1503,7 +1558,9 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl movie_file_name = File::GetUserPath(D_DUMPFRAMES_IDX) + "framedump.raw"; pFrameDump.Open(movie_file_name, "wb"); if (!pFrameDump) + { OSD::AddMessage("Error opening framedump.raw for writing.", 2000); + } else { OSD::AddMessage(StringFromFormat("Dumping Frames to \"%s\" (%dx%d RGB24)", movie_file_name.c_str(), w, h), 2000); @@ -1679,7 +1736,9 @@ void Renderer::SetGenerationMode() glFrontFace(bpmem.genMode.cullmode == 2 ? GL_CCW : GL_CW); } else + { glDisable(GL_CULL_FACE); + } } void Renderer::SetDepthMode() |
