diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt index f454646b30..ade52cadda 100644 --- a/pcsx2/CMakeLists.txt +++ b/pcsx2/CMakeLists.txt @@ -602,9 +602,7 @@ set(pcsx2GSSources GS/GSTables.cpp GS/GSUtil.cpp GS/GSVector.cpp - GS/GSdx.cpp GS/GS_res.cpp - GS/GS_types.h GS/Renderers/Common/GSDevice.cpp GS/Renderers/Common/GSDirtyRect.cpp GS/Renderers/Common/GSFunctionMap.cpp @@ -662,8 +660,8 @@ set(pcsx2GSHeaders GS/GSDrawingContext.h GS/GSDrawingEnvironment.h GS/GSDump.h - GS/GSdx.h GS/GS_res.h + GS/GS_types.h GS/GS.h GS/GSLocalMemory.h GS/GSLzma.h diff --git a/pcsx2/GS/GS.cpp b/pcsx2/GS/GS.cpp index fbd2e2ae03..b31ae756f3 100644 --- a/pcsx2/GS/GS.cpp +++ b/pcsx2/GS/GS.cpp @@ -37,6 +37,8 @@ #include "Window/GSWndWGL.h" #include "Window/GSSettingsDlg.h" +#undef None + static HRESULT s_hr = E_FAIL; #else @@ -100,7 +102,7 @@ int GSinit() return -1; } - // Vector instructions must be avoided when initialising GSdx since PCSX2 + // Vector instructions must be avoided when initialising GS since PCSX2 // can crash if the CPU does not support the instruction set. // Initialise it here instead - it's not ideal since we have to strip the // const type qualifier from all the affected variables. @@ -268,7 +270,7 @@ int _GSopen(void** dsp, const char* title, GSRendererType renderer, int threads break; } - catch (GSDXRecoverableError) + catch (GSRecoverableError) { wnd->Detach(); } @@ -350,7 +352,7 @@ int _GSopen(void** dsp, const char* title, GSRendererType renderer, int threads // be problematic, because of differing typeids between DLL and EXE compilations. // ('new' could throw std::alloc) - printf("GSdx error: Exception caught in GSopen: %s", ex.what()); + printf("GS error: Exception caught in GSopen: %s", ex.what()); return -1; } @@ -375,9 +377,9 @@ int _GSopen(void** dsp, const char* title, GSRendererType renderer, int threads if (renderer == GSRendererType::OGL_HW && theApp.GetConfigI("debug_glsl_shader") == 2) { - printf("GSdx: test OpenGL shader. Please wait...\n\n"); + printf("GS: test OpenGL shader. Please wait...\n\n"); static_cast(s_gs->m_dev)->SelfShaderTest(); - printf("\nGSdx: test OpenGL shader done. It will now exit\n"); + printf("\nGS: test OpenGL shader done. It will now exit\n"); return -1; } @@ -488,7 +490,7 @@ void GSreset() { s_gs->Reset(); } - catch (GSDXRecoverableError) + catch (GSRecoverableError) { } } @@ -499,7 +501,7 @@ void GSgifSoftReset(uint32 mask) { s_gs->SoftReset(mask); } - catch (GSDXRecoverableError) + catch (GSRecoverableError) { } } @@ -510,7 +512,7 @@ void GSwriteCSR(uint32 csr) { s_gs->WriteCSR(csr); } - catch (GSDXRecoverableError) + catch (GSRecoverableError) { } } @@ -522,12 +524,12 @@ void GSinitReadFIFO(uint8* mem) { s_gs->InitReadFIFO(mem, 1); } - catch (GSDXRecoverableError) + catch (GSRecoverableError) { } catch (const std::bad_alloc&) { - fprintf(stderr, "GSdx: Memory allocation error\n"); + fprintf(stderr, "GS: Memory allocation error\n"); } } @@ -537,12 +539,12 @@ void GSreadFIFO(uint8* mem) { s_gs->ReadFIFO(mem, 1); } - catch (GSDXRecoverableError) + catch (GSRecoverableError) { } catch (const std::bad_alloc&) { - fprintf(stderr, "GSdx: Memory allocation error\n"); + fprintf(stderr, "GS: Memory allocation error\n"); } } @@ -553,12 +555,12 @@ void GSinitReadFIFO2(uint8* mem, uint32 size) { s_gs->InitReadFIFO(mem, size); } - catch (GSDXRecoverableError) + catch (GSRecoverableError) { } catch (const std::bad_alloc&) { - fprintf(stderr, "GSdx: Memory allocation error\n"); + fprintf(stderr, "GS: Memory allocation error\n"); } } @@ -568,12 +570,12 @@ void GSreadFIFO2(uint8* mem, uint32 size) { s_gs->ReadFIFO(mem, size); } - catch (GSDXRecoverableError) + catch (GSRecoverableError) { } catch (const std::bad_alloc&) { - fprintf(stderr, "GSdx: Memory allocation error\n"); + fprintf(stderr, "GS: Memory allocation error\n"); } } @@ -583,7 +585,7 @@ void GSgifTransfer(const uint8* mem, uint32 size) { s_gs->Transfer<3>(mem, size); } - catch (GSDXRecoverableError) + catch (GSRecoverableError) { } } @@ -594,7 +596,7 @@ void GSgifTransfer1(uint8* mem, uint32 addr) { s_gs->Transfer<0>(const_cast(mem) + addr, (0x4000 - addr) / 16); } - catch (GSDXRecoverableError) + catch (GSRecoverableError) { } } @@ -605,7 +607,7 @@ void GSgifTransfer2(uint8* mem, uint32 size) { s_gs->Transfer<1>(const_cast(mem), size); } - catch (GSDXRecoverableError) + catch (GSRecoverableError) { } } @@ -616,7 +618,7 @@ void GSgifTransfer3(uint8* mem, uint32 size) { s_gs->Transfer<2>(const_cast(mem), size); } - catch (GSDXRecoverableError) + catch (GSRecoverableError) { } } @@ -644,12 +646,12 @@ void GSvsync(int field) s_gs->VSync(field); } - catch (GSDXRecoverableError) + catch (GSRecoverableError) { } catch (const std::bad_alloc&) { - fprintf(stderr, "GSdx: Memory allocation error\n"); + fprintf(stderr, "GS: Memory allocation error\n"); } } @@ -676,7 +678,7 @@ uint32 GSmakeSnapshot(char* path) return s_gs->MakeSnapshot(s + "gsdx"); } - catch (GSDXRecoverableError) + catch (GSRecoverableError) { return false; } @@ -691,7 +693,7 @@ void GSkeyEvent(GSKeyEventData* e) s_gs->KeyEvent(e); } } - catch (GSDXRecoverableError) + catch (GSRecoverableError) { } } @@ -713,7 +715,7 @@ int GSfreeze(int mode, GSFreezeData* data) return s_gs->Defrost(data); } } - catch (GSDXRecoverableError) + catch (GSRecoverableError) { } @@ -763,7 +765,7 @@ void GSconfigure() #endif } - catch (GSDXRecoverableError) + catch (GSRecoverableError) { } } @@ -801,17 +803,17 @@ bool GSsetupRecording(std::string& filename) { if (s_gs == NULL) { - printf("GSdx: no s_gs for recording\n"); + printf("GS: no s_gs for recording\n"); return false; } #if defined(__unix__) || defined(__APPLE__) if (!theApp.GetConfigB("capture_enabled")) { - printf("GSdx: Recording is disabled\n"); + printf("GS: Recording is disabled\n"); return false; } #endif - printf("GSdx: Recording start command\n"); + printf("GS: Recording start command\n"); if (s_gs->BeginCapture(filename)) { pt(" - Capture started\n"); @@ -826,7 +828,7 @@ bool GSsetupRecording(std::string& filename) void GSendRecording() { - printf("GSdx: Recording end command\n"); + printf("GS: Recording end command\n"); s_gs->EndCapture(); pt(" - Capture ended\n"); } @@ -983,7 +985,7 @@ void GSReplay(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) ::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS); - Console console{"GSdx", true}; + Console console{"GS", true}; const std::string f{lpszCmdLine}; const bool is_xz = f.size() >= 4 && f.compare(f.size() - 3, 3, ".xz") == 0; @@ -1113,7 +1115,7 @@ void GSBenchmark(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) { ::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS); - Console console("GSdx", true); + Console console("GS", true); if (1) { @@ -1716,7 +1718,7 @@ void* fifo_alloc(size_t size, size_t repeat) { ASSERT(s_shm_fd == -1); - const char* file_name = "/GSDX.mem"; + const char* file_name = "/GS.mem"; s_shm_fd = shm_open(file_name, O_RDWR | O_CREAT | O_EXCL, 0600); if (s_shm_fd != -1) { @@ -1758,3 +1760,546 @@ void fifo_free(void* ptr, size_t size, size_t repeat) } #endif + +static void* s_hModule; + +#ifdef _WIN32 + +bool GSApp::LoadResource(int id, std::vector& buff, const wchar_t* type) +{ + buff.clear(); + HRSRC hRsrc = FindResource((HMODULE)s_hModule, MAKEINTRESOURCE(id), type != NULL ? type : (LPWSTR)RT_RCDATA); + if (!hRsrc) + return false; + HGLOBAL hGlobal = ::LoadResource((HMODULE)s_hModule, hRsrc); + if (!hGlobal) + return false; + DWORD size = SizeofResource((HMODULE)s_hModule, hRsrc); + if (!size) + return false; + // On Linux resources are always NULL terminated + // Add + 1 on size to do the same for compatibility sake (required by GSDeviceOGL) + buff.resize(size + 1); + memcpy(buff.data(), LockResource(hGlobal), size); + return true; +} + +#else + +#include "GS_res.h" + +bool GSApp::LoadResource(int id, std::vector& buff, const char* type) +{ + std::string path; + switch (id) + { + case IDR_COMMON_GLSL: + path = "/GS/res/glsl/common_header.glsl"; + break; + case IDR_CONVERT_GLSL: + path = "/GS/res/glsl/convert.glsl"; + break; + case IDR_FXAA_FX: + path = "/GS/res/fxaa.fx"; + break; + case IDR_INTERLACE_GLSL: + path = "/GS/res/glsl/interlace.glsl"; + break; + case IDR_MERGE_GLSL: + path = "/GS/res/glsl/merge.glsl"; + break; + case IDR_SHADEBOOST_GLSL: + path = "/GS/res/glsl/shadeboost.glsl"; + break; + case IDR_TFX_VGS_GLSL: + path = "/GS/res/glsl/tfx_vgs.glsl"; + break; + case IDR_TFX_FS_GLSL: + path = "/GS/res/glsl/tfx_fs.glsl"; + break; + case IDR_FONT_ROBOTO: + path = "/GS/res/fonts-roboto/Roboto-Regular.ttf"; + break; + default: + printf("LoadResource not implemented for id %d\n", id); + return false; + } + + GBytes* bytes = g_resource_lookup_data(GS_res_get_resource(), path.c_str(), G_RESOURCE_LOOKUP_FLAGS_NONE, nullptr); + + size_t size = 0; + const void* data = g_bytes_get_data(bytes, &size); + + if (data == nullptr || size == 0) + { + printf("Failed to get data for resource: %d\n", id); + return false; + } + + buff.clear(); + buff.resize(size + 1); + memcpy(buff.data(), data, size + 1); + + g_bytes_unref(bytes); + + return true; +} +#endif + +size_t GSApp::GetIniString(const char* lpAppName, const char* lpKeyName, const char* lpDefault, char* lpReturnedString, size_t nSize, const char* lpFileName) +{ + BuildConfigurationMap(lpFileName); + + std::string key(lpKeyName); + std::string value = m_configuration_map[key]; + if (value.empty()) + { + // save the value for futur call + m_configuration_map[key] = std::string(lpDefault); + strcpy(lpReturnedString, lpDefault); + } + else + strcpy(lpReturnedString, value.c_str()); + + return 0; +} + +bool GSApp::WriteIniString(const char* lpAppName, const char* lpKeyName, const char* pString, const char* lpFileName) +{ + BuildConfigurationMap(lpFileName); + + std::string key(lpKeyName); + std::string value(pString); + m_configuration_map[key] = value; + + // Save config to a file + FILE* f = px_fopen(lpFileName, "w"); + + if (f == NULL) + return false; // FIXME print a nice message + + // Maintain compatibility with GSDumpGUI/old Windows ini. +#ifdef _WIN32 + fprintf(f, "[Settings]\n"); +#endif + + for (const auto& entry : m_configuration_map) + { + // Do not save the inifile key which is not an option + if (entry.first.compare("inifile") == 0) + continue; + + // Only keep option that have a default value (allow to purge old option of the GS.ini) + if (!entry.second.empty() && m_default_configuration.find(entry.first) != m_default_configuration.end()) + fprintf(f, "%s = %s\n", entry.first.c_str(), entry.second.c_str()); + } + fclose(f); + + return false; +} + +int GSApp::GetIniInt(const char* lpAppName, const char* lpKeyName, int nDefault, const char* lpFileName) +{ + BuildConfigurationMap(lpFileName); + + std::string value = m_configuration_map[std::string(lpKeyName)]; + if (value.empty()) + { + // save the value for futur call + SetConfig(lpKeyName, nDefault); + return nDefault; + } + else + return atoi(value.c_str()); +} + +GSApp theApp; + +GSApp::GSApp() +{ + // Empty constructor causes an illegal instruction exception on an SSE4.2 machine on Windows. + // Non-empty doesn't, but raises a SIGILL signal when compiled against GCC 6.1.1. + // So here's a compromise. +#ifdef _WIN32 + Init(); +#endif +} + +void GSApp::Init() +{ + static bool is_initialised = false; + if (is_initialised) + return; + is_initialised = true; + + m_current_renderer_type = GSRendererType::Undefined; + + if (m_ini.empty()) + m_ini = "inis/GS.ini"; + m_section = "Settings"; + +#ifdef _WIN32 + m_gs_renderers.push_back(GSSetting(static_cast(GSRendererType::DX1011_HW), "Direct3D 11", "")); + m_gs_renderers.push_back(GSSetting(static_cast(GSRendererType::OGL_HW), "OpenGL", "")); + m_gs_renderers.push_back(GSSetting(static_cast(GSRendererType::OGL_SW), "Software", "")); +#else // Linux + m_gs_renderers.push_back(GSSetting(static_cast(GSRendererType::OGL_HW), "OpenGL", "")); + m_gs_renderers.push_back(GSSetting(static_cast(GSRendererType::OGL_SW), "Software", "")); +#endif + + // The null renderer goes third, it has use for benchmarking purposes in a release build + m_gs_renderers.push_back(GSSetting(static_cast(GSRendererType::Null), "Null", "")); + + m_gs_interlace.push_back(GSSetting(0, "None", "")); + m_gs_interlace.push_back(GSSetting(1, "Weave tff", "saw-tooth")); + m_gs_interlace.push_back(GSSetting(2, "Weave bff", "saw-tooth")); + m_gs_interlace.push_back(GSSetting(3, "Bob tff", "use blend if shaking")); + m_gs_interlace.push_back(GSSetting(4, "Bob bff", "use blend if shaking")); + m_gs_interlace.push_back(GSSetting(5, "Blend tff", "slight blur, 1/2 fps")); + m_gs_interlace.push_back(GSSetting(6, "Blend bff", "slight blur, 1/2 fps")); + m_gs_interlace.push_back(GSSetting(7, "Automatic", "Default")); + + m_gs_aspectratio.push_back(GSSetting(0, "Stretch", "")); + m_gs_aspectratio.push_back(GSSetting(1, "4:3", "")); + m_gs_aspectratio.push_back(GSSetting(2, "16:9", "")); + + m_gs_upscale_multiplier.push_back(GSSetting(1, "Native", "PS2")); + m_gs_upscale_multiplier.push_back(GSSetting(2, "2x Native", "~720p")); + m_gs_upscale_multiplier.push_back(GSSetting(3, "3x Native", "~1080p")); + m_gs_upscale_multiplier.push_back(GSSetting(4, "4x Native", "~1440p 2K")); + m_gs_upscale_multiplier.push_back(GSSetting(5, "5x Native", "~1620p 3K")); + m_gs_upscale_multiplier.push_back(GSSetting(6, "6x Native", "~2160p 4K")); + m_gs_upscale_multiplier.push_back(GSSetting(8, "8x Native", "~2880p 5K")); + + m_gs_max_anisotropy.push_back(GSSetting(0, "Off", "Default")); + m_gs_max_anisotropy.push_back(GSSetting(2, "2x", "")); + m_gs_max_anisotropy.push_back(GSSetting(4, "4x", "")); + m_gs_max_anisotropy.push_back(GSSetting(8, "8x", "")); + m_gs_max_anisotropy.push_back(GSSetting(16, "16x", "")); + + m_gs_dithering.push_back(GSSetting(0, "Off", "")); + m_gs_dithering.push_back(GSSetting(2, "Unscaled", "Default")); + m_gs_dithering.push_back(GSSetting(1, "Scaled", "")); + + m_gs_bifilter.push_back(GSSetting(static_cast(BiFiltering::Nearest), "Nearest", "")); + m_gs_bifilter.push_back(GSSetting(static_cast(BiFiltering::Forced_But_Sprite), "Bilinear", "Forced excluding sprite")); + m_gs_bifilter.push_back(GSSetting(static_cast(BiFiltering::Forced), "Bilinear", "Forced")); + m_gs_bifilter.push_back(GSSetting(static_cast(BiFiltering::PS2), "Bilinear", "PS2")); + + m_gs_trifilter.push_back(GSSetting(static_cast(TriFiltering::None), "None", "Default")); + m_gs_trifilter.push_back(GSSetting(static_cast(TriFiltering::PS2), "Trilinear", "")); + m_gs_trifilter.push_back(GSSetting(static_cast(TriFiltering::Forced), "Trilinear", "Ultra/Slow")); + + m_gs_generic_list.push_back(GSSetting(-1, "Automatic", "Default")); + m_gs_generic_list.push_back(GSSetting(0, "Force-Disabled", "")); + m_gs_generic_list.push_back(GSSetting(1, "Force-Enabled", "")); + + m_gs_hack.push_back(GSSetting(0, "Off", "Default")); + m_gs_hack.push_back(GSSetting(1, "Half", "")); + m_gs_hack.push_back(GSSetting(2, "Full", "")); + + m_gs_offset_hack.push_back(GSSetting(0, "Off", "Default")); + m_gs_offset_hack.push_back(GSSetting(1, "Normal", "Vertex")); + m_gs_offset_hack.push_back(GSSetting(2, "Special", "Texture")); + m_gs_offset_hack.push_back(GSSetting(3, "Special", "Texture - aggressive")); + + m_gs_hw_mipmapping = { + GSSetting(HWMipmapLevel::Automatic, "Automatic", "Default"), + GSSetting(HWMipmapLevel::Off, "Off", ""), + GSSetting(HWMipmapLevel::Basic, "Basic", "Fast"), + GSSetting(HWMipmapLevel::Full, "Full", "Slow"), + }; + + m_gs_crc_level = { + GSSetting(CRCHackLevel::Automatic, "Automatic", "Default"), + GSSetting(CRCHackLevel::None, "None", "Debug"), + GSSetting(CRCHackLevel::Minimum, "Minimum", "Debug"), +#ifdef _DEBUG + GSSetting(CRCHackLevel::Partial, "Partial", "OpenGL"), + GSSetting(CRCHackLevel::Full, "Full", "Direct3D"), +#endif + GSSetting(CRCHackLevel::Aggressive, "Aggressive", ""), + }; + + m_gs_acc_blend_level.push_back(GSSetting(0, "None", "Fastest")); + m_gs_acc_blend_level.push_back(GSSetting(1, "Basic", "Recommended")); + m_gs_acc_blend_level.push_back(GSSetting(2, "Medium", "")); + m_gs_acc_blend_level.push_back(GSSetting(3, "High", "")); + m_gs_acc_blend_level.push_back(GSSetting(4, "Full", "Very Slow")); + m_gs_acc_blend_level.push_back(GSSetting(5, "Ultra", "Ultra Slow")); + + m_gs_acc_blend_level_d3d11.push_back(GSSetting(0, "None", "Fastest")); + m_gs_acc_blend_level_d3d11.push_back(GSSetting(1, "Basic", "Recommended")); + m_gs_acc_blend_level_d3d11.push_back(GSSetting(2, "Medium", "Debug")); + m_gs_acc_blend_level_d3d11.push_back(GSSetting(3, "High", "Debug")); + + m_gs_tv_shaders.push_back(GSSetting(0, "None", "")); + m_gs_tv_shaders.push_back(GSSetting(1, "Scanline filter", "")); + m_gs_tv_shaders.push_back(GSSetting(2, "Diagonal filter", "")); + m_gs_tv_shaders.push_back(GSSetting(3, "Triangular filter", "")); + m_gs_tv_shaders.push_back(GSSetting(4, "Wave filter", "")); + + // clang-format off + // Avoid to clutter the ini file with useless options +#ifdef _WIN32 + // Per OS option. + m_default_configuration["Adapter"] = "default"; + m_default_configuration["CaptureFileName"] = ""; + m_default_configuration["CaptureVideoCodecDisplayName"] = ""; + m_default_configuration["dx_break_on_severity"] = "0"; + // D3D Blending option + m_default_configuration["accurate_blending_unit_d3d11"] = "1"; +#else + m_default_configuration["linux_replay"] = "1"; +#endif + m_default_configuration["aa1"] = "0"; + m_default_configuration["accurate_date"] = "1"; + m_default_configuration["accurate_blending_unit"] = "1"; + m_default_configuration["AspectRatio"] = "1"; + m_default_configuration["autoflush_sw"] = "1"; + m_default_configuration["capture_enabled"] = "0"; + m_default_configuration["capture_out_dir"] = "/tmp/GS_Capture"; + m_default_configuration["capture_threads"] = "4"; + m_default_configuration["CaptureHeight"] = "480"; + m_default_configuration["CaptureWidth"] = "640"; + m_default_configuration["clut_load_before_draw"] = "0"; + m_default_configuration["crc_hack_level"] = std::to_string(static_cast(CRCHackLevel::Automatic)); + m_default_configuration["CrcHacksExclusions"] = ""; + m_default_configuration["debug_glsl_shader"] = "0"; + m_default_configuration["debug_opengl"] = "0"; + m_default_configuration["disable_hw_gl_draw"] = "0"; + m_default_configuration["dithering_ps2"] = "2"; + m_default_configuration["dump"] = "0"; + m_default_configuration["extrathreads"] = "2"; + m_default_configuration["extrathreads_height"] = "4"; + m_default_configuration["filter"] = std::to_string(static_cast(BiFiltering::PS2)); + m_default_configuration["force_texture_clear"] = "0"; + m_default_configuration["fxaa"] = "0"; + m_default_configuration["interlace"] = "7"; + m_default_configuration["conservative_framebuffer"] = "1"; + m_default_configuration["linear_present"] = "1"; + m_default_configuration["MaxAnisotropy"] = "0"; + m_default_configuration["mipmap"] = "1"; + m_default_configuration["mipmap_hw"] = std::to_string(static_cast(HWMipmapLevel::Automatic)); + m_default_configuration["ModeHeight"] = "480"; + m_default_configuration["ModeWidth"] = "640"; + m_default_configuration["NTSC_Saturation"] = "1"; +#ifdef _WIN32 + m_default_configuration["osd_fontname"] = "C:\\Windows\\Fonts\\my_favorite_font_e_g_tahoma.ttf"; +#else + m_default_configuration["osd_fontname"] = "/usr/share/fonts/truetype/my_favorite_font_e_g_DejaVu Sans.ttf"; +#endif + m_default_configuration["osd_color_r"] = "0"; + m_default_configuration["osd_color_g"] = "160"; + m_default_configuration["osd_color_b"] = "255"; + m_default_configuration["osd_color_opacity"] = "100"; + m_default_configuration["osd_fontsize"] = "25"; + m_default_configuration["osd_log_enabled"] = "1"; + m_default_configuration["osd_log_timeout"] = "4"; + m_default_configuration["osd_monitor_enabled"] = "0"; + m_default_configuration["osd_max_log_messages"] = "2"; + m_default_configuration["override_geometry_shader"] = "-1"; + m_default_configuration["override_GL_ARB_compute_shader"] = "-1"; + m_default_configuration["override_GL_ARB_copy_image"] = "-1"; + m_default_configuration["override_GL_ARB_clear_texture"] = "-1"; + m_default_configuration["override_GL_ARB_clip_control"] = "-1"; + m_default_configuration["override_GL_ARB_direct_state_access"] = "-1"; + m_default_configuration["override_GL_ARB_draw_buffers_blend"] = "-1"; + m_default_configuration["override_GL_ARB_get_texture_sub_image"] = "-1"; + m_default_configuration["override_GL_ARB_gpu_shader5"] = "-1"; + m_default_configuration["override_GL_ARB_multi_bind"] = "-1"; + m_default_configuration["override_GL_ARB_shader_image_load_store"] = "-1"; + m_default_configuration["override_GL_ARB_shader_storage_buffer_object"] = "-1"; + m_default_configuration["override_GL_ARB_sparse_texture"] = "-1"; + m_default_configuration["override_GL_ARB_sparse_texture2"] = "-1"; + m_default_configuration["override_GL_ARB_texture_view"] = "-1"; + m_default_configuration["override_GL_ARB_vertex_attrib_binding"] = "-1"; + m_default_configuration["override_GL_ARB_texture_barrier"] = "-1"; + m_default_configuration["paltex"] = "0"; + m_default_configuration["png_compression_level"] = std::to_string(Z_BEST_SPEED); + m_default_configuration["preload_frame_with_gs_data"] = "0"; + m_default_configuration["Renderer"] = std::to_string(static_cast(GSRendererType::Default)); + m_default_configuration["resx"] = "1024"; + m_default_configuration["resy"] = "1024"; + m_default_configuration["save"] = "0"; + m_default_configuration["savef"] = "0"; + m_default_configuration["savel"] = "5000"; + m_default_configuration["saven"] = "0"; + m_default_configuration["savet"] = "0"; + m_default_configuration["savez"] = "0"; + m_default_configuration["ShadeBoost"] = "0"; + m_default_configuration["ShadeBoost_Brightness"] = "50"; + m_default_configuration["ShadeBoost_Contrast"] = "50"; + m_default_configuration["ShadeBoost_Saturation"] = "50"; + m_default_configuration["shaderfx"] = "0"; + m_default_configuration["shaderfx_conf"] = "shaders/GS_FX_Settings.ini"; + m_default_configuration["shaderfx_glsl"] = "shaders/GS.fx"; + m_default_configuration["TVShader"] = "0"; + m_default_configuration["upscale_multiplier"] = "1"; + m_default_configuration["UserHacks"] = "0"; + m_default_configuration["UserHacks_align_sprite_X"] = "0"; + m_default_configuration["UserHacks_AutoFlush"] = "0"; + m_default_configuration["UserHacks_DisableDepthSupport"] = "0"; + m_default_configuration["UserHacks_Disable_Safe_Features"] = "0"; + m_default_configuration["UserHacks_DisablePartialInvalidation"] = "0"; + m_default_configuration["UserHacks_CPU_FB_Conversion"] = "0"; + m_default_configuration["UserHacks_Half_Bottom_Override"] = "-1"; + m_default_configuration["UserHacks_HalfPixelOffset"] = "0"; + m_default_configuration["UserHacks_merge_pp_sprite"] = "0"; + m_default_configuration["UserHacks_round_sprite_offset"] = "0"; + m_default_configuration["UserHacks_SkipDraw"] = "0"; + m_default_configuration["UserHacks_SkipDraw_Offset"] = "0"; + m_default_configuration["UserHacks_TCOffsetX"] = "0"; + m_default_configuration["UserHacks_TCOffsetY"] = "0"; + m_default_configuration["UserHacks_TextureInsideRt"] = "0"; + m_default_configuration["UserHacks_TriFilter"] = std::to_string(static_cast(TriFiltering::None)); + m_default_configuration["UserHacks_WildHack"] = "0"; + m_default_configuration["wrap_gs_mem"] = "0"; + m_default_configuration["vsync"] = "0"; + // clang-format on +} + +void GSApp::ReloadConfig() +{ + if (m_configuration_map.empty()) + return; + + auto file = m_configuration_map.find("inifile"); + if (file == m_configuration_map.end()) + return; + + // A map was built so reload it + std::string filename = file->second; + m_configuration_map.clear(); + BuildConfigurationMap(filename.c_str()); +} + +void GSApp::BuildConfigurationMap(const char* lpFileName) +{ + // Check if the map was already built + std::string inifile_value(lpFileName); + if (inifile_value.compare(m_configuration_map["inifile"]) == 0) + return; + m_configuration_map["inifile"] = inifile_value; + + // Load config from file +#ifdef _WIN32 + std::ifstream file(convert_utf8_to_utf16(lpFileName)); +#else + std::ifstream file(lpFileName); +#endif + if (!file.is_open()) + return; + + std::string line; + while (std::getline(file, line)) + { + const auto separator = line.find('='); + if (separator == std::string::npos) + continue; + + std::string key = line.substr(0, separator); + // Trim trailing whitespace + key.erase(key.find_last_not_of(" \r\t") + 1); + + if (key.empty()) + continue; + + // Only keep options that have a default value so older, no longer used + // ini options can be purged. + if (m_default_configuration.find(key) == m_default_configuration.end()) + continue; + + std::string value = line.substr(separator + 1); + // Trim leading whitespace + value.erase(0, value.find_first_not_of(" \r\t")); + + m_configuration_map[key] = value; + } +} + +void* GSApp::GetModuleHandlePtr() +{ + return s_hModule; +} + +void GSApp::SetConfigDir(const char* dir) +{ + if (dir == NULL) + { + m_ini = "inis/GS.ini"; + } + else + { + m_ini = dir; + + if (m_ini[m_ini.length() - 1] != DIRECTORY_SEPARATOR) + { + m_ini += DIRECTORY_SEPARATOR; + } + + m_ini += "GS.ini"; + } +} + +std::string GSApp::GetConfigS(const char* entry) +{ + char buff[4096] = {0}; + auto def = m_default_configuration.find(entry); + + if (def != m_default_configuration.end()) + { + GetIniString(m_section.c_str(), entry, def->second.c_str(), buff, countof(buff), m_ini.c_str()); + } + else + { + fprintf(stderr, "Option %s doesn't have a default value\n", entry); + GetIniString(m_section.c_str(), entry, "", buff, countof(buff), m_ini.c_str()); + } + + return {buff}; +} + +void GSApp::SetConfig(const char* entry, const char* value) +{ + WriteIniString(m_section.c_str(), entry, value, m_ini.c_str()); +} + +int GSApp::GetConfigI(const char* entry) +{ + auto def = m_default_configuration.find(entry); + + if (def != m_default_configuration.end()) + { + return GetIniInt(m_section.c_str(), entry, std::stoi(def->second), m_ini.c_str()); + } + else + { + fprintf(stderr, "Option %s doesn't have a default value\n", entry); + return GetIniInt(m_section.c_str(), entry, 0, m_ini.c_str()); + } +} + +bool GSApp::GetConfigB(const char* entry) +{ + return !!GetConfigI(entry); +} + +void GSApp::SetConfig(const char* entry, int value) +{ + char buff[32] = {0}; + + sprintf(buff, "%d", value); + + SetConfig(entry, buff); +} + +void GSApp::SetCurrentRendererType(GSRendererType type) +{ + m_current_renderer_type = type; +} + +GSRendererType GSApp::GetCurrentRendererType() const +{ + return m_current_renderer_type; +} diff --git a/pcsx2/GS/GS.h b/pcsx2/GS/GS.h index e021bcfa40..8ad0e9dfc3 100644 --- a/pcsx2/GS/GS.h +++ b/pcsx2/GS/GS.h @@ -27,6 +27,7 @@ #include "config.h" #include "Pcsx2Types.h" #include "GS_types.h" +#include "Window/GSSetting.h" #ifdef _WIN32 @@ -211,7 +212,7 @@ // sse #if defined(__GNUC__) -// Convert gcc see define into GSdx (windows) define +// Convert gcc see define into GS (windows) define #if defined(__AVX2__) #if defined(__x86_64__) #define _M_SSE 0x500 // TODO @@ -1907,3 +1908,84 @@ void GSgetTitleInfo2(char* dest, size_t length); void GSsetFrameSkip(int frameskip); void GSsetVsync(int vsync); void GSsetExclusive(int enabled); + +class GSApp +{ + std::string m_ini; + std::string m_section; + std::map m_default_configuration; + std::map m_configuration_map; + GSRendererType m_current_renderer_type; + +public: + GSApp(); + + void Init(); + void* GetModuleHandlePtr(); + +#ifdef _WIN32 + HMODULE GetModuleHandle() + { + return (HMODULE)GetModuleHandlePtr(); + } +#endif + + void BuildConfigurationMap(const char* lpFileName); + void ReloadConfig(); + + size_t GetIniString(const char* lpAppName, const char* lpKeyName, const char* lpDefault, char* lpReturnedString, size_t nSize, const char* lpFileName); + bool WriteIniString(const char* lpAppName, const char* lpKeyName, const char* pString, const char* lpFileName); + int GetIniInt(const char* lpAppName, const char* lpKeyName, int nDefault, const char* lpFileName); + +#ifdef _WIN32 + bool LoadResource(int id, std::vector& buff, const wchar_t* type = nullptr); +#else + bool LoadResource(int id, std::vector& buff, const char* type = nullptr); +#endif + + void SetConfig(const char* entry, const char* value); + void SetConfig(const char* entry, int value); + // Avoid issue with overloading + template + T GetConfigT(const char* entry) + { + return static_cast(GetConfigI(entry)); + } + int GetConfigI(const char* entry); + bool GetConfigB(const char* entry); + std::string GetConfigS(const char* entry); + + void SetCurrentRendererType(GSRendererType type); + GSRendererType GetCurrentRendererType() const; + + void SetConfigDir(const char* dir); + + std::vector m_gs_renderers; + std::vector m_gs_interlace; + std::vector m_gs_aspectratio; + std::vector m_gs_upscale_multiplier; + std::vector m_gs_max_anisotropy; + std::vector m_gs_dithering; + std::vector m_gs_bifilter; + std::vector m_gs_trifilter; + std::vector m_gs_hack; + std::vector m_gs_generic_list; + std::vector m_gs_offset_hack; + std::vector m_gs_hw_mipmapping; + std::vector m_gs_crc_level; + std::vector m_gs_acc_blend_level; + std::vector m_gs_acc_blend_level_d3d11; + std::vector m_gs_tv_shaders; +}; + +struct GSError +{ +}; +struct GSRecoverableError : GSError +{ +}; +struct GSErrorGlVertexArrayTooSmall : GSError +{ +}; + +extern GSApp theApp; diff --git a/pcsx2/GS/GSCapture.cpp b/pcsx2/GS/GSCapture.cpp index b37c81e862..e8e05c82f4 100644 --- a/pcsx2/GS/GSCapture.cpp +++ b/pcsx2/GS/GSCapture.cpp @@ -23,6 +23,7 @@ #include "GSCapture.h" #include "GSPng.h" #include "GSUtil.h" +#include "GS_types.h" #ifdef _WIN32 @@ -406,7 +407,7 @@ static IPin* GetFirstPin(IBaseFilter* pBF, PIN_DIRECTION dir) GSCapture::GSCapture() : m_capturing(false), m_frame(0) - , m_out_dir("/tmp/GSdx_Capture") // FIXME Later add an option + , m_out_dir("/tmp/GS_Capture") // FIXME Later add an option { m_out_dir = theApp.GetConfigS("capture_out_dir"); m_threads = theApp.GetConfigI("capture_threads"); diff --git a/pcsx2/GS/GSCodeBuffer.cpp b/pcsx2/GS/GSCodeBuffer.cpp index d6d4aa74c1..d57b3850d6 100644 --- a/pcsx2/GS/GSCodeBuffer.cpp +++ b/pcsx2/GS/GSCodeBuffer.cpp @@ -21,6 +21,7 @@ #include "PrecompiledHeader.h" #include "GSCodeBuffer.h" +#include "GS_types.h" GSCodeBuffer::GSCodeBuffer(size_t blocksize) : m_blocksize(blocksize) @@ -40,8 +41,8 @@ GSCodeBuffer::~GSCodeBuffer() void* GSCodeBuffer::GetBuffer(size_t size) { - ASSERT(size < m_blocksize); - ASSERT(m_reserved == 0); + pxAssert(size < m_blocksize); + pxAssert(m_reserved == 0); size = (size + 15) & ~15; @@ -63,11 +64,11 @@ void* GSCodeBuffer::GetBuffer(size_t size) void GSCodeBuffer::ReleaseBuffer(size_t size) { - ASSERT(size <= m_reserved); + pxAssert(size <= m_reserved); m_pos = ((m_pos + size) + 15) & ~15; - ASSERT(m_pos < m_blocksize); + pxAssert(m_pos < m_blocksize); m_reserved = 0; } diff --git a/pcsx2/GS/GSCodeBuffer.h b/pcsx2/GS/GSCodeBuffer.h index 1cea4a89a3..34ae0da00b 100644 --- a/pcsx2/GS/GSCodeBuffer.h +++ b/pcsx2/GS/GSCodeBuffer.h @@ -21,6 +21,8 @@ #pragma once +#include "GS_types.h" + class GSCodeBuffer { std::vector m_buffers; diff --git a/pcsx2/GS/GSCrc.cpp b/pcsx2/GS/GSCrc.cpp index 145e6ce060..03a5123d03 100644 --- a/pcsx2/GS/GSCrc.cpp +++ b/pcsx2/GS/GSCrc.cpp @@ -20,7 +20,7 @@ */ #include "PrecompiledHeader.h" -#include "GSdx.h" +#include "GS.h" #include "GSCrc.h" CRC::Game CRC::m_games[] = @@ -535,12 +535,12 @@ bool IsCrcExcluded(std::string exclusionList, uint32 crc) CRC::Game CRC::Lookup(uint32 crc) { - printf("GSdx Lookup CRC:%08X\n", crc); + printf("GS Lookup CRC:%08X\n", crc); if (m_map.empty()) { std::string exclusions = theApp.GetConfigS("CrcHacksExclusions"); if (exclusions.length() != 0) - printf("GSdx: CrcHacksExclusions: %s\n", exclusions.c_str()); + printf("GS: CrcHacksExclusions: %s\n", exclusions.c_str()); int crcDups = 0; for (size_t i = 0; i < countof(m_games); i++) { @@ -548,17 +548,17 @@ CRC::Game CRC::Lookup(uint32 crc) { if (m_map[m_games[i].crc]) { - printf("[FIXME] GSdx: Duplicate CRC: 0x%08X: (game-id/region-id) %d/%d overrides %d/%d\n", m_games[i].crc, m_games[i].title, m_games[i].region, m_map[m_games[i].crc]->title, m_map[m_games[i].crc]->region); + printf("[FIXME] GS: Duplicate CRC: 0x%08X: (game-id/region-id) %d/%d overrides %d/%d\n", m_games[i].crc, m_games[i].title, m_games[i].region, m_map[m_games[i].crc]->title, m_map[m_games[i].crc]->region); crcDups++; } m_map[m_games[i].crc] = &m_games[i]; } //else - // printf( "GSdx: excluding CRC hack for 0x%08x\n", m_games[i].crc ); + // printf( "GS: excluding CRC hack for 0x%08x\n", m_games[i].crc ); } if (crcDups) - printf("[FIXME] GSdx: Duplicate CRC: Overall: %d\n", crcDups); + printf("[FIXME] GS: Duplicate CRC: Overall: %d\n", crcDups); } auto i = m_map.find(crc); diff --git a/pcsx2/GS/GSDrawingContext.cpp b/pcsx2/GS/GSDrawingContext.cpp index 6ddea7c23d..049afc6bb9 100644 --- a/pcsx2/GS/GSDrawingContext.cpp +++ b/pcsx2/GS/GSDrawingContext.cpp @@ -21,7 +21,7 @@ #include "PrecompiledHeader.h" #include "GSDrawingContext.h" -#include "GSdx.h" +#include "GS.h" static int findmax(int tl, int br, int limit, int wm, int minuv, int maxuv) { diff --git a/pcsx2/GS/GSLocalMemory.cpp b/pcsx2/GS/GSLocalMemory.cpp index 9af37bc364..cc02cab70b 100644 --- a/pcsx2/GS/GSLocalMemory.cpp +++ b/pcsx2/GS/GSLocalMemory.cpp @@ -26,7 +26,7 @@ #include "PrecompiledHeader.h" #include "GSLocalMemory.h" -#include "GSdx.h" +#include "GS.h" #define ASSERT_BLOCK(r, w, h) \ ASSERT((r).width() >= (w) && (r).height() >= (h) && !((r).left & ((w) - 1)) && !((r).top & ((h) - 1)) && !((r).right & ((w) - 1)) && !((r).bottom & ((h) - 1))); \ diff --git a/pcsx2/GS/GSPerfMon.cpp b/pcsx2/GS/GSPerfMon.cpp index 8fa8793734..9157d088ac 100644 --- a/pcsx2/GS/GSPerfMon.cpp +++ b/pcsx2/GS/GSPerfMon.cpp @@ -21,6 +21,7 @@ #include "PrecompiledHeader.h" #include "GSPerfMon.h" +#include "GS_types.h" GSPerfMon::GSPerfMon() : m_frame(0) diff --git a/pcsx2/GS/GSPerfMon.h b/pcsx2/GS/GSPerfMon.h index c5e059f759..9f4104536b 100644 --- a/pcsx2/GS/GSPerfMon.h +++ b/pcsx2/GS/GSPerfMon.h @@ -21,6 +21,8 @@ #pragma once +#include "GS_types.h" + class GSPerfMon { public: diff --git a/pcsx2/GS/GSPng.cpp b/pcsx2/GS/GSPng.cpp index 1a0c88eb8a..8a44d71bfc 100644 --- a/pcsx2/GS/GSPng.cpp +++ b/pcsx2/GS/GSPng.cpp @@ -65,14 +65,14 @@ namespace GSPng try { if (png_ptr == nullptr) - throw GSDXRecoverableError(); + throw GSRecoverableError(); info_ptr = png_create_info_struct(png_ptr); if (info_ptr == nullptr) - throw GSDXRecoverableError(); + throw GSRecoverableError(); if (setjmp(png_jmpbuf(png_ptr))) - throw GSDXRecoverableError(); + throw GSRecoverableError(); png_init_io(png_ptr, fp); png_set_compression_level(png_ptr, compression); @@ -96,7 +96,7 @@ namespace GSPng success = true; } - catch (GSDXRecoverableError&) + catch (GSRecoverableError&) { fprintf(stderr, "Failed to write image %s\n", file.c_str()); diff --git a/pcsx2/GS/GSState.cpp b/pcsx2/GS/GSState.cpp index df4e8cf86c..03e9963105 100644 --- a/pcsx2/GS/GSState.cpp +++ b/pcsx2/GS/GSState.cpp @@ -21,7 +21,7 @@ #include "PrecompiledHeader.h" #include "GSState.h" -#include "GSdx.h" +#include "GS.h" #include "GSUtil.h" //#define Offset_ST // Fixes Persona3 mini map alignment which is off even in software rendering @@ -235,7 +235,7 @@ void GSState::SetFrameSkip(int skip) void GSState::Reset() { - //printf("GSdx info: GS reset\n"); + //printf("GS info: GS reset\n"); // FIXME: memset(m_mem.m_vm8, 0, m_mem.m_vmsize); // bios logo not shown cut in half after reset, missing graphics in GoW after first FMV memset(&m_path[0], 0, sizeof(m_path[0]) * countof(m_path)); @@ -1684,7 +1684,7 @@ void GSState::FlushPrim() { Draw(); } - catch (GSDXRecoverableError&) + catch (GSRecoverableError&) { // could be an unsupported draw call } @@ -1692,7 +1692,7 @@ void GSState::FlushPrim() { // Texture Out Of Memory PurgePool(); - fprintf(stderr, "GSDX OUT OF MEMORY\n"); + fprintf(stderr, "GS OUT OF MEMORY\n"); } m_context->RestoreReg(); @@ -1745,7 +1745,7 @@ void GSState::Write(const uint8* mem, int len) * * #Bug number 2. (darker screen) * The game will restore the previously saved buffer at position 0x0 to - * 0x7F8. Because of the extra RT pixels, GSdx will partialy invalidate + * 0x7F8. Because of the extra RT pixels, GS will partialy invalidate * the texture located at 0x700. Next access will generate a cache miss * * The no-solution: instead to handle garbage (aka RT) at the end of the @@ -2393,7 +2393,7 @@ void GSState::Transfer(const uint8* mem, uint32 size) } else { - // Unused in 0.9.7 and above, but might as well keep this for now; allows GSdx + // Unused in 0.9.7 and above, but might as well keep this for now; allows GS // to work with legacy editions of PCSX2. Transfer<0>(mem - 0x4000, 0x4000 / 16); @@ -2518,7 +2518,7 @@ int GSState::Defrost(const GSFreezeData* fd) if (version > m_version) { - printf("GSdx: Savestate version is incompatible. Load aborted.\n"); + printf("GS: Savestate version is incompatible. Load aborted.\n"); return -1; } @@ -2689,8 +2689,8 @@ void GSState::GrowVertexBuffer() if (vertex == NULL || index == NULL) { - printf("GSdx: failed to allocate %d bytes for verticles and %d for indices.\n", (int)sizeof(GSVertex) * maxcount, (int)sizeof(uint32) * maxcount * 3); - throw GSDXError(); + printf("GS: failed to allocate %d bytes for verticles and %d for indices.\n", (int)sizeof(GSVertex) * maxcount, (int)sizeof(uint32) * maxcount * 3); + throw GSError(); } if (m_vertex.buff != NULL) diff --git a/pcsx2/GS/GSTables.cpp b/pcsx2/GS/GSTables.cpp index ce2432e336..3e1e33c58c 100644 --- a/pcsx2/GS/GSTables.cpp +++ b/pcsx2/GS/GSTables.cpp @@ -23,6 +23,7 @@ #include "PrecompiledHeader.h" #include "GSTables.h" +#include "GS_types.h" const uint8 blockTable32[4][8] = { diff --git a/pcsx2/GS/GSTables.h b/pcsx2/GS/GSTables.h index cd05929557..a587e4dcf1 100644 --- a/pcsx2/GS/GSTables.h +++ b/pcsx2/GS/GSTables.h @@ -21,6 +21,8 @@ #pragma once +#include "GS_types.h" + extern const uint8 blockTable32[4][8]; extern const uint8 blockTable32Z[4][8]; extern const uint8 blockTable16[8][4]; diff --git a/pcsx2/GS/GSThread.h b/pcsx2/GS/GSThread.h index cfe390dcb3..e6001220bb 100644 --- a/pcsx2/GS/GSThread.h +++ b/pcsx2/GS/GSThread.h @@ -21,7 +21,7 @@ #pragma once -#include "GSdx.h" +#include "GS.h" // http://software.intel.com/en-us/blogs/2012/11/06/exploring-intel-transactional-synchronization-extensions-with-intel-software #if 0 diff --git a/pcsx2/GS/GSThread_CXX11.h b/pcsx2/GS/GSThread_CXX11.h index 00537ee4b4..3fe09bfa57 100644 --- a/pcsx2/GS/GSThread_CXX11.h +++ b/pcsx2/GS/GSThread_CXX11.h @@ -21,7 +21,7 @@ #pragma once -#include "GSdx.h" +#include "GS.h" #include "Utilities/boost_spsc_queue.hpp" template diff --git a/pcsx2/GS/GSUtil.cpp b/pcsx2/GS/GSUtil.cpp index 61a0ae4729..9557c7611a 100644 --- a/pcsx2/GS/GSUtil.cpp +++ b/pcsx2/GS/GSUtil.cpp @@ -47,7 +47,7 @@ const char* GSUtil::GetLibName() g_cpu.has(Xbyak::util::Cpu::tSSSE3) ? "SSSE3" : "SSE2"; #endif - snprintf(name, sizeof(name), "GSdx " + snprintf(name, sizeof(name), "GS " #ifdef _WIN32 "%lld " diff --git a/pcsx2/GS/GS_types.h b/pcsx2/GS/GS_types.h index 12402bf795..c8c95e03a3 100644 --- a/pcsx2/GS/GS_types.h +++ b/pcsx2/GS/GS_types.h @@ -1,6 +1,8 @@ #pragma once +#include + typedef unsigned char uint8; typedef signed char int8; typedef unsigned short uint16; @@ -31,3 +33,39 @@ typedef signed long long int64; #endif #endif + +#define _MM_TRANSPOSE4_SI128(row0, row1, row2, row3) \ + { \ + __m128 tmp0 = _mm_shuffle_ps(_mm_castsi128_ps(row0), _mm_castsi128_ps(row1), 0x44); \ + __m128 tmp2 = _mm_shuffle_ps(_mm_castsi128_ps(row0), _mm_castsi128_ps(row1), 0xEE); \ + __m128 tmp1 = _mm_shuffle_ps(_mm_castsi128_ps(row2), _mm_castsi128_ps(row3), 0x44); \ + __m128 tmp3 = _mm_shuffle_ps(_mm_castsi128_ps(row2), _mm_castsi128_ps(row3), 0xEE); \ + (row0) = _mm_castps_si128(_mm_shuffle_ps(tmp0, tmp1, 0x88)); \ + (row1) = _mm_castps_si128(_mm_shuffle_ps(tmp0, tmp1, 0xDD)); \ + (row2) = _mm_castps_si128(_mm_shuffle_ps(tmp2, tmp3, 0x88)); \ + (row3) = _mm_castps_si128(_mm_shuffle_ps(tmp2, tmp3, 0xDD)); \ + } + + +extern void* vmalloc(size_t size, bool code); +extern void vmfree(void* ptr, size_t size); + +// _wfopen has to be used on Windows for pathnames containing non-ASCII characters. +inline FILE* px_fopen(const std::string& filename, const std::string& mode) +{ +#ifdef _WIN32 + return _wfopen(convert_utf8_to_utf16(filename).c_str(), convert_utf8_to_utf16(mode).c_str()); +#else + return fopen(filename.c_str(), mode.c_str()); +#endif +} + +#define countof(a) (sizeof(a) / sizeof(a[0])) + +#ifdef __cpp_constinit +#define CONSTINIT constinit +#elif __has_attribute(require_constant_initialization) +#define CONSTINIT __attribute__((require_constant_initialization)) +#else +#define CONSTINIT +#endif diff --git a/pcsx2/GS/GSdx.cpp b/pcsx2/GS/GSdx.cpp deleted file mode 100644 index 66a52be1f5..0000000000 --- a/pcsx2/GS/GSdx.cpp +++ /dev/null @@ -1,581 +0,0 @@ -/* - * Copyright (C) 2007-2009 Gabest - * http://www.gabest.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -#include "PrecompiledHeader.h" -#include "GSdx.h" -#include "GS.h" -#include - -static void* s_hModule; - -#ifdef _WIN32 - -BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - s_hModule = hModule; - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - - return TRUE; -} - -bool GSdxApp::LoadResource(int id, std::vector& buff, const wchar_t* type) -{ - buff.clear(); - HRSRC hRsrc = FindResource((HMODULE)s_hModule, MAKEINTRESOURCE(id), type != NULL ? type : (LPWSTR)RT_RCDATA); - if (!hRsrc) - return false; - HGLOBAL hGlobal = ::LoadResource((HMODULE)s_hModule, hRsrc); - if (!hGlobal) - return false; - DWORD size = SizeofResource((HMODULE)s_hModule, hRsrc); - if (!size) - return false; - // On Linux resources are always NULL terminated - // Add + 1 on size to do the same for compatibility sake (required by GSDeviceOGL) - buff.resize(size + 1); - memcpy(buff.data(), LockResource(hGlobal), size); - return true; -} - -#else - -#include "GSdxResources.h" - -bool GSdxApp::LoadResource(int id, std::vector& buff, const char* type) -{ - std::string path; - switch (id) - { - case IDR_COMMON_GLSL: - path = "/GSdx/res/glsl/common_header.glsl"; - break; - case IDR_CONVERT_GLSL: - path = "/GSdx/res/glsl/convert.glsl"; - break; - case IDR_FXAA_FX: - path = "/GSdx/res/fxaa.fx"; - break; - case IDR_INTERLACE_GLSL: - path = "/GSdx/res/glsl/interlace.glsl"; - break; - case IDR_MERGE_GLSL: - path = "/GSdx/res/glsl/merge.glsl"; - break; - case IDR_SHADEBOOST_GLSL: - path = "/GSdx/res/glsl/shadeboost.glsl"; - break; - case IDR_TFX_VGS_GLSL: - path = "/GSdx/res/glsl/tfx_vgs.glsl"; - break; - case IDR_TFX_FS_GLSL: - path = "/GSdx/res/glsl/tfx_fs.glsl"; - break; - case IDR_FONT_ROBOTO: - path = "/GSdx/res/fonts-roboto/Roboto-Regular.ttf"; - break; - default: - printf("LoadResource not implemented for id %d\n", id); - return false; - } - - GBytes* bytes = g_resource_lookup_data(GSdx_res_get_resource(), path.c_str(), G_RESOURCE_LOOKUP_FLAGS_NONE, nullptr); - - size_t size = 0; - const void* data = g_bytes_get_data(bytes, &size); - - if (data == nullptr || size == 0) - { - printf("Failed to get data for resource: %d\n", id); - return false; - } - - buff.clear(); - buff.resize(size + 1); - memcpy(buff.data(), data, size + 1); - - g_bytes_unref(bytes); - - return true; -} -#endif - -size_t GSdxApp::GetIniString(const char* lpAppName, const char* lpKeyName, const char* lpDefault, char* lpReturnedString, size_t nSize, const char* lpFileName) -{ - BuildConfigurationMap(lpFileName); - - std::string key(lpKeyName); - std::string value = m_configuration_map[key]; - if (value.empty()) - { - // save the value for futur call - m_configuration_map[key] = std::string(lpDefault); - strcpy(lpReturnedString, lpDefault); - } - else - strcpy(lpReturnedString, value.c_str()); - - return 0; -} - -bool GSdxApp::WriteIniString(const char* lpAppName, const char* lpKeyName, const char* pString, const char* lpFileName) -{ - BuildConfigurationMap(lpFileName); - - std::string key(lpKeyName); - std::string value(pString); - m_configuration_map[key] = value; - - // Save config to a file - FILE* f = px_fopen(lpFileName, "w"); - - if (f == NULL) - return false; // FIXME print a nice message - - // Maintain compatibility with GSDumpGUI/old Windows ini. -#ifdef _WIN32 - fprintf(f, "[Settings]\n"); -#endif - - for (const auto& entry : m_configuration_map) - { - // Do not save the inifile key which is not an option - if (entry.first.compare("inifile") == 0) - continue; - - // Only keep option that have a default value (allow to purge old option of the GSdx.ini) - if (!entry.second.empty() && m_default_configuration.find(entry.first) != m_default_configuration.end()) - fprintf(f, "%s = %s\n", entry.first.c_str(), entry.second.c_str()); - } - fclose(f); - - return false; -} - -int GSdxApp::GetIniInt(const char* lpAppName, const char* lpKeyName, int nDefault, const char* lpFileName) -{ - BuildConfigurationMap(lpFileName); - - std::string value = m_configuration_map[std::string(lpKeyName)]; - if (value.empty()) - { - // save the value for futur call - SetConfig(lpKeyName, nDefault); - return nDefault; - } - else - return atoi(value.c_str()); -} - -GSdxApp theApp; - -GSdxApp::GSdxApp() -{ - // Empty constructor causes an illegal instruction exception on an SSE4.2 machine on Windows. - // Non-empty doesn't, but raises a SIGILL signal when compiled against GCC 6.1.1. - // So here's a compromise. -#ifdef _WIN32 - Init(); -#endif -} - -void GSdxApp::Init() -{ - static bool is_initialised = false; - if (is_initialised) - return; - is_initialised = true; - - m_current_renderer_type = GSRendererType::Undefined; - - if (m_ini.empty()) - m_ini = "inis/GSdx.ini"; - m_section = "Settings"; - -#ifdef _WIN32 - m_gs_renderers.push_back(GSSetting(static_cast(GSRendererType::DX1011_HW), "Direct3D 11", "")); - m_gs_renderers.push_back(GSSetting(static_cast(GSRendererType::OGL_HW), "OpenGL", "")); - m_gs_renderers.push_back(GSSetting(static_cast(GSRendererType::OGL_SW), "Software", "")); -#else // Linux - m_gs_renderers.push_back(GSSetting(static_cast(GSRendererType::OGL_HW), "OpenGL", "")); - m_gs_renderers.push_back(GSSetting(static_cast(GSRendererType::OGL_SW), "Software", "")); -#endif - - // The null renderer goes third, it has use for benchmarking purposes in a release build - m_gs_renderers.push_back(GSSetting(static_cast(GSRendererType::Null), "Null", "")); - - m_gs_interlace.push_back(GSSetting(0, "None", "")); - m_gs_interlace.push_back(GSSetting(1, "Weave tff", "saw-tooth")); - m_gs_interlace.push_back(GSSetting(2, "Weave bff", "saw-tooth")); - m_gs_interlace.push_back(GSSetting(3, "Bob tff", "use blend if shaking")); - m_gs_interlace.push_back(GSSetting(4, "Bob bff", "use blend if shaking")); - m_gs_interlace.push_back(GSSetting(5, "Blend tff", "slight blur, 1/2 fps")); - m_gs_interlace.push_back(GSSetting(6, "Blend bff", "slight blur, 1/2 fps")); - m_gs_interlace.push_back(GSSetting(7, "Automatic", "Default")); - - m_gs_aspectratio.push_back(GSSetting(0, "Stretch", "")); - m_gs_aspectratio.push_back(GSSetting(1, "4:3", "")); - m_gs_aspectratio.push_back(GSSetting(2, "16:9", "")); - - m_gs_upscale_multiplier.push_back(GSSetting(1, "Native", "PS2")); - m_gs_upscale_multiplier.push_back(GSSetting(2, "2x Native", "~720p")); - m_gs_upscale_multiplier.push_back(GSSetting(3, "3x Native", "~1080p")); - m_gs_upscale_multiplier.push_back(GSSetting(4, "4x Native", "~1440p 2K")); - m_gs_upscale_multiplier.push_back(GSSetting(5, "5x Native", "~1620p 3K")); - m_gs_upscale_multiplier.push_back(GSSetting(6, "6x Native", "~2160p 4K")); - m_gs_upscale_multiplier.push_back(GSSetting(8, "8x Native", "~2880p 5K")); - - m_gs_max_anisotropy.push_back(GSSetting(0, "Off", "Default")); - m_gs_max_anisotropy.push_back(GSSetting(2, "2x", "")); - m_gs_max_anisotropy.push_back(GSSetting(4, "4x", "")); - m_gs_max_anisotropy.push_back(GSSetting(8, "8x", "")); - m_gs_max_anisotropy.push_back(GSSetting(16, "16x", "")); - - m_gs_dithering.push_back(GSSetting(0, "Off", "")); - m_gs_dithering.push_back(GSSetting(2, "Unscaled", "Default")); - m_gs_dithering.push_back(GSSetting(1, "Scaled", "")); - - m_gs_bifilter.push_back(GSSetting(static_cast(BiFiltering::Nearest), "Nearest", "")); - m_gs_bifilter.push_back(GSSetting(static_cast(BiFiltering::Forced_But_Sprite), "Bilinear", "Forced excluding sprite")); - m_gs_bifilter.push_back(GSSetting(static_cast(BiFiltering::Forced), "Bilinear", "Forced")); - m_gs_bifilter.push_back(GSSetting(static_cast(BiFiltering::PS2), "Bilinear", "PS2")); - - m_gs_trifilter.push_back(GSSetting(static_cast(TriFiltering::None), "None", "Default")); - m_gs_trifilter.push_back(GSSetting(static_cast(TriFiltering::PS2), "Trilinear", "")); - m_gs_trifilter.push_back(GSSetting(static_cast(TriFiltering::Forced), "Trilinear", "Ultra/Slow")); - - m_gs_generic_list.push_back(GSSetting(-1, "Automatic", "Default")); - m_gs_generic_list.push_back(GSSetting(0, "Force-Disabled", "")); - m_gs_generic_list.push_back(GSSetting(1, "Force-Enabled", "")); - - m_gs_hack.push_back(GSSetting(0, "Off", "Default")); - m_gs_hack.push_back(GSSetting(1, "Half", "")); - m_gs_hack.push_back(GSSetting(2, "Full", "")); - - m_gs_offset_hack.push_back(GSSetting(0, "Off", "Default")); - m_gs_offset_hack.push_back(GSSetting(1, "Normal", "Vertex")); - m_gs_offset_hack.push_back(GSSetting(2, "Special", "Texture")); - m_gs_offset_hack.push_back(GSSetting(3, "Special", "Texture - aggressive")); - - m_gs_hw_mipmapping = { - GSSetting(HWMipmapLevel::Automatic, "Automatic", "Default"), - GSSetting(HWMipmapLevel::Off, "Off", ""), - GSSetting(HWMipmapLevel::Basic, "Basic", "Fast"), - GSSetting(HWMipmapLevel::Full, "Full", "Slow"), - }; - - m_gs_crc_level = { - GSSetting(CRCHackLevel::Automatic, "Automatic", "Default"), - GSSetting(CRCHackLevel::None, "None", "Debug"), - GSSetting(CRCHackLevel::Minimum, "Minimum", "Debug"), -#ifdef _DEBUG - GSSetting(CRCHackLevel::Partial, "Partial", "OpenGL"), - GSSetting(CRCHackLevel::Full, "Full", "Direct3D"), -#endif - GSSetting(CRCHackLevel::Aggressive, "Aggressive", ""), - }; - - m_gs_acc_blend_level.push_back(GSSetting(0, "None", "Fastest")); - m_gs_acc_blend_level.push_back(GSSetting(1, "Basic", "Recommended")); - m_gs_acc_blend_level.push_back(GSSetting(2, "Medium", "")); - m_gs_acc_blend_level.push_back(GSSetting(3, "High", "")); - m_gs_acc_blend_level.push_back(GSSetting(4, "Full", "Very Slow")); - m_gs_acc_blend_level.push_back(GSSetting(5, "Ultra", "Ultra Slow")); - - m_gs_acc_blend_level_d3d11.push_back(GSSetting(0, "None", "Fastest")); - m_gs_acc_blend_level_d3d11.push_back(GSSetting(1, "Basic", "Recommended")); - m_gs_acc_blend_level_d3d11.push_back(GSSetting(2, "Medium", "Debug")); - m_gs_acc_blend_level_d3d11.push_back(GSSetting(3, "High", "Debug")); - - m_gs_tv_shaders.push_back(GSSetting(0, "None", "")); - m_gs_tv_shaders.push_back(GSSetting(1, "Scanline filter", "")); - m_gs_tv_shaders.push_back(GSSetting(2, "Diagonal filter", "")); - m_gs_tv_shaders.push_back(GSSetting(3, "Triangular filter", "")); - m_gs_tv_shaders.push_back(GSSetting(4, "Wave filter", "")); - - // Avoid to clutter the ini file with useless options -#ifdef _WIN32 - // Per OS option. - m_default_configuration["Adapter"] = "default"; - m_default_configuration["CaptureFileName"] = ""; - m_default_configuration["CaptureVideoCodecDisplayName"] = ""; - m_default_configuration["dx_break_on_severity"] = "0"; - // D3D Blending option - m_default_configuration["accurate_blending_unit_d3d11"] = "1"; -#else - m_default_configuration["linux_replay"] = "1"; -#endif - m_default_configuration["aa1"] = "0"; - m_default_configuration["accurate_date"] = "1"; - m_default_configuration["accurate_blending_unit"] = "1"; - m_default_configuration["AspectRatio"] = "1"; - m_default_configuration["autoflush_sw"] = "1"; - m_default_configuration["capture_enabled"] = "0"; - m_default_configuration["capture_out_dir"] = "/tmp/GSdx_Capture"; - m_default_configuration["capture_threads"] = "4"; - m_default_configuration["CaptureHeight"] = "480"; - m_default_configuration["CaptureWidth"] = "640"; - m_default_configuration["clut_load_before_draw"] = "0"; - m_default_configuration["crc_hack_level"] = std::to_string(static_cast(CRCHackLevel::Automatic)); - m_default_configuration["CrcHacksExclusions"] = ""; - m_default_configuration["debug_glsl_shader"] = "0"; - m_default_configuration["debug_opengl"] = "0"; - m_default_configuration["disable_hw_gl_draw"] = "0"; - m_default_configuration["dithering_ps2"] = "2"; - m_default_configuration["dump"] = "0"; - m_default_configuration["extrathreads"] = "2"; - m_default_configuration["extrathreads_height"] = "4"; - m_default_configuration["filter"] = std::to_string(static_cast(BiFiltering::PS2)); - m_default_configuration["force_texture_clear"] = "0"; - m_default_configuration["fxaa"] = "0"; - m_default_configuration["interlace"] = "7"; - m_default_configuration["conservative_framebuffer"] = "1"; - m_default_configuration["linear_present"] = "1"; - m_default_configuration["MaxAnisotropy"] = "0"; - m_default_configuration["mipmap"] = "1"; - m_default_configuration["mipmap_hw"] = std::to_string(static_cast(HWMipmapLevel::Automatic)); - m_default_configuration["ModeHeight"] = "480"; - m_default_configuration["ModeWidth"] = "640"; - m_default_configuration["NTSC_Saturation"] = "1"; -#ifdef _WIN32 - m_default_configuration["osd_fontname"] = "C:\\Windows\\Fonts\\my_favorite_font_e_g_tahoma.ttf"; -#else - m_default_configuration["osd_fontname"] = "/usr/share/fonts/truetype/my_favorite_font_e_g_DejaVu Sans.ttf"; -#endif - m_default_configuration["osd_color_r"] = "0"; - m_default_configuration["osd_color_g"] = "160"; - m_default_configuration["osd_color_b"] = "255"; - m_default_configuration["osd_color_opacity"] = "100"; - m_default_configuration["osd_fontsize"] = "25"; - m_default_configuration["osd_log_enabled"] = "1"; - m_default_configuration["osd_log_timeout"] = "4"; - m_default_configuration["osd_monitor_enabled"] = "0"; - m_default_configuration["osd_max_log_messages"] = "2"; - m_default_configuration["override_geometry_shader"] = "-1"; - m_default_configuration["override_GL_ARB_compute_shader"] = "-1"; - m_default_configuration["override_GL_ARB_copy_image"] = "-1"; - m_default_configuration["override_GL_ARB_clear_texture"] = "-1"; - m_default_configuration["override_GL_ARB_clip_control"] = "-1"; - m_default_configuration["override_GL_ARB_direct_state_access"] = "-1"; - m_default_configuration["override_GL_ARB_draw_buffers_blend"] = "-1"; - m_default_configuration["override_GL_ARB_get_texture_sub_image"] = "-1"; - m_default_configuration["override_GL_ARB_gpu_shader5"] = "-1"; - m_default_configuration["override_GL_ARB_multi_bind"] = "-1"; - m_default_configuration["override_GL_ARB_shader_image_load_store"] = "-1"; - m_default_configuration["override_GL_ARB_shader_storage_buffer_object"] = "-1"; - m_default_configuration["override_GL_ARB_sparse_texture"] = "-1"; - m_default_configuration["override_GL_ARB_sparse_texture2"] = "-1"; - m_default_configuration["override_GL_ARB_texture_view"] = "-1"; - m_default_configuration["override_GL_ARB_vertex_attrib_binding"] = "-1"; - m_default_configuration["override_GL_ARB_texture_barrier"] = "-1"; - m_default_configuration["paltex"] = "0"; - m_default_configuration["png_compression_level"] = std::to_string(Z_BEST_SPEED); - m_default_configuration["preload_frame_with_gs_data"] = "0"; - m_default_configuration["Renderer"] = std::to_string(static_cast(GSRendererType::Default)); - m_default_configuration["resx"] = "1024"; - m_default_configuration["resy"] = "1024"; - m_default_configuration["save"] = "0"; - m_default_configuration["savef"] = "0"; - m_default_configuration["savel"] = "5000"; - m_default_configuration["saven"] = "0"; - m_default_configuration["savet"] = "0"; - m_default_configuration["savez"] = "0"; - m_default_configuration["ShadeBoost"] = "0"; - m_default_configuration["ShadeBoost_Brightness"] = "50"; - m_default_configuration["ShadeBoost_Contrast"] = "50"; - m_default_configuration["ShadeBoost_Saturation"] = "50"; - m_default_configuration["shaderfx"] = "0"; - m_default_configuration["shaderfx_conf"] = "shaders/GSdx_FX_Settings.ini"; - m_default_configuration["shaderfx_glsl"] = "shaders/GSdx.fx"; - m_default_configuration["TVShader"] = "0"; - m_default_configuration["upscale_multiplier"] = "1"; - m_default_configuration["UserHacks"] = "0"; - m_default_configuration["UserHacks_align_sprite_X"] = "0"; - m_default_configuration["UserHacks_AutoFlush"] = "0"; - m_default_configuration["UserHacks_DisableDepthSupport"] = "0"; - m_default_configuration["UserHacks_Disable_Safe_Features"] = "0"; - m_default_configuration["UserHacks_DisablePartialInvalidation"] = "0"; - m_default_configuration["UserHacks_CPU_FB_Conversion"] = "0"; - m_default_configuration["UserHacks_Half_Bottom_Override"] = "-1"; - m_default_configuration["UserHacks_HalfPixelOffset"] = "0"; - m_default_configuration["UserHacks_merge_pp_sprite"] = "0"; - m_default_configuration["UserHacks_round_sprite_offset"] = "0"; - m_default_configuration["UserHacks_SkipDraw"] = "0"; - m_default_configuration["UserHacks_SkipDraw_Offset"] = "0"; - m_default_configuration["UserHacks_TCOffsetX"] = "0"; - m_default_configuration["UserHacks_TCOffsetY"] = "0"; - m_default_configuration["UserHacks_TextureInsideRt"] = "0"; - m_default_configuration["UserHacks_TriFilter"] = std::to_string(static_cast(TriFiltering::None)); - m_default_configuration["UserHacks_WildHack"] = "0"; - m_default_configuration["wrap_gs_mem"] = "0"; - m_default_configuration["vsync"] = "0"; -} - -void GSdxApp::ReloadConfig() -{ - if (m_configuration_map.empty()) - return; - - auto file = m_configuration_map.find("inifile"); - if (file == m_configuration_map.end()) - return; - - // A map was built so reload it - std::string filename = file->second; - m_configuration_map.clear(); - BuildConfigurationMap(filename.c_str()); -} - -void GSdxApp::BuildConfigurationMap(const char* lpFileName) -{ - // Check if the map was already built - std::string inifile_value(lpFileName); - if (inifile_value.compare(m_configuration_map["inifile"]) == 0) - return; - m_configuration_map["inifile"] = inifile_value; - - // Load config from file -#ifdef _WIN32 - std::ifstream file(convert_utf8_to_utf16(lpFileName)); -#else - std::ifstream file(lpFileName); -#endif - if (!file.is_open()) - return; - - std::string line; - while (std::getline(file, line)) - { - const auto separator = line.find('='); - if (separator == std::string::npos) - continue; - - std::string key = line.substr(0, separator); - // Trim trailing whitespace - key.erase(key.find_last_not_of(" \r\t") + 1); - - if (key.empty()) - continue; - - // Only keep options that have a default value so older, no longer used - // ini options can be purged. - if (m_default_configuration.find(key) == m_default_configuration.end()) - continue; - - std::string value = line.substr(separator + 1); - // Trim leading whitespace - value.erase(0, value.find_first_not_of(" \r\t")); - - m_configuration_map[key] = value; - } -} - -void* GSdxApp::GetModuleHandlePtr() -{ - return s_hModule; -} - -void GSdxApp::SetConfigDir(const char* dir) -{ - if (dir == NULL) - { - m_ini = "inis/GSdx.ini"; - } - else - { - m_ini = dir; - - if (m_ini[m_ini.length() - 1] != DIRECTORY_SEPARATOR) - { - m_ini += DIRECTORY_SEPARATOR; - } - - m_ini += "GSdx.ini"; - } -} - -std::string GSdxApp::GetConfigS(const char* entry) -{ - char buff[4096] = {0}; - auto def = m_default_configuration.find(entry); - - if (def != m_default_configuration.end()) - { - GetIniString(m_section.c_str(), entry, def->second.c_str(), buff, countof(buff), m_ini.c_str()); - } - else - { - fprintf(stderr, "Option %s doesn't have a default value\n", entry); - GetIniString(m_section.c_str(), entry, "", buff, countof(buff), m_ini.c_str()); - } - - return {buff}; -} - -void GSdxApp::SetConfig(const char* entry, const char* value) -{ - WriteIniString(m_section.c_str(), entry, value, m_ini.c_str()); -} - -int GSdxApp::GetConfigI(const char* entry) -{ - auto def = m_default_configuration.find(entry); - - if (def != m_default_configuration.end()) - { - return GetIniInt(m_section.c_str(), entry, std::stoi(def->second), m_ini.c_str()); - } - else - { - fprintf(stderr, "Option %s doesn't have a default value\n", entry); - return GetIniInt(m_section.c_str(), entry, 0, m_ini.c_str()); - } -} - -bool GSdxApp::GetConfigB(const char* entry) -{ - return !!GetConfigI(entry); -} - -void GSdxApp::SetConfig(const char* entry, int value) -{ - char buff[32] = {0}; - - sprintf(buff, "%d", value); - - SetConfig(entry, buff); -} - -void GSdxApp::SetCurrentRendererType(GSRendererType type) -{ - m_current_renderer_type = type; -} - -GSRendererType GSdxApp::GetCurrentRendererType() const -{ - return m_current_renderer_type; -} diff --git a/pcsx2/GS/GSdx.def b/pcsx2/GS/GSdx.def index 2d20602b2b..7a57f5d8fb 100644 --- a/pcsx2/GS/GSdx.def +++ b/pcsx2/GS/GSdx.def @@ -1,4 +1,4 @@ -; GSdx.def : Declares the module parameters for the DLL. +; GS.def : Declares the module parameters for the DLL. EXPORTS ; Explicit exports can go here diff --git a/pcsx2/GS/GSdx.h b/pcsx2/GS/GSdx.h index 17833be0b9..06fea2c50c 100644 --- a/pcsx2/GS/GSdx.h +++ b/pcsx2/GS/GSdx.h @@ -24,7 +24,7 @@ #include "Window/GSSetting.h" #include "GS.h" -class GSdxApp +class GSApp { std::string m_ini; std::string m_section; @@ -33,7 +33,7 @@ class GSdxApp GSRendererType m_current_renderer_type; public: - GSdxApp(); + GSApp(); void Init(); void* GetModuleHandlePtr(); @@ -93,14 +93,14 @@ public: std::vector m_gs_tv_shaders; }; -struct GSDXError +struct GSError { }; -struct GSDXRecoverableError : GSDXError +struct GSRecoverableError : GSError { }; -struct GSDXErrorGlVertexArrayTooSmall : GSDXError +struct GSErrorGlVertexArrayTooSmall : GSError { }; -extern GSdxApp theApp; +extern GSApp theApp; diff --git a/pcsx2/GS/GSdx.rc b/pcsx2/GS/GSdx.rc index 2be16b76ca..308d0bac07 100644 --- a/pcsx2/GS/GSdx.rc +++ b/pcsx2/GS/GSdx.rc @@ -254,7 +254,7 @@ END IDD_CONFIG DIALOGEX 0, 0, 242, 360 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "GSdx Settings" +CAPTION "GS Settings" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN // General Settings: @@ -393,10 +393,10 @@ BEGIN VALUE "CompanyName", "Gabest" VALUE "FileDescription", "GS plugin for ps2 emulators" VALUE "FileVersion", "1, 2, 0, 0" - VALUE "InternalName", "GSdx.dll" + VALUE "InternalName", "GS.dll" VALUE "LegalCopyright", "Copyright (c) 2007-2008 Gabest. All rights reserved." - VALUE "OriginalFilename", "GSdx.dll" - VALUE "ProductName", "GSdx" + VALUE "OriginalFilename", "GS.dll" + VALUE "ProductName", "GS" VALUE "ProductVersion", "1, 2, 0, 0" END END diff --git a/pcsx2/GS/Renderers/Common/GSDevice.cpp b/pcsx2/GS/Renderers/Common/GSDevice.cpp index 4a04e00f21..5aa41714ee 100644 --- a/pcsx2/GS/Renderers/Common/GSDevice.cpp +++ b/pcsx2/GS/Renderers/Common/GSDevice.cpp @@ -20,7 +20,7 @@ */ #include "PrecompiledHeader.h" -#include "GSdx.h" +#include "../GS.h" #include "GSDevice.h" GSDevice::GSDevice() @@ -279,7 +279,7 @@ void GSDevice::Merge(GSTexture* sTex[3], GSVector4* sRect, GSVector4* dRect, con } else { - printf("GSdx: m_merge is NULL!\n"); + printf("GS: m_merge is NULL!\n"); } m_current = m_merge; @@ -525,4 +525,4 @@ std::array GSDevice::m_blendMap = { 0 , OP_ADD , CONST_ZERO , CONST_ONE} , // 2221: (0 - 0)*F + Cd ==> Cd { BLEND_NO_REC , OP_ADD , CONST_ZERO , CONST_ZERO} , // 2222: (0 - 0)*F + 0 ==> 0 { 0 , OP_ADD , SRC_ALPHA , INV_SRC_ALPHA} , // extra for merge operation -}}; \ No newline at end of file +}}; diff --git a/pcsx2/GS/Renderers/Common/GSFastList.h b/pcsx2/GS/Renderers/Common/GSFastList.h index c8cc3edd70..ec143152ae 100644 --- a/pcsx2/GS/Renderers/Common/GSFastList.h +++ b/pcsx2/GS/Renderers/Common/GSFastList.h @@ -22,6 +22,8 @@ #pragma once +#include "../../GS_types.h" + template struct Element { diff --git a/pcsx2/GS/Renderers/Common/GSOsdManager.cpp b/pcsx2/GS/Renderers/Common/GSOsdManager.cpp index 1794bfd55b..0d9270612e 100644 --- a/pcsx2/GS/Renderers/Common/GSOsdManager.cpp +++ b/pcsx2/GS/Renderers/Common/GSOsdManager.cpp @@ -20,7 +20,7 @@ */ #include "PrecompiledHeader.h" -#include "GSdx.h" +#include "../GS.h" #include "GSOsdManager.h" #ifdef _WIN32 #include "resource.h" @@ -366,8 +366,7 @@ size_t GSOsdManager::Size() } float ratio = (elapsed - std::chrono::seconds(m_log_timeout / 2)).count() / std::chrono::seconds(m_log_timeout / 2).count(); - ratio = ratio > 1.0f ? 1.0f : ratio < 0.0f ? 0.0f : - ratio; + ratio = ratio > 1.0f ? 1.0f : ratio < 0.0f ? 0.0f : ratio; y += offset += ((m_size + 2) * (2.0f / m_real_size.y)) * ratio; sum += it->msg.size(); diff --git a/pcsx2/GS/Renderers/Common/GSRenderer.cpp b/pcsx2/GS/Renderers/Common/GSRenderer.cpp index 5825d522d7..88e2e3d05e 100644 --- a/pcsx2/GS/Renderers/Common/GSRenderer.cpp +++ b/pcsx2/GS/Renderers/Common/GSRenderer.cpp @@ -361,7 +361,7 @@ void GSRenderer::VSync(int field) if (m_wnd->IsManaged()) #endif { - //GSdx owns the window's title, be verbose. + //GS owns the window's title, be verbose. std::string s2 = m_regs->SMODE2.INT ? (std::string("Interlaced ") + (m_regs->SMODE2.FFMD ? "(frame)" : "(field)")) : "Progressive"; @@ -590,7 +590,7 @@ void GSRenderer::KeyEvent(GSKeyEventData* e) case VK_F5: m_interlace = (m_interlace + s_interlace_nb + step) % s_interlace_nb; theApp.SetConfig("interlace", m_interlace); - printf("GSdx: Set deinterlace mode to %d (%s).\n", m_interlace, theApp.m_gs_interlace.at(m_interlace).name.c_str()); + printf("GS: Set deinterlace mode to %d (%s).\n", m_interlace, theApp.m_gs_interlace.at(m_interlace).name.c_str()); return; case VK_F6: if (m_wnd->IsManaged()) @@ -599,27 +599,27 @@ void GSRenderer::KeyEvent(GSKeyEventData* e) case VK_DELETE: m_aa1 = !m_aa1; theApp.SetConfig("aa1", m_aa1); - printf("GSdx: (Software) Edge anti-aliasing is now %s.\n", m_aa1 ? "enabled" : "disabled"); + printf("GS: (Software) Edge anti-aliasing is now %s.\n", m_aa1 ? "enabled" : "disabled"); return; case VK_INSERT: m_mipmap = (m_mipmap + s_mipmap_nb + step) % s_mipmap_nb; theApp.SetConfig("mipmap_hw", m_mipmap); - printf("GSdx: Mipmapping is now %s.\n", theApp.m_gs_hack.at(m_mipmap).name.c_str()); + printf("GS: Mipmapping is now %s.\n", theApp.m_gs_hack.at(m_mipmap).name.c_str()); return; case VK_PRIOR: m_fxaa = !m_fxaa; theApp.SetConfig("fxaa", m_fxaa); - printf("GSdx: FXAA anti-aliasing is now %s.\n", m_fxaa ? "enabled" : "disabled"); + printf("GS: FXAA anti-aliasing is now %s.\n", m_fxaa ? "enabled" : "disabled"); return; case VK_HOME: m_shaderfx = !m_shaderfx; theApp.SetConfig("shaderfx", m_shaderfx); - printf("GSdx: External post-processing is now %s.\n", m_shaderfx ? "enabled" : "disabled"); + printf("GS: External post-processing is now %s.\n", m_shaderfx ? "enabled" : "disabled"); return; case VK_NEXT: // As requested by Prafull, to be removed later char dither_msg[3][16] = {"disabled", "auto", "auto unscaled"}; m_dithering = (m_dithering + 1) % 3; - printf("GSdx: Dithering is now %s.\n", dither_msg[m_dithering]); + printf("GS: Dithering is now %s.\n", dither_msg[m_dithering]); return; } } diff --git a/pcsx2/GS/Renderers/Common/GSTexture.h b/pcsx2/GS/Renderers/Common/GSTexture.h index e7babda86a..2060d1a371 100644 --- a/pcsx2/GS/Renderers/Common/GSTexture.h +++ b/pcsx2/GS/Renderers/Common/GSTexture.h @@ -58,7 +58,7 @@ public: virtual operator bool() { - ASSERT(0); + pxAssert(0); return false; } diff --git a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp index e77792d9f5..43f868fb12 100644 --- a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp +++ b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp @@ -20,7 +20,7 @@ */ #include "PrecompiledHeader.h" -#include "GSdx.h" +#include "GS.h" #include "GSDevice11.h" #include "GSUtil.h" #include "resource.h" @@ -922,7 +922,7 @@ void GSDevice11::InitExternalFX() if (fconfig.good()) shader << fconfig.rdbuf() << "\n"; else - fprintf(stderr, "GSdx: External shader config '%s' not loaded.\n", config_name.c_str()); + fprintf(stderr, "GS: External shader config '%s' not loaded.\n", config_name.c_str()); std::string shader_name(theApp.GetConfigS("shaderfx_glsl")); std::ifstream fshader(shader_name); @@ -936,12 +936,12 @@ void GSDevice11::InitExternalFX() } else { - fprintf(stderr, "GSdx: External shader '%s' not loaded and will be disabled!\n", shader_name.c_str()); + fprintf(stderr, "GS: External shader '%s' not loaded and will be disabled!\n", shader_name.c_str()); } } - catch (GSDXRecoverableError) + catch (GSRecoverableError) { - printf("GSdx: failed to compile external post-processing shader. \n"); + printf("GS: failed to compile external post-processing shader. \n"); } ExShader_Compiled = true; } @@ -980,9 +980,9 @@ void GSDevice11::InitFXAA() ShaderMacro sm(m_shader.model); CreateShader(shader, "fxaa.fx", nullptr, "ps_main", sm.GetPtr(), &m_fxaa.ps); } - catch (GSDXRecoverableError) + catch (GSRecoverableError) { - printf("GSdx: failed to compile fxaa shader.\n"); + printf("GS: failed to compile fxaa shader.\n"); } FXAA_Compiled = true; } @@ -1372,7 +1372,7 @@ void GSDevice11::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector ID3D11DepthStencilView* dsv = NULL; if (!rt && !ds) - throw GSDXRecoverableError(); + throw GSRecoverableError(); if (rt) rtv = *(GSTexture11*)rt; if (ds) dsv = *(GSTexture11*)ds; @@ -1448,14 +1448,14 @@ void GSDevice11::CreateShader(const std::vector& source, const char* fn, I if (FAILED(hr)) { - throw GSDXRecoverableError(); + throw GSRecoverableError(); } hr = m_dev->CreateInputLayout(layout, count, shader->GetBufferPointer(), shader->GetBufferSize(), il); if (FAILED(hr)) { - throw GSDXRecoverableError(); + throw GSRecoverableError(); } } @@ -1471,7 +1471,7 @@ void GSDevice11::CreateShader(const std::vector& source, const char* fn, I if (FAILED(hr)) { - throw GSDXRecoverableError(); + throw GSRecoverableError(); } } @@ -1487,7 +1487,7 @@ void GSDevice11::CreateShader(const std::vector& source, const char* fn, I if (FAILED(hr)) { - throw GSDXRecoverableError(); + throw GSRecoverableError(); } } @@ -1510,7 +1510,7 @@ void GSDevice11::CompileShader(const std::vector& source, const char* fn, fprintf(stderr, "%s\n", (const char*)error->GetBufferPointer()); if (FAILED(hr)) - throw GSDXRecoverableError(); + throw GSRecoverableError(); } uint16 GSDevice11::ConvertBlendEnum(uint16 generic) diff --git a/pcsx2/GS/Renderers/DX11/GSRendererDX11.cpp b/pcsx2/GS/Renderers/DX11/GSRendererDX11.cpp index c8b40dc8d8..8f13f59309 100644 --- a/pcsx2/GS/Renderers/DX11/GSRendererDX11.cpp +++ b/pcsx2/GS/Renderers/DX11/GSRendererDX11.cpp @@ -1015,7 +1015,7 @@ void GSRendererDX11::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sou { // Note potentially we can limit to TBP0:0x2800 - // Depth buffer was moved so GSdx will invalide it which means a + // Depth buffer was moved so GS will invalide it which means a // downscale. ICO uses the MSB depth bits as the texture alpha // channel. However this depth of field effect requires // texel:pixel mapping accuracy. diff --git a/pcsx2/GS/Renderers/HW/GSHwHack.cpp b/pcsx2/GS/Renderers/HW/GSHwHack.cpp index 40e10ce76f..441a163070 100644 --- a/pcsx2/GS/Renderers/HW/GSHwHack.cpp +++ b/pcsx2/GS/Renderers/HW/GSHwHack.cpp @@ -21,7 +21,7 @@ #include "PrecompiledHeader.h" #include "GSState.h" -#include "GSdx.h" +#include "GS.h" bool s_nativeres; static CRCHackLevel s_crc_hack_level = CRCHackLevel::Full; @@ -75,7 +75,7 @@ bool GSC_DBZBT3(const GSFrameInfo& fi, int& skip) bool GSC_DeathByDegreesTekkenNinaWilliams(const GSFrameInfo& fi, int& skip) { // Note: Game also has issues with texture shuffle not supported on strange clamp mode. - // See https://forums.pcsx2.net/Thread-GSDX-Texture-Cache-Bug-Report-Death-By-Degrees-SLUS-20934-NTSC + // See https://forums.pcsx2.net/Thread-GS-Texture-Cache-Bug-Report-Death-By-Degrees-SLUS-20934-NTSC if (skip == 0) { if ((Aggressive || !s_nativeres) && fi.TME && fi.FBP == 0 && fi.TBP0 == 0x34a0 && fi.TPSM == PSM_PSMCT32) diff --git a/pcsx2/GS/Renderers/HW/GSTextureCache.cpp b/pcsx2/GS/Renderers/HW/GSTextureCache.cpp index 1dbb2925b7..0ae2cdea21 100644 --- a/pcsx2/GS/Renderers/HW/GSTextureCache.cpp +++ b/pcsx2/GS/Renderers/HW/GSTextureCache.cpp @@ -115,7 +115,7 @@ GSTextureCache::Source* GSTextureCache::LookupDepthSource(const GIFRegTEX0& TEX0 } else { - throw GSDXRecoverableError(); + throw GSRecoverableError(); } } @@ -212,7 +212,7 @@ GSTextureCache::Source* GSTextureCache::LookupDepthSource(const GIFRegTEX0& TEX0 // The game tries to emulate a texture shuffle with an old depth buffer // (don't exists yet for us due to the cache) // Rendering is nicer (less garbage) if we skip the draw call. - throw GSDXRecoverableError(); + throw GSRecoverableError(); } //ASSERT(0); @@ -1509,7 +1509,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con GSTexture* dTex = m_renderer->m_dev->CreateRenderTarget(w, h); src->m_texture = dTex; - // GH: by default (m_paltex == 0) GSdx converts texture to the 32 bit format + // GH: by default (m_paltex == 0) GS converts texture to the 32 bit format // However it is different here. We want to reuse a Render Target as a texture. // Because the texture is already on the GPU, CPU can't convert it. if (psm.pal > 0) @@ -1576,7 +1576,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con else ASSERT(0); - // Offset hack. Can be enabled via GSdx options. + // Offset hack. Can be enabled via GS options. // The offset will be used in Draw(). float modx = 0.0f; diff --git a/pcsx2/GS/Renderers/OpenGL/GLLoader.cpp b/pcsx2/GS/Renderers/OpenGL/GLLoader.cpp index f0220fdf11..04533d01b6 100644 --- a/pcsx2/GS/Renderers/OpenGL/GLLoader.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GLLoader.cpp @@ -20,7 +20,7 @@ #include "PrecompiledHeader.h" #include "GLLoader.h" -#include "GSdx.h" +#include "GS.h" #include "GS.h" #if defined(__unix__) || defined(__APPLE__) @@ -190,7 +190,7 @@ namespace GLLoader if (!GLExtension::Has(ext)) { fprintf(stderr, "ERROR: %s is NOT SUPPORTED\n", ext.c_str()); - throw GSDXRecoverableError(); + throw GSRecoverableError(); } return; @@ -228,7 +228,7 @@ namespace GLLoader if (s == NULL) { fprintf(stderr, "Error: GLLoader failed to get GL version\n"); - throw GSDXRecoverableError(); + throw GSRecoverableError(); } GLuint v = 1; while (s[v] != '\0' && s[v - 1] != ' ') @@ -279,7 +279,7 @@ namespace GLLoader if ((major_gl < major) || (major_gl == major && minor_gl < minor)) { fprintf(stderr, "OpenGL %d.%d is not supported. Only OpenGL %d.%d\n was found", major, minor, major_gl, minor_gl); - throw GSDXRecoverableError(); + throw GSRecoverableError(); } } diff --git a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp index 87f8a4169f..2bbb714cdb 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp @@ -31,7 +31,7 @@ #ifdef _WIN32 #include "resource.h" #else -#include "GSdxResources.h" +#include "GSResources.h" #endif // TODO port those value into PerfMon API @@ -84,9 +84,9 @@ GSDeviceOGL::GSDeviceOGL() // Reset the debug file #ifdef ENABLE_OGL_DEBUG if (theApp.GetCurrentRendererType() == GSRendererType::OGL_SW) - m_debug_gl_file = fopen("GSdx_opengl_debug_sw.txt", "w"); + m_debug_gl_file = fopen("GS_opengl_debug_sw.txt", "w"); else - m_debug_gl_file = fopen("GSdx_opengl_debug_hw.txt", "w"); + m_debug_gl_file = fopen("GS_opengl_debug_hw.txt", "w"); #endif m_debug_gl_call = theApp.GetConfigB("debug_opengl"); @@ -229,7 +229,7 @@ void GSDeviceOGL::GenerateProfilerData() fprintf(stderr, "%3u ms => %3u ms\t%4u\n", 2 * i, 2 * (i + 1), time_repartition[i]); } - FILE* csv = fopen("GSdx_profile.csv", "w"); + FILE* csv = fopen("GS_profile.csv", "w"); if (csv) { for (size_t i = 0; i < times.size(); i++) @@ -1040,7 +1040,7 @@ GLuint GSDeviceOGL::CompilePS(PSSelector sel) void GSDeviceOGL::SelfShaderTestRun(const std::string& dir, const std::string& file, const PSSelector& sel, int& nb_shader) { #ifdef __unix__ - std::string out = "/tmp/GSdx_Shader/"; + std::string out = "/tmp/GS_Shader/"; GSmkdir(out.c_str()); out += dir + "/"; @@ -1412,7 +1412,7 @@ void GSDeviceOGL::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture // Flip y axis only when we render in the backbuffer // By default everything is render in the wrong order (ie dx). // 1/ consistency between several pass rendering (interlace) - // 2/ in case some GSdx code expect thing in dx order. + // 2/ in case some GS code expect thing in dx order. // Only flipping the backbuffer is transparent (I hope)... GSVector4 flip_sr = sRect; if (static_cast(dTex)->IsBackbuffer()) diff --git a/pcsx2/GS/Renderers/OpenGL/GSRendererOGL.cpp b/pcsx2/GS/Renderers/OpenGL/GSRendererOGL.cpp index 984bf1ce9f..4be23e75a1 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSRendererOGL.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GSRendererOGL.cpp @@ -1038,7 +1038,7 @@ void GSRendererOGL::SendDraw() else { // FIXME: Investigate: a dynamic check to pack as many primitives as possibles - // I'm nearly sure GSdx already have this kind of code (maybe we can adapt GSDirtyRect) + // I'm nearly sure GS already have this kind of code (maybe we can adapt GSDirtyRect) const size_t nb_vertex = GSUtil::GetClassVertexCount(m_vt.m_primclass); GL_PUSH("Split the draw"); @@ -1392,7 +1392,7 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour { // Note potentially we can limit to TBP0:0x2800 - // Depth buffer was moved so GSdx will invalide it which means a + // Depth buffer was moved so GS will invalide it which means a // downscale. ICO uses the MSB depth bits as the texture alpha // channel. However this depth of field effect requires // texel:pixel mapping accuracy. diff --git a/pcsx2/GS/Renderers/OpenGL/GSShaderOGL.cpp b/pcsx2/GS/Renderers/OpenGL/GSShaderOGL.cpp index afb7e0068e..fc0136d5c9 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSShaderOGL.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GSShaderOGL.cpp @@ -26,7 +26,7 @@ #ifdef _WIN32 #include "resource.h" #else -#include "GSdxResources.h" +#include "GSResources.h" #endif GSShaderOGL::GSShaderOGL(bool debug) diff --git a/pcsx2/GS/Renderers/OpenGL/GSTextureOGL.cpp b/pcsx2/GS/Renderers/OpenGL/GSTextureOGL.cpp index 6c05d50b82..1dde825902 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSTextureOGL.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GSTextureOGL.cpp @@ -471,7 +471,7 @@ bool GSTextureOGL::Map(GSMap& m, const GSVector4i* _r, int layer) if (m_type == GSTexture::Offscreen) { - // The fastest way will be to use a PBO to read the data asynchronously. Unfortunately GSdx + // The fastest way will be to use a PBO to read the data asynchronously. Unfortunately GS // architecture is waiting the data right now. #if 0 diff --git a/pcsx2/GS/Renderers/OpenGL/GSVertexArrayOGL.h b/pcsx2/GS/Renderers/OpenGL/GSVertexArrayOGL.h index 34eba5d973..d33b96e275 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSVertexArrayOGL.h +++ b/pcsx2/GS/Renderers/OpenGL/GSVertexArrayOGL.h @@ -86,7 +86,7 @@ public: if (!m_buffer_ptr) { fprintf(stderr, "Failed to map buffer\n"); - throw GSDXError(); + throw GSError(); } } @@ -109,7 +109,7 @@ public: m_count = count; if (m_count >= m_limit) - throw GSDXErrorGlVertexArrayTooSmall(); + throw GSErrorGlVertexArrayTooSmall(); size_t offset = m_start * STRIDE; size_t length = m_count * STRIDE; @@ -315,7 +315,7 @@ public: ptr = m_vb->map(count); break; } - catch (GSDXErrorGlVertexArrayTooSmall) + catch (GSErrorGlVertexArrayTooSmall) { GL_INS("GL vertex buffer is too small"); @@ -337,7 +337,7 @@ public: m_vb->upload(vertices, count); break; } - catch (GSDXErrorGlVertexArrayTooSmall) + catch (GSErrorGlVertexArrayTooSmall) { GL_INS("GL vertex buffer is too small"); @@ -357,7 +357,7 @@ public: m_ib->upload(index, count); break; } - catch (GSDXErrorGlVertexArrayTooSmall) + catch (GSErrorGlVertexArrayTooSmall) { GL_INS("GL index buffer is too small"); diff --git a/pcsx2/GS/Renderers/SW/GSRendererSW.cpp b/pcsx2/GS/Renderers/SW/GSRendererSW.cpp index f1d33741cf..946036a51a 100644 --- a/pcsx2/GS/Renderers/SW/GSRendererSW.cpp +++ b/pcsx2/GS/Renderers/SW/GSRendererSW.cpp @@ -1551,7 +1551,7 @@ void GSRendererSW::SharedData::UpdateSource() } else { - printf("GSdx: out-of-memory, texturing temporarily disabled\n"); + printf("GS: out-of-memory, texturing temporarily disabled\n"); global.sel.tfx = TFX_NONE; } diff --git a/pcsx2/GS/Renderers/SW/GSTextureSW.h b/pcsx2/GS/Renderers/SW/GSTextureSW.h index 2d2b58f83c..2061f2248e 100644 --- a/pcsx2/GS/Renderers/SW/GSTextureSW.h +++ b/pcsx2/GS/Renderers/SW/GSTextureSW.h @@ -21,7 +21,7 @@ #pragma once -#include "Renderers/Common/GSTexture.h" +#include "../Common/GSTexture.h" class GSTextureSW final : public GSTexture { diff --git a/pcsx2/GS/Window/GSCaptureDlg.cpp b/pcsx2/GS/Window/GSCaptureDlg.cpp index 9fd6cbe148..814d771312 100644 --- a/pcsx2/GS/Window/GSCaptureDlg.cpp +++ b/pcsx2/GS/Window/GSCaptureDlg.cpp @@ -20,7 +20,7 @@ */ #include "PrecompiledHeader.h" -#include "GSdx.h" +#include "GS.h" #include "GSCaptureDlg.h" #define BeginEnumSysDev(clsid, pMoniker) \ @@ -37,8 +37,8 @@ void GSCaptureDlg::InvalidFile() { - const std::wstring message = L"GSdx couldn't open file for capturing: " + m_filename + L".\nCapture aborted."; - MessageBox(GetActiveWindow(), message.c_str(), L"GSdx System Message", MB_OK | MB_SETFOREGROUND); + const std::wstring message = L"GS couldn't open file for capturing: " + m_filename + L".\nCapture aborted."; + MessageBox(GetActiveWindow(), message.c_str(), L"GS System Message", MB_OK | MB_SETFOREGROUND); } GSCaptureDlg::GSCaptureDlg() diff --git a/pcsx2/GS/Window/GSDialog.cpp b/pcsx2/GS/Window/GSDialog.cpp index 17a7f92559..f7a4ddde3e 100644 --- a/pcsx2/GS/Window/GSDialog.cpp +++ b/pcsx2/GS/Window/GSDialog.cpp @@ -22,7 +22,7 @@ #include "StdAfx.h" #include #include -#include "GSdx.h" +#include "GS.h" #include "GSDialog.h" #include "GSVector.h" diff --git a/pcsx2/GS/Window/GSLinuxDialog.cpp b/pcsx2/GS/Window/GSLinuxDialog.cpp index da1b0bc6a2..9458adc572 100644 --- a/pcsx2/GS/Window/GSLinuxDialog.cpp +++ b/pcsx2/GS/Window/GSLinuxDialog.cpp @@ -22,8 +22,8 @@ #include "PrecompiledHeader.h" #include #include "GS.h" -#include "GSdx.h" -#include "GSdxResources.h" +#include "GS.h" +#include "GSResources.h" #include "GSSetting.h" // Port of deprecated GTK2 API to recent GTK3. Those defines @@ -650,7 +650,7 @@ bool RunLinuxDialog() /* Create the widgets */ dialog = gtk_dialog_new_with_buttons( - "GSdx Config", + "GS Config", NULL, /* parent window*/ (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), "OK", GTK_RESPONSE_ACCEPT, @@ -668,8 +668,8 @@ bool RunLinuxDialog() // Grab a logo, to make things look nice. if (BigEnough()) { - GResource* resources = GSdx_res_get_resource(); - GInputStream* ogl_stream = g_resource_open_stream(resources, "/GSdx/res/logo-ogl.bmp", G_RESOURCE_LOOKUP_FLAGS_NONE, NULL); + GResource* resources = GS_res_get_resource(); + GInputStream* ogl_stream = g_resource_open_stream(resources, "/GS/res/logo-ogl.bmp", G_RESOURCE_LOOKUP_FLAGS_NONE, NULL); GdkPixbuf* ogl_logo = gdk_pixbuf_new_from_stream(ogl_stream, NULL, NULL); g_object_unref(ogl_stream); GtkWidget* logo_image = gtk_image_new_from_pixbuf(ogl_logo); @@ -685,7 +685,7 @@ bool RunLinuxDialog() GtkWidget* gl_table = CreateTableInBox(advanced_box, "OpenGL Very Advanced Custom Settings", 6, 2); GtkWidget* record_table = CreateTableInBox(debug_box, "Recording Settings", 4, 3); - GtkWidget* debug_table = CreateTableInBox(debug_box, "OpenGL / GSdx Debug Settings", 6, 3); + GtkWidget* debug_table = CreateTableInBox(debug_box, "OpenGL / GS Debug Settings", 6, 3); GtkWidget* shader_table = CreateTableInBox(shader_box, "Custom Shader Settings", 9, 2); GtkWidget* osd_table = CreateTableInBox(osd_box, "OSD", 6, 2); diff --git a/pcsx2/GS/Window/GSSettingsDlg.cpp b/pcsx2/GS/Window/GSSettingsDlg.cpp index 8c68d33da8..2993a72ba6 100644 --- a/pcsx2/GS/Window/GSSettingsDlg.cpp +++ b/pcsx2/GS/Window/GSSettingsDlg.cpp @@ -20,7 +20,7 @@ */ #include "PrecompiledHeader.h" -#include "GSdx.h" +#include "GS.h" #include "GSSettingsDlg.h" #include "GSUtil.h" #include "Renderers/DX11/GSDevice11.h" diff --git a/pcsx2/GS/Window/GSWndDX.cpp b/pcsx2/GS/Window/GSWndDX.cpp index 8495606c6e..676c3d000d 100644 --- a/pcsx2/GS/Window/GSWndDX.cpp +++ b/pcsx2/GS/Window/GSWndDX.cpp @@ -82,7 +82,7 @@ LRESULT GSWndDX::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) bool GSWndDX::Create(const std::string& title, int w, int h) { if (m_hWnd) - throw GSDXRecoverableError(); + throw GSRecoverableError(); m_managed = true; @@ -102,7 +102,7 @@ bool GSWndDX::Create(const std::string& title, int w, int h) { if (!RegisterClass(&wc)) { - throw GSDXRecoverableError(); + throw GSRecoverableError(); } } @@ -136,7 +136,7 @@ bool GSWndDX::Create(const std::string& title, int w, int h) m_hWnd = CreateWindow(wc.lpszClassName, tmp.c_str(), style, r.left, r.top, r.width(), r.height(), NULL, NULL, wc.hInstance, (LPVOID)this); if (!m_hWnd) - throw GSDXRecoverableError(); + throw GSRecoverableError(); return true; } @@ -155,7 +155,7 @@ void GSWndDX::Detach() { if (m_hWnd && m_managed) { - // close the window, since it's under GSdx care. It's not taking messages anyway, and + // close the window, since it's under GS care. It's not taking messages anyway, and // that means its big, ugly, and in the way. DestroyWindow(m_hWnd); diff --git a/pcsx2/GS/Window/GSWndEGL.cpp b/pcsx2/GS/Window/GSWndEGL.cpp index 89a7b51328..fc37721594 100644 --- a/pcsx2/GS/Window/GSWndEGL.cpp +++ b/pcsx2/GS/Window/GSWndEGL.cpp @@ -103,14 +103,14 @@ void GSWndEGL::CreateContext(int major, int minor) if (numConfigs == 0) { fprintf(stderr, "EGL: Failed to get a frame buffer config! (0x%x)\n", eglGetError()); - throw GSDXRecoverableError(); + throw GSRecoverableError(); } m_eglSurface = eglCreatePlatformWindowSurface(m_eglDisplay, eglConfig, m_native_window, nullptr); if (m_eglSurface == EGL_NO_SURFACE) { fprintf(stderr, "EGL: Failed to get a window surface\n"); - throw GSDXRecoverableError(); + throw GSRecoverableError(); } m_eglContext = eglCreateContext(m_eglDisplay, eglConfig, EGL_NO_CONTEXT, contextAttribs); @@ -127,12 +127,12 @@ void GSWndEGL::CreateContext(int major, int minor) { fprintf(stderr, "EGL: Failed to create the context\n"); fprintf(stderr, "EGL STATUS: %x\n", status); - throw GSDXRecoverableError(); + throw GSRecoverableError(); } if (!eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext)) { - throw GSDXRecoverableError(); + throw GSRecoverableError(); } } @@ -171,7 +171,7 @@ void GSWndEGL::BindAPI() if (api != EGL_OPENGL_API) { fprintf(stderr, "EGL: Failed to bind the OpenGL API got 0x%x instead\n", api); - throw GSDXRecoverableError(); + throw GSRecoverableError(); } } @@ -232,7 +232,7 @@ void* GSWndEGL::GetProcAddress(const char* name, bool opt) fprintf(stderr, "Failed to find %s\n", name); if (!opt) - throw GSDXRecoverableError(); + throw GSRecoverableError(); } return ptr; } @@ -280,13 +280,13 @@ void GSWndEGL::OpenEGLDisplay() if (m_eglDisplay == EGL_NO_DISPLAY) { fprintf(stderr, "EGL: Failed to open a display! (0x%x)\n", eglGetError()); - throw GSDXRecoverableError(); + throw GSRecoverableError(); } if (!eglInitialize(m_eglDisplay, nullptr, nullptr)) { fprintf(stderr, "EGL: Failed to initialize the display! (0x%x)\n", eglGetError()); - throw GSDXRecoverableError(); + throw GSRecoverableError(); } } @@ -320,7 +320,7 @@ void* GSWndEGL_X11::CreateNativeWindow(int w, int h) if (m_NativeDisplay == nullptr) { fprintf(stderr, "EGL X11: display wasn't created before the window\n"); - throw GSDXRecoverableError(); + throw GSRecoverableError(); } xcb_connection_t* c = XGetXCBConnection(m_NativeDisplay); @@ -334,7 +334,7 @@ void* GSWndEGL_X11::CreateNativeWindow(int w, int h) if (m_NativeWindow == 0) { fprintf(stderr, "EGL X11: failed to create the native window\n"); - throw GSDXRecoverableError(); + throw GSRecoverableError(); } xcb_create_window(c, depth, m_NativeWindow, screen->root, x, y, w, h, diff --git a/pcsx2/GS/Window/GSWndWGL.cpp b/pcsx2/GS/Window/GSWndWGL.cpp index 946ed42c74..1ebf9629da 100644 --- a/pcsx2/GS/Window/GSWndWGL.cpp +++ b/pcsx2/GS/Window/GSWndWGL.cpp @@ -33,7 +33,7 @@ static void win_error(const wchar_t* msg, bool fatal = true) if (fatal) { MessageBox(NULL, msg, L"ERROR", MB_OK | MB_ICONEXCLAMATION); - throw GSDXRecoverableError(); + throw GSRecoverableError(); } else { @@ -343,7 +343,7 @@ void* GSWndWGL::GetProcAddress(const char* name, bool opt) fprintf(stderr, "Failed to find %s\n", name); if (!opt) - throw GSDXRecoverableError(); + throw GSRecoverableError(); } return ptr; } diff --git a/pcsx2/GS/linux_replay.cpp b/pcsx2/GS/linux_replay.cpp index c87753e7f0..a2ca2ef939 100644 --- a/pcsx2/GS/linux_replay.cpp +++ b/pcsx2/GS/linux_replay.cpp @@ -28,7 +28,7 @@ static void* handle; void help() { fprintf(stderr, "Loader gs file\n"); - fprintf(stderr, "ARG1 GSdx plugin\n"); + fprintf(stderr, "ARG1 GS plugin\n"); fprintf(stderr, "ARG2 .gs file\n"); fprintf(stderr, "ARG3 Ini directory\n"); if (handle) diff --git a/pcsx2/GS/res/fxaa.fx b/pcsx2/GS/res/fxaa.fx index a502289da2..a4611c771d 100644 --- a/pcsx2/GS/res/fxaa.fx +++ b/pcsx2/GS/res/fxaa.fx @@ -4,7 +4,7 @@ #define FXAA_GLSL_130 0 #endif -#define UHQ_FXAA 1 //High Quality Fast Approximate Anti Aliasing. Adapted for GSdx from Timothy Lottes FXAA 3.11. +#define UHQ_FXAA 1 //High Quality Fast Approximate Anti Aliasing. Adapted for GS from Timothy Lottes FXAA 3.11. #define FxaaSubpixMax 0.0 //[0.00 to 1.00] Amount of subpixel aliasing removal. 0.00: Edge only antialiasing (no blurring) #define FxaaEarlyExit 1 //[0 or 1] Use Fxaa early exit pathing. When disabled, the entire scene is antialiased(FSAA). 0 is off, 1 is on. diff --git a/pcsx2/GS/res/glsl/tfx_fs.glsl b/pcsx2/GS/res/glsl/tfx_fs.glsl index 9419492c17..0494a005fa 100644 --- a/pcsx2/GS/res/glsl/tfx_fs.glsl +++ b/pcsx2/GS/res/glsl/tfx_fs.glsl @@ -187,7 +187,7 @@ vec4 sample_4_index(vec4 uv) { vec4 c; - // Either GSdx will send a texture that contains a single channel + // Either GS will send a texture that contains a single channel // in this case the red channel is remapped as alpha channel // // Or we have an old RT (ie RGBA8) that contains index (4/8) in the alpha channel diff --git a/pcsx2/GS/resource.h b/pcsx2/GS/resource.h index 3c730facc6..d4b365444f 100644 --- a/pcsx2/GS/resource.h +++ b/pcsx2/GS/resource.h @@ -2,7 +2,7 @@ //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. -// Used by GSdx.rc +// Used by GS.rc // // General Dialog: #define IDD_CONFIG 2001